fireice-uk / xmr-stak

Free Monero RandomX Miner and unified CryptoNight miner
GNU General Public License v3.0
4.05k stars 1.79k forks source link

hacking code to let xmr-stak automatically take hostname as password #1466

Closed moralrebuild closed 6 years ago

moralrebuild commented 6 years ago

My C/C++ experience is very limited. I tried to achieve the title mentioned goal with modifying file xmrstak/jconf.cpp. I just replaced

    cfg.sPasswd = jpasswd->GetString();

with

    char hostname[40];
    gethostname(hostname, sizeof(hostname)-1);
    cfg.sPasswd = hostname;
    puts(cfg.sPasswd);

The code compiled successfully. Although the program failed for SOCKET error, the "puts(cfg.sPasswd);" still gave the correct hostname string.

Then I used the wireshark to capture the raw request packets sent to pool and surprisingly to see the password field was filled with nothing but a single dot character:

      Transmission Control Protocol, Src Port: 50886, Dst Port: 5555, Seq: 1, Ack: 1, Len: 239 
      Data (239 bytes) 
      0000  7b 22 6d 65 74 68 6f 64 22 3a 22 6c 6f 67 69 6e   {"method":"login 
      0010  22 2c 22 70 61 72 61 6d 73 22 3a 7b 22 6c 6f 67   ","params":{"log 
      0020  69 6e 22 3a 22 34 37 4d 34 39 61 78 70 64 35 6d   in":"57M49axpd5m 
      0030  44 6a 63 38 43 65 6d 64 4b 4b 56 58 4b 56 68 66   Djc8CemdKKVXKVhf 
      0040  65 62 76 4b 74 58 41 66 75 6f 51 7a 46 4d 66 71   ebvKtXAfuoQzFMfq 
      0050  4d 33 51 74 67 4d 72 4c 65 37 61 57 32 6f 42 71   M3QtgMrLe7aW2oBq 
      0060  44 6a 47 75 79 71 6f 4a 55 75 39 54 76 6e 62 33   DjGuyqoJU99Tvnb3 
      0070  68 63 37 44 76 59 33 38 46 71 52 64 5a 34 72 47   hc7DvY38FqRdZ4rG 
      0080  56 48 63 66 22 2c 22 70 61 73 73 22 3a 22 09 22   DHcf","pass":"." 
      0090  2c 22 72 69 67 69 64 22 3a 22 22 2c 22 61 67 65   ,"rigid":"","age 
      00a0  6e 74 22 3a 22 78 6d 72 2d 73 74 61 6b 2f 32 2e   nt":"xmr-stak/2. 
      00b0  34 2e 32 2f 65 31 30 65 38 65 36 2f 6d 61 73 74   4.2/e10e8e6/mast 
      00c0  65 72 2f 6c 69 6e 2f 63 70 75 2f 61 65 6f 6e 2d   er/lin/cpu/aeon
      00d0  63 72 79 70 74 6f 6e 69 67 68 74 2d 6d 6f 6e 65   cryptonight-mone 
      00e0  72 6f 2f 30 22 7d 2c 22 69 64 22 3a 31 7d 0a      ro/0"},"id":1}.    
          Data: 7b226d6574686f64223a226c6f67696e222c22706172616d...    
          [Length: 239]

Can anyone help me? Thanks.

moralrebuild commented 6 years ago

Get it solved after moving the code to the right place: xmrstak/misc/executor.cpp