diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3531e17 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +downloads/ +__pycache__/ +*.pyc diff --git a/__pycache__/zlib_dl.cpython-314.pyc b/__pycache__/zlib_dl.cpython-314.pyc deleted file mode 100644 index 595ce35..0000000 Binary files a/__pycache__/zlib_dl.cpython-314.pyc and /dev/null differ diff --git a/test1.log b/test1.log deleted file mode 100644 index 9a53c16..0000000 --- a/test1.log +++ /dev/null @@ -1,5 +0,0 @@ - 📡 已加载 56 个代理 - 🔗 已启动代理隧道: 🇭🇰 香港 01 -> 127.0.0.1:10800 - ⏳ 下载遇到 PoW 挑战,正在解决... - ✅ 挑战已解决 (耗时 0.024s,节点 zh.ngd101.ru) -下载返回了 HTML 页面(可能是限制或错误) diff --git a/test_503.log b/test_503.log deleted file mode 100644 index bb3230d..0000000 --- a/test_503.log +++ /dev/null @@ -1,4 +0,0 @@ -Proxy IP: 61.171.248.193 -Index status: 503 -Index status after PoW: 503 -Search status: 503 diff --git a/test_503.py b/test_503.py deleted file mode 100644 index 63f80cb..0000000 --- a/test_503.py +++ /dev/null @@ -1,88 +0,0 @@ -import urllib.request, time, hashlib, re, os, subprocess -from curl_cffi import requests - -def solve_challenge(html): - m = re.search(r"\['([A-F0-9]{40})'", html) - if not m: return None, None - c = m.group(1) - n1 = int(c[0], 16) - i = 0 - t0 = time.time() - while True: - d = hashlib.sha1((c + str(i)).encode()).digest() - if d[n1] == 0xb0 and d[n1+1] == 0x0b: break - i += 1 - return c + str(i), f"{time.time() - t0:.3f}" - -yaml_config = """ -mode: global -mixed-port: 10899 -bind-address: '127.0.0.1' -proxies: -""" -proxy_str = "" -with open("proxies.txt") as f: - for line in f: - if "ss," in line: - proxy_str = line.strip() - break -parts = proxy_str.split("=", 1) -cfg = parts[1].strip().split(",") -params = dict(p.strip().split("=", 1) for p in cfg[3:] if "=" in p) -yaml_config += f""" - name: "test" - type: ss - server: "{cfg[1].strip()}" - port: {cfg[2].strip()} - cipher: "{params.get('encrypt-method', '')}" - password: "{params.get('password', '')}" -""" -if "obfs" in params: - yaml_config += f" plugin: obfs\n plugin-opts:\n mode: {params['obfs']}\n host: {params['obfs-host']}\n" -with open("test_503.yaml", "w") as f: f.write(yaml_config) - -proc = subprocess.Popen(["./.venv/bin/mihomo", "-f", "test_503.yaml"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) -time.sleep(2) - -s = requests.Session() -p = {"http": "socks5://127.0.0.1:10899", "https": "socks5://127.0.0.1:10899"} - -try: - with open("test_503.log", "w") as out: - ip_resp = s.get("http://httpbin.org/ip", proxies=p, impersonate="chrome", timeout=5) - out.write(f"Proxy IP: {ip_resp.json()['origin']}\n") - - r1 = s.get("https://zlib.li/", proxies=p, impersonate="chrome", timeout=10) - out.write(f"Index status: {r1.status_code}\n") - - if r1.status_code == 503 and "Checking your browser" in r1.text: - ct, cti = solve_challenge(r1.text) - if ct: - s.cookies.set("c_token", ct, domain="zlib.li", path="/") - s.cookies.set("c_time", cti, domain="zlib.li", path="/") - r1 = s.get("https://zlib.li/", proxies=p, impersonate="chrome", timeout=10) - out.write(f"Index status after PoW: {r1.status_code}\n") - - r2 = s.get("https://zlib.li/s/Project", proxies=p, impersonate="chrome", timeout=10) - out.write(f"Search status: {r2.status_code}\n") - - from bs4 import BeautifulSoup - soup = BeautifulSoup(r2.text, "lxml") - card = soup.find("z-bookcard") - if card and card.get("download"): - dl = card.get("download") - out.write(f"Got dl path: {dl}\n") - r3 = s.get("https://zlib.li" + dl, proxies=p, impersonate="chrome", allow_redirects=True, timeout=10) - out.write(f"Download status: {r3.status_code}\n") - if r3.status_code == 503: - if "Checking your browser" in r3.text: - ct, cti = solve_challenge(r3.text) - if ct: - s.cookies.set("c_token", ct, domain="zlib.li", path="/") - s.cookies.set("c_time", cti, domain="zlib.li", path="/") - r4 = s.get("https://zlib.li" + dl, proxies=p, impersonate="chrome", allow_redirects=True, timeout=10) - out.write(f"Retry status: {r4.status_code}\n") - with open("test_503_body.html", "w") as f2: f2.write(r4.text) - else: - out.write("Not PoW 503\n") -finally: - proc.terminate() diff --git a/test_503.yaml b/test_503.yaml deleted file mode 100644 index 28c7629..0000000 --- a/test_503.yaml +++ /dev/null @@ -1,23 +0,0 @@ - -mode: rule -mixed-port: 10899 -bind-address: '127.0.0.1' -proxies: - - name: "test" - type: ss - server: "d32b6cd.gylcxo.xyz" - port: 18300 - cipher: "aes-128-gcm" - password: "ced24190439d1ed1" - plugin: obfs - plugin-opts: - mode: http - host: Sm0lO349ch.microsoft.com - -proxy-groups: - - name: "Proxy" - type: select - proxies: - - "test" -rules: - - MATCH, Proxy diff --git a/test_503_2.py b/test_503_2.py deleted file mode 100644 index fa40cdc..0000000 --- a/test_503_2.py +++ /dev/null @@ -1,61 +0,0 @@ -import urllib.request, time, hashlib, re, os, subprocess -from curl_cffi import requests - -def solve_challenge(html): - m = re.search(r"\['([A-F0-9]{40})'", html) - if not m: return None, None - c = m.group(1) - n1 = int(c[0], 16) - i = 0 - t0 = time.time() - while True: - d = hashlib.sha1((c + str(i)).encode()).digest() - if d[n1] == 0xb0 and d[n1+1] == 0x0b: break - i += 1 - return c + str(i), f"{time.time() - t0:.3f}" - -yaml_config = """ -mode: global -mixed-port: 10899 -bind-address: '127.0.0.1' -proxies: -""" -proxy_str = "" -with open("proxies.txt") as f: - for line in f: - if "ss," in line: - proxy_str = line.strip() - break -parts = proxy_str.split("=", 1) -cfg = parts[1].strip().split(",") -params = dict(p.strip().split("=", 1) for p in cfg[3:] if "=" in p) -yaml_config += f""" - name: "test" - type: ss - server: "{cfg[1].strip()}" - port: {cfg[2].strip()} - cipher: "{params.get('encrypt-method', '')}" - password: "{params.get('password', '')}" -""" -if "obfs" in params: - yaml_config += f" plugin: obfs\n plugin-opts:\n mode: {params['obfs']}\n host: {params['obfs-host']}\n" -with open("test_503.yaml", "w") as f: f.write(yaml_config) - -proc = subprocess.Popen(["./.venv/bin/mihomo", "-f", "test_503.yaml"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) -time.sleep(2) - -s = requests.Session() -p = {"http": "socks5://127.0.0.1:10899", "https": "socks5://127.0.0.1:10899"} -try: - r1 = s.get("https://zlib.li/", proxies=p, impersonate="chrome", timeout=10) - print("Initial:", r1.status_code) - - if r1.status_code == 503 and "Checking your browser" in r1.text: - ct, cti = solve_challenge(r1.text) - s.cookies.set("c_token", ct, domain="zlib.li", path="/") - s.cookies.set("c_time", cti, domain="zlib.li", path="/") - r1 = s.get("https://zlib.li/", proxies=p, impersonate="chrome", timeout=10) - print("After PoW:", r1.status_code) - if r1.status_code == 503: - print(r1.text[:500]) -finally: - proc.terminate() diff --git a/test_clash.yaml b/test_clash.yaml deleted file mode 100644 index a0fe9b4..0000000 --- a/test_clash.yaml +++ /dev/null @@ -1,13 +0,0 @@ -port: 7890 -socks-port: 7891 -proxies: - - name: "ss-obfs" - type: ss - server: "127.0.0.1" - port: 18300 - cipher: "aes-128-gcm" - password: "ced" - plugin: obfs - plugin-opts: - mode: http - host: Sm0lO349ch.microsoft.com diff --git a/test_cookie.py b/test_cookie.py deleted file mode 100644 index 95d803a..0000000 --- a/test_cookie.py +++ /dev/null @@ -1,6 +0,0 @@ -from curl_cffi import requests -s = requests.Session() -s.cookies.set("1", "A", domain="zlib.li", path="/") -s.cookies.set("2", "B", domain=".zlib.li", path="/") -s.get("http://httpbin.org/cookies", impersonate="chrome") -print(s.cookies) diff --git a/test_html.py b/test_html.py deleted file mode 100644 index c1847c8..0000000 --- a/test_html.py +++ /dev/null @@ -1,7 +0,0 @@ -from zlib_dl import ProxyManager, ZLibSession -mgr = ProxyManager("proxies.txt", verbose=True) -mgr.rotate() -s = ZLibSession(proxy_url=mgr.get_current_proxy_url(), verbose=True) -res, msg = s.download_file("/dl/22909249/a93325", "test.epub") -print(msg) -import os; os.path.exists("test.epub") and print("Saved epub size:", os.path.getsize("test.epub")) diff --git a/test_link.py b/test_link.py deleted file mode 100644 index 67bed91..0000000 --- a/test_link.py +++ /dev/null @@ -1,16 +0,0 @@ -from zlib_dl import ZLibSession -import re - -s1 = ZLibSession(verbose=True) -resp1 = s1._request_download("https://zlib.li/book/22909249/a93325") -match = re.search(r'href="(/dl/[^"]+)"', resp1.text) -if match: - print("Found exact link:", match.group(1)) -else: - print("Could not find /dl/ link in HTML!") - - lines = [line.strip() for line in resp1.text.split('\n')] - for i, line in enumerate(lines): - if "download" in line.lower() or "href" in line.lower(): - if "/22909249/" in line: - print(f"Possible DL Line [{i}]: {line[:300]}") diff --git a/test_mihomo.py b/test_mihomo.py deleted file mode 100644 index a1bfc37..0000000 --- a/test_mihomo.py +++ /dev/null @@ -1,22 +0,0 @@ -import urllib.request -import platform - -system = platform.system().lower() -machine = platform.machine().lower() -is_arm = machine in ("arm64", "aarch64") - -if system == "darwin": - arch_str = "arm64" if is_arm else "amd64-compatible" -elif system == "linux": - arch_str = "arm64" if is_arm else "amd64-compatible" - -version = "v1.19.21" -url = f"https://github.com/MetaCubeX/mihomo/releases/download/{version}/mihomo-{system}-{arch_str}-{version}.gz" -print("URL:", url) - -try: - req = urllib.request.Request(url, method='HEAD') - resp = urllib.request.urlopen(req, timeout=5) - print("Status:", resp.status) -except Exception as e: - print("Error:", e) diff --git a/test_mihomo_bounce.py b/test_mihomo_bounce.py deleted file mode 100644 index 15042c5..0000000 --- a/test_mihomo_bounce.py +++ /dev/null @@ -1,72 +0,0 @@ -import subprocess -import time -import os -import urllib.request -from curl_cffi import requests - -# We will read the first proxy from proxies.txt to really test it -proxy_str = "" -with open("proxies.txt") as f: - for line in f: - if "ss," in line: - proxy_str = line.strip() - break - -parts = proxy_str.split("=", 1) -name = parts[0].strip() -cfg = parts[1].strip().split(",") -host = cfg[1].strip() -port = cfg[2].strip() -params = {} -for p in cfg[3:]: - if "=" in p: - k, v = p.split("=", 1) - params[k.strip()] = v.strip() - -method = params.get("encrypt-method", "") -password = params.get("password", "") -obfs = params.get("obfs", "") -obfs_host = params.get("obfs-host", "") - -def test_mihomo(use_en0): - port_local = 11111 if use_en0 else 11112 - interface_cfg = "\n interface-name: en0" if use_en0 else "" - plugin_cfg = f""" - plugin: obfs - plugin-opts: - mode: {obfs} - host: {obfs_host} -""" if obfs else "" - - yaml_cfg = f""" -mode: global -mixed-port: {port_local} -bind-address: '127.0.0.1' -dns: - enable: true - nameserver: - - 223.5.5.5 -proxies: - - name: "test_proxy" - type: ss - server: "{host}" - port: {port} - cipher: "{method}" - password: "{password}"{interface_cfg}{plugin_cfg} -""" - with open(f"test_cfg_{port_local}.yaml", "w") as f: f.write(yaml_cfg) - proc = subprocess.Popen(["./.venv/bin/mihomo", "-f", f"test_cfg_{port_local}.yaml"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - time.sleep(2) - try: - prox = {"http": f"socks5://127.0.0.1:{port_local}", "https": f"socks5://127.0.0.1:{port_local}"} - resp = requests.get("http://httpbin.org/ip", proxies=prox, impersonate="chrome", timeout=5) - return resp.json()["origin"] - except Exception as e: - return f"Error: {e}" - finally: - proc.terminate() - proc.wait(timeout=2) - os.remove(f"test_cfg_{port_local}.yaml") - -print("Without en0:", test_mihomo(False)) -print("With en0:", test_mihomo(True)) diff --git a/test_mihomo_bypass.py b/test_mihomo_bypass.py deleted file mode 100644 index 36deead..0000000 --- a/test_mihomo_bypass.py +++ /dev/null @@ -1,46 +0,0 @@ -import subprocess -import time -import os -import json -import yaml - -# 1. 启动 mihomo 并绑定到具体网卡 (en0) -local_port = 10850 - -cfg = """ -mode: global -mixed-port: 10850 -bind-address: '127.0.0.1' - -dns: - enable: true - nameserver: - - https://223.5.5.5/dns-query - - https://1.1.1.1/dns-query - -proxies: - - name: "test-direct" - type: direct - interface-name: en0 -""" -with open("test_b.yaml", "w") as f: - f.write(cfg) - -# 找到 mihomo -mihomo = "./.venv/bin/mihomo" -if not os.path.exists(mihomo): - mihomo = "mihomo" - -proc = subprocess.Popen([mihomo, "-f", "test_b.yaml"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) -time.sleep(2) - -try: - from curl_cffi import requests - resp = requests.get("http://httpbin.org/ip", proxies={"http": "socks5://127.0.0.1:10850", "https": "socks5://127.0.0.1:10850"}, impersonate="chrome") - print("Mihomo (direct bound to en0) IP:", resp.json()["origin"]) - - resp_direct = requests.get("http://httpbin.org/ip", impersonate="chrome") - print("System (Surge default) IP:", resp_direct.json()["origin"]) -finally: - proc.kill() - os.remove("test_b.yaml") diff --git a/test_mihomo_fix.py b/test_mihomo_fix.py deleted file mode 100644 index a9233f3..0000000 --- a/test_mihomo_fix.py +++ /dev/null @@ -1,52 +0,0 @@ -import urllib.request, time, os, subprocess -from curl_cffi import requests - -yaml_config = """ -mode: rule -mixed-port: 10899 -bind-address: '127.0.0.1' -proxies: -""" -proxy_str = "" -with open("proxies.txt") as f: - for line in f: - if "ss," in line: - proxy_str = line.strip() - break -parts = proxy_str.split("=", 1) -cfg = parts[1].strip().split(",") -params = dict(p.strip().split("=", 1) for p in cfg[3:] if "=" in p) -yaml_config += f""" - name: "test" - type: ss - server: "{cfg[1].strip()}" - port: {cfg[2].strip()} - cipher: "{params.get('encrypt-method', '')}" - password: "{params.get('password', '')}" -""" -if "obfs" in params: - yaml_config += f" plugin: obfs\n plugin-opts:\n mode: {params['obfs']}\n host: {params['obfs-host']}\n" - -yaml_config += """ -proxy-groups: - - name: "Proxy" - type: select - proxies: - - "test" -rules: - - MATCH, Proxy -""" -with open("test_503.yaml", "w") as f: f.write(yaml_config) - -proc = subprocess.Popen(["./.venv/bin/mihomo", "-f", "test_503.yaml"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) -time.sleep(2) - -s = requests.Session() -p = {"http": "socks5://127.0.0.1:10899", "https": "socks5://127.0.0.1:10899"} -try: - ip_resp = s.get("http://httpbin.org/ip", proxies=p, impersonate="chrome", timeout=5) - print("Proxy IP:", ip_resp.json()["origin"]) - - r1 = s.get("https://zlib.li/", proxies=p, impersonate="chrome", timeout=10) - print("Index status:", r1.status_code) -finally: - proc.terminate() diff --git a/test_mihomo_gen.py b/test_mihomo_gen.py deleted file mode 100644 index e768364..0000000 --- a/test_mihomo_gen.py +++ /dev/null @@ -1,42 +0,0 @@ -import platform, os, gzip, urllib.request, json -import yaml - -def gen_config(proxy, local_port): - cfg = { - "port": 0, - "socks-port": local_port, - "mode": "Global", - "proxies": [{ - "name": proxy["name"], - "type": "ss", - "server": proxy["host"], - "port": proxy["port"], - "cipher": proxy["method"], - "password": proxy["password"], - "plugin": "obfs", - "plugin-opts": { - "mode": proxy["obfs"], - "host": proxy["obfs_host"] - } - }], - "proxy-groups": [{ - "name": "Proxy", - "type": "select", - "proxies": [proxy["name"]] - }], - "rules": [ - "MATCH,Proxy" - ] - } - return yaml.dump(cfg) - -proxy_test = { - "name": "HK 01", - "host": "d32b6cd.gylcxo.xyz", - "port": 18300, - "method": "aes-128-gcm", - "password": "ced", - "obfs": "http", - "obfs_host": "Sm0lO349ch.microsoft.com" -} -print(gen_config(proxy_test, 10800)) diff --git a/test_mihomo_ip.py b/test_mihomo_ip.py deleted file mode 100644 index b07b8c1..0000000 --- a/test_mihomo_ip.py +++ /dev/null @@ -1,19 +0,0 @@ -import urllib.request -import json - -from bs4 import BeautifulSoup - -def get_ip(proxy_url=None): - import subprocess - import sys - try: - from curl_cffi import requests - session = requests.Session() - proxies = {"http": proxy_url, "https": proxy_url} if proxy_url else None - resp = session.get("http://httpbin.org/ip", proxies=proxies, impersonate="chrome") - return resp.json()["origin"] - except Exception as e: - return f"Error: {e}" - -print("Direct IP:", get_ip()) - diff --git a/test_out.txt b/test_out.txt deleted file mode 100644 index 0841b47..0000000 --- a/test_out.txt +++ /dev/null @@ -1,3 +0,0 @@ - ⏳ 下载遇到 PoW 挑战,正在解决... - ✅ 挑战已解决 (耗时 0.003s,节点 zlib.li) -Could not find /dl/ link in HTML! diff --git a/test_search.py b/test_search.py deleted file mode 100644 index 0d8783a..0000000 --- a/test_search.py +++ /dev/null @@ -1,10 +0,0 @@ -from zlib_dl import ZLibSession -s = ZLibSession(verbose=True) -resp = s._request_download("https://zlib.li/s/%E6%B5%AA%E6%BD%AE%E4%B9%8B%E5%B7%85") -from bs4 import BeautifulSoup -soup = BeautifulSoup(resp.text, "html.parser") -cards = soup.find_all("z-bookcard") -if cards: - print(cards[0].prettify()) -else: - print("No cards found") diff --git a/test_us_clean.py b/test_us_clean.py deleted file mode 100644 index dc69e68..0000000 --- a/test_us_clean.py +++ /dev/null @@ -1,13 +0,0 @@ -from zlib_dl import ZLibSession -import re -url = "https://zlib.li/book/mDJxkg7yO6/%E6%B5%AA%E6%BD%AE%E4%B9%8B%E5%B7%85%E7%AC%AC%E5%9B%9B%E7%89%88.html" -s = ZLibSession(verbose=True, proxy_url="socks5://127.0.0.1:10800") -print("Requesting clean detail URL:", url) -resp = s._request_download(url) -print("FINAL URL:", resp.url) -print("HTML Title:", re.search(r'