Created
May 18, 2021 15:06
-
-
Save Pamplemousse/bcdcd6158573d78689881983533113f5 to your computer and use it in GitHub Desktop.
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
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