make test //直接生成没有什么保护的程序 gcc -o test test.c // 默认情况下,开启Canary保护,开启NX保护,不开启PIE,不开启RELRO保护 g++ -o test test.c //编译C++程序,其他相同 gcc -m32 -o test test.c //编译32位的程序:加个-m32
gcc -fno-stack-protector -o test test.c //禁用栈保护
gcc -fstack-protector -o test test.c //启用堆栈保护,不过只为局部变量中含有 char 数组的函数插入保护代码 gcc -fstack-protector-all -o test test.c //启用堆栈保护,为所有函数插入保护代码
gcc -g -z execstack -o test test.c // 禁用NX保护 gcc -z noexecstack -o test test.c // 开启NX保护
gcc -fpie -pie -o test test.c // 开启PIE,此时强度为1 gcc -fPIE -pie -o test test.c // 开启PIE,此时为最高强度2
gcc -z norelro -o test test.c // 关闭,即No RELRO gcc -z lazy -o test test.c // 部分开启,即Partial RELRO,got表可改 gcc -z now -o test test.c // 全部开启,即got表不可改
gcc -s -fstack-protector-all -fpie -pie -z now -o test test.c // 保护全开! format strings: -D_FORTIFY_SOURCE=0(close) -D_FORTIFY_SOURCE=1 -O1(open1) -D_FORTIFY_SOURCE=2 -O2(open2)
-s (delete strings table) //df
//one time Docker create pwn environment //Edit ctf.xinetd. replace ./helloworld to your challenge. sudo docker build -t "helloworld" . sudo docker run -d -p "0.0.0.0:7777:9999" -h "helloworld" --name="helloworld" helloworld
仅打包,不压缩 tar -cvf /home/morgen.tar /home/morgen 打包后,以gzip压缩 tar -zcvf /home/morgen.tar.gz /home/morgen 打包后,以bzip2压缩 tar -jcvf /home/imorgen.tar.bz2 /home/morgen
4关机/重启命令 shutdown 系统关机 -r 关机后立即重启 -h 关机后关闭电源
-time 设定关机〔shutdown〕前的时间。
-now 立即关机
halt 关机后关闭电源 reboot 重新启动
#pwngdb的使用方法 libc : Print the base address of libc ld : Print the base address of ld codebase : Print the base of code segment heap : Print the base of heap got : Print the Global Offset Table infomation dyn : Print the Dynamic section infomation findcall : Find some function call bcall : Set the breakpoint at some function call tls : Print the thread local storage address at : Attach by process name findsyscall : Find the syscall fmtarg : Calculate the index of format string You need to stop on printf which has vulnerability. force : Calculate the nb in the house of force. heapinfo : Print some infomation of heap heapinfo (Address of arena) default is the arena of current thread If tcache is enable, it would show infomation of tcache entry heapinfoall : Print some infomation of heap (all threads) arenainfo : Print some infomation of all arena chunkinfo: Print the infomation of chunk chunkinfo (Address of victim) chunkptr : Print the infomation of chunk chunkptr (Address of user ptr) mergeinfo : Print the infomation of merge mergeinfo (Address of victim) printfastbin : Print some infomation of fastbin tracemalloc on : Trace the malloc and free and detect some error . You need to run the process first than tracemalloc on, it will record all of the malloc and free. You can set the DEBUG in pwngdb.py , than it will print all of the malloc and free infomation such as the screeshot. parseheap : Parse heap layout magic : Print useful variable and function in glibc fp : show FILE structure fp (Address of FILE) fpchain: show linked list of FILE orange : Test house of orange condition in the _IO_flush_lockp orange (Address of FILE) glibc version <= 2.23