-
Notifications
You must be signed in to change notification settings - Fork 12
/
EthHackSQL.py
71 lines (63 loc) · 2.08 KB
/
EthHackSQL.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
#!/usr/bin/python3
import sha3
import multiprocessing
import psutil
import pyodbc
import os
import random
from ecdsa import SigningKey, SECP256k1
from web3 import Web3, KeepAliveRPCProvider
# Point to RPC server
ethNode = 'localhost'
# Configure SQL connection parameters
# https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server
# {ODBC Driver 13 for SQL Server}
def sql_upload(private,address,balance):
try:
cnxn = pyodbc.connect(
driver='',
server='',
database='',
uid='',
pwd=''
)
cursor = cnxn.cursor()
values = "('{0}','{1}','{2}')".format(private, address, balance)
query = "BEGIN INSERT INTO Unverified (PRIVATE, ADDRESS, BALANCE) VALUES "+values+" END;"
cursor.execute(query)
cnxn.commit()
cursor.close()
cnxn.close()
except:
with open(address, 'w') as f:
f.write("PRIVATE: {0}\nADDRESS: {1}\nBALANCE: {2}\n".format(private, address, balance))
f.close()
def ethhack():
web3 = Web3(KeepAliveRPCProvider(host=ethNode, port='8545'))
while True:
keccak = sha3.keccak_256()
private = SigningKey.generate(curve=SECP256k1)
public = private.get_verifying_key().to_string()
keccak.update(public)
address = "0x{}".format(keccak.hexdigest()[24:])
try:
balance = web3.eth.getBalance(address)
except:
balance = -1
if balance != 0:
sql_upload(private.to_string().hex(),address,balance)
if __name__ == "__main__":
cores = multiprocessing.cpu_count()
pool = multiprocessing.Pool(processes=cores)
parent = psutil.Process()
if os.name == 'nt':
parent.nice(psutil.BELOW_NORMAL_PRIORITY_CLASS)
for child in parent.children():
child.nice(psutil.IDLE_PRIORITY_CLASS)
else:
parent.nice(10)
for child in parent.children():
child.nice(19)
[pool.apply_async(ethhack) for i in range(cores)]
pool.close()
pool.join()