Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string>
- #include <fstream>
- #include <unistd.h>
- #include <sys/stat.h>
- #include <filesystem>
- // build command:
- // g++ crack.cpp --std=c++17 -lstdc++fs -o crack.bin
- /* This application is designed to crack lost coin wallets provided the
- user has a portion (at lest 23 of the 24) of the words used to unlock
- the account, the position of the missing word is irrelivant as you
- can set it to check any position with the second input.
- NOTE: This application CAN be abstracted to check each word in a
- nmemonic phrase, HOWEVER to do so for each would take more time than a
- human being has, at a factor of
- (time to complete one collumn) * (collumns to check)^2048
- if you just want to steal someone's coin, this is THE WORST POSSIBLE
- WAY TO DO SO.
- METHOD: The application generates a string using known characters,
- leaving one blank at a specified position to be filled with a word from
- the english mnemonic word list as presented in BIP-32. It does not
- however check if the string is a valid mnemonic sequence and will
- simply try every mnemonic word until it finds a valid one, at which
- point the user must manually open the account and check for the valid
- balance themselves. This is very fast to do using system calls to
- 'xdotool' however it requires that the user keep the phrase entry box
- in focus until a correct entry has been found, this also limits OS
- compatibility to essentially just linux, which you should be using
- anyways.
- ARGUMENTS: There are two arguments you can provide to the application,
- "offset" (arg 1) and "position" (arg 2). "offset" is where in the
- wordlist to start and should not be set higher than the "max_words"
- variable less one. "position" is the position in the string to
- substitute the wordlist index for, this should not be set higher than
- "w_length" less one.
- STRING GENERATION: Strings are kept in the "known_words" array, into
- which any words from "known.txt" are placed, there must be AT LEAST the
- total number of words in the final mnemonic phrase less one. After the
- array has been filled (skipping the string at the "position" index) the
- string is then ready to be passed to the "run_crack" function.
- CRACKING: Cracking is done by subsituting the string at the index of
- "position" then outputting that to the Coinomi recovery window,
- checking if it is valid and pausing if it is, if not it clears the
- window and tries the next word in the wordlist.
- */
- /*
- RUN UNSTRUCTIONS:
- Put any known words in a file in the same DIR as the program
- named 'known.txt' and make sure you have the wordlist in the
- same folder as well, open coinomi and hit recover, then run
- the application and wait
- */
- namespace fs = std::filesystem;
- using std::string;
- using std::ifstream;
- const string run_com = "xdotool key --delay 0 ctrl+0x0061 && xdotool type --delay 0 \"";
- const uint16_t max_words = 2048;
- const int w_length = 24;
- unsigned int microsecond = 1000000;
- bool got_wrong = false;
- string words[max_words];
- string known_words[w_length];
- void load_words(int position)
- {
- ifstream klist("known.txt");
- string line;
- int i = 0;
- while(getline(klist, line))
- {
- if(i == position)
- i++;
- if(line.find("EOF") == string::npos)
- {
- known_words[i] = line;
- printf(
- "Word %s added to position %i\n",
- known_words[i].c_str(),
- i
- );
- }
- i++;
- }
- i = 0;
- ifstream wlist("english.txt");
- while(getline(wlist, line))
- {
- words[i] = line;
- printf("Added '%s' to wordlist\n", words[i].c_str());
- i++;
- }
- }
- /* XDOTOOL KEYS
- * 0x0061 = 'a'
- * 0xff09 = TAB
- * 0x0020 = SPACE
- * 0xff0d = RETURN
- */
- void run_crack(string line)
- {
- int log_size = fs::file_size("logger.txt");
- system((run_com + line + "\"").c_str());
- string enter_line_com = "xdotool key --delay 0 ctrl+0xff09 && xdotool key --delay 0 ctrl+0xff09 && xdotool key --delay 0 ctrl+0xff09 && xdotool key --delay 0 ctrl+0xff09 && xdotool key --delay 0 0x0020 && xdotool key --delay 0 0x0xff09";
- if(got_wrong)
- enter_line_com = "xdotool key --delay 0 ctrl+0xff09 && " + enter_line_com;
- system((enter_line_com).c_str());
- usleep(0.01 * microsecond);
- int log_size2 = fs::file_size("logger.txt");
- if(log_size2 == log_size)
- {
- printf("FOUND CORRECT PATTERN '%s'\n", line.c_str());
- system(("echo \"" + line + "\" >> valid_codes.txt").c_str());
- got_wrong = false;
- getchar();
- usleep(2 * microsecond);
- }
- else
- {
- got_wrong = true;
- system("xdotool key --delay 0 ctrl+0xff09");
- }
- }
- int main(int argc, char * argv[])
- {
- usleep(5 * microsecond);
- long int offset = 0;
- int position = 0;
- if(argc > 1)
- offset = atoi(argv[1]);
- if(argc > 2)
- {
- position = atoi(argv[2]);
- if(position > 23)
- {
- printf("Position cannot be greater than 23\n");
- printf("position starts at 0\n");
- position = 23;
- }
- }
- int attempts = offset;
- load_words(position);
- for(int index = offset; index < max_words; index++)
- {
- known_words[position] = words[index];
- string at_str = "";
- for(int in = 0; in < w_length; in++)
- {
- at_str += known_words[in] + " ";
- }
- printf("TRYING STRING '%s' ATTEMPT: %i\n", at_str.c_str(), attempts);
- run_crack(at_str);
- attempts++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement