airjack.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  aj_config
struct  a3_80211

Defines

#define mh_fc   fc1.fc1_frame_control
#define mh_version   fc1.fc2.fc2_version
#define mh_type   fc1.fc2.fc2_type
#define mh_subtype   fc1.fc2.fc2_subtype
#define mh_to_ds   fc1.fc2.fc2_to_ds
#define mh_from_ds   fc1.fc2.fc2_from_ds
#define mh_more_frag   fc1.fc2.fc2_more_frag
#define mh_retry   fc1.fc2.fc2_retry
#define mh_pwr_man   fc1.fc2.fc2_pwr_man
#define mh_more_data   fc1.fc2.fc2_more_data
#define mh_wep   fc1.fc2.fc2_wep
#define mh_order   fc1.fc2.fc2_order
#define mh_aid   mh_duration_id
#define mh_ra   mh_mac1
#define mh_da   mh_mac1
#define mh_ps_bssid   mh_mac1
#define mh_cf_bssid   mh_mac2
#define mh_ta   mh_mac2
#define mh_sa   mh_mac2
#define mh_bssid   mh_mac3
#define mh_seq   seq1.seq1_seq
#define mh_frag_num   seq1.seq2.seq2_frag_num
#define mh_seq_num   seq1.seq2.seq2_seq_num
#define FC_TYPE_MGT   0x00
#define FC_TYPE_CTL   0x01
#define FC_TYPE_DATA   0x02
#define FC_TYPE_RESR   0x03
#define MGT_AS_RQ   0x00
#define MGT_AS_RS   0x01
#define MGT_REAS_RQ   0x02
#define MGT_REAS_RS   0x03
#define MGT_PB_RQ   0x04
#define MGT_PB_RS   0x05
#define MGT_RESERV1   0x06
#define MGT_RESERV2   0x07
#define MGT_BEACON   0x08
#define MGT_ATIM   0x09
#define MGT_DISAS   0x0A
#define MGT_AUTH   0x0B
#define MGT_DEAUTH   0x0C
#define MGT_RESERV3   0x0D
#define MGT_RESERV4   0x0E
#define MGT_RESERV5   0x0F
#define SIOCAJSMODE   SIOCDEVPRIVATE
#define SIOCAJGMODE   SIOCAJSMODE + 1

Functions

int selectChannelAIRJACK (char *devname, int channel)
int shutCardAIRJACK (char *devname)
int openCardAIRJACK (char *devname)
int getPacketAIRJACK (p80211_caphdr_t *wlan_header, UINT8 *buf, int maxlen)
int openPacketAIRJACK (char *devname)
void closePacketAIRJACK (void)
void sendDeauth (UINT8 dest[WLAN_ADDR_LEN], UINT8 bssid[WLAN_ADDR_LEN], UINT8 channel)


Define Documentation

#define mh_fc   fc1.fc1_frame_control

Definition at line 76 of file airjack.h.

#define mh_version   fc1.fc2.fc2_version

Definition at line 77 of file airjack.h.

#define mh_type   fc1.fc2.fc2_type

Definition at line 78 of file airjack.h.

#define mh_subtype   fc1.fc2.fc2_subtype

Definition at line 79 of file airjack.h.

#define mh_to_ds   fc1.fc2.fc2_to_ds

Definition at line 80 of file airjack.h.

#define mh_from_ds   fc1.fc2.fc2_from_ds

Definition at line 81 of file airjack.h.

#define mh_more_frag   fc1.fc2.fc2_more_frag

Definition at line 82 of file airjack.h.

#define mh_retry   fc1.fc2.fc2_retry

Definition at line 83 of file airjack.h.

#define mh_pwr_man   fc1.fc2.fc2_pwr_man

Definition at line 84 of file airjack.h.

#define mh_more_data   fc1.fc2.fc2_more_data

Definition at line 85 of file airjack.h.

#define mh_wep   fc1.fc2.fc2_wep

Definition at line 86 of file airjack.h.

#define mh_order   fc1.fc2.fc2_order

Definition at line 87 of file airjack.h.

#define mh_aid   mh_duration_id

