niceBit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 066ecf3edbcc9b17edeeb04d4c2f45c0ab4eee2b
parent 2723bd9700bad2a8dcecbbc7cba0828602d80183
Author: NicholasFarrow <nicholas.w.farrow@gmail.com>
Date:   Fri, 14 Aug 2020 20:31:45 +1000

Added ability to search from dictionary file.

Diffstat:
MniceBit.c | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 58 insertions(+), 14 deletions(-)

diff --git a/niceBit.c b/niceBit.c @@ -76,7 +76,7 @@ int gen_keypair(unsigned char *seckey, char *pubaddress, secp256k1_context *ctx) return 1; } -int check_vanity(char *pubaddress, int searchlen) { +int check_nums(char *pubaddress, int searchlen) { unsigned char compstr[40]; char possibleChars[] = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; int j; @@ -84,16 +84,16 @@ int check_vanity(char *pubaddress, int searchlen) { /* For each vanity length * ('len' digits in a row) */ - for(int len=10; len>=searchlen; len--) { + for (int len=10; len>=searchlen; len--) { /* For each digit 1-9 */ - for(int i=0; i<58; i++) { + for (int i=0; i<58; i++) { /* Comprise compstr of 'len' repeats * of digit 'i' */ j = 0; - while(j<len) { + while (j<len) { compstr[j] = possibleChars[i]; j++; } @@ -102,35 +102,63 @@ int check_vanity(char *pubaddress, int searchlen) { compstr[j] = '\0'; /* Check if string in pubaddress */ - if(strstr(pubaddress, compstr) != NULL) { + if (strstr(pubaddress, compstr) != NULL) { printf("Found : %s\n", compstr); return 1; } } } + return 0; +} + +int check_words(char *pubaddress, char (*words)[34], int nwords) { + for (int i=0; i<nwords; i++) { + /* printf("%s\n", words[i]); + puts(pubaddress); */ + if (strstr(pubaddress, words[i]) != NULL) { + printf("Found : %s\n", words[i]); + return 1; + } + } + return 0; +} +int check_vanity(char *pubaddress, int searchlen, char (*words)[34], int nwords) { + if ((nwords > 0) && check_words(pubaddress, words, nwords)) { + return 1; + } + if ((searchlen >0) && check_nums(pubaddress, searchlen)) { + return 1; + } return 0; } int main(int argc, char **argv) { unsigned char seckey[32]; char pubaddress[34]; + char *p = pubaddress; - char *n = "5"; + char *n = "0"; + char *filename = ""; + int searchlen; int c; /* Get input arguments (length) */ - while ((c = getopt(argc, argv, "n:")) != -1) { + while ((c = getopt(argc, argv, "n:f:")) != -1) { switch (c) { case 'n': n = optarg; break; + case 'f': + filename = optarg; + break; case '?': printf("Invalid argument: %c\n", optopt); return 1; } } + searchlen = atoi(n); ctx = secp256k1_context_create( @@ -141,17 +169,33 @@ int main(int argc, char **argv) { clock_t starttime = clock(); double timespent; double rate; - - while(1) { - if(!gen_keypair(seckey, pubaddress, ctx)) { + + char words[100][34]; + int n_words = 0; + /* Load Dictionary File */ + if (filename != "") { + puts("Loading words..."); + FILE *fptr = fopen(filename, "r"); + + while (fgets(words[n_words], 34, fptr)) { + /* words[n_words][strlen(words[n_words]) - 1] = '\0'; */ + words[n_words][strlen(words[n_words]) - 1] = '\0'; + puts(words[n_words]); + n_words++; + } + printf("%d words have been loaded.\n", n_words); + } + + while (1) { + if (!gen_keypair(seckey, pubaddress, ctx)) { printf("Failed to create keypair\n"); return 1; } - if(check_vanity(pubaddress, searchlen)) { + if (check_vanity(pubaddress, searchlen, words, n_words)) { printf("Seckey : "); - for(int i=0; i<32; i++) { - printf("%02X", seckey[i]); + for (int j=0; j<32; j++) { + printf("%02X", seckey[j]); } printf("\nWIF: "); create_wif(seckey); @@ -159,7 +203,7 @@ int main(int argc, char **argv) { printf("Public Address: %s\n\n", pubaddress); } - if(i % 100000 == 0) { + if (i % 100000 == 0) { clock_t currenttime = clock(); timespent = (double)((currenttime - starttime)