Esempio n. 1
0
    def wrapper(self):
        global operation_done

        cprint('\n' + INDENT)
        printer(self)
        cprint(INDENT + '\n')
        operation_done = True
Esempio n. 2
0
    def wrapper(self):
        global operation_done

        cprint('\n' + INDENT)
        printer(self)
        cprint(INDENT + '\n')
        operation_done = True
Esempio n. 3
0
 def dsm(self):
     if self.mode != DSM_MODE:
         self.mode = DSM_MODE
         self.pexec = self.__dsm
         cprint(
             '\n<green>[+]</> Changed to <white,underline>dsm</> (disassembly) mode\n'
         )
Esempio n. 4
0
 def asm(self):
     if self.mode != ASM_MODE:
         self.mode = ASM_MODE
         self.pexec = self.__asm
         cprint(
             '\n<green>[+]</> Changed to <white,underline>asm</> (assembly) mode\n'
         )
Esempio n. 5
0
    def start(self):
        self._host = self._get_host_ip()
        if self._host is None:
            return False
        cprint(IP_ADDR.format(self._host[0], str(self._host[1])))

        self.add_thread(self._handle_recv)
        self.add_thread(self.check_connection)

        if self._server_host is not None:
            if not self._get_connected():
                return False
            while not self.user_id_assigned:
                pass
            self._handle_username()
            self._connect()
        else:
            self._handle_username()
            self.host2user_id[self._host] = self.user_id
            self.user_id2host[self.user_id] = self._host

        # Add self public key in keys dictionary
        self.encryptor.add_pubkey(self.user_id, None, _self=True)

        return True
Esempio n. 6
0
def main():
    shell = Shellen()

    cprint(('<magenta>[*]</> You can type <white, bold>help</> to see the list of available commands.\n'
            '<magenta>[*]</> Also, to close this session you should enter <white,bold>q</> or <white,bold>quit</>\n'))
    
    shell.irun()
Esempio n. 7
0
 def shell(self, pattern, count):
     count = count.strip()
     if count == '':
         count = DEFUALT_COUNT
     else:
         count = int(count)
     cprint('\n' + self.__shellstorm.fetch_table(pattern, os=self.os, arch=self.__get_arch(), count=count).table + '\n')
Esempio n. 8
0
 def help(self, *args):
     cprint((
         '\n'
         '   <white,bold>* help</>:            Show this help\n'
         '   <white,bold>* back, Ctrl+C</>:    Back to the main menu.\n'
         '   <white,bold>* file [filepath]</>: Send a file.\n'
     ))
Esempio n. 9
0
 def shell(self, pattern, count):
     count = count.strip()
     if count == '':
         count = DEFUALT_COUNT
     else:
         count = int(count)
     cprint('\n' + self.__shellstorm.fetch_table(pattern, os=self.os, arch=self.__get_arch(), count=count).table + '\n')
Esempio n. 10
0
 def remove_room(self, room_name):
     self.stop_printing = True
     self.send_room_message(room_name,
                            "Room was deleted",
                            remove_room='Yes')
     self.db_helper.remove_room(room_name)
     cprint(ROOM_REMOVED.format(room_name))
Esempio n. 11
0
 def setos(self, os):
     try:
         OS_MATCHING[os]
         self.os = os
         cprint('\n<green>[+]</> OS changed to {}.\n'.format(os))
     except KeyError:
         cprint('\n<red,bold>[-]</> There isn\'t such OS.\n')
Esempio n. 12
0
 def specify_root_path(self, root_path):
     if not os.path.isdir(root_path):
         cprint(NOT_A_DIRECTORY)
         return False
     root_path = os.path.join(root_path, '')
     self.root_path = root_path
     return True
Esempio n. 13
0
 def parse_root_path(self, parse):
     new_root_path = parse.group(1)
     if not os.path.isdir(new_root_path):
         cprint(NOT_A_DIRECTORY)
     if new_root_path[-1] != '/':
         new_root_path += '/'
     self.db_helper.set_root_path(new_root_path)
     cprint(PATH_CHANGED)
Esempio n. 14
0
 def setos(self, ros):
     os = ros.lower()
     try:
         OS_MATCHING[os]
         self.os = os
         cprint('\n<green>[+]</> OS changed to {}.\n'.format(os))
     except KeyError:
         cprint('\n<red,bold>[-]</> There isn\'t such OS.\n')
