예제 #1
0
    def parse_cmd(self, data):
        cmd = data.split(" ", 1)[0].lower() 
        
        # interacting with a shell
        if not self.guid == "":
            if cmd == "background":
                self._prompt = "Main"
                self.guid = ""
            
            elif cmd == "exit":
                UI.error("*** You really want to kill this shell *** (yes/no)")
                if UI.prompt("Exit").lower() == "yes":
                    self.db.push_cmd(self.guid, "exit")
                    self._prompt = "Main"
                    self.guid = ""
            else:
                Log.log_shell(self.guid, "Sending", data)
                if self.shell_cmds.has_key(cmd):
                    callback = self.shell_cmds[cmd]
                    data = callback(data)

                if not (cmd == "help" or data == ""):
                    self.db.push_cmd(self.guid, data)
                    self.get_cmd_output()
                
        # interacting with the main console
        else:
            if self.cmds.has_key(cmd):
                callback = self.cmds[cmd]
                callback(data)
            else:
                UI.error("%s is not a valid command" % cmd)
예제 #2
0
 def parse_cmd(self, data):
     cmd = data.split(" ", 1)[0].lower()
     if not self.guid == "":
         if cmd == "background":
             self._prompt = "Main"
             self.db.remove_active_user(self.config.get("uid"), self.guid)
             self.guid = ""
         elif cmd == "exit":
             UI.error("*** You really want to kill this shell *** (yes/no)")
             if UI.prompt("Exit").lower() == "yes":
                 self.db.push_cmd(self.guid, "exit", Utils.guid(), self.config.get("username"))
                 self._prompt = "Main"
                 self.guid = ""
         else:
             self.db.append_shell_data(self.guid, "[%s] %s - Sending command: \n%s\n\n" % (Utils.timestamp(), self.config.get("username"), data))
             Log.log_shell(self.guid, "- Sending command", data, self.config.get("username"))
             if cmd in self.shell_cmds:
                 callback = self.shell_cmds[cmd]
                 data = callback(data)
             if not (cmd == "help" or data == ""):
                 self.db.push_cmd(self.guid, data, Utils.guid(),self.config.get("username"))
     else:
     # interacting with the main console
         if cmd in self.cmds:
             callback = self.cmds[cmd]
             callback(data)
         elif not cmd.strip() == "":
             UI.error("%s is not a valid command" % cmd)
예제 #3
0
 def parse_cmd(self, data):
     cmd = data.split(' ', 1)[0].lower()
     if not self.guid == '':
         if cmd == 'background':
             self._prompt = 'Main'
             self.db.remove_active_user(self.config.get('uid'), self.guid)
             self.guid = ''
         elif cmd == 'exit':
             UI.error('*** You really want to kill this shell *** (yes/no)')
             if UI.prompt('Exit').lower() == 'yes':
                 self.db.push_cmd(self.guid, 'exit', Utils.guid(),
                                  self.config.get('username'))
                 self._prompt = 'Main'
                 self.guid = ''
         else:
             self.db.append_shell_data(
                 self.guid, '[%s] %s Sending: \n%s\n\n' %
                 (Utils.timestamp(), self.config.get('username'), data))
             Log.log_shell(self.guid, 'Sending', data,
                           self.config.get('username'))
             if self.shell_cmds.has_key(cmd):
                 callback = self.shell_cmds[cmd]
                 data = callback(data)
             if not (cmd == 'help' or data == ''):
                 self.db.push_cmd(self.guid, data, Utils.guid(),
                                  self.config.get('username'))
     else:
         # interacting with the main console
         if self.cmds.has_key(cmd):
             callback = self.cmds[cmd]
             callback(data)
         elif not cmd.strip() == '':
             UI.error('%s is not a valid command' % cmd)
예제 #4
0
    def parse_cmd(self, data):
        cmd = data.split(" ", 1)[0].lower()
        
        # interacting with a shell
        if not self.guid == "":
            if cmd == "background":
                self._prompt = "Main"
                self.guid = ""
            
            elif cmd == "exit":
                UI.error("*** You really want to kill this shell *** (yes/no)")
                if UI.prompt("Exit").lower() == "yes":
                    self.db.push_cmd(self.guid, "exit")
                    self._prompt = "Main"
                    self.guid = ""
            else:
                Log.log_shell(self.guid, "Sending", data)
                if self.shell_cmds.has_key(cmd):
                    callback = self.shell_cmds[cmd]
                    data = callback(data)

                if not (cmd == "help" or data == ""):
                    self.db.push_cmd(self.guid, data)
                    self.get_cmd_output()
                
        # interacting with the main console
        else:
            if self.cmds.has_key(cmd):
                callback = self.cmds[cmd]
                callback(data)
            else:
                UI.error("%s is not a valid command" % cmd)
