def run(self, args): if args.tool_args: args.tool_args = " ".join(args.tool_args) else: args.tool_args = "" if args.profile1: args.tool_args += " " + args.profile1_data elif args.profile2: args.tool_args += " " + args.profile2_data elif args.profile3: args.tool_args += " " + args.profile3_data elif args.profile4: args.tool_args += " " + args.profile4_data if not args.binary: self.binary = which.run(self.binary_name) else: self.binary = which.run(args.binary) if not self.binary: print( "%s binary not found. Please explicitly provide path with --binary" % self.name) else: if args.timeout and args.timeout != "0": timeout = int(args.timeout) else: timeout = None # Currently not used, therefor to please flake8 commenting out. # if args.hard_timeout and args.hard_timeout != "0": # hard_timeout = int(args.hard_timeout) # else: # hard_timeout = None targets = self.get_targets(args) if not args.no_binary and targets: cmd = self.build_cmd(args).strip() cmds = [ shlex.split(cmd.format(**t)) + [timeout] for t in targets ] # if hard_timeout: # Popen(['./kill_process.py', str(os.getpid()), self.binary, str(hard_timeout)], preexec_fn=os.setpgrp) self.pre_run(args) pool = ThreadPool(int(args.threads)) pool.map(run_cmd, cmds) self.post_run(args) if targets: self.process_output(targets)
def run(self, args): if not args.keyword: display_error("You need to supply a keyword to search for.") return if not args.binary: self.binary = which.run(self.binary_name) else: self.binary = args.binary if not self.binary: display_error( "Asnlookup binary not found. Please explicitly provide path with --binary" ) if args.output_path[0] == "/": output_path = os.path.join( self.base_config["PROJECT"]["base_path"], 'output', args.output_path[1:]) else: output_path = os.path.join( self.base_config["PROJECT"]["base_path"], 'output', args.output_path) if not os.path.exists(output_path): os.makedirs(output_path) command_args = " -o {} --output {} ".format(args.keyword, output_path) current_dir = os.getcwd() new_dir = "/".join(self.binary.split("/")[:-1]) os.chdir(new_dir) cmd = shlex.split("python3 " + self.binary + command_args) print("Executing: %s" % " ".join(cmd)) subprocess.Popen(cmd).wait() os.chdir(current_dir) ip_ranges = open( os.path.join(output_path, "{}_ipv4.txt".format( args.keyword))).read().split('\n') for r in ip_ranges: if r: display("Processing {}".format(r)) current_cidrs = [c.cidr for c in self.ScopeCIDRs.all()] new_cidr = True for nc in current_cidrs: if IPNetwork(r) in IPNetwork(nc): new_cidr = False if new_cidr: created, SC = self.ScopeCIDRs.find_or_create(cidr=r) if created: display_new( "New CIDR added to ScopeCIDRS: {}".format(r)) self.ScopeCIDRs.commit()
def run(self, args): if not args.domain: display_error("You need to supply a domain to search for.") return if not args.binary: self.binary = which.run(self.binary_name) else: self.binary = args.binary if not self.binary: display_error( "{} binary not found. Please explicitly provide path with --binary" .format(self.binary_name)) if args.output_path[0] == "/": output_path = os.path.join( self.base_config["PROJECT"]["base_path"], 'output', args.output_path[1:]) else: output_path = os.path.join( self.base_config["PROJECT"]["base_path"], 'output', args.output_path) if not os.path.exists(output_path): os.makedirs(output_path) output_path = os.path.join(output_path, "{}.txt".format(args.domain)) command_args = " {} -o {} ".format(args.domain, output_path) if args.tool_args: command_args += ' '.join(args.tool_args) if not args.no_binary: current_dir = os.getcwd() new_dir = "/".join(self.binary.split("/")[:-1]) os.chdir(new_dir) cmd = shlex.split("python2 " + self.binary + command_args) print("Executing: %s" % " ".join(cmd)) subprocess.Popen(cmd).wait() os.chdir(current_dir) results = open(output_path).read().split('\n') cur_type = None for r in results: if r: if '### Company Names' in r: cur_type = "company" elif '### Domain Names' in r: cur_type = "domain" elif '### Email Addresses' in r: cur_type = "email" else: if cur_type == "domain": if args.scope == "active": created, d = self.Domains.find_or_create( domain=r, in_scope=True, passive_scope=True) elif args.scope == "passive": created, d = self.Domains.find_or_create( domain=r, in_scope=False, passive_scope=True) else: created, d = self.Domains.find_or_create( domain=r, in_scope=False, passive_scope=False) self.Domains.commit()
def run(self, args): # pdb.set_trace() if not args.binary: self.binary = which.run("LinkedInt.py") else: self.binary = which.run(args.binary) if not self.binary: display_error( "LinkedInt binary not found. Please explicitly provide path with --binary" ) if args.domain: created, domain = self.BaseDomain.find_or_create( domain=args.domain) if args.top: titles = [ user.job_title.split(" at ")[0] for user in domain.users if user.job_title ] words = [] for t in titles: words += [w.lower() for w in get_words(t)] word_count = Counter(words).most_common() display("Using the top %s words:" % args.top) res = [] for w in word_count[:int(args.top)]: display("\t{}\t{}".format(w[0], w[1])) res.append(w[0]) # pdb.set_trace() args.smart_shuffle = ",".join(res) if args.auto_keyword: if not args.top: display_error( "You must specify the top number of keywords using --top" ) else: if os.path.isfile('/tmp/armory_linkedinsearchqueries'): blacklist = open('/tmp/armory_linkedinsearchqueries' ).read().split('\n') else: blacklist = [] bfile = open('/tmp/armory_linkedinsearchqueries', 'a') for w in args.smart_shuffle.split(','): if w not in blacklist: args.keywords = w self.process_domain(domain, args) self.BaseDomain.commit() bfile.write('{}\n'.format(w)) else: display( "Skipped {} due to it already being searched.". format(w)) bfile.close() elif args.smart_shuffle: args.keywords = " OR ".join( ['"{}"'.format(i) for i in args.smart_shuffle.split(",")]) self.process_domain(domain, args) self.BaseDomain.commit() args.keywords = " AND ".join( ['-"{}"'.format(i) for i in args.smart_shuffle.split(",")]) self.process_domain(domain, args) self.BaseDomain.commit() else: self.process_domain(domain, args) self.BaseDomain.commit() self.BaseDomain.commit()
def run(self, args): if args.tool_args: args.tool_args = " ".join(args.tool_args) else: args.tool_args = "" if args.profile1: args.tool_args += " " + args.profile1_data elif args.profile2: args.tool_args += " " + args.profile2_data elif args.profile3: args.tool_args += " " + args.profile3_data elif args.profile4: args.tool_args += " " + args.profile4_data if not args.binary: self.binary = which.run(self.binary_name) else: self.binary = which.run(args.binary) if not self.binary: print( "%s binary not found. Please explicitly provide path with --binary" % self.name) else: if args.timeout and args.timeout != "0": timeout = int(args.timeout) else: timeout = None # Currently not used, therefor to please flake8 commenting out. # if args.hard_timeout and args.hard_timeout != "0": # hard_timeout = int(args.hard_timeout) # else: # hard_timeout = None targets = self.get_targets(args) if not args.no_binary and targets: cmd = self.build_cmd(args).strip() cmds = [ shlex.split(cmd.format(**t)) + [timeout] for t in targets ] # if hard_timeout: # Popen(['./kill_process.py', str(os.getpid()), self.binary, str(hard_timeout)], preexec_fn=os.setpgrp) self.pre_run(args) pool = ThreadPool(int(args.threads)) total_commands = len(cmds) done = 1 for i in pool.imap_unordered(run_cmd, cmds): display_purple( "Processing results from command {} of {}.".format( done, total_commands)) done += 1 # display("DEBUG: i: {}".format(i)) # display("DEBUG: target: {}".format(targets[cmds.index(i)])) self.process_output([targets[cmds.index(i)]]) self.post_run(args) if targets and args.no_binary: self.process_output(targets)