c - C语言破解密码
问题描述
问题: 1. 密码用于加密不超过5位的密码。当只剩下 1,2,3,4 用于..语言时,我可以测试 1,2,3,4 数字。但它不适用于 5 位密码。2. 我也想使用代码一次测试不超过 5 位的密码,但我不知道如何实现?
else
{
string hash = argv[1];
string alphabet = "abcdefghijklmnopqrestuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
// salt is the first two letter of hash
// same key and same salt will come to the same hash
char salt[2];
salt[0] = hash[0];
salt[1] = hash[1];
char key[5];
int i,m,n,p,s;
for (i=0; i<strlen(alphabet); i++)
{
for (m=0; m<strlen(alphabet); m++)
{
for (n=0; n<strlen(alphabet);n++)
{
for (p=0; p<strlen(alphabet); p++)
{
for( s=0; s<strlen(alphabet);s++)
{
key[0]=alphabet[i];
key[1]=alphabet[m];
key[2]=alphabet[n];
key[3]=alphabet[p];
key[4]=alphabet[s];
if (strcmp(crypt(key,salt),hash) == 0)
{
printf("%s\n",key);
return 0;
}
}
}
}
}
}
}
printf("\n");
}
解决方案
推荐阅读
- java - 外键约束违反 JPA
- ios - AKNodeOutputPlot 无法与 Inter App Audio 一起正常工作
- android - 日历在某些 Android 设备上返回糟糕的一周开始
- javascript - 获取图像元素的第一个 src
- python - 在 google colab 上保存对克隆的 repo 的更改
- math - MIPS Mars4.5 保存算术项中的第一个数字
- angularjs - $http - post - 错误请求错误未处理(未定义)
- mnemonics - 我有 BIP39 助记符,需要 BIP44 xpub
- datetime - 检查时间戳是否为 1 小时前 - Groovy
- python - 在 tkinter 中单击按钮后如何更新值