0% found this document useful (0 votes)
129 views

Contoh Scrypt

This Python script generates random private keys, converts them to WIF format, then checks the corresponding public addresses on a blockchain explorer API to see if they have any balance. If an address is found with a balance, it logs the WIF, timestamp, and address to a CSV file. It handles exceptions from request timeouts or errors from the API.

Uploaded by

Irpan s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
129 views

Contoh Scrypt

This Python script generates random private keys, converts them to WIF format, then checks the corresponding public addresses on a blockchain explorer API to see if they have any balance. If an address is found with a balance, it logs the WIF, timestamp, and address to a CSV file. It handles exceptions from request timeouts or errors from the API.

Uploaded by

Irpan s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1. #!

/usr/bin/env

2.
3.

4. import os
5. import ecdsa
6. import hashlib
7. import base58
8. import requests
9. import time
10.from smtplib import SMTP_SSL as SMTP
11.import logging
12.

13.

14. wif = ""


15.

16.

17.

18. logging.basicConfig(filename='BTC_PrivateKeys_'+time.strftime("%Y
-%m-%d-%H-%M")+'.csv', \
19. level=logging.INFO, format='%(message)s', datefmt='%Y-%m-
%d,%H:%M:%S')
20. logging.getLogger("requests").setLevel(logging.WARNING)
21. logging.info ('"Timestamp", "WifKey", "PublicAddress"')
22.

23.

24.

25. def ping_address(publicAddress):


26. global pk
27. global wif
28. global publicKey
29.
30. """
31. sends Request to a Block Explorer
32. Main one is blockexplorer - seems to be UNLIMITED...using
chain.so has a rate limiter
33. https://blockexplorer.com/api/addr/
34. balance = pmts['balance']
35. https://chain.so/api/v2/get_address_balance/BTC/
36. balance = pmts['data']['confirmed_balance']
37. """
38.

39. req =
requests.get("https://bitaps.com/api/address/"+publicAddress)
40. pmts = req.json()
41. # print pmts
42. balance = pmts['balance']
43. print balance
44.

45. # "WifKey", "HexKey", "PublicAddress", "PublicKey",


"Balance"
46. #Comment out this line if you wish to NOT record blank
keys
47. logging.info (''+ time.strftime("%m-%d-%y %H:%M:%S") +','+
wif +','+publicAddress)
48.

49. if float(balance) > 0.00000000:


50. logging.info (''+ time.strftime("%m-%d-%y
%H:%M:%S") +','+ wif +','+publicAddress)
51.
52. print "Congratulations...alert the world cause you
just made some sort of history friend!"
53.

54.

55. def wif_conversion(pk):


56. global wif
57. padding = '80' + pk
58. # print padding
59.
60. hashedVal =
hashlib.sha256(padding.decode('hex')).hexdigest()
61. checksum =
hashlib.sha256(hashedVal.decode('hex')).hexdigest()[:8]
62. # print hashedVal
63. # print padding+checksum
64.

65. payload = padding + checksum


66. wif = base58.b58encode(payload.decode('hex'))
67. print wif
68.
69.

70. while True:


71.

72. pk = os.urandom(32).encode("hex")
73. wif_conversion(pk)
74.

75. sk = ecdsa.SigningKey.from_string(pk.decode("hex"), curve


= ecdsa.SECP256k1)
76. vk = sk.verifying_key
77. publicKey = ("\04" + vk.to_string())
78. ripemd160 = hashlib.new('ripemd160')
79. ripemd160.update(hashlib.sha256(publicKey).digest())
80. networkAppend = '\00' + ripemd160.digest()
81. checksum =
hashlib.sha256(hashlib.sha256(networkAppend).digest()).digest()[:
4]
82. binary_address = networkAppend + checksum
83. publicAddress = base58.b58encode(binary_address)
84. print publicAddress
85. while True:
86. try:
87. ping_address(publicAddress)
88. except ValueError:
89. print "Aaaannnnd we got Timed Out"
90. print pk
91. print publicAddress
92. time.sleep(3)
93. continue
94. except KeyError:
95. print "we may be denied or something, keep
the script moving"
96. time.sleep(10)
97. break
98.

99. # msg = "I own your Private Key for %s" %(publicAddress)
100. # signed_msg = sk.sign(msg)
101. # encoded_msg = signed_msg.encode("hex")

You might also like