Esempio n. 15
0
 def parse_user(self, parse):
     username = parse.group(1)
     if self.db_helper.user_exists(username) and \
        self.db_helper.get_visibility(username) and \
        self.is_online(username=username):
         UserChat(username=username, client=self.client).open()
     else:
         cprint(NO_SUCH_USER)
Esempio n. 16
0
 def parse_root_path(self, parse):
     new_root_path = parse.group(1)
     if not os.path.isdir(new_root_path):
         cprint(NOT_A_DIRECTORY)
     if new_root_path[-1] != '/':
         new_root_path += '/'
     self.db_helper.set_root_path(new_root_path)
     cprint(PATH_CHANGED)
Esempio n. 17
0
 def print_last_messages(self, dst, room=False):
     for message in list(self.db_helper.get_history(dst, 10, room))[::-1]:
         if message is None or message[1] == -1:
             continue
         cprint(
             LAST_MESSAGE.format(message[3],
                                 self.db_helper.get_username(message[2]),
                                 message[0]))
Esempio n. 18
0
 def parse_user(self, parse):
     username = parse.group(1)
     if self.db_helper.user_exists(username) and \
        self.db_helper.get_visibility(username) and \
        self.is_online(username=username):
         UserChat(username=username, client=self.client).open()
     else:
         cprint(NO_SUCH_USER)
Esempio n. 19
0
 def help(self, *args):
     cprint((
         '\n'
         '   <white,bold>* help</>:              Show this help\n'
         '   <white,bold>* back, Ctrl+C</>:      Change the current username.\n'
         '   <white,bold>* adduser [usrname]</>: Send a file.\n'
         '   <white,bold>* rmroom</>:            Remove current room.\n'
         '   <white,bold>* file [filepath]</>:   Send a file.\n'
     ))
Esempio n. 20
0
def main():
    shell = Shellen()

    cprint((
        '<magenta>[*]</> You can type <white, bold>help</> to see the list of available commands.\n'
        '<magenta>[*]</> Also, to close this session you should enter <white,bold>q</> or <white,bold>quit</>\n'
    ))

    shell.irun()
Esempio n. 21
0
 def add_user2room(self, username, room_name):
     if not self.db_helper.user_exists(username):
         cprint(NO_SUCH_USED)
         return False
     self.db_helper.add_user2room(username=username, room_name=room_name)
     # Invites user to the room by sending
     # empty message
     self.send_room_message(room_name, EMPTY, room_user=username)
     cprint(YOU_INVITED.format(username, room_name))
     return True
Esempio n. 22
0
 def setarch(self, arch):
     if not self.pexec.setarch(arch):
         cprint(
             '\n<red,bold>[-]</> Incorrect architecture. Enter <white,bold>archs</> to see a list of available archs.\n'
         )
         return
     cprint(
         '\n<green>[+]</> Architecture of <white,underline>{}</> changed to <white,underline>{}</>\n'
         .format(self.mode, arch))
     self.arch = arch
Esempio n. 23
0
    def _check_correctness(self, msg, err_msg, obj, is_correct):
        '''
        Check if object is correct
        '''

        if not obj:
            obj = input(msg)
        while not is_correct(obj):
            cprint('<lred>[-]</lred> Incorrect {}'.format(err_msg))
            obj = input(msg)
        return obj
Esempio n. 24
0
    def _check_correctness(self, msg, err_msg, obj, is_correct):
        '''
        Check if object is correct
        '''

        if not obj:
            obj = input(msg)
        while not is_correct(obj):
            cprint('<lred>[-]</lred> Incorrect {}'.format(err_msg))
            obj = input(msg)
        return obj
Esempio n. 25
0
 def handle_command(self, command):
     for pattern, handler in self.handlers:
         match = pattern.match(command)
         if match:
             handler(match)
             return True
     send_file = self.R_SEND_FILE.match(command)
     if send_file:
         self.parse_sending_file(send_file, username=self.username)
     else:
         if not self.send_message(username=self.username, text=command):
             cprint(ERROR_WHILE_SENDING)
