-
Notifications
You must be signed in to change notification settings - Fork 3
/
range.py
68 lines (53 loc) · 2.45 KB
/
range.py
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
import bitcoin
import os
# Set the starting hexadecimal value
start_hex = "0000000000000000000000000000000000000000000000000000000000000002"
# Set a flag to indicate whether all the addresses have been found
all_addresses_found = False
# Check if a progress file exists
if os.path.exists("progress.txt"):
# Read the last hexadecimal value from the progress file
with open("progress.txt", "r") as f:
start_hex = f.read().strip()
# Convert the hexadecimal value to an integer
start_int = int(start_hex, 16)
else:
# Convert the starting hexadecimal value to an integer
start_int = int(start_hex, 16)
# Set the ending hexadecimal value
end_hex = "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"
# Convert the ending hexadecimal value to an integer
end_int = int(end_hex, 16)
while not all_addresses_found:
# Iterate through all the integers in the range
for i in range(start_int, end_int):
# Convert the integer to a hexadecimal value
private_key_hex = hex(i)[2:]
# Pad the hexadecimal value with leading zeros if necessary
private_key_hex = private_key_hex.zfill(64)
# Generate the public key and address from the private key
public_key = bitcoin.privkey_to_pubkey(private_key_hex)
address = bitcoin.pubkey_to_address(public_key)
# Log the current address and private key
print(f"Address: {address}\nPrivate key: {private_key_hex}\n")
# Check if the address exists in the address.txt file
if os.path.exists("address.txt"):
with open("address.txt", "r") as f:
addresses = f.read().splitlines()
if address in addresses:
# Save the address and private key to foundit.txt
with open("foundit.txt", "a") as f:
f.write(f"Address: {address}\nPrivate key: {private_key_hex}\n")
# Remove the found address from the list of addresses
addresses.remove(address)
# If all the addresses have been found, set the flag to True
if len(addresses) == 0:
all_addresses_found = True
break
# Save the last hexadecimal value used to the progress file
with open("progress.txt", "w") as f:
f.write(private_key_hex)
# Save the remaining addresses to the address.txt file
with open("address.txt", "w") as f:
for address in addresses:
f.write(address + "\n")