예제 #5
0
 def check_version():
     current = Version.VERSION
     request = urllib.request.Request(
         "http://thundershell.ringzer0team.com/version.html?%s" % current)
     response = urllib.request.urlopen(request).read().strip().decode()
     if not response == current:
         UI.error(
             "Your ThunderShell installation is outdated latest is %s. Your version is %s"
             % (response, current), False)
         UI.warn("Do you want to exit ThunderShell and update it")
         if UI.prompt('Updating (Yes/No)').lower() == 'yes':
             os.system("git pull")
             UI.error("Installation updated! Please restart ThunderShell",
                      True)
             os._exit(0)
예제 #6
0
파일: cli.py 프로젝트: u53r55/ThunderShell
    def parse_cmd(self, data):
        cmd = data.split(" ", 1)[0].lower()

        # interacting with a shell
        if not self.guid == "":
            if cmd == "background":
                self._prompt = "Main"
                self.mysql.delete_active_user(self.config.get("uid"),
                                              self.guid)
                self.guid = ""

            elif cmd == "exit":
                UI.error("*** You really want to kill this shell *** (yes/no)")
                if UI.prompt("Exit").lower() == "yes":
                    self.db.push_cmd(self.guid, "exit", Utils.guid(),
                                     self.config.get("username"))
                    self._prompt = "Main"
                    self.guid = ""
            else:
                Log.log_shell(self.guid, "Sending", data,
                              self.config.get("username"))
                if self.shell_cmds.has_key(cmd):
                    callback = self.shell_cmds[cmd]
                    data = callback(data)

                if not (cmd == "help" or data == ""):
                    self.db.push_cmd(self.guid, data, Utils.guid(),
                                     self.config.get("username"))

        # interacting with the main console
        else:
            if self.cmds.has_key(cmd):
                callback = self.cmds[cmd]
                callback(data)
            elif not cmd.strip() == "":
                UI.error("%s is not a valid command" % cmd)
예제 #7
0
    uid = Utils.guid()
    config.set("uid", uid)
    config.set("username", "(CLI)%s" % sys.argv[2])
    db = RedisQuery(config)
    sql = MySQLQuery(config)
    sql.install_db().init_uid()

    config.set("redis", db)
    config.set("mysql", sql)

    db.update_config(config).init_sql()

    UI.warn("Current Active session UUID is %s" % config.get("uid"))

    # Launch the HTTPD daemon
    if not "-nohttpd" in sys.argv:
        httpd_thread = init_httpd_thread(config)

    cli = Cli(config)

    while True:
        try:
            cmd = cli.prompt()
            cli.parse_cmd(cmd)

        except KeyboardInterrupt as e:
            UI.error(
                "*** You really want to exit the application? *** (yes/no)")
            if UI.prompt("Exit").lower() == "yes":
                os._exit(0)
예제 #8
0
 def prompt(self):
     return UI.prompt(self._prompt)
예제 #9
0
    uid = Utils.guid()
    config.set('uid', uid)
    config.set('username', '%s' % sys.argv[2])
    db = RedisQuery(config)

    config.set('redis', db)

    UI.warn('Current Active CLI session UUID is %s' % config.get('uid'))

    cli = Cli(config)

    # Launch the GUI
    if not '-nogui' in sys.argv:
        webui_thread = init_gui_thread(config, cli)

    # Launch the HTTPD daemon
    if not '-nohttpd' in sys.argv:
        httpd_thread = init_httpd_thread(config)

    while True:
        try:
            cmd = cli.prompt()
            cli.parse_cmd(cmd)
        except KeyboardInterrupt as e:
            UI.error(
                '*** You really want to exit the application? *** (yes/no)')
            if UI.prompt('Exit').lower() == 'yes':
                os._exit(0)
                sql.shutdown()
예제 #10
0
from core.httpd import init_httpd_thread
from core.cli import Cli
from core.ui import UI

if __name__ == "__main__":
    UI.banner()
    
    if len(sys.argv) < 2:
        UI.error("Missing configuration file path\n\nUsage: %s config (optional -nohttpd)" % sys.argv[0], True)
        
    config = CONFIG(sys.argv[1])
    db = RedisQuery(config)
    config.set("redis", db)
    
    
    # Launch the HTTPD daemon
    if not "-nohttpd" in sys.argv:
        httpd_thread = init_httpd_thread(config)
    
    cli = Cli(config)
    
    while True:
        try:
            cmd = cli.prompt()
            cli.parse_cmd(cmd)
            
        except KeyboardInterrupt as e:
            UI.error("*** You really want to exit the application? *** (yes/no)")
            if UI.prompt("Exit").lower() == "yes":
                os._exit(0)
            
예제 #11
0
 def prompt(self):
     return UI.prompt(self._prompt)