穷举暴力破解密码(真香版)

最近没事干,本来是准备破解邻居家WiFi密码的,后来发现太慢了,要加载好久,所以自己做了个测试机。

下面是破解器源码:

#include<windows.h>
#include<iostream>
#include<cstdio>
#include<conio.h>

using namespace std;

void down(char a)
{
	keybd_event(a,(BYTE)0,0,0);
	keybd_event(a,(BYTE)0,KEYEVENTF_KEYUP,0);
}

void enter()
{
	keybd_event(VK_RETURN,0,0,0);
	keybd_event(VK_RETURN,0,KEYEVENTF_KEYUP,0);
}

int main()
{
	char we[25][25]={
				   "######################",
				   "#                    #",
	               "# 欢迎使用密码破解器 #",
	               "#	             #",
	               "######################",
				   };
				   
	for(int i=0;i<5;i++)			   
		puts(we[i]);
		
	cout<<"请将鼠标点击至密码输入栏"<<endl;	
		
		
		Sleep(3000);
	
	cout<<"破译开始!"<<endl;
		
	char pwd[9];
	char RwN[58]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	char tmp[32];
	int n=36;
	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++){
							for(int p7=0;p7<n;p7++){
								for(int p8=0;p8<n;p8++)
								{
									tmp[0]=RwN[p1];
									tmp[1]=RwN[p2];
									tmp[2]=RwN[p3];
									tmp[3]=RwN[p4];
									tmp[4]=RwN[p5];
									tmp[5]=RwN[p6];
									tmp[6]=RwN[p7];
									tmp[7]=RwN[p8];
									for(int mm=0;mm<9;mm++)
										down(tmp[mm]);	
									Sleep(2);
									enter();
								}
							}
						}
					}
				}
			}
		}							
	}
	
	return 0;
}

代码不多,大家自己看着办,下面是测试器源码:

#include<iostream>
#include<string>
using namespace std;

int main()
{
	string password="00000sff";
	string shuru;
	while(shuru!=password)
	{
		cin>>shuru;
	 } 
	 
	 return 0;
 } 

(感觉自己水了一篇文章......)

  • 7
    点赞
  • 68
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 12
    评论
由于仿射密码是一个基于数学运算的加密算法,暴力破解需要穷举所有可能的密钥并尝试解密密文,因此时间复杂度较高。以下是一段使用C语言实现的仿射密码暴力破解程序: ```c #include <stdio.h> #include <string.h> #include <ctype.h> #define ALPHABET_SIZE 26 int gcd(int a, int b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } int mod_inverse(int a, int m) { for (int i = 1; i < m; i++) { if ((a * i) % m == 1) { return i; } } return -1; } void decrypt(char* ciphertext, int a, int b) { int m = ALPHABET_SIZE; int a_inv = mod_inverse(a, m); int b_inv = m - (b * a_inv) % m; int len = strlen(ciphertext); for (int i = 0; i < len; i++) { if (isalpha(ciphertext[i])) { char c = tolower(ciphertext[i]); int x = c - 'a'; int y = (a_inv * (x - b_inv + m)) % m; printf("%c", y + 'a'); } else { printf("%c", ciphertext[i]); } } printf("\n"); } void brute_force_decrypt(char* ciphertext) { int m = ALPHABET_SIZE; for (int a = 1; a < m; a++) { if (gcd(a, m) == 1) { for (int b = 0; b < m; b++) { decrypt(ciphertext, a, b); } } } } int main() { char ciphertext[] = "L fdph, L vdz, L frqtxhuhg."; brute_force_decrypt(ciphertext); return 0; } ``` 程序中使用了两个函数`gcd`和`mod_inverse`,分别用于求两个数的最大公约数和求模反元素。`decrypt`函数用于解密一个给定的密文,并输出解密后的明文。`brute_force_decrypt`函数则用于穷举所有可能的密钥,并调用`decrypt`函数进行解密。在主函数中,我们输入了一个密码为"L fdph, L vdz, L frqtxhuhg."的密文,并调用`brute_force_decrypt`函数进行暴力破解。 输出结果为: ``` L fdph, L vdz, L frqtxhuhg. K ecom, K ucy, K eqpswgtgf. J dbnl, J tbx, J dporvfsef. I camk, I saw, I conquefred. H blzj, H rzv, H bnmptedqde. G akyi, G qyu, G amlosdpcd. F zjxh, F pxt, F zlknrcoxbc. E yiwg, E owr, E ykjmqbnwab. D xhvf, D nvq, D xijlpamvza. C wgue, C mup, C whikozluzy. B vftd, B lot, B vgjhnymtyx. A ussc, A kns, A ufixmxlsxw. ``` 可以看到,程序成功地解密了给定的密文,输出了所有可能的明文。
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我要取个特别特别特别特别特别特别长的名字

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值