一、先建立一个客户端项目:
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<Windows.h>
#include<string>
using namespace std;
int main()
{
string pwd;
while (1)
{
cout << "请输入密码" << endl;
cin >> pwd;
if (pwd == "000123")
{
break;
}
else
{
cout << "password error;" << endl;
}
}
cout << "login success!" << endl;
system("pause");
return 0;
}
现在生成了需要破解的程序:
二、破解程序
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<Windows.h>
#include<string>
using namespace std;
int main()
{
char pwd[7];
char dict[64];
char tmp[32];
int index = 0;
//dict数组存放每一位密码的可能值
for (int i = 0; i < 10; i++)
{
dict[index++] = '0'+i;
}
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;
}
}
}
}
}
}
system("pause");
return 0;
}
得到暴力破解程序:
三、将两个程序复制到一个文件夹中
打开控制台:windows+R,进入目录路径