forked from Isaacdelly/Plutus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplutus.py
189 lines (172 loc) · 6.7 KB
/
plutus.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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# Plutus Bitcoin Brute Forcer
# Made by Isaac Delly
# https://github.com/Isaacdelly/Plutus
# Donate: 1B1k2fMs6kEmpxdYor6qvd2MRVUX2zGEHa
import requests
import os
import binascii
import ecdsa
import hashlib
import base58
import time
import sys
from multiprocessing import Process, Queue
class pause: # Counts API failures for timeout
p = 0
def privateKey(): # Generates random 256 bit private key in hex format
return binascii.hexlify(os.urandom(32)).decode('utf-8')
def publicKey(privatekey): # Private Key -> Public Key
privatekey = binascii.unhexlify(privatekey)
s = ecdsa.SigningKey.from_string(privatekey, curve = ecdsa.SECP256k1)
return '04' + binascii.hexlify(s.verifying_key.to_string()).decode('utf-8')
def address(publickey): # Public Key -> Wallet Address
alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
c = '0'; byte = '00'; zero = 0
var = hashlib.new('ripemd160')
var.update(hashlib.sha256(binascii.unhexlify(publickey.encode())).digest())
a = (byte + var.hexdigest())
doublehash = hashlib.sha256(hashlib.sha256(binascii.unhexlify(a.encode())).digest()).hexdigest()
address = a + doublehash[0:8]
for char in address:
if (char != c):
break
zero += 1
zero = zero // 2
n = int(address, 16)
output = []
while (n > 0):
n, remainder = divmod (n, 58)
output.append(alphabet[remainder])
count = 0
while (count < zero):
output.append(alphabet[0])
count += 1
return ''.join(output[::-1])
def balance(address): # Query API for wallet balance
try:
API = requests.get("https://bitcoinlegacy.blockexplorer.com/api/addr/" + str(address) + "/balance")
if (API.status_code == 429):
pause.p += 1
if (pause.p >= 10):
print ("\nUnable to connect to API after several attempts\nRetrying in 30 seconds\n")
time.sleep(30)
pause.p = 0
return -1
print("\nHTTP Error Code: " + str(API.status_code) + "\n")
return -1
if (API.status_code != 200 and API.status_code != 400):
print("\nHTTP Error Code: " + str(API.status_code) + "\nRetrying in 5 seconds\n")
time.sleep(5)
return -1
balance = int(API.text)
pause.p = 0
return balance
except:
pause.p += 1
if (pause.p >= 10):
print ("\nUnable to connect to API after several attempts\nRetrying in 30 seconds\n")
time.sleep(30)
pause.p = 0
return -1
def toWIF(privatekey): # Hex Private Key -> WIF format
var80 = "80" + str(privatekey)
var = hashlib.sha256(binascii.unhexlify(hashlib.sha256(binascii.unhexlify(var80)).hexdigest())).hexdigest()
return str(base58.b58encode(binascii.unhexlify(str(var80) + str(var[0:8]))))
def Plutus(): # Main Plutus Function
data = [0,0,0,0]
while True:
data[0] = privateKey()
data[1] = publicKey(data[0])
data[2] = address(data[1])
data[3] = balance(data[2])
if (data[3] == -1):
continue
if (data[3] == 0):
print("{:<34}".format(str(data[2])) + " = " + str(data[3]))
if (data[3] > 0):
print ("\naddress: " + str(data[2]) + "\n" +
"private key: " + str(data[0]) + "\n" +
"WIF private key: " + str(toWIF(str(data[0]))) + "\n" +
"public key: " + str(data[1]).upper() + "\n" +
"balance: " + str(data[3]) + "\n")
file = open("plutus.txt","a")
file.write("address: " + str(data[2]) + "\n" +
"private key: " + str(data[0]) + "\n" +
"WIF private key: " + str(toWIF(str(data[0]))) + "\n" +
"public key: " + str(data[1]).upper() + "\n" +
"balance: " + str(data[3]) + "\n" +
"Donate to the author of this program: 1B1k2fMs6kEmpxdYor6qvd2MRVUX2zGEHa\n\n")
file.close()
### Multiprocessing Extension Made By Wayne Yao https://github.com/wx-Yao ###
def put_dataset(queue):
while True:
if queue.qsize() > 100:
time.sleep(10)
else:
privatekey = privateKey()
publickey = publicKey(privatekey)
Address = address(publickey)
WIF = toWIF(privatekey)
dataset = (Address, privatekey, publickey, WIF)
queue.put(dataset, block = False)
return None
def worker(queue):
time.sleep(1)
while True:
if queue.qsize() > 0:
dataset = queue.get(block = True)
balan = balance(dataset[0])
process_balance(dataset, balan)
else:
time.sleep(3)
return None
def process_balance(dataset,balance):
if balance == -1 :
return None
elif balance == 0 :
print("{:<34}".format(str(dataset[0])) + " = " + str(balance))
return None
else:
addr = dataset[0]
privatekey = dataset[1]
publickey = dataset[2]
WIF = dataset[3]
file = open("plutus.txt","a")
file.write("address: " + str(addr) + "\n" +
"private key: " + str(privatekey) + "\n" +
"WIF private key: " + str(WIF) + "\n" +
"public key: " + str(publickey).upper() + "\n" +
"balance: " + str(balance) + "\n" +
"Donate to the author of this program: 1B1k2fMs6kEmpxdYor6qvd2MRVUX2zGEHa\n\n")
file.close()
return None
def multi():
processes = []
dataset = Queue()
datasetProducer = Process(target = put_dataset, args = (dataset,))
datasetProducer.daemon = True
processes.append(datasetProducer)
datasetProducer.start()
for core in range(4):
work = Process(target = worker, args = (dataset,))
work.deamon = True
processes.append(work)
work.start()
try:
datasetProducer.join()
except KeyboardInterrupt:
for process in processes:
process.terminate()
print('\n\n------------------------\nALL PROCESSES TERMINATED\n')
### End of Multiprocessing Extension ###
def main():
if ("-m" in sys.argv):
print("\n-------- MULTIPROCESSING MODE ACTIVATED --------\n")
time.sleep(3)
print("\n|-------- Wallet Address --------| = Balance in Satoshi")
multi()
else:
print("\n|-------- Wallet Address --------| = Balance in Satoshi")
Plutus()
if __name__ == '__main__':
main()