Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Marshal TITO on April 20, 2021, 04:44:06 PM



Title: Need help with Python Scrict Private Key Search
Post by: Marshal TITO on April 20, 2021, 04:44:06 PM
Hi all

i am new to this Forum so a BIG "HI" to all.

I try different scripts from Github, now i found one, that bring me to a Problem.

https://github.com/shiky8/Btc_Brute (https://github.com/shiky8/Btc_Brute)

i want to play around with this script, and i try to change it to print all results in a txt file.

But it dont work.

The script is made to only show the "Match" Result, is it possible to write all, that is shown on the screen in a txt file ?

Hope i write understandable, my english is so LALA !



Title: Re: Need help with Python Scrict Private Key Search
Post by: NotATether on April 20, 2021, 05:47:54 PM
Yeah in fact it's very simple to tweak it to print all addresses.

This is the source code of the entire script:

Code:
import blocksmith
address_1 = str(input('Enter the btc address: ')) #'1PQc5NNSdvRwyw2RvrrQcBF4jHnmQFRkaL'
sert=0
while True:    
    paddress_1aphrase = blocksmith.KeyGenerator()
    paddress_1aphrase.seed_input('qwertyuiopasdfghjklzxcvbnm1234567890') # paddress_1aphrase
    private_Key = paddress_1aphrase.generate_key()
    address = blocksmith.BitcoinWallet.generate_address(private_Key)
    sert+=1
    if address_1 == address:
        print("we found it ")
        print("private private_Key = ", private_Key)
        print("address = ",address)
        break
    else:
        print("trying private private_Key = ", private_Key)
        print("address = ",address)
        continue

To print to a file like you asked, we just write f = open("results.txt", "w") followed by print(..., file=f) on every statement you want to redirect. This has the consequence of causing no output to be sent to the terminal.

So the modified script would look like this:

Code:
import blocksmith
address_1 = str(input('Enter the btc address: ')) #'1PQc5NNSdvRwyw2RvrrQcBF4jHnmQFRkaL'
sert=0
f = open("results.txt", "w")
while True:    
    paddress_1aphrase = blocksmith.KeyGenerator()
    paddress_1aphrase.seed_input('qwertyuiopasdfghjklzxcvbnm1234567890') # paddress_1aphrase
    private_Key = paddress_1aphrase.generate_key()
    address = blocksmith.BitcoinWallet.generate_address(private_Key)
    sert+=1
    if address_1 == address:
        print("we found it ", file=f)
        print("private private_Key = ", private_Key, file=f)
        print("address = ",address, file=f)
        break
    else:
        print("trying private private_Key = ", private_Key, file=f)
        print("address = ",address, file=f)
        continue

However, I do not recommend making this change. The computational speed of programs is limited by the time it takes to write I/O to a console or disk, and it has very high latency because you are making the same write() kernel call millions of times, and that's going to dominate and throttle the program speed.

Basically instead of iterating through billions of keys per second you will be printing and iterating through just thousands per second.


Title: Re: Need help with Python Scrict Private Key Search
Post by: Marshal TITO on April 20, 2021, 06:01:14 PM
UPS this side of the medal i have not look at.

Thank you for your help, now i understand the position of the " print " funktion a bit more.

This was the only, so called brute script i found, that ws not to hard to handle for me.

My goal was to fix 2 PK i have, one starts with a 5 and one with L5, but only 42 and 43 characters are left, after my daughter try to be Picasso, when she was 3 years old.

Not only Picasso drawing, also she tear of the paper, where it was written, in 2016.
I forget the pice that was left, and found it yesterday when i sort the old documents out.

I have the Public Keys so i try this script, maybe it exist a better solution !?


Title: Re: Need help with Python Scrict Private Key Search
Post by: NotATether on April 20, 2021, 06:07:45 PM
UPS this side of the medal i have not look at.

Thank you for your help, now i understand the position of the " print " funktion a bit more.

This was the only, so called brute script i found, that ws not to hard to handle for me.

My goal was to fix 2 PK i have, one starts with a 5 and one with L5, but only 42 and 43 characters are left, after my daughter try to be Picasso, when she was 3 years old.

Not only Picasso drawing, also she tear of the paper, where it was written, in 2016.
I forget the pice that was left, and found it yesterday when i sort the old documents out.

I have the Public Keys so i try this script, maybe it exist a better solution !?

