Created
January 12, 2018 04:41
-
-
Save bkth/d969e1f823030780684c0e6fc9cf77c0 to your computer and use it in GitHub Desktop.
server for lfa during 34c3ctf
This file contains 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
#!/usr/bin/python | |
import tempfile | |
import os | |
import string | |
import random | |
def randstr(): | |
return ''.join(random.choice(string.ascii_uppercase + string.digits + string.ascii_lowercase) for _ in range(10)) | |
code = "require 'LFA'\n" | |
code += "syscall 1, 1, \"hello\\n\", 6\n\n" | |
max = 600 # 600 linex should be more than enough ;) | |
print "Enter your code, enter the string END_OF_PWN to finish " | |
while max: | |
new_code = raw_input("code> ") | |
if new_code == "END_OF_PWN": | |
break | |
code += new_code + "\n" | |
max -= 1 | |
name = "/tmp/%s" % randstr() | |
with open(name, "w+") as f: | |
f.write(code) | |
flag = open("flag", "r") | |
os.dup2(flag.fileno(), 1023) | |
flag.close() | |
cmd = "timeout 40 ruby %s" % name | |
os.system(cmd) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment