Bitcoin Forum
June 17, 2024, 01:12:53 PM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: « 1 ... 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 [81] 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 ... 142 »
  Print  
Author Topic: Pollard's kangaroo ECDLP solver  (Read 56574 times)
NotATether
Legendary
*
Offline Offline

Activity: 1638
Merit: 6897


bitcoincleanup.com / bitmixlist.org


View Profile WWW
March 29, 2021, 11:00:33 AM
 #1601

these is the data of that kind speed......

Kangaroo v2.1 : Added Start End Options
~snip
[1948901416.30 MK/s][GPU 1193969262.41 MK/s][Count 2^29.27][Dead 2][16s (Avg 13s)][155.9/201.6MB]

Is this output from my fork? (I did not bump the version number, maybe it would be wise for me to do so)?

I have not changed the code related to speed reporting, and I also haven't made any of the planned optimizations yet.

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

Activity: 406
Merit: 45


View Profile
April 04, 2021, 06:09:41 AM
 #1602


Kangaroo calculate  Tame,Wild

Can anybody tell me what number Tame,Wild calculate and How I calculate with what formula?

two number one is hash on hex format and two is random value in range
What is first number on hex

I would like to testing some experiment by  random Tame,Wild (in range) and see can possible to collision or not
WanderingPhilospher
Full Member
***
Offline Offline

Activity: 1078
Merit: 219

Shooters Shoot...


View Profile
April 04, 2021, 06:19:12 AM
Last edit: April 04, 2021, 06:45:12 AM by WanderingPhilospher
 #1603


Kangaroo calculate  Tame,Wild

Can anybody tell me what number Tame,Wild calculate and How I calculate with what formula?

two number one is hash on hex format and two is random value in range
What is first number on hex

I would like to testing some experiment by  random Tame,Wild (in range) and see can possible to collision or not

Can you give example of what you mean by "two number one is hash on hex format and two is random value in range
What is first number on hex" ?

If you mean the columns from the saved file, for tame and wild both, column/tab 1 is the point, a.k.a pubkey, for tame in column/tab 2 is the distance, a.k.a. privkey and column/tab 2 for the wild is the distance a.k.a. the offset of pubkey you are searching for. If column 1 matches up, then for JLPs kangaroo program, you would subtract column/tab 2 "distances" from each other and then add back the start range you entered in command line.

Example:
Tame
Code:
D141E70913A6F67CD00DB847B31C28 00CF048E0B6645018CE925D30B01F1
Wild
Code:
D141E70913A6F67CD00DB847B31C28 000F048E0B6645018CE925D30B01F1

Both column 1s line up (points) so that is a collision. Now subtract column 2s from each other and add back start range and that is the private key to the pubkey you are searching for.

EDIT: I forgot to mention that the column 1/pubkeys are the least significant bits, the last x amount of characters in the pubkey; so in the example above, if you look at privkey CF048E0B6645018CE925D30B01F1 you will see that D141E70913A6F67CD00DB847B31C28 are the last bits of its pubkey's x coord.

fxsniper
Member
**
Offline Offline

Activity: 406
Merit: 45


View Profile
April 04, 2021, 12:27:40 PM
 #1604


Example:
Tame
Code:
D141E70913A6F67CD00DB847B31C28 00CF048E0B6645018CE925D30B01F1
Wild
Code:
D141E70913A6F67CD00DB847B31C28 000F048E0B6645018CE925D30B01F1


Thank you for help answer

kangaroo save file is binary format right
I try to open in text editor it is not work

this one random on range right
00CF048E0B6645018CE925D30B01F1  = 304597017357365078784491997823473

this long how can I calculate
D141E70913A6F67CD00DB847B31C28  = 1086526704572680266696100020277681192

I think kangaroo.exe calculate better

may be difference work with kangaroo.exe and kangaroo python version

example pubkey 03a2efa402fd5268400c77c20e574ba86409ededee7c4020e4b9f0edbee53de0d4

command
Code:
python pollard-kangaroo-multi.py 40 03a2efa402fd5268400c77c20e574ba86409ededee7c4020e4b9f0edbee53de0d4

results.txt
Code:
000000000000000000000000000000000000000000000000000000e9ae4933d6:03a2efa402fd5268400c77c20e574ba86409ededee7c4020e4b9f0edbee53de0d4