Was the beginning or end of the private key torn off?

If it was at the end, then given that it was only a few characters lost, we can use the BitCrack program (https://bitcointalk.org/index.php?topic=4453897.msg39845999#msg39845999) to brute force the key by trying all the possible characters that it could've been. I'll help you set it up (and run it for free for you if you can't).

Alternatively, have you ever spent Bitcoin from that private key? There is a faster program we can use if you manage to find a transaction ID that spends from it, but it requires its public key.


Title: Re: Need help with Python Scrict Private Key Search
Post by: Marshal TITO on April 20, 2021, 06:36:49 PM
Like you guess, it is the end that is missed.

The child logic was, ooo the right side of the paper is free, there i can draw, and nobody will be angry  ::) ::) nobody was angry BTC was around 450 $ and now, its a CAR  :'( :'(

Like i say the PK with the 5 at the start has 42 Characters left,

The PK with the L5 has 43 characters left.

And there have be Transactions made on the addresses its a bit confussed,

I try to send you pm, but it says i cant because new member.

The TX method maybe work.


Title: Re: Need help with Python Scrict Private Key Search
Post by: NotATether on April 20, 2021, 07:01:04 PM
And there have be Transactions made on the addresses its a bit confussed,

OK, what is the address for this private key so I can look it up in a block explorer to extract the public key?


Title: Re: Need help with Python Scrict Private Key Search
Post by: PrimeNumber7 on April 21, 2021, 02:29:32 AM
Code:
    else:
        print("trying private private_Key = ", private_Key, file=f)
        print("address = ",address, file=f)
        continue
I don't think this code snippet should be used. I don't see any point in logging private keys that are not a match if you are trying to brute force a private key.

However, I do not recommend making this change. The computational speed of programs is limited by the time it takes to write I/O to a console or disk, and it has very high latency because you are making the same write() kernel call millions of times, and that's going to dominate and throttle the program speed.

Basically instead of iterating through billions of keys per second you will be printing and iterating through just thousands per second.
If I am not mistaken, the sdout on the terminal would quickly eat up available memory since the sdout is never flushed, so printing to the terminal IMO is not a good idea. Your concern would also be addressed if my above suggestion is implemented.


Title: Re: Need help with Python Scrict Private Key Search
Post by: WanderingPhilospher on April 21, 2021, 05:20:44 AM
Like you guess, it is the end that is missed.

The child logic was, ooo the right side of the paper is free, there i can draw, and nobody will be angry  ::) ::) nobody was angry BTC was around 450 $ and now, its a CAR  :'( :'(

Like i say the PK with the 5 at the start has 42 Characters left,

The PK with the L5 has 43 characters left.

And there have be Transactions made on the addresses its a bit confussed,

I try to send you pm, but it says i cant because new member.

The TX method maybe work.
With only 9 to 10 characters missing at the end, should only take a few seconds to find your private key. Easy.


Title: Re: Need help with Python Scrict Private Key Search
Post by: Coding Enthusiast on April 21, 2021, 06:09:41 AM
Like i say the PK with the 5 at the start has 42 Characters left,
The PK with the L5 has 43 characters left.
Check out my project, The FinderOuter (https://bitcointalk.org/index.php?topic=5214021.0).
In "Missing Base58" option enter the characters you have and replace the remaining missing characters with '*' and click Find button.
Look at examples 3 and 4 for more information.
https://i.imgur.com/1EUfmWL.jpg

The optimized method works for up to 11 missing chars at the end of a compressed key and up to 9 for uncompressed. Since you are missing 9 for both it works for you. I'll optimize it soon to support more.


Title: Re: Need help with Python Scrict Private Key Search
Post by: Marshal TITO on April 21, 2021, 09:33:15 AM
Looks great, i have win 10, does it run on it ?


Title: Re: Need help with Python Scrict Private Key Search
Post by: Coding Enthusiast on April 21, 2021, 10:53:14 AM
Looks great, i have win 10, does it run on it ?
Yes, FinderOuter can run on all operating systems.
You have to compile the source code yourself for Windows, although I suggest always dealing with private keys on an air-gap machine (https://github.com/Coding-Enthusiast/FinderOuter#step-1-preparation).
Steps are explained in ReadMe file on GitHub (https://github.com/Coding-Enthusiast/FinderOuter#step-2-download-and-build).
Remember to use release configuration:
Code:
dotnet build --c Release