client.cpp
#include <iostream> #include <Windows.h> #include <string> using namespace std; int main (void){ string pwd; while (1) { cout << "Please input your password: "; cin >> pwd; if (pwd == "000123") { break; } else { cout << "Password error." << endl; } } cout << "login success" << endl; cout << "1. 注册" << endl; cout << "2. 管理" << endl; cout << "3. 查询" << endl; cout << "4. 删除" << endl; system("pause"); return 0; }
crack.cpp
#include <iostream> using namespace std; int main(void) { char pwd[7]; char dict[64]; //10+26+26+1 = 63; char tmp[32]; int index = 0; for (int i=0; i<10; i++) { dict[index++] = '0' + i; } /* for (int i=0; i<26; i++) { dict[index++] = 'a' + i; } for (int i=0; i<26; i++) { dict[index++] = 'A' + i; } dict[index++] = '_'; */ dict[index] = '\0'; int n = index; // 字符个数 for (int p1=0; p1<n; p1++) { for (int p2=0; p2<n; p2++) { for (int p3=0; p3<n; p3++) { for(int p4=0; p4<n; p4++) { for(int p5=0; p5<n; p5++){ for (int p6=0; p6<n; p6++) { tmp[0] = dict[p1]; tmp[1] = dict[p2]; tmp[2] = dict[p3]; tmp[3] = dict[p4]; tmp[4] = dict[p5]; tmp[5] = dict[p6]; tmp[6] = '\0'; cout << tmp << endl; } } } } } } return 0; }
在控制台:
crack.exe | client.exe