Advertisement
Guest User

Untitled

a guest
Feb 28th, 2021
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.23 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string>
  3. #include <fstream>
  4. #include <unistd.h>
  5. #include <sys/stat.h>
  6. #include <filesystem>
  7.  
  8. // build command:
  9. //    g++ crack.cpp --std=c++17 -lstdc++fs -o crack.bin
  10.  
  11. /* This application is designed to crack lost coin wallets provided the
  12.  user has a portion (at lest 23 of the 24) of the words used to unlock
  13.  the account, the position of the missing word is irrelivant as you
  14.  can set it to check any position with the second input.
  15.  
  16.  NOTE: This application CAN be abstracted to check each word in a
  17.  nmemonic phrase, HOWEVER to do so for each would take more time than a
  18.  human being has, at a factor of
  19.     (time to complete one collumn) * (collumns to check)^2048
  20.  if you just want to steal someone's coin, this is THE WORST POSSIBLE
  21.  WAY TO DO SO.
  22.  
  23.  METHOD: The application generates a string using known characters,
  24.  leaving one blank at a specified position to be filled with a word from
  25.  the english mnemonic word list as presented in BIP-32. It does not
  26.  however check if the string is a valid mnemonic sequence and will
  27.  simply try every mnemonic word until it finds a valid one, at which
  28.  point the user must manually open the account and check for the valid
  29.  balance themselves. This is very fast to do using system calls to
  30.  'xdotool' however it requires that the user keep the phrase entry box
  31.  in focus until a correct entry has been found, this also limits OS
  32.  compatibility to essentially just linux, which you should be using
  33.  anyways.
  34.  
  35.  ARGUMENTS: There are two arguments you can provide to the application,
  36.  "offset" (arg 1) and "position" (arg 2). "offset" is where in the
  37.  wordlist to start and should not be set higher than the "max_words"
  38.  variable less one. "position" is the position in the string to
  39.  substitute the wordlist index for, this should not be set higher than
  40.  "w_length" less one.
  41.  
  42.  STRING GENERATION: Strings are kept in the "known_words" array, into
  43.  which any words from "known.txt" are placed, there must be AT LEAST the
  44.  total number of words in the final mnemonic phrase less one. After the
  45.  array has been filled (skipping the string at the "position" index) the
  46.  string is then ready to be passed to the "run_crack" function.
  47.  
  48.  CRACKING: Cracking is done by subsituting the string at the index of
  49.  "position" then outputting that to the Coinomi recovery window,
  50.  checking if it is valid and pausing if it is, if not it clears the
  51.  window and tries the next word in the wordlist.
  52. */
  53.  
  54. /*
  55. RUN UNSTRUCTIONS:
  56.     Put any known words in a file in the same DIR as the program
  57.     named 'known.txt' and make sure you have the wordlist in the
  58.     same folder as well, open coinomi and hit recover, then run
  59.     the application and wait
  60. */
  61.  
  62. namespace fs = std::filesystem;
  63. using std::string;
  64. using std::ifstream;
  65. const string run_com = "xdotool key --delay 0 ctrl+0x0061 && xdotool type --delay 0 \"";
  66. const uint16_t max_words = 2048;
  67. const int w_length = 24;
  68. unsigned int microsecond = 1000000;
  69.  
  70.  
  71.  
  72. bool got_wrong = false;
  73.  
  74. string words[max_words];
  75. string known_words[w_length];
  76.  
  77. void load_words(int position)
  78. {
  79.     ifstream klist("known.txt");
  80.     string line;
  81.     int i = 0;
  82.     while(getline(klist, line))
  83.     {
  84.         if(i == position)
  85.             i++;
  86.         if(line.find("EOF") == string::npos)
  87.         {
  88.             known_words[i] = line;
  89.             printf(
  90.                 "Word %s added to position %i\n",
  91.                 known_words[i].c_str(),
  92.                 i
  93.             );
  94.         }
  95.         i++;
  96.     }
  97.     i = 0;
  98.     ifstream wlist("english.txt");
  99.     while(getline(wlist, line))
  100.     {
  101.         words[i] = line;
  102.         printf("Added '%s' to wordlist\n", words[i].c_str());
  103.         i++;
  104.     }
  105. }
  106.  
  107. /* XDOTOOL KEYS
  108.  * 0x0061 = 'a'
  109.  * 0xff09 = TAB
  110.  * 0x0020 = SPACE
  111.  * 0xff0d = RETURN
  112.  */
  113.  
  114. void run_crack(string line)
  115. {
  116.     int log_size = fs::file_size("logger.txt");
  117.     system((run_com + line + "\"").c_str());   
  118.     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";
  119.     if(got_wrong)
  120.         enter_line_com = "xdotool key --delay 0 ctrl+0xff09 && " + enter_line_com;
  121.     system((enter_line_com).c_str());
  122.     usleep(0.01 * microsecond);
  123.     int log_size2 = fs::file_size("logger.txt");
  124.     if(log_size2 == log_size)
  125.     {
  126.         printf("FOUND CORRECT PATTERN '%s'\n", line.c_str());
  127.         system(("echo \"" + line + "\" >> valid_codes.txt").c_str());
  128.         got_wrong = false;
  129.         getchar();
  130.         usleep(2 * microsecond);
  131.     }
  132.     else
  133.     {
  134.         got_wrong = true;
  135.         system("xdotool key --delay 0 ctrl+0xff09");
  136.     }
  137. }
  138.  
  139. int main(int argc, char * argv[])
  140. {
  141.     usleep(5 * microsecond);
  142.     long int offset = 0;
  143.     int position = 0;
  144.     if(argc > 1)
  145.         offset = atoi(argv[1]);
  146.     if(argc > 2)
  147.     {
  148.         position = atoi(argv[2]);
  149.         if(position > 23)
  150.         {
  151.             printf("Position cannot be greater than 23\n");
  152.             printf("position starts at 0\n");
  153.             position = 23;
  154.         }
  155.     }
  156.     int attempts = offset;
  157.     load_words(position);
  158.     for(int index = offset; index < max_words; index++)
  159.     {
  160.         known_words[position] = words[index];
  161.         string at_str = "";
  162.         for(int in = 0; in < w_length; in++)
  163.         {
  164.             at_str += known_words[in] + " ";
  165.         }
  166.         printf("TRYING STRING '%s' ATTEMPT: %i\n", at_str.c_str(), attempts);
  167.         run_crack(at_str);
  168.         attempts++;
  169.     }
  170.     return 0;
  171. }
  172.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement