Created
May 22, 2016 00:59
-
-
Save vito-lbs/124f7b33bc148d3a06ab7e0dcd9f2a7c 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
#!/bin/env python -u | |
import random | |
from os import environ, listdir, path | |
from sys import exit | |
from subprocess import Popen, PIPE | |
import signal | |
from base64 import b64decode | |
def alarm_handler(signum, frame): | |
print "timed out, sorry" | |
exit(-1) | |
signal.signal(signal.SIGALRM, alarm_handler) | |
input_timeout = int(environ.get('INPUT_TIMEOUT', 15)) | |
crash_timeout = int(environ.get('CRASH_TIMEOUT', 5)) | |
chall_path = "." | |
picked = ["easy-prasky-with-buffalo-on-bing"] | |
print "send your crash string as base64, followed by a newline" | |
for c in picked: | |
print c | |
signal.alarm(input_timeout) | |
crasher = b64decode(raw_input()) | |
signal.alarm(0) | |
signal.alarm(crash_timeout) | |
proc = Popen(path.join(chall_path, c), | |
stdin=PIPE, stdout=PIPE, stderr=PIPE) | |
(out, err) = proc.communicate(crasher) | |
signal.alarm(0) | |
if out != "canary ok": | |
print "didn't pass canary, sorry" | |
exit(-1) | |
if proc.returncode != -signal.SIGSEGV: | |
print "didn't segfault, sorry" | |
exit(-1) | |
print "The flag is: {}".format( | |
environ.get('FLAG', "")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment