Spaces:
1
Sleeping

1
File size: 4,140 Bytes
0322c67
5203d08
0322c67
 
 
a15c45e
 
5203d08
0322c67
5203d08
a15c45e
0322c67
 
 
a15c45e
5203d08
0322c67
 
 
 
 
 
 
5203d08
0322c67
 
a15c45e
0322c67
 
5203d08
a15c45e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0322c67
 
 
 
5203d08
0322c67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a15c45e
 
0322c67
 
 
 
 
 
 
 
a15c45e
 
 
0322c67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5203d08
0322c67
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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 = """
    <!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)