Example #1
0
    def do_exit(self, line, sigint=None):
        """Leave the Blackfell Shell Framework,
        terminating all agents & listeners. (-y to force)"""

        input_str = bc.warn_format(
            "[-]",
            " Do you want to exit, terminating all agents and listeners? [Y/n]:"
        )
        if '-y' not in line and input(
                input_str.format(line)).lower() not in ['y', 'yes', 'ye']:
            return False
        else:
            for l in self.root_menu.listeners:
                l.terminate()
                l.join(self.terminate_timeout)
                if l.is_alive() == 1:
                    bc.err_print(
                        "[!] ",
                        "- Could not elegantly kill listener: {}, continuing.".
                        format(l.name))
            bc.blue_print("[!] ", "- All Listeners killed.")
            time.sleep(0.2)
            self.post_loop()
            sys.exit(0)
            return True
Example #2
0
 def do_back(self, line):
     'Exit this submenu - back to main menu. Will NOT exit shell'
     input_str = bc.warn_format(
         "[-]",
         " Do you want to go back? Check your module ran successfully. [Y/n]:"
     )
     if input(input_str.format(line)).lower() in ['y', 'yes', 'ye']:
         return True
Example #3
0
 def do_demo(self, line):
     """Walkthrough BShell key functions within the interpreter"""
     input_str = bc.warn_format(
         "[-]",
         " This will run through a demo of the BlackfellShell for a couple of minutes, do you want to continue? [Y/n]:"
     )
     if '-y' not in line and input(
             input_str.format(line)).lower() not in ['y', 'yes', 'ye']:
         return False
     else:
         demo.demo()
Example #4
0
 def do_kill(self, line):
     """OVerridden kill method, acting only on listeners in this context"""
     if not line:
         input_str = bc.warn_format("[!]", " Do you want to kill all listeners? [Y/n]:")
         if input(input_str.format(line)).lower() not in ['y', 'yes', 'ye']:
             return
     for l in self.root_menu.listeners:
         if line in l.name:
             l.terminate()
         #It's not our listener
         else:
             bc.warn("Listener not found, not terminating.")
Example #5
0
    def default(self, line):
        """If no known menu command is provided, this function will be called
        offers user to run the command as a local shell command instead of a
        BlackfellShell built-in command."""

        input_str = bc.warn_format(
            "[-]",
            " Command not recognised, exec local shell command '{}'? [Y/n]:")
        if line == None:
            pass
        if input(input_str.format(line)).lower() in ['y', 'yes', 'ye']:
            print(os.popen(line).read())
Example #6
0
    def do_kill(self, line):
        """Overridden version of the base kill function, this version
        only kills agents since we're in the agent menu now."""

        if not line or line == "*":
            input_str = bc.warn_format(
                "[!]", " Do you want to kill all agents? [Y/n]:")
            if input(input_str.format(line)).lower() not in ['y', 'yes', 'ye']:
                return
        for l in self.root_menu.listeners:
            for a in l.agent_list:
                if line in a.name:
                    l.terminate_agent(a)
                #It's not our listener
                else:
                    bc.warn("Agent not found, not terminating.")
Example #7
0
    def do_kill(self, line):
        """Kill agents and/or listeners by name"""

        if not line or line == "*":
            input_str = bc.warn_format(
                "[!]", " Do you want to kill all agents and listeners? [Y/n]:")
            if input(input_str.format(line)).lower() not in ['y', 'yes', 'ye']:
                return
        for l in self.root_menu.listeners:
            for a in l.agent_list:
                if line in l.name:
                    bc.info("killing : {}".format(l.name))
                    #l.terminate()
                    l.send_q.put('terminate')
                elif line in a.name:
                    #l.terminate_agent(a)
                    bc.info("killing : {}".format(a.name))
                    l.send_q.put('terminate_agent {}'.format(a.name))
                #It's not our listener
                else:
                    bc.warn("{} not found, not terminating.".format(line))