Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: ncdlek on August 05, 2016, 08:15:45 PM



Title: Random Address generator and balance checker
Post by: ncdlek on August 05, 2016, 08:15:45 PM
Hi,

Nowadays I am planing to give a talk about bitcoin and blockchain and want to show about address security. So I want to code a script which randomly (and if possible a vocabulary attack) generates bitcoin address and check their balances. When I tell people it is really secure, they didn't get it. And my plan is showing them actually how is strong while I talk.
 
I don't have enough technical background but I had learned some python in ccodecademy.com.

Thanks for help.


Title: Re: Random Address generator and balance checker
Post by: OmegaStarScream on August 05, 2016, 08:19:24 PM
Electrum (which is a desktop wallet in case you don't know) is written in Python. I'm pretty sure you could start from there for what comes to generating addresses , as for checking the balances If you can't run bitcoind on your own server , you can simply use the Blockchain.info API , there is a lot of tutorials out there.


Title: Re: Random Address generator and balance checker
Post by: achow101 on August 05, 2016, 08:22:49 PM
You don't necessarily need to generate Bitcoin addresses to get your point across. Just show them the math and the probabilities. The number of possible addresses is 2^160.

If you actually do want to write a program to do this, then you could use python, but it probably won't be very well optimized. Just use python with openssl and have openssl generate the keys. Then do the base58check encoding on the public key in order to get the Bitcoin address. Lastly, you can use it with cURL to send api requests to whatever REST API you want to use.


Title: Re: Random Address generator and balance checker
Post by: ncdlek on August 05, 2016, 08:23:59 PM
Electrum (which is a desktop wallet in case you don't know) is written in Python. I'm pretty sure you could start from there for what comes to generating addresses , as for checking the balances If you can't run bitcoind on your own server , you can simply use the Blockchain.info API , there is a lot of tutorials out there.

Thanks. I will check.


Title: Re: Random Address generator and balance checker
Post by: ncdlek on August 05, 2016, 08:41:38 PM
You don't necessarily need to generate Bitcoin addresses to get your point across. Just show them the math and the probabilities. The number of possible addresses is 2^160.

If you actually do want to write a program to do this, then you could use python, but it probably won't be very well optimized. Just use python with openssl and have openssl generate the keys. Then do the base58check encoding on the public key in order to get the Bitcoin address. Lastly, you can use it with cURL to send api requests to whatever REST API you want to use.

Yes I know it is impossible and I found really useful infographics and graphs. but if it is not hard for me, i want to show this matrix lines :). Thanks for advice, i will check.


Title: Re: Random Address generator and balance checker
Post by: coinableS on August 09, 2016, 02:27:38 AM
Here you go. Don't run this more than 100 times in 5 minutes or you'll get the ban hammer from Blockchain.

http://phpfiddle.org/lite/code/4q2m-6sga

Code:
<?php
$counter 
0;
while(
$counter 5){
//gen new key pair
$url "https://blockchain.info/q/newkey";
$content file_get_contents($url);
$arrEx explode(" "$content);

$bitcoin_address $arrEx[0];
$privKey $arrEx[1];
//check the balance
$jsondata json_decode(file_get_contents("https://blockchain.info/address/$bitcoin_address?format=json"), true);
$totRec $jsondata["total_received"];
echo "Address: ".$bitcoin_address;
echo "<br>Key: ".$privKey;
echo "<br>Bal: ".$totRec ."<br><br>";
$counter++;
}
?>