|
|
import atexit |
|
|
import subprocess |
|
|
from DrissionPage._configs.chromium_options import ChromiumOptions |
|
|
from DrissionPage import Chromium |
|
|
from DrissionPage._pages.web_page import WebPage |
|
|
from urllib.parse import urlparse, parse_qs |
|
|
from mitmproxy import http |
|
|
from mitmproxy.tools.main import mitmdump |
|
|
import os |
|
|
import httpx |
|
|
import json |
|
|
|
|
|
try: |
|
|
import time |
|
|
except: |
|
|
pass |
|
|
|
|
|
|
|
|
def get_info(): |
|
|
|
|
|
current_directory = os.getcwd() |
|
|
|
|
|
relative_file_path = "2.html" |
|
|
|
|
|
absolute_file_path = os.path.join(current_directory, relative_file_path) |
|
|
print(absolute_file_path) |
|
|
|
|
|
proxy_server = "http://127.0.0.1:12346" |
|
|
co = ChromiumOptions().set_paths(browser_path=r"microsoft-edge") |
|
|
co.incognito(on_off=True) |
|
|
co.headless(on_off=True) |
|
|
co.set_local_port("12369") |
|
|
|
|
|
co.set_proxy(proxy_server) |
|
|
|
|
|
co.set_argument("--disable-gpu") |
|
|
co.set_argument('--no-sandbox') |
|
|
co.set_argument('--disable-dev-shm-usage') |
|
|
co.set_argument('--ignore-certificate-errors') |
|
|
|
|
|
co.set_user_agent( |
|
|
user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTM, like Gecko) chrome/124.0.0.8 safari/537.36') |
|
|
try: |
|
|
browser2 = Chromium(chromium_options=co) |
|
|
time.sleep(2) |
|
|
browser2.get(absolute_file_path, retry=3, interval=2, timeout=15) |
|
|
return browser2 |
|
|
except Exception as e: |
|
|
print(f"打开主页失败,请检查网络连接,{e}") |
|
|
return None |
|
|
print(f"启动成功...") |
|
|
|
|
|
|
|
|
def open_browser(): |
|
|
|
|
|
current_directory = os.getcwd() |
|
|
|
|
|
|
|
|
relative_file_path = "2.html" |
|
|
|
|
|
|
|
|
absolute_file_path = os.path.join(current_directory, relative_file_path) |
|
|
print(absolute_file_path) |
|
|
|
|
|
proxy_server = "http://127.0.0.1:12346" |
|
|
|
|
|
command = [ |
|
|
r"microsoft-edge", |
|
|
|
|
|
"--headless", |
|
|
"--no-sandbox", |
|
|
"--disable-gpu", |
|
|
"--remote-debugging-port=9222", |
|
|
"--disable-dev-shm-usage", |
|
|
"--ignore-certificate-errors", |
|
|
"2>/dev/null", |
|
|
f"--proxy-server={proxy_server}", |
|
|
f"file:///{absolute_file_path}" |
|
|
] |
|
|
|
|
|
|
|
|
try: |
|
|
process = subprocess.Popen(command) |
|
|
|
|
|
except Exception as e: |
|
|
|
|
|
process = None |
|
|
return process |
|
|
|
|
|
|
|
|
class ListenComment: |
|
|
def __init__(self): |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
def request(self, flow: http.HTTPFlow) -> None: |
|
|
if 'speech.platform.bing.com' in flow.request.pretty_url: |
|
|
try: |
|
|
flow.kill() |
|
|
except Exception as e: |
|
|
print(e) |
|
|
|
|
|
url = flow.request.pretty_url |
|
|
parsed_url = urlparse(url) |
|
|
|
|
|
utc_time = time.time() |
|
|
|
|
|
|
|
|
beijing_time = utc_time + 8 * 3600 |
|
|
|
|
|
|
|
|
beijing_struct_time = time.localtime(beijing_time) |
|
|
t = time.strftime('%Y-%m-%d %H:%M:%S', beijing_struct_time) |
|
|
|
|
|
|
|
|
query_params = parse_qs(parsed_url.query) |
|
|
try: |
|
|
ConnectionId = query_params['ConnectionId'][0] |
|
|
|
|
|
except KeyError: |
|
|
pass |
|
|
|
|
|
print(t, ' ', url) |
|
|
|
|
|
|
|
|
try: |
|
|
Sec_MS_GEC = query_params['Sec-MS-GEC'][0] |
|
|
Sec_MS_GEC_Version = query_params['Sec-MS-GEC-Version'][0] |
|
|
print(f"{t} Sec-MS-GEC: {Sec_MS_GEC}\nSec-MS-GEC-Version: {Sec_MS_GEC_Version}") |
|
|
data = { |
|
|
"Sec-MS-GEC": Sec_MS_GEC, |
|
|
"Sec-MS-GEC-Version": Sec_MS_GEC_Version, |
|
|
"last_update": int(time.time()), |
|
|
"last_update_format(UTC +8)": t |
|
|
} |
|
|
|
|
|
body = {"key": "edge", |
|
|
"value": json.dumps(data), |
|
|
} |
|
|
url = 'https://edge-sec.myaitool.top/lsjafadslhhi' |
|
|
with httpx.Client() as client: |
|
|
response = client.post(url, json=body) |
|
|
print(response.text) |
|
|
return data |
|
|
except Exception as e: |
|
|
print(f'cuowu: {e}') |
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addons = [ListenComment()] |
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
|
|
|
|
|
|
|
|
b = get_info() |
|
|
|
|
|
mitmdump(['-s', __file__, '-p 12346', '-q', ]) |