def get_char_dic(objflag): storepath = finalsavepath(fun_name()) countchecker(len(objflag), pyoptions.minlen, pyoptions.maxlen) # 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) with open(storepath, "a") as f: for i in range_compatible(pyoptions.minlen, pyoptions.maxlen + 1): for item in itertools.product(objflag, repeat=i): if encode_name == "none": buffer.append(head + "".join(item) + tail) else: buffer.append(encode_fun(head + "".join(item) + tail)) if len(buffer) == buffer_size: f.write(crlf.join(buffer) + crlf) buffer = [] f.write(crlf.join(buffer)) finishprinter(storepath)
def get_chunk_dic(objflag): countchecker(len(objflag)) storepath = finalsavepath(paths.results_path, pystrs.CHUNK_prefix, mybuildtime(), pyoptions.filextension, paths.results_file_name) with open(storepath, "a") as f: for item in itertools.permutations(objflag, len(objflag)): 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(finishcounter(storepath), storepath)
def get_chunk_dic(objflag): countchecker(len(objflag)) @magic def chunk(): for item in itertools.permutations(objflag): yield "".join(item)
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 get_base_dic(objflag): storepath = finalsavepath(fun_name()) objflag = getchars(objflag) countchecker(len(objflag), pyoptions.minlen, pyoptions.maxlen) with open(storepath, "a") as f: for i in range_compatible(pyoptions.minlen, pyoptions.maxlen + 1): for item in itertools.product(objflag, repeat=i): f.write( pyoptions.operator.get(pyoptions.encode) (pyoptions.head + "".join(item) + pyoptions.tail) + pyoptions.CRLF) finishprinter(storepath)
def get_base_dic(objflag, need_char_dic=False): objflag = getchars(objflag, need_char=need_char_dic) countchecker(len(objflag), pyoptions.minlen, pyoptions.maxlen) dict_prefix = pystrs.BASE_prefix if need_char_dic: dict_prefix = pystrs.CHAR_prefix storepath = finalsavepath(paths.results_path, dict_prefix, mybuildtime(), pyoptions.filextension, paths.results_file_name) with open(storepath, "a") as f: for i in range_compatible(pyoptions.minlen, pyoptions.maxlen + 1): for item in itertools.product(objflag, repeat=i): f.write( pyoptions.operator.get(pyoptions.encode) (pyoptions.head + "".join(item) + pyoptions.tail) + pyoptions.CRLF) finishprinter(finishcounter(storepath), storepath)
def confcore(resource): 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]) listpool = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for x in range(0, finalen): lengthchecker(confdicts[pystrs.conf_minlen][x], confdicts[pystrs.conf_maxlen][x]) listpool[x] = get_conf_dic(int(confdicts[pystrs.conf_minlen][x]), int(confdicts[pystrs.conf_maxlen][x]), confdicts[pystrs.conf_char][x], confdicts[pystrs.conf_encode][x], confdicts[pystrs.conf_head][x], confdicts[pystrs.conf_tail][x]) if finalen == 1: countchecker(-1, len(listpool[0])) for item in itertools.product(listpool[0]): yield "".join(item) elif finalen == 2: countchecker(-1, len(listpool[0]), len(listpool[1])) for item in itertools.product(listpool[0], listpool[1]): yield "".join(item) elif finalen == 3: countchecker(-1, len(listpool[0]), len(listpool[1]), len(listpool[2])) for item in itertools.product(listpool[0], listpool[1], listpool[2]): yield "".join(item) elif finalen == 4: countchecker(-1, len(listpool[0]), len(listpool[1]), len(listpool[2]), len(listpool[3])) for item in itertools.product(listpool[0], listpool[1], listpool[2], listpool[3]): yield "".join(item) elif finalen == 5: countchecker(-1, len(listpool[0]), len(listpool[1]), len(listpool[2]), len(listpool[3]), len(listpool[4])) for item in itertools.product(listpool[0], listpool[1], listpool[2], listpool[3], listpool[4]): yield "".join(item) elif finalen == 6: countchecker(-1, len(listpool[0]), len(listpool[1]), len(listpool[2]), len(listpool[3]), len(listpool[4]), len(listpool[5])) for item in itertools.product(listpool[0], listpool[1], listpool[2], listpool[3], listpool[4], listpool[5]): yield "".join(item) elif finalen == 7: countchecker(-1, len(listpool[0]), len(listpool[1]), len(listpool[2]), len(listpool[3]), len(listpool[4]), len(listpool[5]), len(listpool[6])) for item in itertools.product(listpool[0], listpool[1], listpool[2], listpool[3], listpool[4], listpool[5], listpool[6]): yield "".join(item) elif finalen == 8: countchecker(-1, len(listpool[0]), len(listpool[1]), len(listpool[2]), len(listpool[3]), len(listpool[4]), len(listpool[5]), len(listpool[6]), len(listpool[7])) for item in itertools.product(listpool[0], listpool[1], listpool[2], listpool[3], listpool[4], listpool[5], listpool[6], listpool[7]): yield "".join(item) elif finalen == 9: countchecker(-1, len(listpool[0]), len(listpool[1]), len(listpool[2]), len(listpool[3]), len(listpool[4]), len(listpool[5]), len(listpool[6]), len(listpool[7]), len(listpool[8])) for item in itertools.product(listpool[0], listpool[1], listpool[2], listpool[3], listpool[4], listpool[5], listpool[6], listpool[7], listpool[8]): yield "".join(item) elif finalen == 10: countchecker(-1, len(listpool[0]), len(listpool[1]), len(listpool[2]), len(listpool[3]), len(listpool[4]), len(listpool[5]), len(listpool[6]), len(listpool[7]), len(listpool[8]), len(listpool[9])) for item in itertools.product(listpool[0], listpool[1], listpool[2], listpool[3], listpool[4], listpool[5], listpool[6], listpool[7], listpool[8], listpool[9]): yield "".join(item)