Khipha ama-IP e-proxy namachweba e-hex ku-JSON efakiwe
Dekhoda ama-payload e-JSON aziwayo asuka ezingxenyeni ze-script zohlu lwe-proxy futhi uhumushe ingcwebo ye-hex kuphela lapho ifomethi yomthombo ikusho.
Ithebula le-HTML elingenalutho alisho njalo ukuthi impendulo ayinazo izinto eziqoshiwe ze-proxy. Olunye uhlu lubeka izinto ze-JSON ngaphakathi kwezingcingo ze-JavaScript bese lugcwalisa imigqa kamuva.
Kumthombo oseke watholakala osebenzisa isisongelo esithile gp.insertPrx esilandelwa into ye-JSON:
import ipaddress
import json
import re
decoder = json.JSONDecoder()
endpoints = set()
for marker in re.finditer(r"gp[.]insertPrx\(\s*", html):
try:
row, end = decoder.raw_decode(html, marker.end())
if not isinstance(row, dict):
continue
address = ipaddress.ip_address(row["PROXY_IP"])
port = int(row["PROXY_PORT"], 16)
except (ValueError, KeyError, TypeError):
continue
if 1 <= port <= 65535 and html[end:].lstrip().startswith(");"):
endpoints.add((str(address), port))
html umbhalo womthombo, hhayi into yesiphequluli. Isisho esivamile sithola isisongelo esaziwayo; i-JSONDecoder inquma ukuthi inani le-JSON liphela kuphi. Lokhu kugwema umzamo wokuhlaziya i-JSON efakwe ngaphakathi ngesisho esivamile kuphela.
Inkambu yengcwebo esibonelweni i-hex ngokucacile: i-C38 isho u-3128 wedesimali. Ungasebenzisi isisekelo 16 enkambwini yedesimali yomunye umhlinzeki ngoba nje zombili zibizwa ngengcwebo.
Lesi isihlaziyi sefomethi eshiwo, hhayi umhumushi we-JavaScript. Ama-literal ezinto anophawu lokucaphuna olulodwa, amanani abaliwe nezinye izisho ze-JavaScript zidinga enye inguxa yedatha ebhaliwe. Ungasebenzisi ikhodi yekhasi engafanele ukuze uthole uhlu lweziphetho.
Qinisekisa isivumelwano somthombo futhi gcina izinkambu zeprotocol zodwa. Uma umthombo unemigqa ye-HTML egcwalisiwe esikhundleni salokho, sebenzisa ukukhipha iziphetho ngomugqa esikhundleni salesi sihlaziyi sesisongelo se-JavaScript. Ukukhipha ikheli nengcwebo akufakazeli ukuthi isiphetho sinikeza umsebenzi we-proxy osebenzisekayo njengamanje.