本来是不想写,但是前两周因为一些事没写代码,现在再写发现很多东西都忘了,还是把它记下来比较好,本篇记录的工具包括readelf,peda,objdump,ROPgadget…..
ltrace/strace 跟踪用,能够轻易看出问题原因:
1 2 3 4 5 ltrace -c count time and calls, and report a summary on exit . -e FILTER read +execve+write -l, --library=LIBRARY_PATTERN only trace symbols implemented by this library. -p PID attach to the process with the process ID pid.
nasm 1 2 3 4 nasm -felf32 shell.asm -o shell.o ld -melf_i386 shell.o -o shell objcopy -O binary shell.o shell.bin objdump -b binaty -m i386 -D shell.bin
*cat 用来监听的
1 2 3 socat tcp-l :6666,reuseaddr,fork exec :"./pwn" ncat -vc ./shellcode -kl 127.0.0.1 1234 ncat -vc "strace -e trace=read ./shellcode" -kl 127.0.0.1 1234
readelf 喜欢它的格式,比较清晰~
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 SYNOPSIS readelf [-a|--all] [-h|--file-header] [-l|--program-headers|--segments] [-S|--section-headers|--sections] [-g|--section-groups] [-t|--section-details] [-e|--headers] [-s|--syms|--symbols] [--dyn-syms] [-n|--notes] [-r|--relocs] [-u|--unwind] [-d|--dynamic] [-V|--version-info] [-A|--arch-specific] [-D|--use-dynamic] [-x <number or name>|--hex-dump=<number or name>] [-p <number or name>|--string-dump=<number or name>] [-R <number or name>|--relocated-dump=<number or name>] [-z|--decompress] [-c|--archive-index] [-w[lLiaprmfFsoRt]| --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index]] [--dwarf-depth=n] [--dwarf-start=n] [-I|--histogram] [-v|--version] [-W|--wide] [-H|--help ] elffile...
objdump 功能要更强大丁丁~
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 OBJDUMP(1) GNU Development Tools OBJDUMP(1) NAME objdump - display information from object files. SYNOPSIS objdump [-a|--archive-headers] [-b bfdname|--target=bfdname] [-C|--demangle[=style] ] [-d|--disassemble] [-D|--disassemble-all] [-z|--disassemble-zeroes] [-EB|-EL|--endian={big | little }] [-f|--file-headers] [-F|--file-offsets] [--file-start-context] [-g|--debugging] [-e|--debugging-tags] [-h|--section-headers|--headers] [-i|--info] [-j section|--section=section] [-l|--line-numbers] [-S|--source ] [-m machine|--architecture=machine] [-M options|--disassembler-options=options] [-p|--private-headers] [-P options|--private=options] [-r|--reloc] [-R|--dynamic-reloc] [-s|--full-contents] [-W[lLiaprmfFsoRt]| --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames] [=aranges,=macro,=frames,=frames-interp,=str,=loc] [=Ranges,=pubtypes,=trace_info,=trace_abbrev] [=trace_aranges,=gdb_index] [-G|--stabs] [-t|--syms] [-T|--dynamic-syms] [-x|--all-headers] [-w|--wide] [--start-address=address] [--stop-address=address] [--[no-]show-raw-insn] [--adjust-vma=offset] [--dwarf-depth=n] [--dwarf-start=n] [--special-syms] [--prefix=prefix] [--prefix-strip=level] [--insn-width=width] [-V|--version] [-H|--help ] objfile...
参考
[1]http://www.win.tue.nl/~aeb/linux/hh/stack-layout.html