-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbeacon_flood_lcpa.c
More file actions
195 lines (148 loc) · 4.62 KB
/
beacon_flood_lcpa.c
File metadata and controls
195 lines (148 loc) · 4.62 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
beacon_flood_lcpa.c
by brad.antoniewicz@foundstone.com
simple IEEE 802.11 beacon flooder using LORCON2's
packet assembly functionality
*/
#include <stdio.h>
#include <getopt.h>
#include <string.h>
#include <sys/time.h> // Needed for timestamp
#include <lorcon2/lorcon.h> // For LORCON
#include <lorcon2/lorcon_packasm.h> // For metapack packet assembly
void usage(char *argv[]) {
printf("\t-s <SSID>\tSSID to flood\n");
printf("\t-i <int> \tInterface\n");
printf("\t-c <channel>\tChannel\n");
printf("\nExample:\n");
printf("\t%s -s brad -i wlan0 -c 1\n\n",argv[0]);
}
int main(int argc, char *argv[]) {
char *interface = NULL, *ssid = NULL;
int c;
uint8_t channel;
unsigned int count=0;
lorcon_driver_t *drvlist, *driver; // Needed to set up interface/context
lorcon_t *context; // LORCON context
lcpa_metapack_t *metapack; // metapack for LORCON packet assembly
lorcon_packet_t *txpack; // The raw packet to be sent
/*
These are needed for the actual beacon frame
*/
// BSSID and source MAC address
uint8_t *mac = "\x00\xDE\xAD\xBE\xEF\x00";
// Timestamp
struct timeval time;
uint64_t timestamp;
// Supported Rates
uint8_t rates[] = "\x8c\x12\x98\x24\xb0\x48\x60\x6c"; // 6,9,12,18,24,36,48,54
// Beacon Interval
int interval = 100;
// Capabilities
int capabilities = 0x0421;
printf ("%s - Simple 802.11 Beacon Flooder\n", argv[0]);
printf ("-----------------------------------------------------\n\n");
/*
This handles all of the command line arguments
*/
while ((c = getopt(argc, argv, "i:s:hc:")) != EOF) {
switch (c) {
case 'i':
interface = strdup(optarg);
break;
case 's':
if ( strlen(strdup(optarg)) < 255 ) {
ssid = strdup(optarg);
} else {
printf("ERROR: SSID Length too long! Should not exceed 255 characters\n");
return -1;
}
break;
case 'c':
channel = atoi(optarg);
break;
case 'h':
usage(argv);
break;
default:
usage(argv);
break;
}
}
if ( interface == NULL || ssid == NULL ) {
printf ("ERROR: Interface, channel, or SSID not set (see -h for more info)\n");
return -1;
}
printf("[+] Using interface %s\n",interface);
/*
The following is all of the standard interface, driver, and context setup
*/
// Automatically determine the driver of the interface
if ( (driver = lorcon_auto_driver(interface)) == NULL) {
printf("[!] Could not determine the driver for %s\n",interface);
return -1;
} else {
printf("[+]\t Driver: %s\n",driver->name);
}
// Create LORCON context
if ((context = lorcon_create(interface, driver)) == NULL) {
printf("[!]\t Failed to create context");
return -1;
}
// Create Monitor Mode Interface
if (lorcon_open_injmon(context) < 0) {
printf("[!]\t Could not create Monitor Mode interface!\n");
return -1;
} else {
printf("[+]\t Monitor Mode VAP: %s\n",lorcon_get_vap(context));
lorcon_free_driver_list(driver);
}
// Set the channel we'll be injecting on
lorcon_set_channel(context, channel);
printf("[+]\t Using channel: %d\n\n",channel);
/*
The following is the packet creation and sending code
*/
// Keep sending frames until interrupted
while(1) {
// Create timestamp
gettimeofday(&time, NULL);
timestamp = time.tv_sec * 1000000 + time.tv_usec;
// Initialize the LORCON metapack
metapack = lcpa_init();
// Create a Beacon frame from 00:DE:AD:BE:EF:00
lcpf_beacon(metapack, mac, mac, 0x00, 0x00, 0x00, 0x00, timestamp, interval, capabilities);
// Append IE Tag 0 for SSID
lcpf_add_ie(metapack, 0, strlen(ssid),ssid);
// Most of the following IE tags are not needed, but added here as examples
// Append IE Tag 1 for rates
lcpf_add_ie(metapack, 1, sizeof(rates)-1, rates);
// Append IE Tag 3 for Channel
lcpf_add_ie(metapack, 3, 1, &channel);
// Append IE Tags 42/47 for ERP Info
lcpf_add_ie(metapack, 42, 1, "\x05");
lcpf_add_ie(metapack, 47, 1, "\x05");
// Convert the LORCON metapack to a LORCON packet for sending
txpack = (lorcon_packet_t *) lorcon_packet_from_lcpa(context, metapack);
// Send and exit if error
if ( lorcon_inject(context,txpack) < 0 )
return -1;
// Wait interval before next beacon
usleep(interval * 1000);
// Print nice and pretty
printf("\033[K\r");
printf("[+] Sent %d frames, Hit CTRL + C to stop...", count);
fflush(stdout);
count++;
// Free the metapack
lcpa_free(metapack);
}
/*
The following is all of the standard cleanup stuff
*/
// Close the interface
lorcon_close(context);
// Free the LORCON Context
lorcon_free(context);
return 0;
}