Skip to content

Instantly share code, notes, and snippets.

@Pamplemousse
Created May 18, 2021 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pamplemousse/bcdcd6158573d78689881983533113f5 to your computer and use it in GitHub Desktop.
Save Pamplemousse/bcdcd6158573d78689881983533113f5 to your computer and use it in GitHub Desktop.
import argparse
import sys
from pwnlib.tubes.listen import listen
def main(cli_arguments):
l = listen(port=cli_arguments.port, bindaddr='localhost', typ='tcp')
_ = l.wait_for_connection()
request = l.recv()
message = "request received:\n\t%s" % str(request)
length = len(message)
response = """HTTP/1.1 200 OK
Content-Length: %s
Content-Type: text/html
%s""" % (length, message)
l.send(response)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("port", help="The port to listen to.")
cli_arguments = parser.parse_args()
main(cli_arguments)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment