mirror of
https://github.com/albertobsd/keyhunt.git
synced 2025-09-27 05:16:37 +02:00
Added method pub2rmd to find publickeys of puzzles
This commit is contained in:
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,11 +1,12 @@
|
||||
# Version Last
|
||||
- Change N variable type for modes address,rmd160 and xpoint, from uint32_t to uint64_t
|
||||
- Added method pub2rmd to search publickeys of the puzzles
|
||||
|
||||
# Version 0.1.20210331
|
||||
- Small changes to be compiled with mingw on Windows
|
||||
- Changed sort funtions and binary search for modes address/rmd160/xpoint, now those modes can load MAX 2^64 items
|
||||
- Changed sort functions and binary search for modes address/rmd160/xpoint, now those modes can load MAX 2^64 items
|
||||
- xpoint input file now can contains Comments after the line of data
|
||||
- from this version all furters developments will be in the branch `development`
|
||||
- from this version all furthers developments will be in the branch `development`
|
||||
|
||||
# Version 0.1.20210328
|
||||
- Added a progress counter (this solve bug https://github.com/albertobsd/keyhunt/issues/18 )
|
||||
@@ -13,13 +14,13 @@
|
||||
- Fixed the code to avoid warnings (this solve the issue https://github.com/albertobsd/keyhunt/issues/19)
|
||||
|
||||
# Version 0.1.20210322
|
||||
- Added xxhash for bloomfilter it hash better performance than murmurhash2. And it is 64 bits hash :)
|
||||
- Added xxhash for bloomfilter this hash have better performance than murmurhash2. And it is 64 bits hash :)
|
||||
- We reduce the number of items of the bPtable in ram using a second bloom filter, thanks @iceland2k14
|
||||
- The ram saved space is around 80%, so we can use a bigger K value, around 4 or 5 times bigger than previous version
|
||||
|
||||
# Version 0.1.20210320 K*BSGS
|
||||
- Solved little error with compress and uncompress new param -l. See https://github.com/albertobsd/keyhunt/issues/17
|
||||
- funtion bsgs optimized to use a little less RAM (not related with Pfile)
|
||||
- function bsgs optimized to use a little less RAM (not related with Pfile)
|
||||
- Again removed some compile warnings. See https://github.com/albertobsd/keyhunt/issues/16
|
||||
|
||||
# Version 0.1.20210311 K*BSGS
|
||||
@@ -40,7 +41,6 @@
|
||||
- Added mode BSGS this work with a file with uncompressed keys
|
||||
- Updated bloom filter to allow More items
|
||||
|
||||
|
||||
# Version 0.1.20201228
|
||||
- Change Quicksort to Introsort, this solve some edge cases of quicksort.
|
||||
- Introsort is avaible to keyhunt and hexcharstoraw. worst case. O(N log N).
|
||||
@@ -64,5 +64,5 @@
|
||||
- Minor bugs fixed.
|
||||
|
||||
# Version 0.1.20201217
|
||||
- First Realease
|
||||
- First Release
|
||||
- Thanks to all CryptoHunters to make this code possible
|
||||
|
62
README.md
62
README.md
@@ -137,7 +137,7 @@ Total 26214400 keys in 150 seconds: 174762 keys/s
|
||||
|
||||
rmd stand for RIPE Message Digest (see https://en.wikipedia.org/wiki/RIPEMD )
|
||||
|
||||
mode rmd160 work in the same why than address, but the diference is that file need to have hash rmd160 instead of addresses.
|
||||
mode rmd160 work in the same way than address, but the diference is that file need to have hash rmd160 instead of addresses.
|
||||
|
||||
This mode is almost two times faster than addres mode
|
||||
|
||||
@@ -300,6 +300,66 @@ The Operation is `800258a2ce` hex (+/-) in this case + `453856235784` decimal eq
|
||||
|
||||
This is an easy example, I been trying the puzzle 120 with more than 500 millions of substracted keys and no luck.
|
||||
|
||||
## pub2rmd mode
|
||||
This method is made to try to get the puzzles publickey key it works a little more faster because it skip the EC Operations
|
||||
|
||||
The input file need to have the hash RMD160 of the address without publickey leaked:
|
||||
|
||||
```
|
||||
3ee4133d991f52fdf6a25c9834e0745ac74248a4
|
||||
20d45a6a762535700ce9e0b216e31994335db8a5
|
||||
739437bb3dd6d1983e66629c5f08c70e52769371
|
||||
e0b8a2baee1b77fc703455f39d51477451fc8cfc
|
||||
61eb8a50c86b0584bb727dd65bed8d2400d6d5aa
|
||||
f6f5431d25bbf7b12e8add9af5e3475c44a0a5b8
|
||||
bf7413e8df4e7a34ce9dc13e2f2648783ec54adb
|
||||
105b7f253f0ebd7843adaebbd805c944bfb863e4
|
||||
9f1adb20baeacc38b3f49f3df6906a0e48f2df3d
|
||||
86f9fea5cdecf033161dd2f8f8560768ae0a6d14
|
||||
783c138ac81f6a52398564bb17455576e8525b29
|
||||
35003c3ef8759c92092f8488fca59a042859018c
|
||||
67671d5490c272e3ab7ddd34030d587738df33da
|
||||
351e605fac813965951ba433b7c2956bf8ad95ce
|
||||
20d28d4e87543947c7e4913bcdceaa16e2f8f061
|
||||
24cef184714bbd030833904f5265c9c3e12a95a2
|
||||
7c99ce73e19f9fbfcce4825ae88261e2b0b0b040
|
||||
c60111ed3d63b49665747b0e31eb382da5193535
|
||||
fbc708d671c03e26661b9c08f77598a529858b5e
|
||||
38a968fdfb457654c51bcfc4f9174d6ee487bb41
|
||||
5c3862203d1e44ab3af441503e22db97b1c5097e
|
||||
9978f61b92d16c5f1a463a0995df70da1f7a7d2a
|
||||
6534b31208fe6e100d29f9c9c75aac8bf06fbb38
|
||||
463013cd41279f2fd0c31d0a16db3972bfffac8d
|
||||
c6927a00970d0165327d0a6db7950f05720c295c
|
||||
2da63cbd251d23c7b633cb287c09e6cf888b3fe4
|
||||
578d94dc6f40fff35f91f6fba9b71c46b361dff2
|
||||
7eefddd979a1d6bb6f29757a1f463579770ba566
|
||||
c01bf430a97cbcdaedddba87ef4ea21c456cebdb
|
||||
```
|
||||
|
||||
To target that file you need to do:
|
||||
|
||||
`./keyhunt -m pub2rmd -f tests/puzzleswopublickey.txt -q`
|
||||
|
||||
Output:
|
||||
|
||||
```
|
||||
[+] Version 0.1.20210331
|
||||
[+] Setting mode pub2rmd
|
||||
[+] Set quiet thread output
|
||||
[+] Opening file tests/puzzleswopublickey.txt
|
||||
[+] Allocating memory for 29 elements: 0.00 MB
|
||||
[+] Initializing bloom filter for 29 elements.
|
||||
[+] Loading data to the bloomfilter total: 0.00 MB
|
||||
[+] Bloomfilter completed
|
||||
[+] Sorting data
|
||||
[+] 29 values were loaded and sorted
|
||||
Total 76546048 keys in 90 seconds: 850511 keys/s
|
||||
```
|
||||
|
||||
You can let it run for a while together with others scripts, if you get one of those publickeys now you can target it with a better method like bsgs or another tools like kangaroo
|
||||
|
||||
|
||||
## bsgs mode (baby step giant step)
|
||||
|
||||
Keyhunt implement the BSGS algorithm to search privatekeys for a knowed publickey.
|
||||
|
105
bloom/bloom.c
105
bloom/bloom.c
@@ -116,6 +116,42 @@ int bloom_init2(struct bloom * bloom, uint64_t entries, long double error)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bloom_dummy(struct bloom * bloom, uint64_t entries, long double error)
|
||||
{
|
||||
memset(bloom, 0, sizeof(struct bloom));
|
||||
if (entries < 1000 || error <= 0 || error >= 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bloom->entries = entries;
|
||||
bloom->error = error;
|
||||
|
||||
long double num = -log(bloom->error);
|
||||
long double denom = 0.480453013918201; // ln(2)^2
|
||||
bloom->bpe = (num / denom);
|
||||
|
||||
long double dentries = (long double)entries;
|
||||
long double allbits = dentries * bloom->bpe;
|
||||
bloom->bits = (uint64_t)allbits;
|
||||
|
||||
bloom->bytes = (uint64_t) bloom->bits / 8;
|
||||
if (bloom->bits % 8) {
|
||||
bloom->bytes +=1;
|
||||
}
|
||||
|
||||
bloom->hashes = (uint8_t)ceil(0.693147180559945 * bloom->bpe); // ln(2)
|
||||
/*
|
||||
bloom->bf = (uint8_t *)calloc(bloom->bytes, sizeof(uint8_t));
|
||||
if (bloom->bf == NULL) { // LCOV_EXCL_START
|
||||
return 1;
|
||||
} // LCOV_EXCL_STOP
|
||||
|
||||
bloom->ready = 1;
|
||||
bloom->major = BLOOM_VERSION_MAJOR;
|
||||
bloom->minor = BLOOM_VERSION_MINOR;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bloom_check(struct bloom * bloom, const void * buffer, int len)
|
||||
{
|
||||
@@ -162,6 +198,75 @@ int bloom_reset(struct bloom * bloom)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bloom_loadcustom(struct bloom * bloom, char * filename) {
|
||||
if (filename == NULL || filename[0] == 0) {
|
||||
return 1;
|
||||
}
|
||||
FILE *fd_str,*fd_dat;
|
||||
char filename_str[70],filename_dat[70];
|
||||
memset(filename_str,0,70);
|
||||
memset(filename_dat,0,70);
|
||||
snprintf(filename_str,68,"%s.blm",filename);
|
||||
snprintf(filename_dat,68,"%s.dat",filename);
|
||||
fd_str = fopen(filename_str,"rb");
|
||||
fd_dat = fopen(filename_dat,"rb");
|
||||
if (fd_str == NULL || fd_dat == NULL) {
|
||||
return 1;
|
||||
}
|
||||
if(fread(bloom,1,sizeof(struct bloom),fd_str) != sizeof(struct bloom) ) {
|
||||
fclose(fd_str);
|
||||
fclose(fd_dat);
|
||||
return 1;
|
||||
}
|
||||
bloom->bf = malloc(bloom->bytes);
|
||||
if(bloom->bf == NULL) {
|
||||
memset(bloom, 0, sizeof(struct bloom));
|
||||
return 1;
|
||||
}
|
||||
if(fread(bloom->bf,1, bloom->bytes,fd_dat) !=bloom->bytes) {
|
||||
free(bloom->bf);
|
||||
memset(bloom, 0, sizeof(struct bloom));
|
||||
fclose(fd_str);
|
||||
fclose(fd_dat);
|
||||
return 1;
|
||||
}
|
||||
fclose(fd_str);
|
||||
fclose(fd_dat);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bloom_savecustom(struct bloom * bloom, char * filename) {
|
||||
if (filename == NULL || filename[0] == 0) {
|
||||
return 1;
|
||||
}
|
||||
FILE *fd_str,*fd_dat;
|
||||
char filename_str[70],filename_dat[70];
|
||||
memset(filename_str,0,70);
|
||||
memset(filename_dat,0,70);
|
||||
snprintf(filename_str,68,"%s.blm",filename);
|
||||
snprintf(filename_dat,68,"%s.dat",filename);
|
||||
fd_str = fopen(filename_str,"wb");
|
||||
fd_dat = fopen(filename_dat,"wb");
|
||||
if (fd_str == NULL || fd_dat == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(fwrite(bloom,1,sizeof(struct bloom),fd_str) != sizeof(struct bloom) ) {
|
||||
fclose(fd_str);
|
||||
fclose(fd_dat);
|
||||
return 1;
|
||||
}
|
||||
if(fwrite(bloom->bf,1, bloom->bytes,fd_dat) !=bloom->bytes) {
|
||||
fclose(fd_str);
|
||||
fclose(fd_dat);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fclose(fd_str);
|
||||
fclose(fd_dat);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int bloom_save(struct bloom * bloom, char * filename)
|
||||
{
|
||||
|
@@ -39,6 +39,13 @@ struct bloom
|
||||
double bpe;
|
||||
uint8_t *bf;
|
||||
};
|
||||
/*
|
||||
Customs
|
||||
*/
|
||||
|
||||
int bloom_dummy(struct bloom * bloom, uint64_t entries, long double error);
|
||||
int bloom_loadcustom(struct bloom * bloom, char * filename);
|
||||
int bloom_savecustom(struct bloom * bloom, char * filename);
|
||||
|
||||
|
||||
/** ***************************************************************************
|
||||
|
226
keyhunt.c
226
keyhunt.c
@@ -32,6 +32,7 @@ email: alberto.bsd@gmail.com
|
||||
#define MODE_ADDRESS 1
|
||||
#define MODE_BSGS 2
|
||||
#define MODE_RMD160 3
|
||||
#define MODE_PUB2RMD 4
|
||||
|
||||
#define SEARCH_UNCOMPRESS 0
|
||||
#define SEARCH_COMPRESS 1
|
||||
@@ -69,6 +70,18 @@ struct bPload {
|
||||
uint64_t counter;
|
||||
};
|
||||
|
||||
struct __attribute__((__packed__)) publickey {
|
||||
uint8_t parity;
|
||||
union {
|
||||
uint8_t data8[32];
|
||||
uint32_t data32[8];
|
||||
uint64_t data64[4];
|
||||
} X;
|
||||
};
|
||||
|
||||
|
||||
const char *bloomnames[256] = {"bloom_0","bloom_1","bloom_2","bloom_3","bloom_4","bloom_5","bloom_6","bloom_7","bloom_8","bloom_9","bloom_10","bloom_11","bloom_12","bloom_13","bloom_14","bloom_15","bloom_16","bloom_17","bloom_18","bloom_19","bloom_20","bloom_21","bloom_22","bloom_23","bloom_24","bloom_25","bloom_26","bloom_27","bloom_28","bloom_29","bloom_30","bloom_31","bloom_32","bloom_33","bloom_34","bloom_35","bloom_36","bloom_37","bloom_38","bloom_39","bloom_40","bloom_41","bloom_42","bloom_43","bloom_44","bloom_45","bloom_46","bloom_47","bloom_48","bloom_49","bloom_50","bloom_51","bloom_52","bloom_53","bloom_54","bloom_55","bloom_56","bloom_57","bloom_58","bloom_59","bloom_60","bloom_61","bloom_62","bloom_63","bloom_64","bloom_65","bloom_66","bloom_67","bloom_68","bloom_69","bloom_70","bloom_71","bloom_72","bloom_73","bloom_74","bloom_75","bloom_76","bloom_77","bloom_78","bloom_79","bloom_80","bloom_81","bloom_82","bloom_83","bloom_84","bloom_85","bloom_86","bloom_87","bloom_88","bloom_89","bloom_90","bloom_91","bloom_92","bloom_93","bloom_94","bloom_95","bloom_96","bloom_97","bloom_98","bloom_99","bloom_100","bloom_101","bloom_102","bloom_103","bloom_104","bloom_105","bloom_106","bloom_107","bloom_108","bloom_109","bloom_110","bloom_111","bloom_112","bloom_113","bloom_114","bloom_115","bloom_116","bloom_117","bloom_118","bloom_119","bloom_120","bloom_121","bloom_122","bloom_123","bloom_124","bloom_125","bloom_126","bloom_127","bloom_128","bloom_129","bloom_130","bloom_131","bloom_132","bloom_133","bloom_134","bloom_135","bloom_136","bloom_137","bloom_138","bloom_139","bloom_140","bloom_141","bloom_142","bloom_143","bloom_144","bloom_145","bloom_146","bloom_147","bloom_148","bloom_149","bloom_150","bloom_151","bloom_152","bloom_153","bloom_154","bloom_155","bloom_156","bloom_157","bloom_158","bloom_159","bloom_160","bloom_161","bloom_162","bloom_163","bloom_164","bloom_165","bloom_166","bloom_167","bloom_168","bloom_169","bloom_170","bloom_171","bloom_172","bloom_173","bloom_174","bloom_175","bloom_176","bloom_177","bloom_178","bloom_179","bloom_180","bloom_181","bloom_182","bloom_183","bloom_184","bloom_185","bloom_186","bloom_187","bloom_188","bloom_189","bloom_190","bloom_191","bloom_192","bloom_193","bloom_194","bloom_195","bloom_196","bloom_197","bloom_198","bloom_199","bloom_200","bloom_201","bloom_202","bloom_203","bloom_204","bloom_205","bloom_206","bloom_207","bloom_208","bloom_209","bloom_210","bloom_211","bloom_212","bloom_213","bloom_214","bloom_215","bloom_216","bloom_217","bloom_218","bloom_219","bloom_220","bloom_221","bloom_222","bloom_223","bloom_224","bloom_225","bloom_226","bloom_227","bloom_228","bloom_229","bloom_230","bloom_231","bloom_232","bloom_233","bloom_234","bloom_235","bloom_236","bloom_237","bloom_238","bloom_239","bloom_240","bloom_241","bloom_242","bloom_243","bloom_244","bloom_245","bloom_246","bloom_247","bloom_248","bloom_249","bloom_250","bloom_251","bloom_252","bloom_253","bloom_254","bloom_255"};
|
||||
|
||||
|
||||
const char *version = "0.1.20210331";
|
||||
const char *EC_constant_N = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141";
|
||||
@@ -109,6 +122,7 @@ void *thread_process_bsgs(void *vargp);
|
||||
void *thread_process_bsgs_random(void *vargp);
|
||||
void *thread_bPload(void *vargp);
|
||||
void *thread_bPloadFile(void *vargp);
|
||||
void *thread_pub2rmd(void *vargp);
|
||||
|
||||
void init_doublingG(struct Point *P);
|
||||
char *publickeytohashrmd160(char *pkey,int length);
|
||||
@@ -119,7 +133,7 @@ int THREADOUTPUT = 0;
|
||||
char *bit_range_str_min;
|
||||
char *bit_range_str_max;
|
||||
|
||||
const char *modes[4] = {"xpoint","address","bsgs","rmd160"};
|
||||
const char *modes[5] = {"xpoint","address","bsgs","rmd160","pub2rmd"};
|
||||
const char *cryptos[3] = {"btc","eth","all"};
|
||||
const char *publicsearch[3] = {"uncompress","compress","both"};
|
||||
const char *default_filename = "addresses.txt";
|
||||
@@ -131,6 +145,7 @@ pthread_mutex_t write_random;
|
||||
pthread_mutex_t bsgs_thread;
|
||||
|
||||
struct Elliptic_Curve EC;
|
||||
struct bloom dummybloom;
|
||||
struct bloom bloom;
|
||||
struct Point G;
|
||||
|
||||
@@ -219,17 +234,16 @@ int main(int argc, char **argv) {
|
||||
char *filename,*precalculated_mp_filename;
|
||||
FILE *fd;
|
||||
char *hextemp,*aux,*aux2,*pointx_str,*pointy_str;
|
||||
uint64_t i,seconds;
|
||||
uint64_t j,total_precalculated,PERTHREAD,BASE,PERTHREAD_R;
|
||||
uint64_t j,total_precalculated,i,seconds,PERTHREAD,BASE,PERTHREAD_R;
|
||||
uint64_t itemsbloom,itemsbloom2;
|
||||
int readed,s,continue_flag,check_flag,r,lenaux,lendiff;
|
||||
mpz_t total,pretotal,debugcount_mpz,Ysquared,mpz_aux,mpz_aux2;
|
||||
clock_t c_beging,c_ending, time_spent;
|
||||
struct bPload *temp;
|
||||
|
||||
int c;
|
||||
|
||||
gmp_randinit_mt(state);
|
||||
gmp_randseed_ui(state, ((int)clock()) + ((int)time(NULL)) );
|
||||
printf("[+] Version %s\n",version);
|
||||
mpz_init_set_str(EC.p, EC_constant_P, 16);
|
||||
mpz_init_set_str(EC.n, EC_constant_N, 16);
|
||||
mpz_init_set_str(G.x , EC_constant_Gx, 16);
|
||||
@@ -237,6 +251,7 @@ int main(int argc, char **argv) {
|
||||
init_doublingG(&G);
|
||||
mpz_init_set_ui(TWO,2);
|
||||
|
||||
printf("[+] Version %s\n",version);
|
||||
|
||||
while ((c = getopt(argc, argv, "dehqRwzb:c:f:g:k:l:m:n:p:r:s:t:v:-:")) != -1) {
|
||||
switch(c) {
|
||||
@@ -361,7 +376,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
switch(indexOf(optarg,modes,4)) {
|
||||
switch(indexOf(optarg,modes,5)) {
|
||||
case MODE_XPOINT: //xpoint
|
||||
FLAGMODE = MODE_XPOINT;
|
||||
printf("[+] Setting mode xpoint\n");
|
||||
@@ -378,6 +393,10 @@ int main(int argc, char **argv) {
|
||||
FLAGMODE = MODE_RMD160;
|
||||
printf("[+] Setting mode rmd160\n");
|
||||
break;
|
||||
case MODE_PUB2RMD:
|
||||
FLAGMODE = MODE_PUB2RMD;
|
||||
printf("[+] Setting mode pub2rmd\n");
|
||||
break;
|
||||
default:
|
||||
FLAGMODE = MODE_ADDRESS;
|
||||
fprintf(stderr,"[+] Unknow mode value %s.\n",optarg);
|
||||
@@ -544,7 +563,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
}
|
||||
N =0;
|
||||
N = 0;
|
||||
if(FLAGMODE != MODE_BSGS) {
|
||||
aux = malloc(1000);
|
||||
if(aux == NULL) {
|
||||
@@ -567,6 +586,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
MAXLENGTHADDRESS = 32;
|
||||
break;
|
||||
case MODE_PUB2RMD:
|
||||
case MODE_RMD160:
|
||||
if(FLAGRAWDATA) {
|
||||
while(!feof(fd)) {
|
||||
@@ -619,9 +639,8 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
fseek(fd,0,SEEK_SET);
|
||||
|
||||
printf("[+] Allocating memory for %"PRIu64" elements: %.2f MB\n",N,(double)(sizeof(struct address_value)*N)/1048576);
|
||||
printf("[+] Allocating memory for %"PRIu64" elements: %.2f MB\n",N,(double)(((double) sizeof(struct address_value)*N)/(double)1048576));
|
||||
i = 0;
|
||||
|
||||
do {
|
||||
addressTable = malloc(sizeof(struct address_value)*N);
|
||||
i++;
|
||||
@@ -753,6 +772,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MODE_PUB2RMD:
|
||||
case MODE_RMD160:
|
||||
if(FLAGRAWDATA) {
|
||||
aux = malloc(MAXLENGTHADDRESS);
|
||||
@@ -1031,20 +1051,63 @@ int main(int argc, char **argv) {
|
||||
bsgs_aux = mpz_get_ui(BSGS_AUX);
|
||||
DEBUGCOUNT = (uint64_t)((uint64_t)bsgs_m * (uint64_t)bsgs_aux);
|
||||
|
||||
printf("[+] Setting N up to %llu.\n",(long long unsigned int)DEBUGCOUNT);
|
||||
printf("[+] Setting N up to %"PRIu64".\n",DEBUGCOUNT);
|
||||
|
||||
for(i=0; i< 256; i++) {
|
||||
if(((int)(bsgs_m/256)) > 1000) {
|
||||
if(bloom_init2(&bloom_bP[i],(int)(bsgs_m/256),0.000001) == 1){
|
||||
fprintf(stderr,"[E] error bloom_init [%"PRIu64"]\n",i);
|
||||
exit(0);
|
||||
itemsbloom = ((uint64_t)(bsgs_m/256)) > 1000 ? (uint64_t)(bsgs_m/256) : 1000;
|
||||
itemsbloom2 = bsgs_m2 > 1000 ? bsgs_m : 1000;
|
||||
|
||||
if( FLAGBLOOMFILTER == 1 ) {
|
||||
int continuebloom = 1;
|
||||
int numberbloom = 0;
|
||||
for(i=0; i< 256 && continuebloom; i++) {
|
||||
if(bloom_loadcustom(&bloom_bP[i],(char*)bloomnames[i]) == 1){
|
||||
continuebloom = 0;
|
||||
}
|
||||
else {
|
||||
if(bloom_dummy(&dummybloom,itemsbloom,0.000001) == 0){
|
||||
numberbloom++;
|
||||
if(dummybloom.bytes != bloom_bP[i].bytes) {
|
||||
continuebloom = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
continuebloom = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(bloom_init2(&bloom_bP[i],1000,0.000001) == 1){
|
||||
fprintf(stderr,"[E] error bloom_init for 1000 elements [%"PRIu64"]\n",i);
|
||||
exit(0);
|
||||
if(continuebloom == 1) {
|
||||
if(bloom_loadcustom(&bloom_bPx2nd,"bPx2nd") == 1) {
|
||||
continuebloom == 0;
|
||||
}
|
||||
else {
|
||||
if(bloom_dummy(&dummybloom,itemsbloom2,0.000001) == 0){
|
||||
if(dummybloom.bytes != bloom_bPx2nd.bytes) {
|
||||
continuebloom = 0;
|
||||
}
|
||||
if(continuebloom == 0) {
|
||||
bloom_free(&bloom_bPx2nd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(continuebloom == 0) {
|
||||
fprintf(stderr,"[E] Some bloom file fail or missmatch size\n");
|
||||
FLAGBLOOMFILTER = 0;
|
||||
for(i=0; i < numberbloom ; i++) {
|
||||
bloom_free(&bloom_bP[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if( FLAGBLOOMFILTER == 0) {
|
||||
*/
|
||||
for(i=0; i< 256; i++) {
|
||||
if(bloom_init2(&bloom_bP[i],itemsbloom,0.000001) == 1){
|
||||
fprintf(stderr,"[E] error bloom_init [%"PRIu64"]\n",i);
|
||||
exit(0);
|
||||
}
|
||||
bloom_bP_totalbytes += bloom_bP[i].bytes;
|
||||
if(FLAGDEBUG) bloom_print(&bloom_bP[i]);
|
||||
@@ -1246,19 +1309,28 @@ int main(int argc, char **argv) {
|
||||
tt = malloc(sizeof(struct tothread));
|
||||
tt->nt = i;
|
||||
steps[i] = 0;
|
||||
s = pthread_create(&tid[i],NULL,thread_process,(void *)tt);
|
||||
switch(FLAGMODE) {
|
||||
case MODE_ADDRESS:
|
||||
case MODE_XPOINT:
|
||||
case MODE_RMD160:
|
||||
s = pthread_create(&tid[i],NULL,thread_process,(void *)tt);
|
||||
break;
|
||||
case MODE_PUB2RMD:
|
||||
s = pthread_create(&tid[i],NULL,thread_pub2rmd,(void *)tt);
|
||||
break;
|
||||
}
|
||||
if(s != 0) {
|
||||
fprintf(stderr,"[E] pthread_create thread_process\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
continue_flag = 1;
|
||||
mpz_init(total);
|
||||
mpz_init(pretotal);
|
||||
mpz_init(debugcount_mpz);
|
||||
sprintf(temporal,"%llu",(long long unsigned int)DEBUGCOUNT);
|
||||
sprintf(temporal,"%"PRIu64,DEBUGCOUNT);
|
||||
//printf("[I] Debug count : %s\n",temporal);
|
||||
mpz_set_str(debugcount_mpz,temporal,10);
|
||||
seconds = 0;
|
||||
do {
|
||||
@@ -2094,7 +2166,7 @@ void *thread_process_bsgs(void *vargp) {
|
||||
//gmp_printf("While cycle: base_key : %Zd < n_range_end: %Zd\n",base_key,n_range_end);
|
||||
if(FLAGQUIET == 0){
|
||||
gmp_sprintf(xpoint_str,"%0.64Zx",base_key);
|
||||
printf("\r[+] Thread %i: %s",thread_number,xpoint_str);
|
||||
printf("\r[+] Thread %s ",xpoint_str);
|
||||
fflush(stdout);
|
||||
THREADOUTPUT = 1;
|
||||
}
|
||||
@@ -2139,7 +2211,7 @@ void *thread_process_bsgs(void *vargp) {
|
||||
|
||||
if(r) {
|
||||
gmp_sprintf(xpoint_str,"%0.64Zx",keyfound);
|
||||
printf("\n[+] Thread %i Key found privkey %s\n",thread_number,xpoint_str);
|
||||
printf("\n[+] Thread Key found privkey %s\n",xpoint_str);
|
||||
Scalar_Multiplication(G,&point_aux2,keyfound);
|
||||
gmp_sprintf(pubkey,"04%0.64Zx%0.64Zx",point_aux2.x,point_aux2.y);
|
||||
printf("[+] Publickey %s\n",pubkey);
|
||||
@@ -2248,7 +2320,7 @@ void *thread_process_bsgs_random(void *vargp) {
|
||||
//gmp_printf("While cycle: base_key : %Zd < n_range_end: %Zd\n",base_key,n_range_end);
|
||||
if(FLAGQUIET == 0){
|
||||
gmp_sprintf(xpoint_str,"%0.64Zx",base_key);
|
||||
printf("\r[+] Thread %i: %s",thread_number,xpoint_str);
|
||||
printf("\r[+] Thread %s",xpoint_str);
|
||||
fflush(stdout);
|
||||
THREADOUTPUT = 1;
|
||||
}
|
||||
@@ -2286,7 +2358,7 @@ void *thread_process_bsgs_random(void *vargp) {
|
||||
r = bsgs_secondcheck(base_key,i,&OriginalPointsBSGS[k],&keyfound);
|
||||
if(r) {
|
||||
gmp_sprintf(xpoint_str,"%0.64Zx",keyfound);
|
||||
printf("\n[+] Thread %i Key found privkey %s\n",thread_number,xpoint_str);
|
||||
printf("\n[+] Thread Key found privkey %s\n",xpoint_str);
|
||||
Scalar_Multiplication(G,&point_aux2,keyfound);
|
||||
gmp_sprintf(pubkey,"04%0.64Zx%0.64Zx",point_aux2.x,point_aux2.y);
|
||||
printf("[+] Publickey %s\n",pubkey);
|
||||
@@ -2523,3 +2595,105 @@ void sleep_ms(int milliseconds) { // cross-platform sleep function
|
||||
usleep((milliseconds % 1000) * 1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
void *thread_pub2rmd(void *vargp) {
|
||||
FILE *fd;
|
||||
mpz_t key_mpz;
|
||||
struct tothread *tt;
|
||||
uint64_t i,limit,j;
|
||||
char digest160[20];
|
||||
char digest256[32];
|
||||
char *temphex;
|
||||
int thread_number,r;
|
||||
int pub2rmd_continue = 1;
|
||||
struct publickey pub;
|
||||
limit = 0xFFFFFFFF;
|
||||
tt = (struct tothread *)vargp;
|
||||
thread_number = tt->nt;
|
||||
mpz_init(key_mpz);
|
||||
do {
|
||||
if(FLAGRANDOM){
|
||||
mpz_urandomm(key_mpz,state,n_range_diff);
|
||||
mpz_add(key_mpz,key_mpz,n_range_start);
|
||||
}
|
||||
else {
|
||||
if(mpz_cmp(n_range_start,n_range_end) <= 0) {
|
||||
pthread_mutex_lock(&write_random);
|
||||
mpz_set(key_mpz,n_range_start);
|
||||
mpz_add_ui(n_range_start,n_range_start,N_SECUENTIAL_MAX);
|
||||
pthread_mutex_unlock(&write_random);
|
||||
}
|
||||
else {
|
||||
pub2rmd_continue = 0;
|
||||
}
|
||||
}
|
||||
if(pub2rmd_continue) {
|
||||
temphex = malloc(65);
|
||||
gmp_sprintf(temphex,"%0.64Zx",key_mpz);
|
||||
hexs2bin(temphex,pub.X.data8);
|
||||
free(temphex);
|
||||
pub.parity = 0x02;
|
||||
pub.X.data32[7] = 0;
|
||||
if(FLAGQUIET == 0) {
|
||||
temphex = tohex((char*)&pub,33);
|
||||
printf("\r[+] Thread %s",temphex);
|
||||
fflush(stdout);
|
||||
THREADOUTPUT = 1;
|
||||
}
|
||||
for(i = 0 ; i < limit ; i++) {
|
||||
pub.parity = 0x02;
|
||||
sha256((char*)&pub, 33, digest256);
|
||||
RMD160Data((const unsigned char*)digest256,32, digest160);
|
||||
r = bloom_check(&bloom,digest160,MAXLENGTHADDRESS);
|
||||
if(r) {
|
||||
r = searchbinary(addressTable,digest160,N);
|
||||
if(r) {
|
||||
temphex = tohex((char*)&pub,33);
|
||||
printf("\nHit: Publickey found %s\n",temphex);
|
||||
fd = fopen("KEYFOUNDKEYFOUND.txt","a+");
|
||||
if(fd != NULL) {
|
||||
pthread_mutex_lock(&write_keys);
|
||||
fprintf(fd,"Publickey found %s\n",temphex);
|
||||
fclose(fd);
|
||||
pthread_mutex_unlock(&write_keys);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"\nPublickey found %s\nbut the file can't be open\n",temphex);
|
||||
exit(0);
|
||||
}
|
||||
free(temphex);
|
||||
}
|
||||
}
|
||||
pub.parity = 0x03;
|
||||
sha256((char*)&pub, 33, digest256);
|
||||
RMD160Data((const unsigned char*)digest256,32, digest160);
|
||||
r = bloom_check(&bloom,digest160,MAXLENGTHADDRESS);
|
||||
if(r) {
|
||||
r = searchbinary(addressTable,digest160,N);
|
||||
if(r) {
|
||||
temphex = tohex((char*)&pub,33);
|
||||
printf("\nHit: Publickey found %s\n",temphex);
|
||||
fd = fopen("KEYFOUNDKEYFOUND.txt","a+");
|
||||
if(fd != NULL) {
|
||||
pthread_mutex_lock(&write_keys);
|
||||
fprintf(fd,"Publickey found %s\n",temphex);
|
||||
fclose(fd);
|
||||
pthread_mutex_unlock(&write_keys);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"\nPublickey found %s\nbut the file can't be open\n",temphex);
|
||||
exit(0);
|
||||
}
|
||||
free(temphex);
|
||||
}
|
||||
}
|
||||
pub.X.data32[7]++;
|
||||
if(pub.X.data32[7] % DEBUGCOUNT == 0) {
|
||||
steps[thread_number]++;
|
||||
}
|
||||
} /* End for */
|
||||
} /* End if */
|
||||
} while(pub2rmd_continue);
|
||||
ends[thread_number] = 1;
|
||||
return NULL;
|
||||
}
|
||||
|
29
tests/puzzleswopublickey.txt
Normal file
29
tests/puzzleswopublickey.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
3ee4133d991f52fdf6a25c9834e0745ac74248a4
|
||||
20d45a6a762535700ce9e0b216e31994335db8a5
|
||||
739437bb3dd6d1983e66629c5f08c70e52769371
|
||||
e0b8a2baee1b77fc703455f39d51477451fc8cfc
|
||||
61eb8a50c86b0584bb727dd65bed8d2400d6d5aa
|
||||
f6f5431d25bbf7b12e8add9af5e3475c44a0a5b8
|
||||
bf7413e8df4e7a34ce9dc13e2f2648783ec54adb
|
||||
105b7f253f0ebd7843adaebbd805c944bfb863e4
|
||||
9f1adb20baeacc38b3f49f3df6906a0e48f2df3d
|
||||
86f9fea5cdecf033161dd2f8f8560768ae0a6d14
|
||||
783c138ac81f6a52398564bb17455576e8525b29
|
||||
35003c3ef8759c92092f8488fca59a042859018c
|
||||
67671d5490c272e3ab7ddd34030d587738df33da
|
||||
351e605fac813965951ba433b7c2956bf8ad95ce
|
||||
20d28d4e87543947c7e4913bcdceaa16e2f8f061
|
||||
24cef184714bbd030833904f5265c9c3e12a95a2
|
||||
7c99ce73e19f9fbfcce4825ae88261e2b0b0b040
|
||||
c60111ed3d63b49665747b0e31eb382da5193535
|
||||
fbc708d671c03e26661b9c08f77598a529858b5e
|
||||
38a968fdfb457654c51bcfc4f9174d6ee487bb41
|
||||
5c3862203d1e44ab3af441503e22db97b1c5097e
|
||||
9978f61b92d16c5f1a463a0995df70da1f7a7d2a
|
||||
6534b31208fe6e100d29f9c9c75aac8bf06fbb38
|
||||
463013cd41279f2fd0c31d0a16db3972bfffac8d
|
||||
c6927a00970d0165327d0a6db7950f05720c295c
|
||||
2da63cbd251d23c7b633cb287c09e6cf888b3fe4
|
||||
578d94dc6f40fff35f91f6fba9b71c46b361dff2
|
||||
7eefddd979a1d6bb6f29757a1f463579770ba566
|
||||
c01bf430a97cbcdaedddba87ef4ea21c456cebdb
|
Reference in New Issue
Block a user