pwncli支持命令的前缀匹配(与gdb的命令前缀匹配类似),通常只需要给出命令的前缀即可成功调用该命令。即输入pwncli debug ./pwn、pwncli de ./pwn和pwncli d ./pwn的执行效果是完全一样的。但是,必须保证前缀不会匹配到两个或多个子命令,否则将会抛出MatchError的匹配错误。
filename = gift.filename # current filename is_debug = gift.debug # is debug or not is_remote = gift.remote # is remote or not gdb_pid = gift.gdb_pid # gdb pid if debug
# 有时候远程提供的libc与本地不一样,打靶机时替换libc为远程libc if gift.remote: libc = ELF("./libc.so.6") gift['libc'] = libc
For cli: pwncli -v subcommand args For python script: script content: from pwncli import * cli_script() then start from cli: ./yourownscript -v subcommand args
Options: -f, --filename TEXT Elf file path to pwn. -v, --verbose Show more info ornot. -V, --version Show the version and exit. -h, --help Show this message and exit.
Commands: config Get orset something about config data. debug Debug the pwn file locally. misc Misc of useful sub-commands. patchelf Patchelf executable file using glibc-all-in-one. qemu Use qemu to debug pwn, for kernel pwn or arm/mips arch. remote Pwn remote host. test Test command.
Options: --argv TEXT Argv for process. -e, --set-env, --env TEXT The env setting for process, such as LD_PRELOAD setting, split using ','or';', assign using '='or':'. -p, --pause, --pause-before-main Pause before main is called ornot, which is helpful for gdb attach. [default: False] -f, -hf, --hook-file TEXT Specify a hook.c file, where you write some functions to hook. -H, -HF, --hook-function TEXT The functions you want to hook would be out of work. -t, --use-tmux, --tmux Use tmux to gdb-debug ornot. [default: False] -w, --use-wsl, --wsl Use wsl to pop up windows for gdb-debug or not. [default: False] -m, -am, --attach-mode [auto|tmux|wsl-b|wsl-u|wsl-o|wsl-wt|wsl-wts] Gdb attach mode, wsl: bash.exe | wsl: ubuntu1x04.exe | wsl: open-wsl.exe | wsl: wt.exe wsl.exe [default: auto] -u, -ug, --use-gdb Use gdb possibly. [default: False] -g, -gt, --gdb-type [auto|pwndbg|gef|peda] Select a gdb plugin. -b, -gb, --gdb-breakpoint TEXT Set gdb breakpoints while gdb-debug is used, it should be a hex address or'\$rebase' addr or a function name. Multiple breakpoints are supported. -s, -gs, --gdb-script TEXT Set gdb commands like '-ex'or'-x'while gdb-debug is used, the content will be passed to gdb and use ';' to split lines. Besides eval-commands, file path is supported. -n, -nl, --no-log Disable context.log ornot. [default: False] -P, -ns, --no-stop Use the 'stop' function ornot. Only for python script mode. [default: False] -v, --verbose Show more info ornot. -h, --help Show this message and exit.
For remote target: pwncli -v remote ./pwn 127.0.0.1:23333 -up --proxy-mode default Or to specify the ip and port: pwncli -v remote -i 127.0.0.1 -p 23333
Options: -i, --ip TEXT The remote ip addr. -p, --port INTEGER The remote port. -P, -up, --use-proxy Use proxy or not. [default: False] -m, -pm, --proxy-mode [undefined|notset|default|primitive] Set proxy mode. undefined: read proxy data from config data(do not set this type in your file); notset: not use proxy; default: pwntools context proxy; primitive: pure socks connection proxy. [default: undefined] -n, -nl, --no-log Disable context.log or not. [default: False] -v, --verbose Show more info or not. -h, --help Show this message and exit.
Options: -s, -sn, --section-name TEXT Set config data by section name. -h, --help Show this message and exit.
参数:
1
CLAUSE 必须的 设置的语句,格式为key=value。
选项:
1 2
-s 可选的 根据section设置数据。 -h 查看帮助。
misc 子命令
misc子命令是一个杂项命令合集,即其会包含许多二级子命令,每个二级子命令的功能都不一样。
输入pwncli misc -h得到帮助信息:
1 2 3 4 5 6 7 8 9
Usage: pwncli misc [OPTIONS] COMMAND [ARGS]...
Options: -h, --help Show this message and exit.
Commands: gadget Get all gadgets using ropper and ROPgadget, and then store them in files. setgdb Copy gdbinit files from and set gdb-scripts for current user.
Options: -a, --all, --all-gadgets Get all gadgets and don't remove duplicates. [default: False] -d, --dir, --directory TEXT The directory to save files. -h, --help Show this message and exit.
参数:
1
FILENAME 必须的 要获取gadgets的binary路径。
选项:
1 2 3
-a 可选的 flag选项,默认关闭。开启后将不会移除重复的gadgets。 -d 可选的 保存gadgets文件的路径。若未指定则为当前目录。 -h 查看帮助。
setgdb 二级子命令
输出pwncli misc setgdb -h得到帮助信息:
1 2 3 4 5 6 7
Usage: pwncli misc setgdb [OPTIONS]
Options: -g, --generate-script Generate the scripts of gdb-gef/gdb-pwndbg/gdb-peda in /usr/local/bin or not. [default: False] --yes Confirm the action without prompting. -h, --help Show this message and exit.
Options: -b, --back, --back-up Backup target file or not. -f, --filter, --filter-string TEXT Add filter condition. -h, --help Show this message and exit.
Options: -d, --debug, --debug-mode Use debug mode or not, default is opened. -r, --remote, --remote-mode Use remote mode or not, default is debug mode. [default: False] -i, --ip TEXT The remote ip addr or gdb listen ip when debug. -p, --port INTEGER The remote port or gdb listen port when debug. -L, --lib TEXT The lib path for current file. -S, --static Use tmux to gdb-debug or not. [default: False] -l, -ls, --launch-script TEXT The script to launch the qemu, only used for qemu-system mode and the script must be shell script. -t, --use-tmux, --tmux Use tmux to gdb-debug or not. [default: False] -w, --use-wsl, --wsl Use wsl to pop up windows for gdb-debug or not. [default: False] -g, --use-gnome, --gnome Use gnome terminal to pop up windows for gdb-debug or not. [default: False] -G, -gt, --gdb-type [auto|pwndbg|gef|peda] Select a gdb plugin. -b, -gb, --gdb-breakpoint TEXT Set gdb breakpoints while gdb-debug is used, it should be a hex address or a function name. Multiple breakpoints are supported. -s, -gs, --gdb-script TEXT Set gdb commands like '-ex' or '-x' while gdb-debug is used, the content will be passed to gdb and use ';' to split lines. Besides eval-commands, file path is supported. -n, -nl, --no-log Disable context.log or not. [default: False] -P, -ns, --no-stop Use the 'stop' function or not. Only for python script mode. [default: False] -v, --verbose Show more info or not. [default: 0] -h, --help Show this message and exit.