Definition at line 88 of file airjack.h.

#define mh_ra   mh_mac1

Definition at line 89 of file airjack.h.

#define mh_da   mh_mac1

Definition at line 90 of file airjack.h.

#define mh_ps_bssid   mh_mac1

Definition at line 91 of file airjack.h.

#define mh_cf_bssid   mh_mac2

Definition at line 92 of file airjack.h.

#define mh_ta   mh_mac2

Definition at line 93 of file airjack.h.

#define mh_sa   mh_mac2

Definition at line 94 of file airjack.h.

#define mh_bssid   mh_mac3

Definition at line 95 of file airjack.h.

#define mh_seq   seq1.seq1_seq

Definition at line 96 of file airjack.h.

#define mh_frag_num   seq1.seq2.seq2_frag_num

Definition at line 97 of file airjack.h.

#define mh_seq_num   seq1.seq2.seq2_seq_num

Definition at line 98 of file airjack.h.

#define FC_TYPE_MGT   0x00

Definition at line 102 of file airjack.h.

Referenced by sendDeauth().

#define FC_TYPE_CTL   0x01

Definition at line 103 of file airjack.h.

#define FC_TYPE_DATA   0x02

Definition at line 104 of file airjack.h.

#define FC_TYPE_RESR   0x03

Definition at line 105 of file airjack.h.

#define MGT_AS_RQ   0x00

Definition at line 108 of file airjack.h.

#define MGT_AS_RS   0x01

Definition at line 109 of file airjack.h.

#define MGT_REAS_RQ   0x02

Definition at line 110 of file airjack.h.

#define MGT_REAS_RS   0x03

Definition at line 111 of file airjack.h.

#define MGT_PB_RQ   0x04

Definition at line 112 of file airjack.h.

#define MGT_PB_RS   0x05

Definition at line 113 of file airjack.h.

#define MGT_RESERV1   0x06

Definition at line 114 of file airjack.h.

#define MGT_RESERV2   0x07

Definition at line 115 of file airjack.h.

#define MGT_BEACON   0x08

Definition at line 116 of file airjack.h.

#define MGT_ATIM   0x09

Definition at line 117 of file airjack.h.

#define MGT_DISAS   0x0A

Definition at line 118 of file airjack.h.

#define MGT_AUTH   0x0B

Definition at line 119 of file airjack.h.

#define MGT_DEAUTH   0x0C

Definition at line 120 of file airjack.h.

Referenced by sendDeauth().

#define MGT_RESERV3   0x0D

Definition at line 121 of file airjack.h.

#define MGT_RESERV4   0x0E

Definition at line 122 of file airjack.h.

#define MGT_RESERV5   0x0F

Definition at line 123 of file airjack.h.

#define SIOCAJSMODE   SIOCDEVPRIVATE

Definition at line 126 of file airjack.h.

Referenced by selectChannelAIRJACK().

#define SIOCAJGMODE   SIOCAJSMODE + 1

Definition at line 127 of file airjack.h.

Referenced by selectChannelAIRJACK().


Function Documentation

int selectChannelAIRJACK ( char *  devname,
int  channel 
)

Definition at line 71 of file airjack.c.

References aj_conf, aj_config::channel, debug, aj_config::monitor, req, SIOCAJGMODE, SIOCAJSMODE, sockfd, and STR_MAX.

Referenced by selectChannel(), and sendDeauth().

00072 {
00073 #define STR_MAX 80
00074   int result = 0;
00075 #if 0
00076   char str[STR_MAX];
00077   snprintf(str, STR_MAX, "set_channel -c %d -i %s 2>/dev/null",
00078            channel, devname);
00079   debug(3, "%s\n", str);
00080   result += system(str);
00081 #else
00082   req.ifr_data = (char *) &aj_conf;
00083 
00084   /* populate the structure */
00085   if (ioctl(sockfd, SIOCAJGMODE, &req) < 0) {
00086     return (-4);
00087   }
00088 
00089   aj_conf.channel = channel;
00090   aj_conf.monitor = 1;
00091 
00092   if (ioctl(sockfd, SIOCAJSMODE, &req) < 0) {
00093     return (-4);
00094   }
00095 #endif
00096   return result;
00097 }

