def do_info(self, line): """Shows all settings, along with default and current values to user""" print("") bc.blue_print("[-] ", "Showing info for module:\n") w, h = os.get_terminal_size() w = 0.9 * w #Scale for beauty format_string = "{{:<{}}} {{:<{}}} {{:<{}}} {{:<{}}}".format( int(0.2 * w), int(0.5 * w), int(0.15 * w), int(0.15 * w)) #format_string = "{:<20} {:<40} {:<30} {:<10}" underline = "=" * int(w) bc.bold_print( format_string.format("Option", "Value", "Default", "Required?"), "") bc.blue_print(underline, "") ''' for opt, dat in self.module_instance.options.items(): default = required = print(format_string.format(opt, str(dat), str(default) , str(required))) ''' for option in self.module_instance.info(): print( format_string.format(option[0], option[1], option[2], option[3])) print("")
def do_info(self, line): """Show global settings associted with the root menu""" info_list = [] for option, value in self.global_options.items(): default = self.defaults[option] if option in self.defaults else None info_list.append([str(option), str(value), str(default)]) bc.blue_print("[-] ", "Showing global idefault settings:\n") w, h = os.get_terminal_size() w = 0.9 * w #Scale for beauty format_string = "{{:<{}}} {{:<{}}} {{:<{}}}".format( int(0.3 * w), int(0.55 * w), int(0.15 * w)) #format_string = "{:<25} {:<45} {:<10}" underline = "=" * int(w) bc.bold_print(format_string.format("Option", "Value", "Default"), "") bc.blue_print(underline, "") for option in info_list: print(format_string.format(option[0], option[1], option[2])) print("")
def list_listeners(self): """List out just listeners, including printing them out""" bc.green_print("\n[-] ", "Listeners:\n") w, h = os.get_terminal_size() w = 0.9 * w #Scale for beauty format_string = "{{:<{}}} {{:<{}}} {{:<{}}} {{:<{}}}".format( int(0.35 * w), int(0.2 * w), int(0.1 * w), int(0.35 * w)) #format_string = "{:<40} {:<20} {:<10} {:<20}" underline = "=" * int(w) bc.bold_print(format_string.format("Name", "Status", "Agents", "Info"), "") bc.blue_print(underline, "") for l in self.root_menu.listeners: print( format_string.format(l.name, 'Alive' if l.is_alive() == 1 else 'Dead', len(l.agent_list), str(l.LHOST) + ':' + str(l.LPORT))) print("")
def print_loaded_methods(self): """Rationalises and prints methods loaded into the agents REports on any descrepancies to the user between agents.""" bc.green_print("[-] ", "Menu options:\n") format_string = "\t{:<15} {:<50}" underline = "\t" + "=" * 70 bc.bold_print(format_string.format("Method", "Description"), "") bc.blue_print(underline, "") for nme, hlp in self.methods.items(): print(format_string.format(str(nme[3:]), hlp)) bc.green_print("\n[-] ", "Loaded agent options:") self.check_loaded() for mod, meths in self.loaded_methods.items(): bc.green_print("\n\t[-] ", "{} Methods:\n".format(mod.title())) bc.bold_print(format_string.format("Method", "Description"), "") bc.blue_print(underline, "") for meth in meths: print(format_string.format(meth[0], meth[1])) print("")
def list_agents(self): """List out just agents, including printing them out.""" bc.green_print("\n[-] ", "Agents:\n") w, h = os.get_terminal_size() w = 0.9 * w #Scale for beauty format_string = "{{:<{}}} {{:<{}}} {{:<{}}} {{:<{}}} {{:<{}}}".format( int(0.3 * w), int(0.1 * w), int(0.2 * w), int(0.1 * w), int(0.3 * w)) #format_string = "{:<30} {:<10} {:20} {:<10} {:<30}" underline = "=" * int(w) bc.bold_print( format_string.format("Name", "Activated", "Listener", "Status", "Info"), "") bc.blue_print(underline, "") for l in self.root_menu.listeners: for a in l.agent_list: print( format_string.format( str(a.name), str(a.active), str(a.listener.name), 'Alive' if a.is_alive() == 1 else 'Dead', str(a.ip) + ":" + str(a.port))) print("")
def post_loop(self): """Just something to say bye to the user""" bc.bold_print("OKByeee!", "")
def demo(): """Print a series of demo BShell commands to console""" w, h = os.get_terminal_size() w = 0.9 * w #Scale for beauty bc.info( "The BlackfellShell can be used to run any python module written for it, but the key functionality it allows is running agents." ) time.sleep(5) bc.info("All modules are called using the keyword 'use' like this:") time.sleep(5) print("BS >\r", end="") time.sleep(1) fake_type('BS > ', 'use auxiliary/example') print("") bc.info("Using module: auxiliary/example") print(""" Example module, for use in understanding the BShell. Hello world within the BShell. Prints your message a number of times. num_repeats must be a string. color can be green, red, orange or blue. """) print("BS : " + bc.green_format("modules/auxiliary/example", "") + " >") time.sleep(10) bc.info("Once you've activated a module, you'll switch to a new menu.") time.sleep(2) bc.info("This new menu will allow you to configure and run the module.") time.sleep(2) bc.info("Start by getting module info:") time.sleep(2) fake_type("BS : " + bc.green_format("modules/auxiliary/example", "") + " > ", \ 'info') print("") bc.info("Showing info for module:\n") format_string = "{{:<{}}} {{:<{}}} {{:<{}}} {{:<{}}}".format( int(0.2 * w), int(0.5 * w), int(0.15 * w), int(0.15 * w)) #format_string = "{:<20} {:<40} {:<30} {:<10}" underline = "=" * int(w) bc.bold_print( format_string.format("Option", "Value", "Default", "Required?"), "") bc.blue_print(underline, "") printer = [['exit_on_exec', 'True', 'True', 'True'], ['message', 'None', 'None', 'True'], ['num_prints', 'None', 'None', 'True'], ['color', 'None', 'None', 'True']] for p in printer: print(format_string.format(p[0], p[1], p[2], p[3])) print("") time.sleep(5) bc.info("Each option in the module can be set with the 'set' keyword") time.sleep(4) fake_type("BS : " + bc.green_format("modules/auxiliary/example", "") + " > ", \ 'set color red') print("BS : " + bc.green_format("modules/auxiliary/example", "") + " > ") time.sleep(4) bc.info("Let's check it made a change.") time.sleep(4) fake_type("BS : " + bc.green_format("modules/auxiliary/example", "") + " > ", \ 'info') print("") bc.info("Showing info for module:\n") format_string = "{{:<{}}} {{:<{}}} {{:<{}}} {{:<{}}}".format( int(0.2 * w), int(0.5 * w), int(0.15 * w), int(0.15 * w)) #format_string = "{:<20} {:<40} {:<30} {:<10}" underline = "=" * int(w) bc.bold_print( format_string.format("Option", "Value", "Default", "Required?"), "") bc.blue_print(underline, "") printer = [['exit_on_exec', 'True', 'True', 'True'], ['message', 'None', 'None', 'True'], ['num_prints', 'None', 'None', 'True'], ['color', 'red', 'None', 'True']] for p in printer: print(format_string.format(p[0], p[1], p[2], p[3])) print("") time.sleep(4) bc.info( "If you didn't like that, the reset keyword will set options back to default." ) time.sleep(4) fake_type("BS : " + bc.green_format("modules/auxiliary/example", "") + " > ", \ 'reset color') time.sleep(2) fake_type("BS : " + bc.green_format("modules/auxiliary/example", "") + " > ", \ 'info') print("") time.sleep(1) bc.info("Showing info for module:\n") format_string = "{{:<{}}} {{:<{}}} {{:<{}}} {{:<{}}}".format( int(0.2 * w), int(0.5 * w), int(0.15 * w), int(0.15 * w)) #format_string = "{:<20} {:<40} {:<30} {:<10}" underline = "=" * int(w) bc.bold_print( format_string.format("Option", "Value", "Default", "Required?"), "") bc.blue_print(underline, "") printer = [['exit_on_exec', 'True', 'True', 'True'], ['message', 'None', 'None', 'True'], ['num_prints', 'None', 'None', 'True'], ['color', 'None', 'None', 'True']] for p in printer: print(format_string.format(p[0], p[1], p[2], p[3])) print("") time.sleep(4) bc.info("You must set all required options.") time.sleep(4) bc.info( "Modules will test for required options, and maybe other things when they run." ) time.sleep(4) bc.info("Let's configure the rest of this module now.") time.sleep(5) fake_type("BS : " + bc.green_format("modules/auxiliary/example", "") + " > ", \ 'set message Hello, World.') time.sleep(2) fake_type("BS : " + bc.green_format("modules/auxiliary/example", "") + " > ", \ 'set color red') time.sleep(2) bc.info( "You can use tab completion on most settings, just hit tab once you've started typing." ) time.sleep(5) message = "BS : " + bc.green_format("modules/auxiliary/example", "") + " > " for i in 'set nu': message += i print('{}\r'.format(message), end="") time.sleep(0.1) time.sleep(1) print('{}<TAB>\r'.format(message), end="") time.sleep(0.5) print('{}<TAB>\r'.format(message), end="") time.sleep(1) message = message + 'm_prints' print('{}\r'.format(message), end="") time.sleep(4) fake_type(message, ' 8') time.sleep(4) print("") fake_type("BS : " + bc.green_format("modules/auxiliary/example", "") + " > ", \ 'info') print("") time.sleep(1) bc.info("Showing info for module:\n") format_string = "{{:<{}}} {{:<{}}} {{:<{}}} {{:<{}}}".format( int(0.2 * w), int(0.5 * w), int(0.15 * w), int(0.15 * w)) #format_string = "{:<20} {:<40} {:<30} {:<10}" underline = "=" * int(w) bc.bold_print( format_string.format("Option", "Value", "Default", "Required?"), "") bc.blue_print(underline, "") printer = [['exit_on_exec', 'True', 'True', 'True'], ['message', 'Hello, World.', 'None', 'True'], ['num_prints', '8', 'None', 'True'], ['color', 'red', 'None', 'True']] for p in printer: print(format_string.format(p[0], p[1], p[2], p[3])) print("") time.sleep(5) bc.info( "Now you're all configured, you can run the module with the 'execute' keyword" ) time.sleep(5) fake_type("BS : " + bc.green_format("modules/auxiliary/example", "") + " > ", \ 'execute') time.sleep(1) bc.info("Setting up module...") bc.success("Setup complete. Executing...") bc.green_print("[-] ", "Print incoming!") for i in range(8): bc.err_print("Hello, World.", "") bc.green_print("[-] ", "Module executed, exiting.") time.sleep(5) bc.info( "Most commands have help messages you can use, just type help in any menu." ) time.sleep(3) bc.success("Good luck!")