Skip to content

Instantly share code, notes, and snippets.

@Eterna1 Eterna1/service.py
Created Aug 8, 2019

Embed
What would you like to do?
service.py
#! /usr/bin/python
import subprocess
import sys
import time
from threading import Timer
def kill(proc):
proc.kill()
def main():
server = sys.stdin.readline()
server = server.strip()
server_len = 0
while server_len < min(128,len(server)) and (server[server_len] == '/' or server[server_len] == '.' or server[server_len] == ':' or server[server_len].isalnum()):
server_len += 1
server = server[:server_len]
if not server.startswith("http://") and not server.startswith("https://"):
print "incorrect url"
exit(0)
args = [
'./binary/chrome',
'--enable-blink-features=MojoJS',
'--disable-gpu',
'--headless',
'--repl', #this flag makes chrome not to exit right after the webpage is loaded, this flag is not a part of the CTF challenge
server
]
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
time.sleep(10)
proc.kill()
stdout = proc.stdout.read()
print 'STDOUT:{}'.format(stdout)
stderr = proc.stderr.read()
print 'STDERR:{}'.format(stderr)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.