int shutCardAIRJACK ( char *  devname  ) 

Definition at line 99 of file airjack.c.

References IfconfigSetFlags().

Referenced by shutCard().

00100 {
00101   return IfconfigSetFlags(devname, IFF_UP);
00102 }

int openCardAIRJACK ( char *  devname  ) 

Definition at line 104 of file airjack.c.

References aj_conf, IfconfigSetFlags(), req, and sockfd.

Referenced by openCard().

00105 {
00106   int result = 0;
00107   struct sockaddr_ll addr;
00108 
00109   // Turn on monitor mode
00110   result += IfconfigSetFlags(devname, IFF_UP + IFF_PROMISC);
00111 
00112   /* open the link layer socket */
00113   if ((sockfd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0) {
00114     return (-1);
00115   }
00116 
00117   /* get the interface index */
00118   memset(&req, 0, sizeof(struct ifreq));
00119   memset(&aj_conf, 0, sizeof(struct aj_config));
00120   strncpy(req.ifr_name, devname, IFNAMSIZ);
00121 
00122   if (ioctl(sockfd, SIOCGIFINDEX, &req) < 0) {
00123     return (-2);
00124   }
00125 
00126   /* bind the socket to the interface */
00127   memset(&addr, 0, sizeof(struct sockaddr_ll));
00128   addr.sll_ifindex = req.ifr_ifindex;
00129   addr.sll_protocol = htons(ETH_P_ALL);
00130   addr.sll_family = AF_PACKET;
00131   if (bind(sockfd, (struct sockaddr *) &addr, sizeof(struct sockaddr_ll)) <
00132       0) {
00133     return (-3);
00134   }
00135 
00136 
00137   return result;
00138 }

int getPacketAIRJACK ( p80211_caphdr_t wlan_header,
UINT8 buf,
int  maxlen 
)

Definition at line 142 of file airjack.c.

References p80211_caphdr::antenna, p80211_caphdr::channel, p80211_caphdr::datarate, p80211_caphdr::encoding, p80211_caphdr::hosttime, p80211_caphdr::length, p80211_caphdr::mactime, memcpy_buff(), CaptureArg_t::pcap, p80211_caphdr::phytype, p80211_caphdr::preamble, p80211_caphdr::priority, p80211_caphdr::ssi_noise, p80211_caphdr::ssi_signal, p80211_caphdr::ssi_type, and p80211_caphdr::version.

Referenced by getPacket().

00143 {
00144   struct pcap_pkthdr pktHdr;
00145   u_char *ret;
00146   fd_set rs;
00147 
00148   FD_ZERO(&rs);
00149   FD_SET(0, &rs);
00150 
00151   ret = (u_char *) pcap_next(ca.pcap, &pktHdr);
00152   // If no problem and packet is enought big (with data)
00153   if ((ret) && (pktHdr.len >= 1)) {
00154     if (memcpy_buff(buf, ret, pktHdr.len) == NULL)
00155       return 0;
00156     // Fill Header
00157     // TODO : find this information in any maner ?!
00158     wlan_header->version = 0;    // It's a reduced capture frame format
00159     wlan_header->length = 0;     // Not used for now
00160     wlan_header->mactime = 0;
00161     wlan_header->hosttime = 0;
00162     wlan_header->phytype = 0;    // Not used for now
00163     wlan_header->channel = 0;
00164     wlan_header->datarate = 0;   // datarate is in units of 100kbps.
00165     wlan_header->antenna = 0;    // Not used for now
00166     wlan_header->priority = 0;   // Not used for now
00167     wlan_header->ssi_type = 0;   // Not used for now
00168     wlan_header->ssi_signal = 0;
00169     wlan_header->ssi_noise = 0;
00170     wlan_header->preamble = 0;   // Not used for now
00171     wlan_header->encoding = 0;   // Not used for now
00172 
00173     return pktHdr.len;
00174   } else {
00175     return (0);                 // Noting to read
00176   }
00177 }

int openPacketAIRJACK ( char *  devname  ) 

Definition at line 179 of file airjack.c.

References debug, DLT_PRISM_HEADER, errbuf, CaptureArg_t::offset, and CaptureArg_t::pcap.

Referenced by openPacket().

00180 {
00181   int DataLink;
00182 
00183   ca.pcap = pcap_open_live(devname, 3000, 1, 0, errbuf);
00184   if (ca.pcap) {
00185     pcap_setnonblock(ca.pcap, 1, errbuf);
00186     DataLink = pcap_datalink(ca.pcap);
00187     switch (DataLink) {
00188     case DLT_PRISM_HEADER:
00189       debug(2,
00190             "pcap_datalink(ca.pcap) = %d = DLT_PRISM_HEADER\n", DataLink);
00191       ca.offset = 0x90;
00192       break;
00193     case DLT_IEEE802_11:
00194       debug(2, "pcap_datalink(ca.pcap) = %d = DLT_IEEE802_11\n", DataLink);
00195       ca.offset = 0;
00196       break;
00197     case DLT_AIRONET_HEADER:
00198       debug(2,
00199             "pcap_datalink(ca.pcap) = %d = DLT_AIRONET_HEADER:\n",
00200             DataLink);
00201       ca.offset = 0;
00202       break;
00203     default:                   //COOKED
00204       debug(2, "pcap_datalink(ca.pcap) = %d = COOKED:\n", DataLink);
00205       ca.offset = 160;
00206     }
00207     return 1;
00208   }
00209   return -1;
00210 }

void closePacketAIRJACK ( void   ) 

Definition at line 212 of file airjack.c.

References CaptureArg_t::pcap.

Referenced by closePacket().

00213 {
00214   pcap_close(ca.pcap);
00215 }

void sendDeauth ( UINT8  dest[WLAN_ADDR_LEN],
UINT8  bssid[WLAN_ADDR_LEN],
UINT8  channel 
)

Definition at line 217 of file airjack.c.

References debug, ConfigStruct::devname, FC_TYPE_MGT, MGT_DEAUTH, ScanResult_t::SChannel, selectChannelAIRJACK(), sockfd, and warning().

Referenced by LogPutIsAP(), and Send_To_All_BSSID_A_Deauth().

00219 {
00220   struct {
00221     struct a3_80211 hdr;
00222     unsigned short int reason;
00223   } __attribute__ ((packed)) frame;
00224   UINT8 OldChannel = 0;
00225 
00226   /* setup the frame */
00227   memset(&frame, 0, sizeof(frame));
00228   memcpy(frame.hdr.mh_mac1, dest, sizeof(frame.hdr.mh_mac1));
00229   memcpy(frame.hdr.mh_mac2, bssid, sizeof(frame.hdr.mh_mac2));
00230   memcpy(frame.hdr.mh_mac3, bssid, sizeof(frame.hdr.mh_mac3));
00231 
00232   frame.hdr.mh_type = FC_TYPE_MGT;
00233   frame.hdr.mh_subtype = MGT_DEAUTH;
00234   frame.hdr.mh_from_ds = 1;
00235   frame.reason = 2;             /* previous authentication is no longer valid */
00236 
00237   if (channel != 0) {           // Backup channel and change to the channel of the AP
00238     OldChannel = Res.SChannel;
00239     selectChannelAIRJACK(config.devname, channel);
00240   }
00241 
00242   if (write(sockfd, &frame, sizeof(frame)) < 0) {
00243     warning("AIRJACK error : write\n");
00244   }
00245 
00246   debug(2, "Send De-auth -- BSSID: %02X:%02X:%02X:%02X:%02X:%02X --"
00247         " DEST: %02X:%02X:%02X:%02X:%02X:%02X -- Channel: %d\n",
00248         bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5],
00249         dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], channel);
00250 
00251   if (channel != 0) {           // restore channel
00252     Res.SChannel = OldChannel;
00253     selectChannelAIRJACK(config.devname, OldChannel);
00254   }
00255 }


Generated on Fri Jul 25 17:10:42 2008 for WifiScanner by  doxygen 1.5.5