注:我只是翻译(机翻加个人使用然后修正)玩玩的,可能会有错,看看就好,有错的地方请私信我:1565328054@qq.com十分感谢
Pwntools 附带了一些有用的命令行实用程序
pwn
Pwntools 命令行界面1
2
3usage: pwn [-h]
{asm,checksec,constgrep,cyclic,debug,disasm,disablenx,elfdiff,elfpatch,errno,hex,phd,pwnstrip,scramble,shellcraft,template,unhex,update}
...
显示这个帮助信息,然后退出1
-h, --help
###
pwn asm (汇编器)
1 | usage: pwn asm [-h] [-f {raw,hex,string,elf}] [-o file] [-c context] |
1 | line |
要组装的代码行。 如果没有提供,请使用 stdin
1 | -h, --help |
显示这个帮助信息,然后退出
1 | -f {raw,hex,string,elf}, --format {raw,hex,string,elf} |
输出格式(对于 ttys,默认为十六进制,否则为原始类型)
1 | -o <file>, --output <file> |
输出文件(默认为 stdout)
1 | -c {16,32,64,android,cgc,freebsd,linux,windows,powerpc64,aarch64,sparc64,powerpc,mips64,msp430,thumb,amd64,sparc,alpha,s390,i386,m68k,mips,ia64,cris,vax,avr,arm,little,big,el,le,be,eb}, --context {16,32,64,android,cgc,freebsd,linux,windows,powerpc64,aarch64,sparc64,powerpc,mips64,msp430,thumb,amd64,sparc,alpha,s390,i386,m68k,mips,ia64,cris,vax,avr,arm,little,big,el,le,be,eb} |
指定生成的shellcode的 操作系统 / 架构 / 字节序(大端小端) / 位数 (默认是: linux/i386), 从: [‘16’, ‘32’, ‘64’, ‘android’, ‘cgc’, ‘freebsd’, ‘linux’, ‘windows’, ‘powerpc64’, ‘aarch64’, ‘sparc64’, ‘powerpc’, ‘mips64’, ‘msp430’, ‘thumb’, ‘amd64’, ‘sparc’, ‘alpha’, ‘s390’, ‘i386’, ‘m68k’, ‘mips’, ‘ia64’, ‘cris’, ‘vax’, ‘avr’, ‘arm’, ‘little’, ‘big’, ‘el’, ‘le’, ‘be’, ‘eb’]中选择
1 | -v <avoid>, --avoid <avoid> |
对 shellcode 进行编码 (provided as hex; default: 000a)
1 | -n, --newline |
将 shell 代码编码以避免换行
1 | -z, --zero |
对 shell 代码进行编码,以避免NULL byte
1 | -d, --debug |
使用GDB 调试 shellcode
1 | -e <encoder>, --encoder <encoder> |
指定编码器
1 | -i <infile>, --infile <infile> |
指定输入文件
1 | -r, --run |
运行输出
pwn disasm (反汇编器)
1 | usage: pwn disasm [-h] [-c arch_or_os] [-a address] [--color] [--no-color] |
1 | hex |
Hex-string to disasemble. If none are supplied, then it uses stdin in non-hex mode.
1 | -h, --help |
显示这个帮助信息,然后退出
1 | -c {16,32,64,android,cgc,freebsd,linux,windows,powerpc64,aarch64,sparc64,powerpc,mips64,msp430,thumb,amd64,sparc,alpha,s390,i386,m68k,mips,ia64,cris,vax,avr,arm,little,big,el,le,be,eb}, --context {16,32,64,android,cgc,freebsd,linux,windows,powerpc64,aarch64,sparc64,powerpc,mips64,msp430,thumb,amd64,sparc,alpha,s390,i386,m68k,mips,ia64,cris,vax,avr,arm,little,big,el,le,be,eb} |
指定生成的shellcode的 操作系统 / 架构 / 字节序(大端小端) / 位数 (默认是: linux/i386), 从: [‘16’, ‘32’, ‘64’, ‘android’, ‘cgc’, ‘freebsd’, ‘linux’, ‘windows’, ‘powerpc64’, ‘aarch64’, ‘sparc64’, ‘powerpc’, ‘mips64’, ‘msp430’, ‘thumb’, ‘amd64’, ‘sparc’, ‘alpha’, ‘s390’, ‘i386’, ‘m68k’, ‘mips’, ‘ia64’, ‘cris’, ‘vax’, ‘avr’, ‘arm’, ‘little’, ‘big’, ‘el’, ‘le’, ‘be’, ‘eb’]中选择
1 | -a <address>, --address <address> |
基址
1 | --color |
彩色输出
1 | --no-color |
禁用颜色输出
pwn checksec (检查elf安全机制)
1 | usage: pwn checksec [-h] [--file [elf [elf ...]]] [elf [elf ...]] |
1 | elf |
要检查的文件
1 | -h, --help |
显示这个帮助信息,然后退出
1 | --file <elf> |
要检查的文件(是否与 checksec.sh 兼容)
pwn cyclic (测溢出点)
1 | usage: pwn cyclic [-h] [-a alphabet] [-n length] [-c context] |
1 | count |
要打印的字符数
1 | -h, --help |
显示这个帮助信息,然后退出
1 | -a <alphabet>, --alphabet <alphabet> |
循环模式中使用的字母表(默认为所有小写字母)
1 | -n <length>, --length <length> |
指定子序列的大小 (defaults to 4).
-c {16,32,64,android,cgc,freebsd,linux,windows,powerpc64,aarch64,sparc64,powerpc,mips64,msp430,thumb,amd64,sparc,alpha,s390,i386,m68k,mips,ia64,cris,vax,avr,arm,little,big,el,le,be,eb}, –context {16,32,64,android,cgc,freebsd,linux,windows,powerpc64,aarch64,sparc64,powerpc,mips64,msp430,thumb,amd64,sparc,alpha,s390,i386,m68k,mips,ia64,cris,vax,avr,arm,little,big,el,le,be,eb}
指定生成的shellcode的 操作系统 / 架构 / 字节序(大端小端) / 位数 (默认是: linux/i386), 从: [‘16’, ‘32’, ‘64’, ‘android’, ‘cgc’, ‘freebsd’, ‘linux’, ‘windows’, ‘powerpc64’, ‘aarch64’, ‘sparc64’, ‘powerpc’, ‘mips64’, ‘msp430’, ‘thumb’, ‘amd64’, ‘sparc’, ‘alpha’, ‘s390’, ‘i386’, ‘m68k’, ‘mips’, ‘ia64’, ‘cris’, ‘vax’, ‘avr’, ‘arm’, ‘little’, ‘big’, ‘el’, ‘le’, ‘be’, ‘eb’]中选择
-l <lookup_value>, -o <lookup_value>, –offset <lookup_value>, –lookup <lookup_value>
Do a lookup instead printing the alphabet
pwn hex (数据转十六进制)
1 | usage: pwn hex [-h] [data [data ...]] |
1 | data |
数据转换为十六进制
1 | -h, --help |
显示这个帮助信息,然后退出
pwn unhex (解码十六进制)
1 | usage: pwn unhex [-h] [hex [hex ...]] |
1 | hex |
要解码的十六进制字节
1 | -h, --help |
显示这个帮助信息,然后退出
pwn update (更新pwntools)
1 | usage: pwn update [-h] [--install] [--pre] |
1 | -h, --help |
显示这个帮助信息,然后退出
1 | --install |
自动安装更新。
1 | --pre |
检查预发行版本。
pwn phd (dump出efl的hex有点像xxd)
1 | usage: pwn phd [-h] [-w WIDTH] [-l [HIGHLIGHT [HIGHLIGHT ...]]] [-s SKIP] |
1 | file |
file 转换到 hex。 如果丢失,从 stdin 读取。
1 | -h, --help |
显示这个帮助信息,然后退出
1 | -w <width>, --width <width> |
每行字节数。
1 | -l <highlight>, --highlight <highlight> |
要高亮的字节。
1 | -s <skip>, --skip <skip> |
跳过多少字节。
1 | -c <count>, --count <count> |
只显示这么多字节。
1 | -o <offset>, --offset <offset> |
左栏中的地址从这个地址开始。
1 | --color {always,never,auto} |
使输出着色。 当”auto”输出正好是着色时,标准输出是 TTY。 默认是自动的。
pwn disablenx (检查elf安全机制)
1 | usage: pwn disablenx [-h] elf [elf ...] |
1 | elf |
要检查的文件
1 | -h, --help |
显示这个帮助信息
pwn shellcraft (shellcode生成器)
1 | usage: pwn shellcraft [-h] [-?] [-o file] [-f format] [-d] [-b] [-a] |
1 | shellcode |
你想要的shellcode
1 | arg |
Argument to the chosen shellcode
1 | -h, --help |
显示这个帮助信息,然后退出
1 | -?, --show |
打印出shellcode文件内容
1 | -o <file>, --out <file> |
Output file (default: stdout)
1 | -f {r,raw,s,str,string,c,h,hex,a,asm,assembly,p,i,hexii,e,elf,d,escaped,default}, --format {r,raw,s,str,string,c,h,hex,a,asm,assembly,p,i,hexii,e,elf,d,escaped,default} |
输出格式(默认值: 十六进制) ,选择{ e } lf,{ r } aw,{ s } tring,{ c }-style array,{ h } ex string,hex { i } ,{ a } ssembly code,{ p } reccssed code,escape { d } hex string
-d, –debug
使用gdb调试shellcode
1 | -b, --before |
在代码之前插入调试陷阱(debug trap)
1 | -a, --after |
在代码之后插入调试陷阱(debug trap)
1 | -v <avoid>, --avoid <avoid> |
对 shell 代码进行编码
1 | -n, --newline |
将 shell 代码编码以避免换行
1 | -z, --zero |
对 shell 代码进行编码,以避免NIULL bytes
1 | -r, --run |
Run output
1 | --color |
Color output
1 | --no-color |
Disable color output
1 | --syscalls |
列出系统调用
1 | --address <address> |
加载地址
1 | -l, --list |
列出可用的shellcode,也可选择提供一个过滤器
1 | -s, --shared |
生成的 ELF 是一个共享库
pwn template
1 | usage: pwn template [-h] [--host HOST] [--port PORT] [--user USER] |
1 | exe |
目标二进制文件
1 | -h, --help |
显示这个帮助信息,然后退出
1 | --host <host> |
远程主机 / SSH 服务器
1 | --port <port> |
远程端口 / SSH 端口
1 | --user <user> |
SSH 用户名
1 | --pass <password> |
SSH 密码
1 | --path <path> |
ssh 服务器上文件的远程路径
1 | --quiet |
较少冗长的模板注释
pwn elfdiff
1 | usage: pwn elfdiff [-h] a b |
a
b
对比a , b两个elf文件
-h, –help
显示这个帮助信息,然后退出
pwn pwnstrip
1 | usage: pwn pwnstrip [-h] [-b] [-p FUNCTION] [-o OUTPUT] file |
file
1 | -h, --help |
显示这个帮助信息,然后退出
1 | -b, --build-id |
Strip build ID
1 | -p <function>, --patch <function> |
Patch function
1 | -o <output>, --output <output> |
pwn constgrep
1 | usage: pwn constgrep [-h] [-e constant] [-i] [-m] [-c arch_or_os] |
1 | regex |
要求匹配常量的正则表达式
1 | constant |
要找的常量
1 | -h, --help |
显示这个帮助信息,然后退出
1 | -e <constant>, --exact <constant> |
对常量执行精确匹配,而不是搜索正则表达式
1 | -i, --case-insensitive |
搜索不区分大小写
1 | -m, --mask-mode |
不要搜索特定的常量值,而是搜索不严格包含比给定值少的位的值。
1 | -c {16,32,64,android,cgc,freebsd,linux,windows,powerpc64,aarch64,sparc64,powerpc,mips64,msp430,thumb,amd64,sparc,alpha,s390,i386,m68k,mips,ia64,cris,vax,avr,arm,little,big,el,le,be,eb}, --context {16,32,64,android,cgc,freebsd,linux,windows,powerpc64,aarch64,sparc64,powerpc,mips64,msp430,thumb,amd64,sparc,alpha,s390,i386,m68k,mips,ia64,cris,vax,avr,arm,little,big,el,le,be,eb} |
指定生成的shellcode的 操作系统 / 架构 / 字节序(大端小端) / 位数 (默认是: linux/i386), 从: [‘16’, ‘32’, ‘64’, ‘android’, ‘cgc’, ‘freebsd’, ‘linux’, ‘windows’, ‘powerpc64’, ‘aarch64’, ‘sparc64’, ‘powerpc’, ‘mips64’, ‘msp430’, ‘thumb’, ‘amd64’, ‘sparc’, ‘alpha’, ‘s390’, ‘i386’, ‘m68k’, ‘mips’, ‘ia64’, ‘cris’, ‘vax’, ‘avr’, ‘arm’, ‘little’, ‘big’, ‘el’, ‘le’, ‘be’, ‘eb’]中选择
pwn debug
1 | usage: pwn debug [-h] [-x GDBSCRIPT] [--pid PID] [-c context] |
1 | -h, --help |
显示这个帮助信息,然后退出
1 | -x <gdbscript> |
从该文件执行 GDB 命令。
1 | --pid <pid> |
PID to attach to
1 | -c {16,32,64,android,cgc,freebsd,linux,windows,powerpc64,aarch64,sparc64,powerpc,mips64,msp430,thumb,amd64,sparc,alpha,s390,i386,m68k,mips,ia64,cris,vax,avr,arm,little,big,el,le,be,eb}, --context {16,32,64,android,cgc,freebsd,linux,windows,powerpc64,aarch64,sparc64,powerpc,mips64,msp430,thumb,amd64,sparc,alpha,s390,i386,m68k,mips,ia64,cris,vax,avr,arm,little,big,el,le,be,eb} |
指定生成的shellcode的 操作系统 / 架构 / 字节序(大端小端) / 位数 (默认是: linux/i386), 从: [‘16’, ‘32’, ‘64’, ‘android’, ‘cgc’, ‘freebsd’, ‘linux’, ‘windows’, ‘powerpc64’, ‘aarch64’, ‘sparc64’, ‘powerpc’, ‘mips64’, ‘msp430’, ‘thumb’, ‘amd64’, ‘sparc’, ‘alpha’, ‘s390’, ‘i386’, ‘m68k’, ‘mips’, ‘ia64’, ‘cris’, ‘vax’, ‘avr’, ‘arm’, ‘little’, ‘big’, ‘el’, ‘le’, ‘be’, ‘eb’]中选择
1 | --exec <executable> |
要调试的文件
1 | --process <process_name> |
要attach的进程的名称(例如”bash”)
1 | --sysroot <sysroot> |
GDB sysroot path
pwn elfpatch
1 | usage: pwn elfpatch [-h] |
-h, –help
显示这个帮助信息,然后退出
pwn errno
1 | usage: pwn errno [-h] error |
error
错误消息或值
-h, –help
显示这个帮助信息,然后退出
###
pwn scramble1
2usage: pwn scramble [-h] [-f {raw,hex,string,elf}] [-o file] [-c context] [-p]
[-v AVOID] [-n] [-z] [-d]
1 | -h, --help |
显示这个帮助信息,然后退出
1 | -f {raw,hex,string,elf}, --format {raw,hex,string,elf} |
输出格式(对于 ttys,默认为十六进制,否则为原始数据)
1 | -o <file>, --output <file> |
输出文件(默认为 stdout)
1 | -c {16,32,64,android,cgc,freebsd,linux,windows,powerpc64,aarch64,sparc64,powerpc,mips64,msp430,thumb,amd64,sparc,alpha,s390,i386,m68k,mips,ia64,cris,vax,avr,arm,little,big,el,le,be,eb}, --context {16,32,64,android,cgc,freebsd,linux,windows,powerpc64,aarch64,sparc64,powerpc,mips64,msp430,thumb,amd64,sparc,alpha,s390,i386,m68k,mips,ia64,cris,vax,avr,arm,little,big,el,le,be,eb} |
指定生成的shellcode的 操作系统 / 架构 / 字节序(大端小端) / 位数 (默认是: linux/i386), 从: [‘16’, ‘32’, ‘64’, ‘android’, ‘cgc’, ‘freebsd’, ‘linux’, ‘windows’, ‘powerpc64’, ‘aarch64’, ‘sparc64’, ‘powerpc’, ‘mips64’, ‘msp430’, ‘thumb’, ‘amd64’, ‘sparc’, ‘alpha’, ‘s390’, ‘i386’, ‘m68k’, ‘mips’, ‘ia64’, ‘cris’, ‘vax’, ‘avr’, ‘arm’, ‘little’, ‘big’, ‘el’, ‘le’, ‘be’, ‘eb’]中选择
-p, –alphanumeric
Encode the shellcode with an alphanumeric encoder
-v
对 shell 代码进行编码
-n, –newline
将 shell 代码编码以避免换行
-z, –zero
对 shell 代码进行编码,以避免NIULL bytes
-d, –debug
使用gdb调试shellcode