gopro2027

Jenkins Brute Force

Oct 29th, 2018
613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. //written by gopro_2027
  2. //this will brute force jenkins hash using just a through z in the string
  3. //this certainly is not the fastest possible way but it will get the job done
  4.  
  5. #include "stdio.h"
  6. #include <cstring>
  7. #include <stdint.h>
  8.  
  9. uint32_t jenkins_one_at_a_time_hash(const uint8_t* key, size_t length) {
  10.   size_t i = 0;
  11.   uint32_t hash = 0;
  12.   while (i != length) {
  13.     hash += key[i++];
  14.     hash += hash << 10;
  15.     hash ^= hash >> 6;
  16.   }
  17.   hash += hash << 3;
  18.   hash ^= hash >> 11;
  19.   hash += hash << 15;
  20.   return hash;
  21. }
  22.  
  23.  
  24. char *incrementString(char *str, int &length) {
  25.     length = strlen(str);//seems to be an issue with this not here hmm
  26.     int spot = length-1;
  27.     for (int i = length-1; i >= 0; i--) {
  28.         if (str[i] == 'z') {
  29.        
  30.         } else {
  31.             str[i]++;
  32.             break;
  33.         }
  34.         spot = i-1;
  35.     }
  36.    
  37.     if (spot == -1) {
  38.         length++;
  39.     }
  40.     for (int i = spot+1; i < length; i++) {
  41.         str[i] = 'a';
  42.     }
  43.     return str;
  44. }
  45.  
  46. char *stringToFind = "";//put chur string in here or set the exact hash in the code below if you don't already know a string with the hash
  47.  
  48. int main() {
  49.     uint32_t hashToFind = jenkins_one_at_a_time_hash((const uint8_t*)stringToFind,strlen(stringToFind));//u can set an exact value here instead if u like
  50.     char str[100];
  51.     str[0] = 'a';
  52.     uint32_t currentHash = 0;
  53.     int length = 1;
  54.     while (true) {
  55.         incrementString(str,length);
  56.         currentHash = jenkins_one_at_a_time_hash((const uint8_t*)str,strlen(str));
  57.         if (currentHash == hashToFind) {
  58.             printf("Hash match (0x%X == 0x%X): %s\n",currentHash,hashToFind,str);
  59.         }
  60.     }
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment