def get_targets(self, args): targets = [] if args.url: targets.append(args.url) if args.file: urls = open(args.file).read().split("\n") for u in urls: if u: targets.append(u) if args.import_database: if args.rescan: targets += get_urls.run(self.db, scope_type="active") else: targets += get_urls.run(self.db, tool=self.name, scope_type="active") if args.output_path[0] == "/": output_path = os.path.join( self.base_config["PROJECT"]["base_path"], args.output_path[1:], str(int(time.time())), ) else: output_path = os.path.join( self.base_config["PROJECT"]["base_path"], args.output_path, str(int(time.time())), ) if not os.path.exists(output_path): os.makedirs(output_path) res = [] for t in targets: res.append( { "target": t, "output": os.path.join( output_path, t.replace(":", "_") .replace("/", "_") .replace("?", "_") .replace("&", "_") + "-dir.txt", # noqa: W503 ), } ) return res
def get_targets(self, args): targets = [] _, fname = tempfile.mkstemp() with open(fname, "w") as meg_file: if args.host: self.add_host(meg_file, args.host) if args.host_file: if not os.path.exists(args.host_file): print("File: '{}' does not exist".format(args.host_file)) exit(1) with open(args.host_file) as host_file: for line in host_file: line = line.strip() if line: self.add_host(meg_file, line) if args.import_database: if args.rescan: for url in get_urls.run(self.db, scope_type="active"): meg_file.write("{}\n".format(url)) else: for url in get_urls.run(self.db, tool=self.name, scope_type="active"): meg_file.write("{}\n".format(url)) if args.output_path[0] == "/": output_path = os.path.join( self.base_config["PROJECT"]["base_path"], args.output_path[1:], str(int(time.time())), ) else: output_path = os.path.join( self.base_config["PROJECT"]["base_path"], args.output_path, str(int(time.time())), ) if not os.path.exists(output_path): os.makedirs(output_path) return [{ "target": fname, "output": os.path.join(output_path), }]
def run(self, args): res = [] self.process_output(get_urls.run(self.db), args)