Esempio n. 26
0
 def add_user2room(self, username, room_name):
     if not self.db_helper.user_exists(username):
         cprint(NO_SUCH_USED)
         return False
     self.db_helper.add_user2room(username=username,
                                  room_name=room_name)
     # Invites user to the room by sending
     # empty message
     self.send_room_message(room_name, EMPTY,
                            room_user=username)
     cprint(YOU_INVITED.format(username, room_name))
     return True
Esempio n. 27
0
 def help(self, *args):
     cprint((
         '\n<white,bold>PROMPT INFO</>\n'
         '   The get_colored_prompt format is <white,bold>OS</>:<white,bold>mode</>:<white,bold>arch</>\n'
         '       <white,bold>* OS</> is a current <white,underline>Operating System</>.\n'
         '           <white,bold>* L</> is <white,underline>Linux</>\n'
         '           <white,bold>* W</> is <white,underline>Windows</>\n'
         '           <white,bold>* M</> is <white,underline>MacOS</>\n'
         '       <white,bold>* mode</> is a current <white,underline>assembly mode</> (by default it\'s asm). See below for more information.\n'
         '       <white,bold>* arch</> is a chosen processor <white,underline>architecture</> (by default it\'s x86_32).\n'
         '\n<white,bold>BASIC</>\n'
         '   Basic commands are listed below:\n'
         '       <white,bold>* clear</>: Clear the terminal screen.\n'
         '       <white,bold>* help</>: Show this help message.\n'
         '       <white,bold>* quit, q, exit</>: Finish the current session and quit.\n'
         '\n<white,bold>MODES</>\n'
         '   If you want to change a current mode, then just type the name of a mode.\n'
         '   There are two assembly modes (each is described below):\n'
         '       <white,bold>* asm</>: Assembler mode.\n'
         '       <white,bold>* dsm</>: Disassembler mode.\n'
         '\n<white,bold>COMMON COMMANDS FOR MODES</>\n'
         '   Common commands can be used for both <white, underline>asm</> and <white, underline>dsm</> modes.\n'
         '       <white,bold>* archs</>: Print a table of available architectures for a current mode.\n'
         '       <white,bold>* run, r, go</>: Jump to the last shellcode in a subprocess. What could go wrong?\n'
         '                     Note that you don\'t get to control the base address your code gets loaded at,\n'
         '                     and this assumes that the instructions will make sense to your CPU.\n'
         '       <white,bold>* setarch [arch]</>: Change current processor architecture.\n'
         '       <white,bold>* setos [OS]</>: Change current operation system: <white,underline>windows/linux/macos</>.\n'
         '       <white,bold>* sys [pattern]</>: Search a syscall depending on OS, architecture and specified pattern.\n'
         '       <white,bold>* sysv [pattern]</>: It\'s <white,underline>sys</> command, but with verbose output.\n'
         '       <white,bold>* shell [keyword] [count]</>: List of shellcodes with URL that suit a given keyword.\n'
         '                                  [count] parameter can be <white,underline>ommited</>\n'
         '                                  This function requests shellcodes from http://shell-storm.org\n'
         '\n<white,bold>ASSEMBLY MODE</>\n'
         '   <white,bold>asm</> mode is intended for assembling instructions.\n'
         '   To assembly instuctions, write them separated by colons.\n'
         '   If your shellcode has a null bytes, then they will be highlighted after assembling.\n'
         '   Remember to use appropriate <white,bold>arch</> for assembling!\n'
         '   <white,underline>Example of using</>:\n'
         '       asm:x86_32 > <white,bold>mov edx, eax; xor eax, eax; inc edx; int 80;</>\n'
         '          [+] Bytes count: 7\n'
         '              Raw bytes:  "\\x89\\xc2\\x31\\xc0\\x42\\xcd\\x50"\n'
         '              Hex string: "89c231c042cd50"\n'
         '\n<white,bold>DISASSEMBLY MODE</>\n'
         '   <white,bold>dsm</> mode allows you to disassembly bytes into instructions, based on the <white,bold>arch</>.\n'
         '   <white,underline>Example of using</>:\n'
         '       dsm:x86_32 > <white,bold>89c231c042cd50</>\n'
         '               0x00080000:     mov     edx, eax\n'
         '               0x00080002:     xor     eax, eax\n'
         '               0x00080004:     inc     edx\n'
         '               0x00080005:     int     0x50\n'
         '\n'
     ))
