Skip to content

Instantly share code, notes, and snippets.

@saru2017
Created June 16, 2019 14:40
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 saru2017/5a228a1c29f4bec3012541b0a6c6ce17 to your computer and use it in GitHub Desktop.
Save saru2017/5a228a1c29f4bec3012541b0a6c6ce17 to your computer and use it in GitHub Desktop.
CTF: pwn05
#!/usr/bin/python3
import sys, os, tempfile, subprocess
data = input(">").strip()
if len(data) > 12:
print("too large file")
exit(-1)
with tempfile.TemporaryDirectory() as dirname:
name = os.path.join(dirname, "user")
f = open(name, "w")
f.write(data)
f.close()
os.chmod(name, 0o500)
print(subprocess.check_output(name).decode())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment