Spaces:
Sleeping

File size: 4,147 Bytes
cc821cd
0863d7c
e758600
 
 
c9c2d6f
 
0863d7c
e758600
c9c2d6f
e758600
0863d7c
 
e758600
0863d7c
 
 
e758600
c9c2d6f
e758600
 
 
 
0863d7c
c9c2d6f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e758600
 
 
 
0863d7c
e758600
 
 
 
0863d7c
e758600
c9c2d6f
e758600
 
c9c2d6f
e758600
c9c2d6f
 
 
 
 
 
 
 
 
 
 
 
e758600
c9c2d6f
 
 
 
 
e758600
c9c2d6f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import sys
import hashlib
import time
import random
import threading
import gradio as gr

# ==========================================
# 1. ติดตั้งแพ็กเกจที่จำเป็น
# ==========================================
try:
    import ecdsa
except ImportError:
    os.system(f"{sys.executable} -m pip install ecdsa")
    import ecdsa

# ==========================================
# 2. ตั้งค่าและตัวแปรส่วนกลาง
# ==========================================
TARGET_RIPEMD160 = "f6f5431d25bbf7b12e8add9af5e3475c44a0a5b8"
START_RANGE = 0x700000000000000000
END_RANGE = 0x7fffffffffffffffff

status_info = {
    "count": 0,
    "speed": 0,
    "last_found": "ยังไม่พบค่าที่ตรง",
    "final_key": "ยังไม่พบ"
}

def get_ripemd160(data):
    try:
        r = hashlib.new('ripemd160', usedforsecurity=False)
    except TypeError:
        r = hashlib.new('ripemd160')
    r.update(data)
    return r.hexdigest()

def check_key(private_key_int):
    priv_key_bytes = private_key_int.to_bytes(32, byteorder='big')
    signing_key = ecdsa.SigningKey.from_string(priv_key_bytes, curve=ecdsa.SECP256k1)
    verifying_key = signing_key.get_verifying_key()
    
    x = verifying_key.pubkey.point.x()
    y = verifying_key.pubkey.point.y()
    prefix = b'\x02' if y % 2 == 0 else b'\x03'
    compressed_pub_key = prefix + x.to_bytes(32, byteorder='big')
    
    sha256_result = hashlib.sha256(compressed_pub_key).digest()
    return get_ripemd160(sha256_result)

# ==========================================
# 3. ฟังก์ชันสุ่มหา Private Key (Background Thread)
# ==========================================
def worker_thread():
    start_time = time.time()
    while True:
        try:
            status_info["count"] += 1
            random_attempt = random.randint(START_RANGE, END_RANGE)
            result = check_key(random_attempt)
            
            # คำนวณความเร็ว
            if status_info["count"] % 10000 == 0:
                elapsed = time.time() - start_time
                status_info["speed"] = int(status_info["count"] / elapsed) if elapsed > 0 else 0

            # ตรวจสอบ 6 ตัวแรก
            if result[:6] == TARGET_RIPEMD160[:6]:
                hex_key = hex(random_attempt)
                status_info["last_found"] = f"พบ 6 ตัวแรกตรง! (รอบที่ {status_info['count']:,}): {hex_key} | Hash: {result}"
                print(f"\n👀 {status_info['last_found']}", flush=True)

            # ตรวจสอบเป้าหมาย 100%
            if result == TARGET_RIPEMD160:
                hex_key = hex(random_attempt)
                status_info["final_key"] = hex_key
                print(f"\n🎉🎉🎉 เจอ Private Key แล้ว!!: {hex_key}", flush=True)
                break

        except Exception as e:
            time.sleep(1)

# เริ่มการทำงานเบื้องหลัง
thread = threading.Thread(target=worker_thread, daemon=True)
thread.start()

# ==========================================
# 4. หน้าเว็บ Gradio สำหรับส่ง Health Check ให้ Hugging Face
# ==========================================
def get_status():
    return (
        f"จำนวนครั้งที่สุ่มแล้ว: {status_info['count']:,} ครั้ง\n"
        f"ความเร็วโดยประมาณ: {status_info['speed']:,} keys/sec\n"
        f"การพบเจอล่าสุด: {status_info['last_found']}\n"
        f"Private Key ที่หาพบ: {status_info['final_key']}"
    )

with gr.Blocks(title="Key Finder Status") as demo:
    gr.Markdown("## 🚀 ระบบกำลังสุ่มหา Private Key อยู่ในเบื้องหลัง")
    out = gr.Textbox(label="สถานะการทำงานปัจจุบัน", value=get_status, every=3)

demo.launch(server_name="0.0.0.0", server_port=7860)