Last active
August 29, 2015 14:17
-
-
Save vhqtvn/4ff6fe679f313be3a8ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* C++ */ | |
#define NEEDSOL "\xff\x7b\x94\x89\x53\xac" | |
//#define NEEDSOL "\x2b\x0e\x60\xef\xf9\xca" | |
char s[20]=""; | |
char hashxor[4]; | |
int len = 10; | |
int lastlen = len-4; | |
char targetHash[10]="\x6b\x76\x12"; | |
char CS[] = "abcdefghijklmnopqrstuvwxyz"; | |
int CSL_ = sizeof(CS)-1; | |
int CSL = CSL_; | |
long long nhash = 0; | |
void solve(int i){ | |
if(i==3){ | |
for(int j=0;j<i;j++) putchar(s[j]);putchar('*');putchar(';');fflush(stdout); | |
} | |
if(i==len){ | |
static unsigned char hash[20]; | |
s[i]=0; | |
//printf("possible key %s | %02X:%02X:%02X\n",s,hashxor[0],hashxor[1],hashxor[2]);exit(0); | |
nhash ++ ; | |
sha1::calc(s, len, hash); | |
if(!strncmp(NEEDSOL,(const char*)hash,6)){ | |
for(int i=0;i<len+3;i++) putchar(s[i]); | |
printf("\n"); | |
exit(0); | |
} | |
return; | |
} | |
if(i>=lastlen && (i%4)!=3){ | |
s[i] = targetHash[i&3]^hashxor[i&3]; | |
if(((s[i]>='a')&&(s[i]<='z'))||((s[i]>='A')&&(s[i]<='Z'))) | |
solve(i+1); | |
}else{ | |
for(int j=0;j<CSL;j++) s[i]=CS[j], hashxor[i&3]^=CS[j], solve(i+1), hashxor[i&3]^=CS[j]; | |
} | |
return; | |
} | |
int main(int argc, char** argv){ | |
int start_index = 0; | |
if(argc>1){ | |
printf("test %s\n",argv[1]); | |
strcpy(s, argv[1]); | |
start_index = strlen(s); | |
for(int i=0;i<start_index;i++) hashxor[i&3]^=s[i]; | |
} | |
solve(start_index); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment