def plug_parser(): if pyoptions.args_plug[0] not in pystrs.plug_range: exit("[!] Choose plug from ({0}, {1}, {2})".format( cool.fuchsia(pystrs.plug_range[0]), cool.fuchsia(pystrs.plug_range[1]), cool.fuchsia(pystrs.plug_range[2]))) else: # id card plugin if len(pyoptions.args_plug ) == 1 and pyoptions.args_plug[0] == pystrs.plug_range[0]: idcard_magic(pystrs.plug_range[0]) elif len(pyoptions.args_plug ) == 1 and pyoptions.args_plug[0] == pystrs.plug_range[1]: idcard_magic(pystrs.plug_range[1]) # passcraper plugin elif len(pyoptions.args_plug) == 1 and pyoptions.args_plug[0] == pystrs.plug_range[2] and \ os.path.isfile(paths.scrapersites_path): scraper_magic() elif len(pyoptions.args_plug ) == 2 and pyoptions.args_plug[0] == pystrs.plug_range[2]: scraper_magic(pyoptions.args_plug[1]) elif len(pyoptions.args_plug) == 1: exit(pyoptions.CRLF + "[-] Plug %s need other arguments" % cool.red(pyoptions.args_plug[0])) else: exit(pyoptions.CRLF + cool.red("[-] Argument option error"))
def combiner_enter(directory=os.path.abspath(sys.argv[0]), need_uniqifer=False): if not os.path.isdir(os.path.abspath(directory)): exit(pyoptions.CRLF + cool.red("[-] path: {} don't exists".format(directory))) filepaths = [] combine_list = [] storepath = finalsavepath(paths.results_path, pystrs.COMBINER_prefix, mybuildtime(), pyoptions.filextension, paths.results_file_name if not need_uniqifer else None) for rootpath, subdirsname, filenames in os.walk(directory): filepaths.extend([os.path.abspath(os.path.join(rootpath, _)) for _ in filenames]) if len(filepaths) > 0: for _ in filepaths: if mimetypes.guess_type(_)[0] == 'text/plain': combine_list.append(_) try: with open(storepath, "a") as f: for onefile in combine_list: with open(onefile, 'r') as tf: f.write(tf.read()) if not need_uniqifer: finishprinter(finishcounter(storepath), storepath) else: uniqifer_enter(storepath, from_combiner=True) except Exception as ex: print(pyoptions.CRLF + cool.red("[-] Combine file failed, Looking: ")) exit(pyoptions.CRLF + traceback.print_exc())
def hybrider_magic(*args): """[file1] [file2] ...""" args = list(args[0]) filepaths = [] hybrid_list = [] if len(args) >= 2: for count in range(1, len(args)): directory = os.path.abspath(args[count]) if not os.path.isfile(os.path.abspath(directory)): exit(pyoptions.CRLF + cool.red("[-] file: {} don't exists".format(directory))) else: filepaths.append(directory) else: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format(args[0], pyoptions.tools_info.get(args[0])))) storepath = finalsavepath(fun_name()) try: for fp in filepaths: tmp = set() with open(fp, "r") as f: for line in f: tmp.add(line.strip()) hybrid_list.append(tmp) with open(storepath, "a") as f: for item in itertools.product(*hybrid_list): f.write(pyoptions.operator.get(pyoptions.encode)(pyoptions.head + "".join(item) + pyoptions.tail) + pyoptions.CRLF) finishprinter(storepath) except Exception as ex: print(pyoptions.CRLF + cool.red("[-] Hybrid files failed, Looking: ")) exit(pyoptions.CRLF + traceback.print_exc())
def combiner_magic(*args): """[dir]""" args = list(args[0]) if len(args) == 2: directory = os.path.abspath(args[1]) if not os.path.isdir(os.path.abspath(directory)): exit(pyoptions.CRLF + cool.red("[-] path: {} don't exists".format(directory))) else: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format( args[0], pyoptions.tools_info.get(args[0])))) storepath = finalsavepath(fun_name()) filepaths = [] combine_list = [] for rootpath, subdirsname, filenames in os.walk(directory): filepaths.extend( [os.path.abspath(os.path.join(rootpath, _)) for _ in filenames]) if len(filepaths) > 0: for _ in filepaths: if mimetypes.guess_type(_)[0] == 'text/plain': combine_list.append(_) try: with codecs.open(storepath, 'a', encoding="utf-8") as f: for onefile in combine_list: with codecs.open(onefile, 'r', encoding="utf-8") as tf: f.write(tf.read()) finishprinter(storepath) except Exception as ex: print(pyoptions.CRLF + cool.red("[-] Combine file failed, Looking: ")) traceback.print_exc()
def confmatcher(resource): configures = [] if not os.path.isfile(resource): matches = re.findall(pyoptions.confpattern, resource.strip()) for match in matches: for m in match: configures.append(m.strip()) else: with open(resource) as f: for item in f: confline = item.strip() if len(confline) >= 1 and confline[0] == pyoptions.annotator: pass else: matches = re.findall(pyoptions.confpattern, confline) for match in matches: for m in match: configures.append(m.strip()) if configures: if len(configures) // 5 > 10: exit(pyoptions.CRLF + cool.red('[-] Max support 10 parser')) else: return configures else: exit(pyoptions.CRLF + cool.red('[-] Match configuration file for nothing'))
def comparer_magic(*args): """[minuend_file] [subtrahend_file]""" args = list(args[0]) if len(args) != 3: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format( args[0], pyoptions.tools_info.get(args[0])))) storepath = finalsavepath(fun_name()) minuend_file = args[1] subtrahend_file = args[2] if not os.path.isfile(os.path.abspath(pyoptions.args_tool[1])): exit(pyoptions.CRLF + cool.red("[-] file: {} don't exists".format(minuend_file))) if not os.path.isfile(os.path.abspath(pyoptions.args_tool[2])): exit(pyoptions.CRLF + cool.red("[-] file: {} don't exists".format(subtrahend_file))) minuend_list = walk_pure_file(minuend_file) subtrahend_list = walk_pure_file(subtrahend_file) with open(storepath, "a") as f: for item in minuend_list: if item not in subtrahend_list: item = filterforfun(item) if item: f.write(item + pyoptions.CRLF) finishprinter(storepath)
def checkurl(urlike): try: if not str(urlike).startswith('http'): return 'http://' + urlike.strip() else: return urlike except: exit(cool.red("[-] Incorrect url/uri: {0}".format(cool.red(urlike.strip()))))
def scratchword(siteList): scrabbler = "scrabbler" resluts = [] # Create an empty list for generation logic. y_arr = [] for site in siteList: try: site = site.strip() response = urlopen(site) response.addheaders = \ [('User-agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0')] # if you don't decode('utf-8'), it will don't work both in python2 and python3 try: x = stripHTMLTags(response.read().decode('utf-8') + site) except: try: x = stripHTMLTags(response.read().decode('GBK') + site) except: exit( cool.red( "[-] Page coding parse error, please use 'extend' plug instead" ) + pyoptions.CRLF) # Replace junk found in our response x = x.replace('\n', ' ') x = x.replace(',', ' ') x = x.replace('.', ' ') x = x.replace('/', ' ') x = re.sub('[^A-Za-z0-9]+', ' ', x) x_arr = x.split(' ') for y in x_arr: y = y.strip() if y and (len(y) >= 5): if ((y[0] == '2') and (y[1] == 'F')) \ or ((y[0] == '2') and (y[1] == '3')) \ or ((y[0] == '3') and (y[1] == 'F')) or ((y[0] == '3') and (y[1] == 'D')): y = y[2:] if len(y) <= 8 and True if y.lower( ) not in passcratch_white_list else False: y_arr.append(y) elif 9 <= len(y) <= 25 and True if y.lower( ) not in passcratch_white_list else False: y_arr.append(y) except Exception: exit( cool.red( "[-] Process abort, please check url and try use 'extend' plug instead" ) + pyoptions.CRLF) for yy in unique(y_arr): if yy.strip().isdigit(): pass else: if not re.findall( pyoptions.passcraper_filter, yy.strip(), flags=re.I): resluts.append(yy.strip()) return unique(resluts)
def tool_parser(): if len(pyoptions.args_tool) >= 1: if pyoptions.args_tool[0] in pystrs.tool_range: # shredder if pyoptions.args_tool[0] == pystrs.tool_range[0]: if len(pyoptions.args_tool) == 1 and os.listdir( paths.results_path): shredder_enter(paths.results_path) elif len(pyoptions.args_tool) == 1: exit(pyoptions.CRLF + cool.orange("[+] %s has been clean" % paths.results_path)) elif len(pyoptions.args_tool) == 2: shredder_enter(pyoptions.args_tool[1]) else: exit(pyoptions.CRLF + cool.red("[-] %s arguments wrong" % pystrs.tool_range[0])) print("[+] Cost :{} seconds".format( cool.orange(str(time.time() - pystrs.startime)[:6]))) # uniqifer elif len(pyoptions.args_tool ) == 2 and pyoptions.args_tool[0] == pystrs.tool_range[1]: if os.path.isfile(pyoptions.args_tool[1]): uniqifer_enter(pyoptions.args_tool[1]) else: exit(pyoptions.CRLF + "[-] Please specify the exists file for %s" % cool.red(pystrs.tool_range[1])) # counter elif len(pyoptions.args_tool ) >= 2 and pyoptions.args_tool[0] == pystrs.tool_range[2]: counter_enter(pyoptions.encode, pyoptions.head, pyoptions.tail, pyoptions.args_tool) # combiner elif len(pyoptions.args_tool ) == 2 and pyoptions.args_tool[0] == pystrs.tool_range[3]: combiner_enter(pyoptions.args_tool[1]) # uniqbiner elif len(pyoptions.args_tool ) == 2 and pyoptions.args_tool[0] == pystrs.tool_range[4]: uniqbiner_enter(pyoptions.args_tool[1]) else: exit(pyoptions.CRLF + cool.red("[-] Need other extra arguments")) else: exit(pyoptions.CRLF + cool.red("[-] No tool named %s" % pyoptions.args_tool[0]) + pyoptions.CRLF + "[!] Choose tool from ({0}, {1}, {2}, {3}, {4})".format( cool.fuchsia(pystrs.tool_range[0]), cool.fuchsia(pystrs.tool_range[1]), cool.fuchsia(pystrs.tool_range[2]), cool.fuchsia(pystrs.tool_range[3]), cool.fuchsia(pystrs.tool_range[4]))) else: exit(pyoptions.CRLF + cool.red("[-] Please specified tool name"))
def counter_magic(*args): """['v','s','vs'] [file] [view_num]""" args = list(args[0]) # counter lack file argument if len(args) == 2 and args[1] in pystrs.counter_cmd_range: exit(pyoptions.CRLF + cool.red("[-] {0} need specify the file path".format( pyoptions.tool_range[2]))) # counter elif len(args) >= 3: if args[1] not in pystrs.counter_cmd_range: exit(pyoptions.CRLF + cool.red( "[-] Need {0}'s options, choose from '{1}' or '{2}' or '{3}'". format(args[0], pystrs.counter_cmd_range[0], pystrs. counter_cmd_range[1], pystrs.counter_cmd_range[2]))) if os.path.isfile(args[2]): # counter s file if len(args) == 3 and args[1] == pystrs.just_save_counter: counter_operator(args[2], True, False) # counter v file elif len(args) == 3 and args[1] == pystrs.just_view_counter: counter_operator(args[2], False, True) # counter vs file elif len(args) == 3 and args[1] == pystrs.save_and_view: counter_operator(args[2], False, False) # counter v file 100 elif len( args) == 4 and args[1] == pystrs.just_view_counter and str( args[3]).isdigit(): counter_operator(args[2], False, True, vs_count=int(args[3])) # counter s file 100 elif len( args) == 4 and args[1] == pystrs.just_save_counter and str( args[3]).isdigit(): counter_operator(args[2], True, False, vs_count=int(args[3])) # counter vs file 100 elif len(args) == 4 and args[1] == pystrs.save_and_view and str( args[3]).isdigit(): counter_operator(args[2], False, False, vs_count=int(args[3])) else: exit(pyoptions.CRLF + cool.red("[-] Some unexpected input")) else: exit(pyoptions.CRLF + cool.red("[-] File: %s not exists" % args[2])) else: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format( args[0], pyoptions.tools_info.get(args[0]))))
def printabler_magic(*args): """[filepath]""" args = list(args[0]) if len(args) >= 2: filepath = args[1] else: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format(args[0], pyoptions.tools_info.get(args[0])))) if not os.path.isfile(filepath): exit(cool.red("[-] File don't exits" + pyoptions.CRLF)) @magic def printabler(): is_py3 = py_ver_egt_3() if is_py3: f = open(filepath, 'r', encoding='utf8', errors='replace') else: import codecs f = codecs.open(filepath, 'r', encoding='utf8', errors='replace') for item in f: item = item.strip() if item: ret = filter(lambda x: x in string.printable, item) if is_py3: if len(list(ret)) == len(item): yield item else: if len(ret) == len(item): yield item f.close()
def get_handler_dic(path): if not os.path.isfile(path): exit(cool.red("[-] File don't exits" + pyoptions.CRLF)) storepath = finalsavepath(paths.results_path, pystrs.HANDLER_prefix, mybuildtime(), pyoptions.filextension, paths.results_file_name) handles = [] with open(path, 'r') as f: for item in f.readlines(): handles.append(item.strip()) with open(storepath, 'a') as save: for item in handles: item = filterforfun("".join(item), head=pyoptions.head, tail=pyoptions.tail, lenght_is_filter=pyoptions.args_pick, minlen=pyoptions.minlen, maxlen=pyoptions.maxlen, regex_is_filter=True, regex=pyoptions.filter_regex, encode_is_filter=True, encode=pyoptions.encode, occur_is_filter=True, letter_occur=pyoptions.letter_occur, digital_occur=pyoptions.digital_occur, special_occur=pyoptions.special_occur, types_is_filter=True, letter_types=pyoptions.letter_types, digital_types=pyoptions.digital_types, special_types=pyoptions.special_types, ) if item: save.write(item + pyoptions.CRLF) finishprinter(finishcounter(storepath), storepath)
def magic(func): storepath = finalsavepath(func.__name__) try: with open(storepath, "a") as f: for item in unique(func()): item = filterforfun( item, head=pyoptions.head, tail=pyoptions.tail, lenght_is_filter=pyoptions.args_pick, minlen=pyoptions.minlen, maxlen=pyoptions.maxlen, regex_is_filter=True, regex=pyoptions.filter_regex, encode_is_filter=True, encode=pyoptions.encode, occur_is_filter=True, letter_occur=pyoptions.letter_occur, digital_occur=pyoptions.digital_occur, special_occur=pyoptions.special_occur, types_is_filter=True, letter_types=pyoptions.letter_types, digital_types=pyoptions.digital_types, special_types=pyoptions.special_types, ) if item: f.write(item + pyoptions.CRLF) finishprinter(storepath) except Exception as e: print(cool.red('[-] Exception as following:') + pyoptions.CRLF) print(traceback.print_exc())
def uniqbiner_magic(*args): """[dir]""" args = list(args[0]) if len(args) == 2: directory = os.path.abspath(args[1]) else: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format(args[0], pyoptions.tools_info.get(args[0])))) filepaths = [] combine_list = [] for rootpath, subdirsname, filenames in os.walk(directory): filepaths.extend([os.path.abspath(os.path.join(rootpath, _)) for _ in filenames]) if len(filepaths) > 0: for _ in filepaths: if mimetypes.guess_type(_)[0] == 'text/plain': combine_list.append(_) tempath = finalsavepath("combiner") try: with open(tempath, "a") as f: for onefile in combine_list: with open(onefile, 'r') as tf: f.write(tf.read()) except Exception as ex: print(pyoptions.CRLF + cool.red("[-] Combine file failed, Looking: ")) exit(pyoptions.CRLF + traceback.print_exc()) @magic def uniqbiner(): with open(tempath) as o_f: for item in o_f.readlines(): yield item.strip() print("[+] Source of :{0} lines".format(cool.orange(finishcounter(tempath))))
def comparer_magic(*args): """[minuend_file] [subtrahend_file]""" args = list(args[0]) if len(args) != 3: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format( args[0], pyoptions.tools_info.get(args[0])))) storepath = finalsavepath(fun_name()) minuend_file = args[1] subtrahend_file = args[2] if not os.path.isfile(os.path.abspath(pyoptions.args_tool[1])): exit(pyoptions.CRLF + cool.red("[-] file: {} don't exists".format(minuend_file))) if not os.path.isfile(os.path.abspath(pyoptions.args_tool[2])): exit(pyoptions.CRLF + cool.red("[-] file: {} don't exists".format(subtrahend_file))) minuend_list = walk_pure_file(minuend_file) subtrahend_list = walk_pure_file(subtrahend_file) with open(storepath, "a") as f: for item in minuend_list: if item not in subtrahend_list: item = filterforfun( item, head=pyoptions.head, tail=pyoptions.tail, lenght_is_filter=pyoptions.args_pick, minlen=pyoptions.minlen, maxlen=pyoptions.maxlen, regex_is_filter=True, regex=pyoptions.filter_regex, encode_is_filter=True, encode=pyoptions.encode, occur_is_filter=True, letter_occur=pyoptions.letter_occur, digital_occur=pyoptions.digital_occur, special_occur=pyoptions.special_occur, types_is_filter=True, letter_types=pyoptions.letter_types, digital_types=pyoptions.digital_types, special_types=pyoptions.special_types, ) if item: f.write(item + pyoptions.CRLF) finishprinter(storepath)
def init(): args = parse_args() pyoptions.leetmode_code = args.leet if not (args.len[0] == pyoptions.minlen and args.len[1] == pyoptions.maxlen): pyoptions.args_pick = True if pyoptions.leetmode_code: pyoptions.extend_leet = True pyoptions.passcraper_leet = True pyoptions.sedb_leet = True paths.results_path = os.path.abspath(args.output) \ if '\\' in args.output or '/' in args.output else os.path.join(paths.results_path, args.output) pyoptions.head = args.head pyoptions.tail = args.tail pyoptions.encode = args.encode pyoptions.minlen = args.len[0] pyoptions.maxlen = args.len[1] pyoptions.letter_occur = args.occur[0] pyoptions.digital_occur = args.occur[1] pyoptions.special_occur = args.occur[2] pyoptions.letter_types = args.types[0] pyoptions.digital_types = args.types[1] pyoptions.special_types = args.types[2] pyoptions.filter_regex = args.regex pyoptions.args_base = args.base pyoptions.args_char = args.char pyoptions.args_chunk = args.chunk pyoptions.args_extend = args.extend pyoptions.args_plug = args.plug pyoptions.args_sedb = args.sedb pyoptions.args_conf = args.conf pyoptions.args_tool = args.tool pyoptions.level = args.level try: if os.path.isfile(paths.results_path): tmp_dirpath, tmp_filename = os.path.split(paths.results_path) if not os.path.isdir(tmp_dirpath): os.makedirs(tmp_dirpath) paths.results_path = tmp_dirpath paths.results_file_name = ''.join(random.sample( 'pydictor', 4)) + '_' + tmp_filename elif not os.path.isdir(paths.results_path): tmp_dirpath, tmp_filename = os.path.split(paths.results_path) if '.' in tmp_filename: if not os.path.isdir(tmp_dirpath): os.makedirs(tmp_dirpath) paths.results_path = tmp_dirpath paths.results_file_name = tmp_filename else: if not os.path.isdir(paths.results_path): os.makedirs(paths.results_path) except WindowsError: exit(pyoptions.CRLF + cool.red("[-] Cannot create result file: %s " % paths.results_path))
def cutout_filter(lists, start='pos-1', end='pos--1', cutout_is_filter=False): start_pos = 0 end_pos = len(lists) def pos_change(position, init_pos, is_start=True): final_pos = init_pos try: match = re.match('pos-(\d*)', position) if match.group(1): final_pos = int(match.group(1)) - 1 if is_start else int( match.group(1)) else: match = re.match('pos--(\d*)', position) if match.group(1): pos = -int(match.group(1)) if is_start: final_pos = pos - 1 if pos >= 1 else len(lists) + pos else: final_pos = pos if pos >= 1 else len(lists) + pos + 1 except: pos = 0 for _ in lists: if position == str(_): final_pos = pos if is_start else pos + 1 pos += 1 return final_pos if lists and cutout_is_filter: start_pos = pos_change(start, start_pos, is_start=True) end_pos = pos_change(end, end_pos, is_start=False) if start_pos == 0 and start != 'pos-1': print( cool.fuchsia('[!] invalid start position changed' + pyoptions.CRLF)) elif end_pos == len(lists) and end != 'pos--1': print( cool.fuchsia('[!] invalid end position changed' + pyoptions.CRLF)) elif start_pos >= end_pos: start_pos = 0 end_pos = len(lists) exit( cool.red('[!] start string behind from the end string' + pyoptions.CRLF)) elif start_pos > len(lists) - 1: print(cool.fuchsia('[!] invalid position changed' + pyoptions.CRLF)) elif end_pos > len(lists): print( cool.fuchsia('[!] end position beyond the scope' + pyoptions.CRLF)) for _ in lists[start_pos:end_pos]: return _ else: for _ in lists: return _
def plug_parser(): if pyoptions.args_plug[0] not in pystrs.plug_range: exit("[!] Choose plug from ({0}, {1}, {2}, {3}, {4}, {5})".format( cool.fuchsia(pystrs.plug_range[0]), cool.fuchsia(pystrs.plug_range[1]), cool.fuchsia(pystrs.plug_range[2]), cool.fuchsia(pystrs.plug_range[3]), cool.fuchsia(pystrs.plug_range[4]), cool.fuchsia(pystrs.plug_range[5]), )) else: # id card plugin if len(pyoptions.args_plug ) == 1 and pyoptions.args_plug[0] == pystrs.plug_range[0]: idcard_magic(pystrs.plug_range[0]) elif len(pyoptions.args_plug ) == 1 and pyoptions.args_plug[0] == pystrs.plug_range[1]: idcard_magic(pystrs.plug_range[1]) elif len(pyoptions.args_plug ) == 1 and pyoptions.args_plug[0] == pystrs.plug_range[2]: idcard_magic(pystrs.plug_range[2]) # scratch plugin elif len(pyoptions.args_plug) == 1 and pyoptions.args_plug[0] == pystrs.plug_range[3] and \ os.path.isfile(paths.scrapersites_path): scraper_magic(only_scratch=True) elif len(pyoptions.args_plug ) == 2 and pyoptions.args_plug[0] == pystrs.plug_range[3]: scraper_magic(pyoptions.args_plug[1], only_scratch=True) # passcraper plugin elif len(pyoptions.args_plug) == 1 and pyoptions.args_plug[0] == pystrs.plug_range[4] and \ os.path.isfile(paths.scrapersites_path): scraper_magic() elif len(pyoptions.args_plug ) == 2 and pyoptions.args_plug[0] == pystrs.plug_range[4]: scraper_magic(pyoptions.args_plug[1]) # birthday elif len(pyoptions.args_plug ) == 3 and pyoptions.args_plug[0] == pystrs.plug_range[5]: birthday_magic(pyoptions.args_plug[1], pyoptions.args_plug[2]) elif len(pyoptions.args_plug) == 1: exit(pyoptions.CRLF + "[-] Plug %s need other arguments" % cool.red(pyoptions.args_plug[0])) else: exit(pyoptions.CRLF + cool.red("[-] Argument option error"))
def conf_parser(): if pyoptions.args_conf == 'const': if os.path.isfile(paths.buildconf_path): build_conf_dic() elif os.path.isfile(pyoptions.args_conf): paths.buildconf_path = pyoptions.args_conf build_conf_dic() else: exit(pyoptions.CRLF + cool.red("[-] Please specify the exists configuration file"))
def tool_parser(): if len(pyoptions.args_tool) >= 1: if pyoptions.args_tool[0] in pyoptions.tool_range: pyoptions.tools_operator.get(pyoptions.args_tool[0])( pyoptions.args_tool) else: exit(pyoptions.CRLF + "[!] Choose tool from ({})".format( cool.fuchsia(" ".join(pyoptions.tool_range)))) else: exit(pyoptions.CRLF + cool.red("[-] Please specified tool name"))
def extend_magic(rawlist, need_passcratch=False): prefix = pystrs.EXTEND_prefix if rawlist == []: exit(pyoptions.CRLF + cool.red("[-] raw extend resource cannot be empty")) leet = pyoptions.extend_leet if need_passcratch: prefix = pystrs.PASSCRAPER_prefix leet = pyoptions.passcraper_leet rawstorepath = os.path.join( paths.results_path, "%s_%s%s" % (pystrs.SCFATCH_prefix, mybuildtime(), pyoptions.filextension)) with open(rawstorepath, "a") as f: for line in rawlist: f.write(str(line) + pyoptions.CRLF) finalstorepath = os.path.join( paths.results_path, "%s_%s%s" % (prefix, mybuildtime(), pyoptions.filextension)) with open(finalstorepath, "a") as f: if not pyoptions.args_pick: for _ in walks_all_files(paths.weblist_path): f.write( pyoptions.operator.get(pyoptions.encode)(str(_) + pyoptions.CRLF)) if pyoptions.level <= 1: for _ in walks_all_files(paths.syslist_path): f.write( pyoptions.operator.get( pyoptions.encode)(str(_) + pyoptions.CRLF)) for _ in extend_enter(rawlist, leet=leet): f.write( pyoptions.operator.get(pyoptions.encode)(str(_) + pyoptions.CRLF)) else: for _ in walks_all_files(paths.weblist_path): if pyoptions.minlen <= len(_) <= pyoptions.maxlen: f.write( pyoptions.operator.get( pyoptions.encode)(str(_) + pyoptions.CRLF)) if pyoptions.level <= 1: for _ in walks_all_files(paths.syslist_path): if pyoptions.minlen <= len(_) <= pyoptions.maxlen: f.write( pyoptions.operator.get( pyoptions.encode)(str(_) + pyoptions.CRLF)) for _ in extend_enter(rawlist, leet=leet): if pyoptions.minlen <= len(_) <= pyoptions.maxlen: f.write( pyoptions.operator.get( pyoptions.encode)(str(_) + pyoptions.CRLF)) finishprinter(finishcounter(finalstorepath), finalstorepath)
def get_conf_dic(minlength, maxlength, objflag, encodeflag, head, tail): diclist = [] for i in range_compatible(minlength, maxlength+1): for item in itertools.product(objflag, repeat=i): if encodeflag in pyoptions.operator.keys(): diclist.append(pyoptions.operator.get(encodeflag)(head + "".join(item) + tail)) else: exit(pyoptions.CRLF + cool.red('[-] wrong encode type')) # items count check countchecker(-1, len(diclist)) return diclist
def magic(func): storepath = finalsavepath(func.__name__) try: with open(storepath, "a") as f: for item in unique(func()): item = filterforfun(item) if item: f.write(item + pyoptions.CRLF) finishprinter(storepath) except Exception as e: print(cool.red('[-] Exception as following:') + pyoptions.CRLF) print(traceback.print_exc())
def magic(func): storepath = finalsavepath(func.__name__) # global variable transfer local variable to improved speed buffer = [] buffer_size = pyoptions.buffer_size head = pyoptions.head tail = pyoptions.tail crlf = pyoptions.CRLF encode_name = pyoptions.encode encode_fun = pyoptions.operator.get(encode_name) minlen = pyoptions.minlen maxlen = pyoptions.maxlen args_pick = pyoptions.args_pick letter_occur = pyoptions.letter_occur digital_occur = pyoptions.digital_occur special_occur = pyoptions.special_occur occur_is_filter = pyoptions.occur_is_filter letter_types = pyoptions.letter_types digital_types = pyoptions.digital_types special_types = pyoptions.special_types types_is_filter = pyoptions.types_is_filter letter_repeat = pyoptions.letter_repeat digital_repeat = pyoptions.digital_repeat special_repeat = pyoptions.special_repeat repeat_is_filter = pyoptions.repeat_is_filter filter_regex = pyoptions.filter_regex regex_is_filter = pyoptions.regex_is_filter try: with open(storepath, "a") as f: for item in unique(func()): item = fff_speed(item, head, tail, minlen, maxlen, args_pick, encode_fun, letter_occur, digital_occur, special_occur, occur_is_filter, letter_types, digital_types, special_types, types_is_filter, letter_repeat, digital_repeat, special_repeat, repeat_is_filter, filter_regex, regex_is_filter) if item: buffer.append(item) if len(buffer) == buffer_size: f.write(crlf.join(buffer) + crlf) buffer = [] f.write(crlf.join(buffer)) finishprinter(storepath) except Exception as e: print(cool.red('[-] Exception as following:') + pyoptions.CRLF) print(traceback.print_exc())
def extend_magic(rawlist): if rawlist == []: exit(pyoptions.CRLF + cool.red("[-] raw extend resource cannot be empty")) leet = pyoptions.extend_leet @magic def extend(): if pyoptions.more: for _ in walks_all_files(paths.weblist_path): yield "".join(_) for _ in walks_all_files(paths.syslist_path): yield "".join(_) for _ in extend_enter(rawlist, leet=leet): yield "".join(_)
def patterncore(resource): pattern_dict = {} try: confdicts = elementparser(confmatcher(resource)) except IndexError: confdicts = {} exit( cool.red( "[-] parse element error, please check your parsing element")) finalen = len(confdicts[pystrs.conf_head]) for x in range(0, finalen): pattern_set_list = confdicts[pystrs.conf_char][x] pattern_dict[x] = "".join(pattern_set_list) return pattern_dict
def handler_magic(*args): """[file]""" args = list(args[0]) if len(args) >= 2: path = args[1] else: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format( args[0], pyoptions.tools_info.get(args[0])))) if not os.path.isfile(path): exit(cool.red("[-] File don't exits" + pyoptions.CRLF)) @magic def handler(): with open(path, 'r') as f: for item in f: yield item.strip()
def shredder_enter(*args): fnum = 0 _ = "".join(args) if _ and os.path.isdir(_): shreder_dir(_) elif _ and os.path.isfile(_): shreder_file(_) elif _ and _.upper() in pystrs.prefix_range: for filename in os.listdir(paths.results_path): if _.upper() in str(filename[0:10]).upper(): fnum += 1 shreder_file(os.path.join(paths.results_path, filename)) if fnum == 0: exit(pyoptions.CRLF + cool.orange("[+] prefix %s files has been clean" % _.upper())) else: exit(pyoptions.CRLF + cool.red("[-] invalid shredder path_or_dir arguments"))
def shreder_dir(directory, rewritecounts=pyoptions.dir_rewrite_count): filepaths = [] dirpaths = [] print(pyoptions.CRLF + "[+] Shredding '%s' ..." % cool.orange(directory)) try: newdirectoryname = os.path.join( os.path.dirname(directory), "".join( chr(random.randint(97, 122)) for _ in range_compatible(1, 6))) os.rename(directory, newdirectoryname) directory = newdirectoryname except: traceback.print_exc() exit(pyoptions.CRLF + cool.red( "[-] Error: cannot rename root directory name, Please check permissions" )) subdir_files_path = get_subdir_files_path(directory, only_file_path=False) dirpaths.extend(subdir_files_path[0]) filepaths.extend(subdir_files_path[1]) for filepath in filepaths: try: os.chmod(filepath, stat.S_IREAD | stat.S_IWRITE) except: pass for _ in range_compatible(0, rewritecounts): print("[+] Rewrite count: %d" % (_ + 1)) for filepath in filepaths: rewrite(filepath) for filepath in filepaths: truncating(filepath) for filepath in filepaths: renamefile(filepath) renamedir(dirpaths) os.chdir(os.path.join(directory, "..")) try: shutil.rmtree(directory) except OSError as ex: print( cool.fuchsia("[!] Error: Cannot removing directory: '%s' " % directory)) traceback.print_exc() print(cool.orange("[+] Done"))
def uniqifer_magic(*args): """[file]""" args = list(args[0]) if len(args) == 2: original_file_path = args[1] if not isfile(original_file_path): exit(pyoptions.CRLF + cool.red("[-] File: {} don't exists".format( original_file_path))) else: exit(pyoptions.CRLF + cool.fuchsia("[!] Usage: {} {}".format( args[0], pyoptions.tools_info.get(args[0])))) @magic def uniqifer(): with open(original_file_path) as o_f: for item in o_f: yield item.strip() print("[+] Source of :{0} lines".format( cool.orange(finishcounter(original_file_path))))