skysider/pwndocker 正确使用姿势
前言现在pwn题是越来越高版本的libc,一场比赛ubuntu16.04,ubuntu18.04切来切去的十分难受。极力推荐这个pwndocker,使用这个pwndocker就不用来回的切虚拟机,利用patchelf 或者process(["/path/to/ld.so", "./test"], env={"LD_PRELOAD":"/path/to/libc.so.6"})指定libc版本运行。这个docker已经集成pwn常用工具以及各个版本libc。included software
[*]pwntools —— CTF framework and exploit development library
[*]pwndbg —— a GDB plug-in that makes debugging with GDB suck less, with a focus on features needed by low-level software developers, hardware hackers, reverse-engineers and exploit developers
[*]pwngdb —— gdb for pwn
[*]ROPgadget —— facilitate ROP exploitation tool
[*]roputils —— A Return-oriented Programming toolkit
[*]one_gadget —— A searching one-gadget of execve(‘/bin/sh’, NULL, NULL) tool for amd64 and i386
[*]angr —— A platform-agnostic binary analysis framework
[*]radare2 —— A rewrite from scratch of radare in order to provide a set of libraries and tools to work with binary files
[*]seccomp-tools —— Provide powerful tools for seccomp analysis
[*]linux_server —— IDA 7.0 debug server for linux
[*]tmux —— a terminal multiplexer
[*]ltrace —— trace library function call
[*]strace —— trace system call
included glibcDefault compiled glibc path is /glibc.
[*]2.19 —— ubuntu 12.04 default libc version
[*]2.23 —— ubuntu 16.04 default libc version
[*]2.24 —— introduce vtable check in file struct
[*]2.27 —— pwndocker default glibc version
[*]2.28~2.31 —— latest libc versions
How to run in custom libc version?
code
1
2
3
cp /glibc/2.27/64/lib/ld-2.27.so /tmp/ld-2.27.so
patchelf --set-interpreter /tmp/ld-2.27.so ./test
LD_PRELOAD=./libc.so.6 ./test
or
code
1
2
from pwn import *
p = process(["/path/to/ld.so", "./test"], env={"LD_PRELOAD":"/path/to/libc.so.6"})
具体参考 https://github.com/skysider/pwndocker18.04 skysider/pwndocker 安装docker hub 可以直接pull
bash
1
docker pull skysider/pwndocker
但是pull的太慢了,我已经把他传到了阿里云上,用下面这条命令即可
bash
1
docker pull registry.cn-hangzhou.aliyuncs.com/pwndocker/pwndocker-nocbtm:1.0
pull完之后重命名一下
bash
1
docker tag registry.cn-hangzhou.aliyuncs.com/pwndocker/pwndocker-nocbtm:1.0 skysider/pwndocker
使用姿势建议用官方的使用姿势,用如下命令run起来
code
1
2
3
4
5
6
7
8
docker run -d
--rm
-h ${ctf_name}
--name ${ctf_name}
-v $(pwd)/${ctf_name}:/ctf/work
-p 23946:23946
--cap-add=SYS_PTRACE
skysider/pwndocker
其中有两个重要的参数
-v $(pwd)/${ctf_name}:/ctf/work 是将当前目录下的文件映射到 docker /ctf/work目录下
这样你在物理机修改文件,docker里面也会发生变化,就不用再docker cp了–cap-add=SYS_PTRACE 这个参数也是要一定加的,不然docker里面没法用gdb调试。可以把上述命令放到 pwndocker_run.sh里面 方便下次使用
然后调试脚本时,要先进去tmux ,python脚本里面指定终端为 tmux
code
1
context.terminal = ['tmux', 'sp', '-h']
就可以 gdb.attach(p)了 如下图
页:
[1]