连接

本地process()、远程remote()。对于remote函数可以接url并且指定端口。

IO模块

下面给出了PwnTools中的主要IO函数。这个比较容易跟zio搞混,记住zio是read、write,pwn是recv、send就可以了。

send(data) : 发送数据
sendline(data) : 发送一行数据,相当于在末尾加\n recv(numb=4096, timeout=default) : 给出接收字节数,timeout指定超时
recvuntil(delims, drop=False) : 接收到delims的pattern
(以下可以看作until的特例)
recvline(keepends=True) : 接收到\n,keepends指定保留\n
recvall() : 接收到EOF
recvrepeat(timeout=default) : 接收到EOF或timeout interactive() : 与shell交互

ELF模块

ELF模块用于获取ELF文件的信息,首先使用ELF()获取这个文件的句柄,然后使用这个句柄调用函数,和IO模块很相似。

下面演示了:获取基地址、获取函数地址(基于符号)、获取函数got地址、获取函数plt地址

>>> e = ELF('/bin/cat')
>>> print hex(e.address) # 文件装载的基地址
0x400000
>>> print hex(e.symbols['write']) # 函数地址
0x401680
>>> print hex(e.got['write']) # GOT表的地址
0x60b070
>>> print hex(e.plt['write']) # PLT的地址
0x401680

数据处理

主要是对整数进行打包,就是转换成二进制的形式,比如转换成地址。p32、p64是打包,u32、u64是解包。

DynELF

DynELF是leak信息的神器。前提条件是要提供一个输入地址,输出此地址最少1byte数的函数。官网给出的说明是:Given a function which can leak data at an arbitrary address, any symbol in any loaded library can be resolved.

很叼啊,有木有。以下是官方例程

# Assume a process or remote connection
p = process('./pwnme') # Declare a function that takes a single address, and
# leaks at least one byte at that address.
def leak(address):
data = p.read(address, 4)
log.debug("%#x => %s" % (address, (data or '').encode('hex')))
return data # For the sake of this example, let's say that we
# have any of these pointers. One is a pointer into
# the target binary, the other two are pointers into libc
main = 0xfeedf4ce
libc = 0xdeadb000
system = 0xdeadbeef # With our leaker, and a pointer into our target binary,
# we can resolve the address of anything.
#
# We do not actually need to have a copy of the target
# binary for this to work.
d = DynELF(leak, main)
assert d.lookup(None, 'libc') == libc
assert d.lookup('system', 'libc') == system # However, if we *do* have a copy of the target binary,
# we can speed up some of the steps.
d = DynELF(leak, main, elf=ELF('./pwnme'))
assert d.lookup(None, 'libc') == libc
assert d.lookup('system', 'libc') == system # Alternately, we can resolve symbols inside another library,
# given a pointer into it.
d = DynELF(leak, libc + 0x1234)
assert d.lookup('system') == system

pwntools使用简介3的更多相关文章

  1. pwntools使用简介2

    大致框架 官网的一个简单样例 from pwn import * context(arch = 'i386', os = 'linux') r = remote() # EXPLOIT CODE GO ...

  2. pwntools简介

    安装binutils: git clone https://github.com/Gallopsled/pwntools-binutils sudo apt-get install software- ...

  3. pwntools各使用模块简介

    pwntools pwntools 是一款专门用于CTF Exploit的python库,能够很方便的进行本地与远程利用的切换,并且里面包含多个模块,使利用变得简单.可以在github上直接搜索pwn ...

  4. ASP.NET Core 1.1 简介

    ASP.NET Core 1.1 于2016年11月16日发布.这个版本包括许多伟大的新功能以及许多错误修复和一般的增强.这个版本包含了多个新的中间件组件.针对Windows的WebListener服 ...

  5. MVVM模式和在WPF中的实现(一)MVVM模式简介

    MVVM模式解析和在WPF中的实现(一) MVVM模式简介 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 MVVM模式解析和在 ...

  6. Cassandra简介

    在前面的一篇文章<图形数据库Neo4J简介>中,我们介绍了一种非常流行的图形数据库Neo4J的使用方法.而在本文中,我们将对另外一种类型的NoSQL数据库——Cassandra进行简单地介 ...

  7. REST简介

    一说到REST,我想大家的第一反应就是“啊,就是那种前后台通信方式.”但是在要求详细讲述它所提出的各个约束,以及如何开始搭建REST服务时,却很少有人能够清晰地说出它到底是什么,需要遵守什么样的准则. ...

  8. Microservice架构模式简介

    在2014年,Sam Newman,Martin Fowler在ThoughtWorks的一位同事,出版了一本新书<Building Microservices>.该书描述了如何按照Mic ...

  9. const,static,extern 简介

    const,static,extern 简介 一.const与宏的区别: const简介:之前常用的字符串常量,一般是抽成宏,但是苹果不推荐我们抽成宏,推荐我们使用const常量. 执行时刻:宏是预编 ...

随机推荐

  1. 仅用递归函数操作逆序一个栈(Swift 4)

    /// 取出栈底的数 func getAndRemoveLastElement(_ items: inout [Int]) -> Int { let value = items.remove(a ...

  2. 关于 typedef struct 和 struct

    举个例子说明:typedef struct abc{ int x; int y; int z;}ABC;是将结构体abc类型重新起个名字为ABC,以后再定义同一类型的变量时,可以写成:ABC m,n; ...

  3. python实现汉诺塔(递归)

    def hanoi(n, A, B, C): if n > 0: hanoi(n-1, A, C, B) print("%s->%s" % (A, C)) hanoi( ...

  4. UVa 12186 Another Crisis 工人的请愿书

    c表示某上司上报的最少请愿下属,k表示总下属c=0.01T*k=kT/100(0.01T*k是整数)c=[0.01T*k]+1=[kT/100]+1(0.01T*k不是整数) kT=100 c=1 k ...

  5. Zernike矩之图像重建(附源码)

    源码下载 参考: [1] Teague M R. Image analysis via the general theory of moments[J]. JOSA, 1980, 70(8): 920 ...

  6. XHTML 1.0 的三种 XML 文档类型 DOCTYPE

    XHTML 1.0 的三种 XML 文档类型 XHTML 1.0 规定了三种 XML 文档类型 XHTML 1.0 Strict <!DOCTYPE html PUBLIC "-//W ...

  7. 128 Longest Consecutive Sequence 一个无序整数数组中找到最长连续序列

    给定一个未排序的整数数组,找出最长连续序列的长度.例如,给出 [100, 4, 200, 1, 3, 2],这个最长的连续序列是 [1, 2, 3, 4].返回所求长度: 4.要求你的算法复杂度为 O ...

  8. vue-resource emulateJSON的作用

    如果Web服务器无法处理编码为application/json的请求,你可以启用emulateJSON选项. 启用该选项后,请求会以application/x-www-form-urlencoded作 ...

  9. PHP设计模式 观察者模式(Observer)

    定义 当一个对象状态发生改变时,依赖它的对象全部会收到通知,并自动更新. 模式要点 Event:事件 Trigger() 触发新的事件 abstract EventGenerator 事件产生者 Fu ...

  10. 找不到draw9patch.bat?已经不用找了

    Google 已经因为 draw9patch 热门的原因,把它集成在 Android Studio 里面了, 你现在可以直接在 Android Studio 里直接打开编辑了.