Esempio n. 28
0
 def handle_command(self, command):
     for pattern, handler in self.handlers:
         match = pattern.match(command)
         if match:
             handler(match)
             return True
     send_file = self.R_SEND_FILE.match(command)
     if send_file:
         self.parse_sending_file(send_file, username=self.username)
     else:
         if not self.send_message(username=self.username, text=command):
             cprint(ERROR_WHILE_SENDING)
Esempio n. 29
0
 def print_entered_users(self):
     last_users = set(self.client.host2user_id.values())
     while not self.stop_printing_users:
         cur_users = set(self.client.host2user_id.values())
         if last_users != cur_users:
             try:
                 for new_user in cur_users.difference(last_users):
                     cprint(USER_JOINED.format(self.db_helper.get_username(new_user)))
                 for rem_user in last_users.difference(cur_users):
                     cprint(USER_LEAVED.format(self.db_helper.get_username(rem_user)))
                 last_users = cur_users
             except TypeError:
                 pass
Esempio n. 30
0
    def exit(self):
        global operation_done
        operation_done = True

        try:
            self.client.disconnect(exit=True)
        except TypeError as e:
            pass
        self.stop_printing = True
        self.stop_printing_users = True
        for thread in self.inner_threads:
            thread.join()
        cprint(BYE)
        sys.exit()
Esempio n. 31
0
 def help(self, *args):
     cprint((
         '\n<white,bold>PROMPT INFO</>\n'
         '   The prompt format is <white,bold>OS</>:<white,bold>mode</>:<white,bold>arch</>\n'
         '       <white,bold>* OS</> is a current <white,underline>Operating System</>.\n'
         '           <white,bold>* L</> is <white,underline>Linux</>\n'
         '           <white,bold>* W</> is <white,underline>Windows</>\n'
         '           <white,bold>* M</> is <white,underline>MacOS</>\n'
         '       <white,bold>* mode</> is a current <white,underline>assembly mode</> (by default it\'s asm). See below for more information.\n'
         '       <white,bold>* arch</> is a chosen processor <white,underline>architecture</> (by default it\'s x86_32).\n'
         '\n<white,bold>BASIC</>\n'
         '   Basic commands are listed below:\n'
         '       <white,bold>* clear</>: Clear the terminal screen.\n'
         '       <white,bold>* help</>: Show this help message.\n'
         '       <white,bold>* quit, q, exit</>: Finish the current session and quit.\n'
         '\n<white,bold>MODES</>\n'
         '   If you want to change a current mode, then just type the name of a mode.\n'
         '   There are two assembly modes (each is described below):\n'
         '       <white,bold>* asm</>: Assembler mode.\n'
         '       <white,bold>* dsm</>: Disassembler mode.\n'
         '\n<white,bold>COMMON COMMANDS FOR MODES</>\n'
         '   Common commands can be used for both <white, underline>asm</> and <white, underline>dsm</> modes.\n'
         '       <white,bold>* archs</>: Print a table of available architectures for a current mode.\n'
         '       <white,bold>* setarch [arch]</>: Change current processor architecture.\n'
         '       <white,bold>* setos [OS]</>: Change current operation system: <white,underline>windows/linux/macos</>.\n'
         '       <white,bold>* sys [pattern]</>: Search a syscall depending on OS, architecture and specified pattern.\n'
         '       <white,bold>* sysv [pattern]</>: It\'s <white,underline>sys</> command, but with verbose output.\n'
         '       <white,bold>* shell [keyword] [count]</>: List of shellcodes with URL that suit a given keyword.\n'
         '                                  [count] parameter can be <white,underline>ommited</>\n'
         '                                  This function requests shellcodes from http://shell-storm.org\n'
         '\n<white,bold>ASSEMBLY MODE</>\n'
         '   <white,bold>asm</> mode is intended for assembling instructions.\n'
         '   To assembly instuctions, write them separated by colons.\n'
         '   If your shellcode has a null bytes, then they will be highlighted after assembling.\n'
         '   Remember to use appropriate <white,bold>arch</> for assembling!\n'
         '   <white,underline>Example of using</>:\n'
         '       asm:x86_32 > <white,bold>mov edx, eax; xor eax, eax; inc edx; int 80;</>\n'
         '          [+] Bytes count: 7\n'
         '              Raw bytes:  "\\x89\\xc2\\x31\\xc0\\x42\\xcd\\x50"\n'
         '              Hex string: "89c231c042cd50"\n'
         '\n<white,bold>DISASSEMBLY MODE</>\n'
         '   <white,bold>dsm</> mode allows you to disassembly bytes into instructions, based on the <white,bold>arch</>.\n'
         '   <white,underline>Example of using</>:\n'
         '       dsm:x86_32 > <white,bold>89c231c042cd50</>\n'
         '               0x00080000:     mov     edx, eax\n'
         '               0x00080002:     xor     eax, eax\n'
         '               0x00080004:     inc     edx\n'
         '               0x00080005:     int     0x50\n'
         '\n'
     ))
Esempio n. 32
0
    def exit(self):
        global operation_done
        operation_done = True

        try:
            self.client.disconnect(exit=True)
        except TypeError as e:
            pass
        self.stop_printing = True
        self.stop_printing_users = True
        for thread in self.inner_threads:
            thread.join()
        cprint(BYE)
        sys.exit()
Esempio n. 33
0
 def print_recv_message(self, dst, room=False):
     last_msg = self.get_last_message(dst, room)
     while not self.stop_printing:
         cur_msg = self.get_last_message(dst, room)
         if last_msg[1] != cur_msg[1]:
             messages = self.db_helper.get_history(dst,
                                                   cur_msg[1] - last_msg[1],
                                                   room)
             for message in messages:
                 if self.self_chat or message[2] != self.client.user_id:
                     cprint(RECV_MESSAGE
                            .format(message[3],
                                    self.db_helper.get_username(message[2]),
                                    message[0]))
             last_msg = cur_msg
Esempio n. 34
0
 def print_recv_message(self, dst, room=False):
     last_msg = self.get_last_message(dst, room)
     while not self.stop_printing:
         cur_msg = self.get_last_message(dst, room)
         if last_msg[1] != cur_msg[1]:
             messages = self.db_helper.get_history(dst,
                                                   cur_msg[1] - last_msg[1],
                                                   room)
             for message in messages:
                 if self.self_chat or message[2] != self.client.user_id:
                     cprint(
                         RECV_MESSAGE.format(
                             message[3],
                             self.db_helper.get_username(message[2]),
                             message[0]))
             last_msg = cur_msg
Esempio n. 35
0
 def help(self):
     cprint((
         '\n'
         '   <white,bold>* help</>:                  Show this output\n'
         '   <white,bold>* username [usrname]</>:    Change current username.\n'
         '   <white,bold>* rooms</>:                 Show available rooms.\n'
         '   <white,bold>* users</>:                 Show online users.\n'
         '   <white,bold>* user [username]</>:       Switch to the user private message mode. Enter in a private messages.\n'
         '   <white,bold>* room [room_name]</>:      Switch to the room message mode. Enter in a room.\n'
         '   <white,bold>* rmroom [roomname]</>:     Remove current user from a room. Room itself still exists.\n'
         '   <white,bold>* adduser [user] [room]</>: Add an user to a room.\n'
         '   <white,bold>* mkroom [roomname]</>:     Create new room.\n'
         '   <white,bold>* exit, q, quit</>:         Finish current chat session.\n'
         '   <white,bold>* chvis</>:                 Change your visibility in the chat.\n'
         '   <white,bold>* chpath [path]</>:         Change the directory for storing files.\n'
     ))
Esempio n. 36
0
 def help(self):
     cprint((
         '\n'
         '   <white,bold>* help</>:                  Show this output\n'
         '   <white,bold>* username [usrname]</>:    Change current username.\n'
         '   <white,bold>* rooms</>:                 Show available rooms.\n'
         '   <white,bold>* users</>:                 Show online users.\n'
         '   <white,bold>* user [username]</>:       Switch to the user private message mode. Enter in a private messages.\n'
         '   <white,bold>* room [room_name]</>:      Switch to the room message mode. Enter in a room.\n'
         '   <white,bold>* rmroom [roomname]</>:     Remove current user from a room. Room itself still exists.\n'
         '   <white,bold>* adduser [user] [room]</>: Add an user to a room.\n'
         '   <white,bold>* mkroom [roomname]</>:     Create new room.\n'
         '   <white,bold>* exit, q, quit</>:         Finish current chat session.\n'
         '   <white,bold>* chvis</>:                 Change your visibility in the chat.\n'
         '   <white,bold>* chpath [path]</>:         Change the directory for storing files.\n'
     ))
Esempio n. 37
0
 def print_entered_users(self):
     last_users = set(self.client.host2user_id.values())
     while not self.stop_printing_users:
         cur_users = set(self.client.host2user_id.values())
         if last_users != cur_users:
             try:
                 for new_user in cur_users.difference(last_users):
                     cprint(
                         USER_JOINED.format(
                             self.db_helper.get_username(new_user)))
                 for rem_user in last_users.difference(cur_users):
                     cprint(
                         USER_LEAVED.format(
                             self.db_helper.get_username(rem_user)))
                 last_users = cur_users
             except TypeError:
                 pass
Esempio n. 38
0
    def send_file(self, file_location, username, room=''):
        if username != '':
            user_id = self.db_helper.get_user_id(username)
        filename = file_location.replace('/', ' ').replace('\\', ' ') \
                                .split()[-1]
        message = self.client.create_file_data(file_location, filename,
                                               user_id=self.client.user_id,
                                               room_name=room)
        if message is None:
            cprint(NO_SUCH_FILE)
            return

        if room != '':
            room_id = self.db_helper.get_room_id(room)
            for user_id in self._get_users(room, room_id):
                self._send_message(user_id, message, room)
        else:
            self._send_message(user_id, message)
Esempio n. 39
0
File: asm.py Progetto: Dliv3/shellen
    def print_res(self, res):
        encoding, count = res
        
        raw_hex   = hexlify(bytearray(encoding)).decode('utf-8')
        raw_bytes = hex2bytes(raw_hex)

        dec_sc_bytes = self.__decorate_shellcode(raw_bytes)
        dec_sc_hex   = self.__decorate_shellcode(raw_hex, False)

        is_zeroed = NULLBYTE in raw_bytes
        
        prefix = ''
        if is_zeroed:
            prefix += '   <yellow,bold>[!]</> Warning! Your shellcode contains <white,underline>null bytes</>!\n'
        cprint(prefix + (
            '   <green,bold>[+]</> Bytes count: <white,bold>{}</>\n'
            '       Raw bytes:  "{}"\n'
            '       Hex string: "{}"\n'
        ).format(len(encoding), dec_sc_bytes, dec_sc_hex))
Esempio n. 40
0
    def send_file(self, file_location, username, room=''):
        if username != '':
            user_id = self.db_helper.get_user_id(username)
        filename = file_location.replace('/', ' ').replace('\\', ' ') \
                                .split()[-1]
        message = self.client.create_file_data(file_location,
                                               filename,
                                               user_id=self.client.user_id,
                                               room_name=room)
        if message is None:
            cprint(NO_SUCH_FILE)
            return

        if room != '':
            room_id = self.db_helper.get_room_id(room)
            for user_id in self._get_users(room, room_id):
                self._send_message(user_id, message, room)
        else:
            self._send_message(user_id, message)
Esempio n. 41
0
    def print_res(self, res):
        encoding, count = res

        raw_hex = hexlify(bytearray(encoding)).decode('utf-8')
        raw_bytes = hex2bytes(raw_hex)

        dec_sc_bytes = self.__decorate_shellcode(raw_bytes)
        dec_sc_hex = self.__decorate_shellcode(raw_hex, False)

        is_zeroed = NULLBYTE in raw_bytes

        prefix = ''
        if is_zeroed:
            prefix += '   <yellow,bold>[!]</> Warning! Your shellcode contains <white,underline>null bytes</>!\n'
        cprint(prefix +
               ('   <green,bold>[+]</> Bytes count: <white,bold>{}</>\n'
                '       Raw bytes:  "{}"\n'
                '       Hex string: "{}"\n'
                ).format(len(encoding), dec_sc_bytes, dec_sc_hex))
Esempio n. 42
0
 def help(self, *args):
     cprint((
         '\n<white,bold>PROMPT INFO</>\n'
         '   The prompt format is <white,bold>OS</>:<white,bold>mode</>:<white,bold>arch</>\n'
         '       <white,bold>* mode</> is a current <white,underline>assembly mode</> (by default it\'s asm). See below for more information.\n'
         '       <white,bold>* arch</> is a chosen processor <white,underline>architecture</> (by default it\'s x86_32).\n'
         '\n<white,bold>BASIC</>\n'
         '   Basic commands are listed below:\n'
         '       <white,bold>* clear</>: Clear the terminal screen.\n'
         '       <white,bold>* help</>: Show this help message.\n'
         '       <white,bold>* quit, q, exit</>: Finish the current session and quit.\n'
         '\n<white,bold>MODES</>\n'
         '   If you want to change a current mode, then just type the name of a mode.\n'
         '   There are two assembly modes (each is described below):\n'
         '       <white,bold>* asm</>: Assembler mode.\n'
         '       <white,bold>* dsm</>: Disassembler mode.\n'
         '\n<white,bold>COMMON COMMANDS FOR MODES</>\n'
         '   Common commands can be used for both <white, underline>asm</> and <white, underline>dsm</> modes.\n'
         '       <white,bold>* archs</>: Print a table of available architectures for a current mode.\n'
         '       <white,bold>* setarch [arch]</>: Change current processor architecture.\n'
         '       <white,bold>* setos [OS]</>: Change current operation system (windows/linux/macos).\n'
         '       <white,bold>* sys [pattern]</>: Search a syscall depending on OS, architecture and specified pattern.\n'
         '\n<white,bold>ASSEMBLY MODE</>\n'
         '   <white,bold>asm</> mode is intended for assembling instructions.\n'
         '   To assembly instuctions, write them separated by colons.\n'
         '   If your shellcode has a null bytes, then they will be highlighted after assembling.\n'
         '   Remember to use appropriate <white,bold>arch</> for assembling!\n'
         '   <white,underline>Example of using</>:\n'
         '       asm:x86_32 > <white,bold>mov edx, eax; xor eax, eax; inc edx; int 80;</>\n'
         '          [+] Bytes count: 7\n'
         '              Raw bytes:  "\\x89\\xc2\\x31\\xc0\\x42\\xcd\\x50"\n'
         '              Hex string: "89c231c042cd50"\n'
         '\n<white,bold>DISASSEMBLY MODE</>\n'
         '   <white,bold>dsm</> mode allows you to disassembly bytes into instructions, based on the <white,bold>arch</>.\n'
         '   <white,underline>Example of using</>:\n'
         '       dsm:x86_32 > <white,bold>89c231c042cd50</>\n'
         '               0x00080000:     mov     edx, eax\n'
         '               0x00080002:     xor     eax, eax\n'
         '               0x00080004:     inc     edx\n'
         '               0x00080005:     int     0x50\n'
         '\n'))
Esempio n. 43
0
    def run(self):
        shellcode = self.last_shellcode()
        if not shellcode:
            cprint('\n<red,bold>[-]</> Assemble or disassemble something first!\n')
            return

        result = native.run(shellcode)
        if result < 0:
            sig_info = signal.Signals(-result)
            cprint('\n<red,bold>[-]</> Exited with signal <white>{}</> (<white,underline>{}</>)\n'.format(sig_info.name, sig_info.value))
        elif result == 0:
            cprint('\n<green>[+]</> Exited with status code 0.\n')
        else: # result > 0
            cprint('\n<yellow>[*]</> Exited with status code {}.\n'.format(result))
Esempio n. 44
0
    def command_mode(self):
        cprint(START_CHAT)

        while True:
            try:
                cprint(MAIN_CHAT_PROMPT.format(self.client.username), end='')
                with lock:
                    command = input(' ')
                if command == '':
                    continue
                if not self.handle_command(command):
                    cprint(INVALID_COMMAND)
            except KeyboardInterrupt as e:
                cprint('')
Esempio n. 45
0
    def command_mode(self):
        cprint(START_CHAT)

        while True:
            try:
                cprint(MAIN_CHAT_PROMPT.format(self.client.username), end='')
                with lock:
                    command = input(' ')
                if command == '':
                    continue
                if not self.handle_command(command):
                    cprint(INVALID_COMMAND)
            except KeyboardInterrupt as e:
                cprint('')
Esempio n. 46
0
 def print_users(self, *args):
     cprint('\n<white,bold>{}</>'.format(INDENT))
     for user_id in self.client.host2user_id.values():
         if (self.db_helper.get_visibility(user_id=user_id) or
         user_id == self.db_helper.get_cur_user_id()) and \
         self.is_online(user_id=user_id):
             cprint(PRINT_USER.format(self.db_helper.get_username(user_id)))
     cprint('<white,bold>{}</>\n'.format(INDENT))
Esempio n. 47
0
 def print_users(self, *args):
     cprint('\n<white,bold>{}</>'.format(INDENT))
     for user_id in self.client.host2user_id.values():
         if (self.db_helper.get_visibility(user_id=user_id) or
         user_id == self.db_helper.get_cur_user_id()) and \
         self.is_online(user_id=user_id):
             cprint(PRINT_USER.format(self.db_helper.get_username(user_id)))
     cprint('<white,bold>{}</>\n'.format(INDENT))
Esempio n. 48
0
 def run(self):
     if not self.cur_user_exists():
         self.specify_username()
         self.specify_root_path()
     else:
         cprint(HELLO_AGAIN.format(self.client.username))
         cprint(STORAGE.format(self.db_helper.get_root_path()))
     self.db_helper.specify_username(self.client)
     if not self.client.start():
         cprint(CONNECTION_ERROR)
         self.exit()
     self.init_print_users()
     self.command_mode()
Esempio n. 49
0
 def run(self):
     if not self.cur_user_exists():
         self.specify_username()
         self.specify_root_path()
     else:
         cprint(HELLO_AGAIN.format(self.client.username))
         cprint(STORAGE.format(self.db_helper.get_root_path()))
     self.db_helper.specify_username(self.client)
     if not self.client.start():
         cprint(CONNECTION_ERROR)
         self.exit()
     self.init_print_users()
     self.command_mode()
Esempio n. 50
0
 def irun(self):
     while True:
         try:
             cmd = self.prompt()
             if cmd == '':
                 continue
             else:
                 if not self.handle_command(cmd):
                     cprint('\n<red,bold>[-]</> Invalid command.\n')
         except Exception as e:
             cprint('\n<red,bold>[-]</> Error occured: {}\n'.format(e))
         except KeyboardInterrupt:
             cprint()
Esempio n. 51
0
    def irun(self):
        while True:
            try:
                self.prompt()
                cmd = input(' ')

                if cmd == '':
                    continue
                else:
                    if not self.handle_command(cmd):
                        cprint('\n<red,bold>[-]</> Invalid command.\n')
            except Exception as e:
                cprint('\n<red,bold>[-]</> Error occured: {}\n'.format(e))
            except KeyboardInterrupt:
                cprint()
Esempio n. 52
0
 def dsm(self):
     if self.mode != DSM_MODE:
         self.mode  = DSM_MODE
         self.pexec = self.__dsm
         cprint('\n<green>[+]</> Changed to <white,underline>dsm</> (disassembly) mode\n')
Esempio n. 53
0
 def prompt(self):
     cprint('<red,bold>{}</>:<blue, bold>{}</>:<blue>{}</> <yellow,bold>></>'.format(OS_MATCHING[self.os], self.mode, self.pexec.arch), end='')
Esempio n. 54
0
 def sys(self, pattern, verbose=False):
     if self.os == LINUX_OS:
         cprint('\n' + self.__linuxsys.get_printable_table(self.__get_arch(), pattern, colored=True, verbose=verbose) + '\n')
Esempio n. 55
0
 def setarch(self, arch):
     if not self.pexec.setarch(arch):
         cprint('\n<red,bold>[-]</> Incorrect architecture. Enter <white,bold>archs</> to see a list of available archs.\n')
         return
     cprint('\n<green>[+]</> Architecture of <white,underline>{}</> changed to <white,underline>{}</>\n'.format(self.mode, arch))
     self.arch = arch
Esempio n. 56
0
 def asm(self):
     if self.mode != ASM_MODE:
         self.mode  = ASM_MODE
         self.pexec = self.__asm
         cprint('\n<green>[+]</> Changed to <white,underline>asm</> (assembly) mode\n')
Esempio n. 57
0
 def archs(self):
     cprint('\n' + self.pexec.archs() + '\n')