Last active
July 30, 2023 05:27
-
-
Save grant-h/f47266a184fd65a79007aacc38ea4d60 to your computer and use it in GitHub Desktop.
Pwntools template
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/env python | |
# coding: utf-8 | |
import sys | |
import time | |
# pip install pwn | |
from pwn import * | |
# pip install ipython | |
from IPython import embed | |
from struct import pack,unpack | |
from binascii import hexlify | |
# Used for delaying after a send vs. a read | |
# You may not need this | |
def delay(name): | |
if name != "": | |
print("[+] Stage: '%s'" % name) | |
time.sleep(0.8) # There MUST be a delay due to setvbuf in read() | |
def main(args): | |
p = None | |
# toggle to remote with ./pwn.py remote | |
if len(args) == 2 and args[1] == "remote": | |
p = remote("remote-server-url", 1234) | |
else: | |
p = process("./your_pwnable") | |
# Try | |
# p.recvlines(1), p.recv(10), p.readline() | |
# p.write('data'), p.write('data with newline') | |
# Note that if your program never ends, you will never see any output | |
print p.recvall() | |
sys.exit(0) | |
if __name__ == "__main__": | |
main(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment