Download app.py from dycd/1: direct link, hf CLI and curl.
- Browser
- Download file 4.14 kB
-
https://huggingface.co/spaces/dycd/1/resolve/main/app.py
- Command line
-
hf download hf://spaces/dycd/1/app.py
-
curl -L -o app.py https://huggingface.co/spaces/dycd/1/resolve/main/app.py
4.14 kB
| 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 | |
| # 主页路由 | |
| def index(): | |
| global is_running, failed_count, success_results | |
| success_results = load_success_results() | |
| html = """ | |
| <!DOCTYPE html> | |
| <html lang="zh-CN"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>加密地址匹配工具</title> | |
| <style> | |
| body { font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; } | |
| .status { padding: 10px; margin: 10px 0; border-radius: 5px; } | |
| .running { background-color: #e8f5e8; color: #2e7d32; } | |
| .stopped { background-color: #ffebee; color: #c62828; } | |
| .success { background-color: #fff3e0; padding: 15px; margin: 10px 0; border-radius: 5px; } | |
| pre { background-color: #f5f5f5; padding: 10px; border-radius: 5px; overflow-x: auto; } | |
| .btn { padding: 8px 16px; background-color: #2196f3; color: white; border: none; border-radius: 4px; cursor: pointer; } | |
| .btn:hover { background-color: #1976d2; } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>加密地址匹配工具</h1> | |
| <div class="status {{ 'running' if is_running else 'stopped' }}"> | |
| <h3>程序状态: {{ '运行中' if is_running else '已停止' }}</h3> | |
| <p>已尝试次数: {{ failed_count }}</p> | |
| {% if not is_running %} | |
| <button class="btn" onclick="window.location.reload()">重新启动</button> | |
| {% endif %} | |
| </div> | |
| <div class="success"> | |
| <h3>匹配结果 (共 {{ len(success_results) }} 条)</h3> | |
| {% if success_results %} | |
| {% for result in success_results %} | |
| <pre>{{ result.strip() }}</pre> | |
| {% endfor %} | |
| {% else %} | |
| <p>暂无匹配结果</p> | |
| {% endif %} | |
| </div> | |
| </body> | |
| </html> | |
| """ | |
| 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) |