Files
home_control/batch/test_api1.py
T

36 lines
958 B
Python
Raw Normal View History

2026-08-22 19:54:38 +02:00
import requests
import re
from urllib.parse import urljoin
ROUTER = "https://192.168.178.2"
r = requests.get(ROUTER, verify=False, timeout=5)
scripts = re.findall(r'<script[^>]+src=["\']([^"\']+)', r.text)
for script in scripts:
if script.endswith("/app.js"):
url = urljoin(ROUTER, script)
print("Downloading:", url)
js = requests.get(url, verify=False, timeout=10).text
print("Size:", len(js), "bytes")
# Print strings containing things that are likely to be API endpoints
print("\nInteresting URLs/strings:\n")
patterns = [
r'["\']([^"\']*(?:api|cgi|device|client|status|dhcp|wifi|wireless|lan)[^"\']*)["\']',
]
found = set()
for pattern in patterns:
for match in re.findall(pattern, js, re.IGNORECASE):
if len(match) < 300:
found.add(match)
for item in sorted(found):
print(item)