tame.txt
Code:
df01ac74ca510e763ab46bce694a8b57886b75a332c5c4723a97295df3cc0000 938995735797
8035da74a13756443b9dae9ed6bea111479f7f6447539e634e1dc7177e2a0000 987988675717
3997d2cad0f2ccea350bd0b0d0d06bfb70186d6daca5c51a6dc6043548a60000 1041424812707
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000 1110317004752

wild.txt
Code:
c3f83617c1d27a2883fbb849e6b990809553db20b3b7b7523d8c7a07f5040000 3343924384
566cf41f4de8b1ec5358fedb956d7c8a2540a24c4f336370723273f9a1fc0000 11271810949
fc241f52dbebdb22cb5b7b68fc98599deebfc7749c272ddb104d7c4d1d6e0000 65004674131
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000 106665591802
9ced97b0ce81010e66f87d91d2414af23fe456da6ec1d0a6dcf598d0e71a0000 87061666288


match/collision

tame.txt
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000 1110317004752
wild.txt
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000 106665591802


number = 1110317004752
and
number = 106665591802

it is random from command = random.randint

and this value
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000

Are they come from?
How to calculate?


fxsniper
Member
**
Offline Offline

Activity: 406
Merit: 45


View Profile
April 04, 2021, 03:18:04 PM
 #1605

code complex more than I can understand
I run pollard-kangaroo-multi.py with config flag_verbose = 2   

look like start from  random tame wild by random with distance tame wild
and get xpoint (how to calculate)
then compare both
and jump to next tame wild (and jump)
if not yet collision do again new random

I am not programmer not yet clear to read complex code

Can I do easy by using python library bit
https://ofek.dev/bit/guide/keys.html

import bit
pvk = random.randrange(2**119,2**120)
key = Key.from_int(pvk)
X,Y = key.public_point

this is same value or not
NotATether
Legendary
*
Offline Offline

Activity: 1638
Merit: 6897


bitcoincleanup.com / bitmixlist.org


View Profile WWW
April 05, 2021, 06:53:11 AM
 #1606

Are kangaroo collisions in the same herd a bad thing? My program (https://github.com/ZenulAbidin/Kangaroo-256) was doing that until I changed the hash table index calculation to use & HASHMASK instead of % HASHMASK.

To my understanding, they don't slow down the search - that happens when your DP size is too small for your search range and initial points are lost - but it just keeps going on forever without colliding the private key in the hash table.

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

Activity: 1078
Merit: 219

Shooters Shoot...


View Profile
April 05, 2021, 06:59:09 AM
 #1607

Are kangaroo collisions in the same herd a bad thing? My program (https://github.com/ZenulAbidin/Kangaroo-256) was doing that until I changed the hash table index calculation to use & HASHMASK instead of % HASHMASK.

To my understanding, they don't slow down the search - that happens when your DP size is too small for your search range and initial points are lost - but it just keeps going on forever without colliding the private key in the hash table.
If you are searching with GPU and searching in a decent sized bit range, say 64 bit range and up, you may get a few same herd collisions, but it's not a bad thing. The program just resets those kangaroos to start a different path from a different random point.

Smaller DP and smaller ranges will create more same herd collisions; especially if using GPU.

Does your program solve keys, or just keep running?
WanderingPhilospher
Full Member
***
Offline Offline

Activity: 1078
Merit: 219

Shooters Shoot...


View Profile
April 05, 2021, 07:03:41 AM
 #1608

code complex more than I can understand
I run pollard-kangaroo-multi.py with config flag_verbose = 2   

look like start from  random tame wild by random with distance tame wild
and get xpoint (how to calculate)
then compare both
and jump to next tame wild (and jump)
if not yet collision do again new random

I am not programmer not yet clear to read complex code

Can I do easy by using python library bit
https://ofek.dev/bit/guide/keys.html

import bit
pvk = random.randrange(2**119,2**120)
key = Key.from_int(pvk)
X,Y = key.public_point

this is same value or not
Not sure 100% about the python one you are running but in general, you set the keyspace search and the pubkey you are looking for.  That tells the program where to start tame and wilds and also does the math to offset the wilds' distances/pubkey x coord.

Tames are randomly set off in the range and basically record the pubkey x coord and private key.  Wilds record the offset pubkey x coord with offset of pubkey for private key.

Your above python library would be ok to mark points as 'tames', but not wilds. You will have to either subtract or add from pubkey you are searching to create a pseudo wild.
WanderingPhilospher
Full Member
***
Offline Offline

Activity: 1078
Merit: 219

Shooters Shoot...


View Profile
April 05, 2021, 07:12:43 AM
 #1609


Example:
Tame
Code:
D141E70913A6F67CD00DB847B31C28 00CF048E0B6645018CE925D30B01F1
Wild
Code:
D141E70913A6F67CD00DB847B31C28 000F048E0B6645018CE925D30B01F1


Thank you for help answer

kangaroo save file is binary format right
I try to open in text editor it is not work

this one random on range right
00CF048E0B6645018CE925D30B01F1  = 304597017357365078784491997823473

this long how can I calculate
D141E70913A6F67CD00DB847B31C28  = 1086526704572680266696100020277681192

I think kangaroo.exe calculate better

may be difference work with kangaroo.exe and kangaroo python version

example pubkey 03a2efa402fd5268400c77c20e574ba86409ededee7c4020e4b9f0edbee53de0d4

command
Code:
python pollard-kangaroo-multi.py 40 03a2efa402fd5268400c77c20e574ba86409ededee7c4020e4b9f0edbee53de0d4

results.txt
Code:
000000000000000000000000000000000000000000000000000000e9ae4933d6:03a2efa402fd5268400c77c20e574ba86409ededee7c4020e4b9f0edbee53de0d4

tame.txt
Code:
df01ac74ca510e763ab46bce694a8b57886b75a332c5c4723a97295df3cc0000 938995735797
8035da74a13756443b9dae9ed6bea111479f7f6447539e634e1dc7177e2a0000 987988675717
3997d2cad0f2ccea350bd0b0d0d06bfb70186d6daca5c51a6dc6043548a60000 1041424812707
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000 1110317004752

wild.txt
Code:
c3f83617c1d27a2883fbb849e6b990809553db20b3b7b7523d8c7a07f5040000 3343924384
566cf41f4de8b1ec5358fedb956d7c8a2540a24c4f336370723273f9a1fc0000 11271810949
fc241f52dbebdb22cb5b7b68fc98599deebfc7749c272ddb104d7c4d1d6e0000 65004674131
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000 106665591802
9ced97b0ce81010e66f87d91d2414af23fe456da6ec1d0a6dcf598d0e71a0000 87061666288


match/collision

tame.txt
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000 1110317004752
wild.txt
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000 106665591802


number = 1110317004752
and
number = 106665591802

it is random from command = random.randint

and this value
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000

Are they come from?
How to calculate?

I think you get confused because you keep mixing decimals with hex. Stay with hex to make it easier to understand.

In your example:
tame.txt
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000 1110317004752
wild.txt
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000 106665591802

keep it all hex:
tame.txt
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000 102840CF7D0
wild.txt
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000 18D5C3C3FA

Now, look at the tames "distance"...the private key in second column: 102840CF7D0
Look up the private key info and you will see its pubkey is:
02ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000

Now drop the 02 in front and you have:
ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000

See how that matches the first column data?

So now you have a collision; the same data in column 1. So now subtract the wild second column from the tame second column:
102840CF7D0 - 18D5C3C3FA = E9AE4933D6 ... which is the private key to the pubkey that the program was searching for; which is in your results file.
NotATether
Legendary
*
Offline Offline

Activity: 1638
Merit: 6897


bitcoincleanup.com / bitmixlist.org


View Profile WWW
April 05, 2021, 07:30:33 AM
Last edit: April 05, 2021, 07:46:01 AM by NotATether
 #1610

Does your program solve keys, or just keep running?

It solves the 40-bit range key with my above patch, but before that I was getting hundreds of false collisions as I approached 2^36. The key itself is around range 2^32.37 so when the previous build skipped that I knew there was trouble.

Using modulus anywhere for the hashtable index was a terrible idea, AND is much better and doesn't make any bad collisions.

https://github.com/ZenulAbidin/Kangaroo-256/commit/6239cfaec35787c7d4556bd2767a2f19db38b017



EDIT: 23.37 was a typo, I meant to write 32.37

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

Activity: 1078
Merit: 219

Shooters Shoot...


View Profile
April 05, 2021, 07:38:31 AM
 #1611

Does your program solve keys, or just keep running?

It solves the 40-bit range key with my above patch, but before that I was getting hundreds of false collisions as I approached 2^36. The key itself is around range 2^23.37 so when the previous build skipped that I knew there was trouble.

Using modulus anywhere for the hashtable index was a terrible idea, AND is much better and doesn't make any bad collisions.

https://github.com/ZenulAbidin/Kangaroo-256/commit/6239cfaec35787c7d4556bd2767a2f19db38b017
Hmmmm...2^36 for 40 bit search?  Seems high, like you should never get that high for group ops.  2^19-2^21 would be about right, depending on DP that was used.  With kangaroo program, You can't look at where the key lies to determine group ops for solving key. You could find key within seconds, if tame and wild both start out on same path where key lies, boom, found within seconds.  Very different versus bruteforce.

Oh well, at least you got it working and solving keys!
fxsniper
Member
**
Offline Offline

Activity: 406
Merit: 45


View Profile
April 05, 2021, 08:01:14 AM
 #1612

I test already to check X, Y value from publickey it is not same  x point on kangaroo

I found x point value kangaroo generate is  point x from elliptic curve


https://learnmeabitcoin.com/technical/public-key
   # multiply generator point by this private key
    point = multiply(k, $g) # this point is the public key

    # convert x and y values of this point to hexadecimal

kagaroo is use this x point  from ECC

my idea small testing just random privatekey in range and mutipy ECC to get x point   may be million key to test compare

that mean some address using same x point to multiply right
WanderingPhilospher
Full Member
***
Offline Offline

Activity: 1078
Merit: 219

Shooters Shoot...


View Profile
April 05, 2021, 08:41:00 AM
 #1613

I test already to check X, Y value from publickey it is not same  x point on kangaroo

I found x point value kangaroo generate is  point x from elliptic curve


https://learnmeabitcoin.com/technical/public-key
   # multiply generator point by this private key
    point = multiply(k, $g) # this point is the public key

    # convert x and y values of this point to hexadecimal

kagaroo is use this x point  from ECC

my idea small testing just random privatekey in range and mutipy ECC to get x point   may be million key to test compare

that mean some address using same x point to multiply right

Well then your program is broke. All TAMES, not WILDS, distances will match x coord of point x. I just showed you in your example above how that was true. Maybe I do not understand what you are stating or maybe you're not really sure what you are doing?
If you are using Jean Luc's kangaroo version you have to look at the least bits, meaning the last characters, not the beginning characters.
NotATether
Legendary
*
Offline Offline

Activity: 1638
Merit: 6897


bitcoincleanup.com / bitmixlist.org


View Profile WWW
April 05, 2021, 09:09:21 AM
 #1614

Well then your program is broke. All TAMES, not WILDS, distances will match x coord of point x.

So this means G•Td = Tx (I'm using that as the x-coordinate of the tame kangaroo), but somehow, this doesn't apply for wilds, i.e G•Wd != Wx (Would-be x-coordinate of wild kangaroo)?

What's different about wild kangaroos that breaks the ECC multiply for it?

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

Activity: 107
Merit: 61


View Profile
April 05, 2021, 11:20:09 AM
Merited by NotATether (1)
 #1615

Well then your program is broke. All TAMES, not WILDS, distances will match x coord of point x.

So this means G•Td = Tx (I'm using that as the x-coordinate of the tame kangaroo), but somehow, this doesn't apply for wilds, i.e G•Wd != Wx (Would-be x-coordinate of wild kangaroo)?

What's different about wild kangaroos that breaks the ECC multiply for it?
TamePoint = TameDistance * G
WildPoint = SearchPoint - LowerRange*G + WildDistance*G
fxsniper
Member
**
Offline Offline

Activity: 406
Merit: 45


View Profile
April 05, 2021, 11:28:18 AM
 #1616

my test is this kangaroo python

puzzle #40  pubkey = 03a2efa402fd5268400c77c20e574ba86409ededee7c4020e4b9f0edbee53de0d4

https://github.com/Telariust/pollard-kangaroo/blob/master/pollard-kangaroo-multi.py

python pollard-kangaroo-multi.py 40 03a2efa402fd5268400c77c20e574ba86409ededee7c4020e4b9f0edbee53de0d4

set verbose to 2 for show message it working process
flag_verbose   = 2   # 0, 1, 2

use verbose  2 script will write file tame.txt and wild.txt and on work message

message show this
[childs][tame-2#15344] newDP: X=ec9d5049bd4509aa41e1f5c312de1900d3eac4adba0692a41286b2497e520000
[childs][tame-2#15344] newDP: dK=0x102840cf7d0


if flag_verbose > 1:
print("\n[childs][%s#%s] newDP: X=%064x " % (child_name,child_pid, Xcoord));
print("\n[childs][%s#%s] newDP: dK=0x%x " % (child_name,child_pid, dK));

two value on tame.txt and wild.txt is
Xcoord
dK

but python code is very complicate
I think code is work function Elliptic Curve on script not using library function
I can see code but don't understand ECC calculate

I use ruby script from this easy
https://learnmeabitcoin.com/technical/public-key
and test print x y to see

point = multiply(k, $g) # this point is the public key

# convert x and y values of this point to hexadecimal
x = point[:x].to_s(16).rjust(64, "0")
y = point[:y].to_s(16).rjust(64, "0")

puts "point[:x] = " + point[:x].to_s
puts "point[:y] =" + point[:y].to_s

this x  is same value on  tame.txt and wild.txt

I don't know much
but think may be same on python script done


Can any help to save file tame.txt and wild.txt from kangaroo.exe

kangaroo.exe save file in binary right I can not read it
bigvito19
Full Member
***
Offline Offline

Activity: 706
Merit: 111


View Profile
April 05, 2021, 03:29:48 PM
 #1617

Are kangaroo collisions in the same herd a bad thing? My program (https://github.com/ZenulAbidin/Kangaroo-256) was doing that until I changed the hash table index calculation to use & HASHMASK instead of % HASHMASK.

To my understanding, they don't slow down the search - that happens when your DP size is too small for your search range and initial points are lost - but it just keeps going on forever without colliding the private key in the hash table.

Can you make an windows version of this too?
NotATether
Legendary
*
Offline Offline

Activity: 1638
Merit: 6897


bitcoincleanup.com / bitmixlist.org


View Profile WWW
April 05, 2021, 05:48:31 PM
 #1618

Are kangaroo collisions in the same herd a bad thing? My program (https://github.com/ZenulAbidin/Kangaroo-256) was doing that until I changed the hash table index calculation to use & HASHMASK instead of % HASHMASK.

To my understanding, they don't slow down the search - that happens when your DP size is too small for your search range and initial points are lost - but it just keeps going on forever without colliding the private key in the hash table.

Can you make an windows version of this too?

My friend's going to attach a K20 to my Windows server and then I'll be able to release a compiled version.

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

Activity: 1078
Merit: 219

Shooters Shoot...


View Profile
April 05, 2021, 06:16:02 PM
Merited by MrFreeDragon (1)
 #1619

Quote
Can any help to save file tame.txt and wild.txt from kangaroo.exe

kangaroo.exe save file in binary right I can not read it
After saving a work file, export it. That will create a readable text document.

You can use this python code. Run with nameoffile.py --wexport

Code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys, os
if sys.version_info.major<3:
    print("Python3 required")
    sys.exit(0)

import argparse
from struct import unpack
from binascii import hexlify,unhexlify
from math import log2

HEADW = 0xFA6A8001  # Full work file
HEADK = 0xFA6A8002  # Kangaroo only file

HASH_SIZE = 2**18

TAME=False
WILD=True




def bytes_to_num(b):
    return int(hexlify(b), 16)

def GetTimeStr(dTime):
  tmp = ''
  nbDay = dTime / 86400.0
  if nbDay >= 1:
    nbYear = nbDay / 365.0
    if nbYear > 1:
      if nbYear < 5:
        tmp += "%.1fy" % (nbYear)
      else:
        tmp += "%gy" % (nbYear)
    else:
      tmp += "%.1fd" % (nbDay)

  else:

    iTime = dTime
    nbHour = ((iTime % 86400) / 3600)
    nbMin = (((iTime % 86400) % 3600) / 60)
    nbSec = (iTime % 60)

    if nbHour == 0:
      if nbMin == 0:
        tmp += "%02ds" % (nbSec)
      else:
        tmp += "%02d:%02d" % (nbMin, nbSec)
    else:
      tmp += "%02d:%02d:%02d" % (nbHour, nbMin, nbSec)

  return tmp


def checkhead(wf):
    head = unpack('I', wf.read(4))[0]
    if head==HEADW:
        return head
    else:
        print('HEADER ERROR %08x %08x' % (head, HEADW))
        return False

def workinfo(workfile):

  wf = open(workfile, 'rb')
  head = checkhead(wf)
  if not head:
    print('Invalid WorkFile Header')
    return
  version = unpack('I', wf.read(4))[0]
  dp1 = unpack('I', wf.read(4))[0]
  RangeStart = bytes(wf.read(32))[::-1]
  RangeEnd = bytes(wf.read(32))[::-1]
  x = bytes(wf.read(32))[::-1]
  y = bytes(wf.read(32))[::-1]
  count = unpack('Q', wf.read(8))[0]
  time = unpack('d', wf.read(8))[0]

  print('Header   : %08x' % head)
  print('Version  : %d' % version)
  print('DP Bits  : %08x' % dp1)
  print('Start    : %x' % bytes_to_num(RangeStart))
  print('Stop     : %x' % bytes_to_num(RangeEnd))
  print('PubKey X : %s' % hexlify(x).decode())
  print('PubKey Y : %s' % hexlify(y).decode())

  if count>0:
    print('Count    : %d 2^%.3f' % (count, log2(count)))
  else:
    print('Count    : %d' % (count))

  print('Time     : %s' % GetTimeStr(time))

  wf.close()


def workexport(workfile):

    wf = open(workfile, 'rb')
    head = checkhead(wf)
    if not head:
      print('Invalid WorkFile Header')
      return
    wf.seek(156,0) # Skip WorkFile header

    tameFile = open('tame.txt','a')
    wildFile = open('wild.txt','a')

    for h in range(HASH_SIZE):
      nbItem = unpack('I', wf.read(4))[0]
      maxItem = unpack('I', wf.read(4))[0]
      for i in range(nbItem):
        x = bytes(wf.read(16))[::-1]
        d = bytes(wf.read(16))[::-1]

        sign = (bytes_to_num(d) & 0x80000000000000000000000000000000)>0
        htype = (bytes_to_num(d) & 0x40000000000000000000000000000000)>0

        if htype==TAME:
          tameFile.write('%05x%032x ' % (h, bytes_to_num(x)))
          tameFile.write('%032x\n' % (bytes_to_num(d) & 0x3fffffffffffffffffffffffffffffff))
        else:
          wildFile.write('%05x%032x ' % (h, bytes_to_num(x)))
          if sign:
            wildFile.write('-')
          wildFile.write('%032x\n' % (bytes_to_num(d) & 0x3fffffffffffffffffffffffffffffff))

        if args.verbose:
          sys.stdout.write('%s' % ('Tame' if htype==TAME else 'Wild'))
          sys.stdout.write(' %05x%032x ' % (h, bytes_to_num(x)))
          if sign:
            sys.stdout.write('-')
          sys.stdout.write('%032x\n' % (bytes_to_num(d) & 0x3fffffffffffffffffffffffffffffff))


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('-f', dest='workfile', type=str, required=True, help='WorkFile path')
    parser.add_argument('--winfo', dest='winfo', action='store_true', help='Show workfile info')
    parser.add_argument('--wexport', dest='wexport', action='store_true', help='Export workfile into tame.txt and wild.txt')
    parser.add_argument('-v', dest='verbose', action='store_true', help='Verbose')
    args = parser.parse_args()

    if args.workfile:
        print("[+] Workfile %s" % args.workfile)

    if args.winfo:
        workinfo(args.workfile)

    if args.wexport:
        workexport(args.workfile)

It will create 2 text files; tame.txt and wild.txt
fxsniper
Member
**
Offline Offline

Activity: 406
Merit: 45


View Profile
April 06, 2021, 11:54:50 AM
 #1620

Quote
Can any help to save file tame.txt and wild.txt from kangaroo.exe

kangaroo.exe save file in binary right I can not read it
After saving a work file, export it. That will create a readable text document.

You can use this python code. Run with nameoffile.py --wexport

Code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys, os
if sys.version_info.major<3:
    print("Python3 required")
    sys.exit(0)

import argparse
from struct import unpack
from binascii import hexlify,unhexlify
from math import log2

HEADW = 0xFA6A8001  # Full work file
HEADK = 0xFA6A8002  # Kangaroo only file

HASH_SIZE = 2**18

TAME=False
WILD=True




def bytes_to_num(b):
    return int(hexlify(b), 16)

def GetTimeStr(dTime):
  tmp = ''
  nbDay = dTime / 86400.0
  if nbDay >= 1:
    nbYear = nbDay / 365.0
    if nbYear > 1:
      if nbYear < 5:
        tmp += "%.1fy" % (nbYear)
      else:
        tmp += "%gy" % (nbYear)
    else:
      tmp += "%.1fd" % (nbDay)

  else:

    iTime = dTime
    nbHour = ((iTime % 86400) / 3600)
    nbMin = (((iTime % 86400) % 3600) / 60)
    nbSec = (iTime % 60)

    if nbHour == 0:
      if nbMin == 0:
        tmp += "%02ds" % (nbSec)
      else:
        tmp += "%02d:%02d" % (nbMin, nbSec)
    else:
      tmp += "%02d:%02d:%02d" % (nbHour, nbMin, nbSec)

  return tmp


def checkhead(wf):
    head = unpack('I', wf.read(4))[0]
    if head==HEADW:
        return head
    else:
        print('HEADER ERROR %08x %08x' % (head, HEADW))
        return False

def workinfo(workfile):

  wf = open(workfile, 'rb')
  head = checkhead(wf)
  if not head:
    print('Invalid WorkFile Header')
    return
  version = unpack('I', wf.read(4))[0]
  dp1 = unpack('I', wf.read(4))[0]
  RangeStart = bytes(wf.read(32))[::-1]
  RangeEnd = bytes(wf.read(32))[::-1]
  x = bytes(wf.read(32))[::-1]
  y = bytes(wf.read(32))[::-1]
  count = unpack('Q', wf.read(8))[0]
  time = unpack('d', wf.read(8))[0]

  print('Header   : %08x' % head)
  print('Version  : %d' % version)
  print('DP Bits  : %08x' % dp1)
  print('Start    : %x' % bytes_to_num(RangeStart))
  print('Stop     : %x' % bytes_to_num(RangeEnd))
  print('PubKey X : %s' % hexlify(x).decode())
  print('PubKey Y : %s' % hexlify(y).decode())

  if count>0:
    print('Count    : %d 2^%.3f' % (count, log2(count)))
  else:
    print('Count    : %d' % (count))

  print('Time     : %s' % GetTimeStr(time))

  wf.close()


def workexport(workfile):

    wf = open(workfile, 'rb')
    head = checkhead(wf)
    if not head:
      print('Invalid WorkFile Header')
      return
    wf.seek(156,0) # Skip WorkFile header

    tameFile = open('tame.txt','a')
    wildFile = open('wild.txt','a')

    for h in range(HASH_SIZE):
      nbItem = unpack('I', wf.read(4))[0]
      maxItem = unpack('I', wf.read(4))[0]
      for i in range(nbItem):
        x = bytes(wf.read(16))[::-1]
        d = bytes(wf.read(16))[::-1]

        sign = (bytes_to_num(d) & 0x80000000000000000000000000000000)>0
        htype = (bytes_to_num(d) & 0x40000000000000000000000000000000)>0

        if htype==TAME:
          tameFile.write('%05x%032x ' % (h, bytes_to_num(x)))
          tameFile.write('%032x\n' % (bytes_to_num(d) & 0x3fffffffffffffffffffffffffffffff))
        else:
          wildFile.write('%05x%032x ' % (h, bytes_to_num(x)))
          if sign:
            wildFile.write('-')
          wildFile.write('%032x\n' % (bytes_to_num(d) & 0x3fffffffffffffffffffffffffffffff))

        if args.verbose:
          sys.stdout.write('%s' % ('Tame' if htype==TAME else 'Wild'))
          sys.stdout.write(' %05x%032x ' % (h, bytes_to_num(x)))
          if sign:
            sys.stdout.write('-')
          sys.stdout.write('%032x\n' % (bytes_to_num(d) & 0x3fffffffffffffffffffffffffffffff))


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('-f', dest='workfile', type=str, required=True, help='WorkFile path')
    parser.add_argument('--winfo', dest='winfo', action='store_true', help='Show workfile info')
    parser.add_argument('--wexport', dest='wexport', action='store_true', help='Export workfile into tame.txt and wild.txt')
    parser.add_argument('-v', dest='verbose', action='store_true', help='Verbose')
    args = parser.parse_args()

    if args.workfile:
        print("[+] Workfile %s" % args.workfile)

    if args.winfo:
        workinfo(args.workfile)

    if args.wexport:
        workexport(args.workfile)

It will create 2 text files; tame.txt and wild.txt

Thank you very much

I using
python nameoffile.py --wexport -f save.work
  • Workfile save.work

got both file tame.txt and wild.txt
Thanks
Pages: « 1 ... 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 [81] 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 ... 142 »
  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!