📚 OpenRCE is preserved as a read-only archive. Launched at RECon Montreal in 2005. Registration and posting are disabled.








Flag: Tornado! Hurricane!

 Forums >>  Brainstorms - General  >>  Snort Back Orifice Pre-Processor Buffer Overflow Vulnerability

Topic created on: October 19, 2005 17:02 CDT by Gerry .

If your new to vulnerability hunting you may want to look at this one as its pretty simple to spot. Writing an exploit for it though, is not as easy as it seems because of the stack layout (you overwrite 'len' and 'i') :)

The vulnerable function, BoGetDirection() is in spp_bo.c. The bad code is here:


// pkt_data => pointer to data after magic cookie
// len      => is a 32 bit int taken from the BO Header, with no checking.
// BoRand   => returns a 'random' number

static int BoGetDirection(Packet *p, char *pkt_data)
{
    u_int32_t len = 0;
    u_int32_t id = 0;
    u_int32_t l, i;
    char type;
    char buf1[1024];
    char buf2[1024];
    char *buf_ptr;
    char plaintext;
    ...

    /* Decrypt data */
    while ( i < len )
    {
        plaintext = (char) (*pkt_data ^ (BoRand()%256));
        *buf_ptr = plaintext;
        i++;
        pkt_data++;
        buf_ptr++;
        if ( plaintext == 0 )
            buf_ptr = buf2;
    }
    ...


/gerry

  pedram     October 19, 2005 17:15.36 CDT
Definetely not the easiest but to exploit however ... you end up overwriting your loop counter and limit in the overflow. Don't forget also that neither your source nor destination port can be 31337 otherwise the following conditional:


    /* Check for the default port on either side */
    if ( p->dp == BACKORIFICE_DEFAULT_PORT )
    {
        return BO_FROM_CLIENT;
    }
    else if ( p->sp == BACKORIFICE_DEFAULT_PORT )
    {
        return BO_FROM_SERVER;
    }


from BoGetDirection() will cause the vulnerable loop to be skipped. Some other random usefulness:


def bo_rand (x):
    return ((x * 214013) + 2531011) % 2**32

def bo_xor (cypher, iv):
    xored = ""
    
    for byte in cypher:
        iv        = bo_rand(iv)
        int_byte  = ord(byte)
        int_byte  = int_byte ^ ((iv >> 16) & 0xff)
        xored    += chr(int_byte)

    return xored


HD Moore has gotten a good chunk of the exploit done:

http://marc.theaimsgroup.com/?l=full-disclosure&m=112975920506599&w=2

I'm sure we'll be seeing the Metasploit module soon enough.

-pedram

  hdm     October 19, 2005 17:46.47 CDT
Remember that you can use a 0x00 byte to cause the overwrite loop to stop whenever you want, regardless of the length parameter. I use that in my code to avoid a crash caused by smashing the function arguments (*p, *pkt_data, etc).

  pedram     October 19, 2005 19:06.48 CDT
Appears to be much easier to exploit on windows as the loop counter is optimized into a register.

...

Yeah definetely easier ;-)

  mcassel     October 26, 2005 04:29.02 CDT
It took me 4 days to write this exploit in c. It was the first exploit i wrote and last in c. It was a bit frustrating to make the loop condition true.
I wonder of the possibilities of exploiting this bug on other architectures like RISC, powerpc... ?

Note: Registration is required to post to the forums.

There are 31,328 total registered users.


Recently Created Topics
[help] Unpacking VMP...
Mar/12
Reverse Engineering ...
Jul/06
let 'IDAPython' impo...
Sep/24
set 'IDAPython' as t...
Sep/24
GuessType return une...
Sep/20
About retrieving the...
Sep/07
How to find specific...
Aug/15
How to get data depe...
Jul/07
Identify RVA data in...
May/06
Question about memor...
Dec/12


Recent Forum Posts
Finding the procedur...
rolEYder
Question about debbu...
rolEYder
Identify RVA data in...
sohlow
let 'IDAPython' impo...
sohlow
How to find specific...
hackgreti
Problem with ollydbg
sh3dow
How can I write olly...
sh3dow
New LoadMAP plugin v...
mefisto...
Intel pin in loaded ...
djnemo
OOP_RE tool available?
Bl4ckm4n


Recent Blog Entries
halsten
Mar/14
Breaking IonCUBE VM

oleavr
Oct/24
Anatomy of a code tracer

hasherezade
Sep/24
IAT Patcher - new tool for ...

oleavr
Aug/27
CryptoShark: code tracer ba...

oleavr
Jun/25
Build a debugger in 5 minutes

More ...


Recent Blog Comments
nieo on:
Mar/22
IAT Patcher - new tool for ...

djnemo on:
Nov/17
Kernel debugger vs user mod...

acel on:
Nov/14
Kernel debugger vs user mod...

pedram on:
Dec/21
frida.github.io: scriptable...

capadleman on:
Jun/19
Using NtCreateThreadEx for ...

More ...


Imagery
SoySauce Blueprint
Jun 6, 2008

[+] expand

View Gallery (11) / Submit