#!/usr/bin/env python # coding=utf-8 from pwn import p64 defgetAddr(write): xor = 0xff addr = [] for i in range(6): result = (xor & write) >> (i * 8) if result != 0: addr.append(result) xor = xor * 0x100 return addr
defPartion(write, bewrite): addr = getAddr(write) part = [] for i in range(len(addr)): part.append( (addr[i], p64(bewrite+i)) ) part.sort(key=lambda tup: tup[0]) #进行排序,按内容大小来排 return part
获取排序后的数组
1 2 3 4 5
defsizeUp(part): size = [] for i in range(len(part)): size.append(part[i][0]) return size
将地址进行打包
因为我是将地址放在后面的,防止00截断,然后在将排序后的地址按顺序打包起来
1 2 3 4
defpackAddr(part): addr =''.join(x[1] for x in part) address = ''.join(addr) return address
#!/usr/bin/env python # coding=utf-8 from pwn import p64
# 获得写入的每一位的内容 defgetAddr(write): xor = 0xff addr = [] for i in range(6): result = (xor & write) >> (i * 8) if result != 0: addr.append(result) xor = xor * 0x100 return addr
# 划分部分,按大小排序 defPartion(write, bewrite): addr = getAddr(write) part = [] for i in range(len(addr)): part.append( (addr[i], p64(bewrite+i)) ) part.sort(key=lambda tup: tup[0]) return part
# 获得排序后的大小,升序 defsizeUp(part): size = [] for i in range(len(part)): size.append(part[i][0]) return size
# 打包地址 defpackAddr(part): addr =''.join(x[1] for x in part) address = ''.join(addr) return address