Skip to content

Instantly share code, notes, and snippets.

@Srinivas11789
Last active July 30, 2020 06:28
Show Gist options
  • Save Srinivas11789/8376943807d42d118a1f015f20882e4b to your computer and use it in GitHub Desktop.
Save Srinivas11789/8376943807d42d118a1f015f20882e4b to your computer and use it in GitHub Desktop.
🏁 CTF Helpers ==> Pwn code frame for an easy start at remote server interaction/ pwning/ reverse engineering
# Helpers for Capture the flag to breeze through the ground work
# - Updating Ctf helper gists to have a fun ctf and reuse some basic ground work
# - For use in Binary exploitation/ Reverse engineering / Pwning / Remote server Interaction
# - "Usage: ./client.py [IP] [Port] [output_key_to_read_until]"
# - output_key_to_read_until ==> ">" or ":" or "?" or "$"
#
import sys
try:
from pwn import *
except ImportError:
print("In order to complete this challenge, please install pwntools")
print("https://pwntools.readthedocs.io/en/stable/install.html")
sys.exit(1)
def processResponse(data):
# I guess we should do something with this data and send it back!
# return processed_data
return ""
def talk(address, port, key):
connection = remote(address, port)
while 1:
try:
response = connection.recvuntil(key)
except:
connection.interactive()
print(response)
connection.sendline(processResponse(response))
def main():
try:
address = sys.argv[1]
port = sys.argv[2]
output_key_to_read_until = sys.argv[3]
except:
print("Usage: ./client.py [IP] [Port] [Key]")
sys.exit(1)
talk(address, port, output_key_to_read_until)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment