Bitcoin Forum
May 06, 2024, 11:25:18 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: what is grep command in Linux to find hex private key in my .txt file? i saved  (Read 196 times)
isolutioncorp (OP)
Newbie
*
Offline Offline

Activity: 9
Merit: 2


View Profile
April 15, 2021, 01:09:21 AM
Merited by ABCbits (1)
 #1

what is grep command in Linux to find hex private key in my .txt file? i saved it somewhere on a backup drive, im not talking about WIF privatekey

please help!
1714994718
Hero Member
*
Offline Offline

Posts: 1714994718

View Profile Personal Message (Offline)

Ignore
1714994718
Reply with quote  #2

1714994718
Report to moderator
1714994718
Hero Member
*
Offline Offline

Posts: 1714994718

View Profile Personal Message (Offline)

Ignore
1714994718
Reply with quote  #2

1714994718
Report to moderator
1714994718
Hero Member
*
Offline Offline

Posts: 1714994718

View Profile Personal Message (Offline)

Ignore
1714994718
Reply with quote  #2

1714994718
Report to moderator
Each block is stacked on top of the previous one. Adding another block to the top makes all lower blocks more difficult to remove: there is more "weight" above each block. A transaction in a block 6 blocks deep (6 confirmations) will be very difficult to remove.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714994718
Hero Member
*
Offline Offline

Posts: 1714994718

View Profile Personal Message (Offline)

Ignore
1714994718
Reply with quote  #2

1714994718
Report to moderator
1714994718
Hero Member
*
Offline Offline

Posts: 1714994718

View Profile Personal Message (Offline)

Ignore
1714994718
Reply with quote  #2

1714994718
Report to moderator
odolvlobo
Legendary
*
Offline Offline

Activity: 4298
Merit: 3214



View Profile
April 15, 2021, 01:30:41 AM
 #2

what is grep command in Linux to find hex private key in my .txt file? i saved it somewhere on a backup drive, im not talking about WIF privatekey

Not an expert but I think this will work:

grep -E '[a-fA-F0-9]{64,64}[^a-fA-F0-9]' <file>


Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
isolutioncorp (OP)
Newbie
*
Offline Offline

Activity: 9
Merit: 2


View Profile
April 15, 2021, 01:36:25 AM
 #3

thanks a lot, will give it a try and let you know, i tried googling this first only came up for WIF not hex private keys
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6728


bitcoincleanup.com / bitmixlist.org


View Profile WWW
April 15, 2021, 06:38:20 AM
 #4

grep -E -o '[1234567890abcdefABCDEF]{64}' also does the job and using the -o option, only prints the part of the line that actually matches the private key. This avoids printing extremely large lines or perhaps an entire binary file that happens to have a matching string.

You should probably redirect the output to a file because most terminals' output buffers are fairly small, only holding he last 1000 or so lines of output.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
10_sjdovn_10
Member
**
Offline Offline

Activity: 100
Merit: 30

Stay humble, be cool, make world better place.


View Profile
April 19, 2021, 08:39:47 AM
 #5

grep -E -o '[1234567890abcdefABCDEF]{64}' also does the job and using the -o option, only prints the part of the line that actually matches the private key. This avoids printing extremely large lines or perhaps an entire binary file that happens to have a matching string.

You should probably redirect the output to a file because most terminals' output buffers are fairly small, only holding he last 1000 or so lines of output.

@NotATether
I don't understand, every private key is Hex type but they showed with A-Z 0-9 characters !?
How about finding a public or private key in wallet files (specially those are not encrypted) dose this technic works on them?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4616



View Profile
April 19, 2021, 01:15:09 PM
Merited by Cyrus (1), ABCbits (1), NotATether (1)
 #6

I don't understand, every private key is Hex type but they showed with A-Z 0-9 characters

If you are seeing characters from G - Z, then it is NOT hex.  Hex generally only uses numeric digits (0-9) and the first 6 characters of the alphabet in either capital or lowercase form  (A - F and a - f).

Additionally, you only want to use grep if the key is stored as UTF-8 encoded string of characters representing the key in a human-readable format.

How about finding a public or private key in wallet files (specially those are not encrypted) dose this technic works on them?

That depends on the file and which wallet software it came from.  Many wallets store the key in binary format rather than an encoded string.  In that case, using grep will be more complicated and messy and probably isn't the best tool for the job.
10_sjdovn_10
Member
**
Offline Offline

Activity: 100
Merit: 30

Stay humble, be cool, make world better place.


View Profile
April 19, 2021, 03:24:06 PM
 #7

I don't understand, every private key is Hex type but they showed with A-Z 0-9 characters

If you are seeing characters from G - Z, then it is NOT hex.  Hex generally only uses numeric digits (0-9) and the first 6 characters of the alphabet in either capital or lowercase form  (A - F and a - f).

Additionally, you only want to use grep if the key is stored as UTF-8 encoded string of characters representing the key in a human-readable format.

How about finding a public or private key in wallet files (specially those are not encrypted) dose this technic works on them?

That depends on the file and which wallet software it came from.  Many wallets store the key in binary format rather than an encoded string.  In that case, using grep will be more complicated and messy and probably isn't the best tool for the job.

Right private keys are Hex but why there is  K, w, y and .... in private key ? Aha, they turn 128bit binary to hex then find it's related Characters ! and show set of characters !!
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6728


bitcoincleanup.com / bitmixlist.org


View Profile WWW
April 19, 2021, 04:42:33 PM
Last edit: April 20, 2021, 11:19:08 AM by NotATether
Merited by ABCbits (1)
 #8

Right private keys are Hex but why there is  K, w, y and .... in private key ? Aha, they turn 128bit binary to hex then find it's related Characters ! and show set of characters !!

If you see a private key with those kind of characters then that is not a hexadecimal formatted key, it is a WIF private key encoded in Base58 (or if it begins with "bc1", bech32).

This regex should find Base58 keys:

Code:
[123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]{51,52}


Additionally, the following regex will find bech32 private keys addresses:

Code:
bc1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{6,87}

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6728


bitcoincleanup.com / bitmixlist.org


View Profile WWW
April 20, 2021, 10:23:45 AM
Merited by ABCbits (1)
 #9

Additionally, the following regex will find bech32 private keys:

Code:
bc1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{6,87}

I notice {6,87} which AFAIK means string with range 6-87 character. Any reason you chose that range because AFAIK Bech32 address isn't that short.

BIP173 said that addresses can be up to 90 characters long, including the human readable part and separator. The data part after bc1 is at least 6 characters long, and 90 when the length of bc1 is taken out is 87.

Granted, I haven't seen Bech32 addresses that small in practice, because the hash160 has a fixed length.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6728


bitcoincleanup.com / bitmixlist.org


View Profile WWW
April 20, 2021, 11:17:50 AM
 #10

On a side note, which wallet uses Bech32 as format of the private key?

Cripes, I must've posted the regex for bech32 address instead  Embarrassed there is no such thing as a Bech32 WIF private key.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!