def __init__(self, name="Armory"): super(MainCommands, self).__init__(name) self.cmd["list_modules"] = { "func": self.list_modules, "help": "List available modules", } self.cmd["list_reports"] = { "func": self.list_reports, "help": "List available reports", } self.cmd["use_module"] = { "func": self.use_module, "help": "Use a module" } self.cmd["use_report"] = { "func": self.use_report, "help": "Use a report" } config = get_config_options() custom_path = config["PROJECT"].get("custom_modules", None) self.modules = [] if custom_path: self.modules += [m for m in get_modules(custom_path)] self.modules += [m for m in get_modules("included/modules")] self.modules = list(set(self.modules)) custom_path = config["PROJECT"].get("custom_reports", None) self.reports = [] if custom_path: self.reports += [m for m in get_modules(custom_path)] self.reports += [m for m in get_modules("included/reports")] self.reports = list(set(self.reports))
def __init__(self, name="Armory"): super(MainCommands, self).__init__(name) self.cmd['list_modules'] = { 'func': self.list_modules, 'help': "List available modules" } self.cmd['list_reports'] = { 'func': self.list_reports, 'help': "List available reports" } self.cmd['use_module'] = { 'func': self.use_module, 'help': "Use a module" } self.cmd['use_report'] = { 'func': self.use_report, 'help': "Use a report" } config = get_config_options() custom_path = config['PROJECT'].get('custom_modules', None) self.modules = [] if custom_path: self.modules += [m for m in get_modules(custom_path)] self.modules += [m for m in get_modules('included/modules')] self.modules = list(set(self.modules)) custom_path = config['PROJECT'].get('custom_reports', None) self.reports = [] if custom_path: self.reports += [m for m in get_modules(custom_path)] self.reports += [m for m in get_modules('included/reports')] self.reports = list(set(self.reports))
def reset_module(self, options=None, module_data=["custom_modules", "included.modules."]): config = get_config_options() db = initialize_database(config) custom_path = config["PROJECT"].get(module_data[0], None) if custom_path and self.name in get_modules(custom_path): module_path = os.path.join(custom_path, self.name) else: module_path = module_data[1] + self.name Module = load_module(module_path) if "custom_modules" in module_data: if Module.Module.__doc__: print("%s" % self.name) print(Module.Module.__doc__) self.m = Module.Module(db) else: if Module.Report.__doc__: print("%s" % self.name) print(Module.Report.__doc__) self.m = Module.Report(db) self.m.base_config = config # Populate the options self.m.set_options() self.options = {} for a in self.m.options._actions: atype = a.__class__.__name__ if atype != "_HelpAction": o = a.option_strings[-1].replace("-", "") self.options[o] = { "arg": a.option_strings[-1], "help": a.help, "type": atype, "required": a.required, } if atype == "_StoreTrueAction": if a.default: self.options[o]["value"] = True else: self.options[o]["value"] = False elif a.default: self.options[o]["value"] = a.default else: self.options[o]["value"] = "" module_config_data = get_config_options(self.name + ".ini") if "ModuleSettings" in module_config_data.sections(): for k in module_config_data["ModuleSettings"].keys(): if k in self.options.keys(): self.options[k]["value"] = module_config_data[ "ModuleSettings"][k]
def reset_module(self, options=None, module_data=['custom_modules', 'included.modules.']): config = get_config_options() db = initialize_database(config) custom_path = config['PROJECT'].get(module_data[0], None) if custom_path and self.name in get_modules(custom_path): module_path = os.path.join(custom_path, self.name) else: module_path = module_data[1] + self.name Module = load_module(module_path) if 'custom_modules' in module_data: if Module.Module.__doc__: print("%s" % self.name) print(Module.Module.__doc__) self.m = Module.Module(db) else: if Module.Report.__doc__: print("%s" % self.name) print(Module.Report.__doc__) self.m = Module.Report(db) self.m.base_config = config # Populate the options self.m.set_options() self.options = {} for a in self.m.options._actions: atype = a.__class__.__name__ if atype != "_HelpAction": o = a.option_strings[-1].replace('-', '') self.options[o] = { 'arg': a.option_strings[-1], 'help': a.help, 'type': atype, 'required': a.required } if atype == "_StoreTrueAction": if a.default: self.options[o]['value'] = True else: self.options[o]['value'] = False elif a.default: self.options[o]['value'] = a.default else: self.options[o]['value'] = "" module_config_data = get_config_options(self.name + '.ini') if 'ModuleSettings' in module_config_data.sections(): for k in module_config_data['ModuleSettings'].keys(): if k in self.options.keys(): self.options[k]['value'] = module_config_data[ 'ModuleSettings'][k]
import database import armory # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. fileConfig(config.config_file_name) # add your model's MetaData object here # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Base.metadata config_options = armory.get_config_options() db = database.create_database(armory.get_connection_string(config_options), init_db=False) target_metadata = db.Base.metadata # other values from the config, defined by the needs of env.py, # can be acquired: # my_important_option = config.get_main_option("my_important_option") # ... etc. def run_migrations_offline(): """Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable
#!/usr/bin/python from armory import initialize_database from armory import get_config_options from database.repositories import BaseDomainRepository, DomainRepository, IPRepository, CIDRRepository, UserRepository, CredRepository, VulnRepository, PortRepository, UrlRepository, ScopeCIDRRepository config = get_config_options() db = initialize_database(config) Domains = DomainRepository(db, "Shell Client") BaseDomains = BaseDomainRepository(db, "Shell Client") IPAddresses = IPRepository(db, "Shell Client") CIDRs = CIDRRepository(db, "Shell Client") Users = UserRepository(db, "Shell Client") Creds = CredRepository(db, "Shell Client") Vulns = VulnRepository(db, "Shell Client") Ports = PortRepository(db, "Shell Client") Urls = UrlRepository(db, "Shell Client") ScopeCIDRs = ScopeCIDRRepository(db, "Shell Client") print("Make sure to use this script with ipython and -i") print(" ipython -i shell.py") print("Available database modules: Domains, BaseDomains, IPAddresses,") print(" CIDRs, Users, Creds, Vulns, Services, Ports, Urls, ScopeCIDRs")