from flask import Flask, render_template_string import os from pathlib import Path import threading import time import subprocess import sys app = Flask(__name__) # 全局变量 is_running = False failed_count = 0 success_results = [] process = None # 读取成功结果 def load_success_results(): success_file = Path("success.txt") if success_file.exists(): with open(success_file, 'r', encoding='utf-8') as f: return f.readlines() return [] # 启动破解程序 def start_bruteforce(): global is_running, process is_running = True try: # 直接运行jms.py作为子进程 process = subprocess.Popen( [sys.executable, "jms.py"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True ) # 实时读取输出 for line in iter(process.stdout.readline, ''): if not is_running: break # 解析尝试次数 if "已尝试次数:" in line: try: global failed_count failed_count = int(line.split("已尝试次数: ")[1].strip()) except: pass # 解析成功结果 if "匹配成功:" in line: success_results.append(line.strip()) # 写入文件 with open("success.txt", 'a', encoding='utf-8') as f: f.write(line.strip() + '\n') process.wait() except Exception as e: print(f"运行错误: {e}") finally: is_running = False # 主页路由 @app.route('/') def index(): global is_running, failed_count, success_results success_results = load_success_results() html = """ 加密地址匹配工具

加密地址匹配工具

程序状态: {{ '运行中' if is_running else '已停止' }}

已尝试次数: {{ failed_count }}

{% if not is_running %} {% endif %}

匹配结果 (共 {{ len(success_results) }} 条)

{% if success_results %} {% for result in success_results %}
{{ result.strip() }}
{% endfor %} {% else %}

暂无匹配结果

{% endif %}
""" return render_template_string(html, is_running=is_running, failed_count=failed_count, success_results=success_results, len=len) if __name__ == '__main__': # 启动破解程序线程 brute_thread = threading.Thread(target=start_bruteforce, daemon=True) brute_thread.start() # 启动Flask服务器 app.run(host='0.0.0.0', port=7860, debug=False)