Exemplo n.º 1
0
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)
Exemplo n.º 2
0
def scraper_magic(target=paths.scrapersites_path, only_scratch=False):
    sites = []
    if os.path.isfile(target):
        with open(target, 'r') as f:
            for _ in f.readlines():
                if _.startswith(pyoptions.annotator):
                    pass
                else:
                    sites.append(checkurl(_))
    else:
        sites.append(checkurl(target))

    rawlist = scratchword(sites)
    if only_scratch:
        storepath = os.path.join(
            paths.results_path, "%s_%s%s" %
            (pystrs.SCFATCH_prefix, mybuildtime(), pyoptions.filextension))
        with open(storepath, "a") as f:
            for line in rawlist:
                f.write(str(line) + pyoptions.CRLF)
        finishprinter(finishcounter(storepath), storepath)
    else:
        storepath = os.path.join(
            paths.results_path, "%s_%s%s" %
            (pystrs.SCFATCH_prefix, mybuildtime(), pyoptions.filextension))
        with open(storepath, "a") as f:
            for line in rawlist:
                f.write(str(line) + pyoptions.CRLF)
        get_extend_dic(rawlist, need_extendscratch=True)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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()
Exemplo n.º 5
0
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 uniqifer_enter(original_file_path, from_combiner=False):
    dict_prefix = pystrs.UNIQIFER_prefix
    if from_combiner:
        dict_prefix = pystrs.UNIQBINER_prefix
    storepath = finalsavepath(paths.results_path, dict_prefix, mybuildtime(), pyoptions.filextension,
                              paths.results_file_name)
    with open(original_file_path) as o_f:
        with open(storepath, "a") as s_f:
            for item in unique(o_f.readlines()):
                item = filterforfun(item.strip(), 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:
                    s_f.write(item + pyoptions.CRLF)
    print("[+] Source of  :{0} lines".format(cool.orange(finishcounter(original_file_path))))
    finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 7
0
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 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 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())
Exemplo n.º 10
0
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)
Exemplo n.º 11
0
def build_conf_dic(source="", file_prefix=pystrs.CONF_prefix):
    storepath = finalsavepath(paths.results_path, file_prefix, mybuildtime(),
                              pyoptions.filextension, paths.results_file_name)
    with open(storepath, "a") as f:
        for item in confcore(source):
            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)
Exemplo n.º 12
0
def build_conf_dic():
    storepath = os.path.join(
        paths.results_path, "%s_%s%s" %
        (pystrs.CONF_prefix, mybuildtime(), pyoptions.filextension))
    with open(storepath, "a") as f:
        for item in confcore(paths.buildconf_path):
            f.write(str(item) + pyoptions.CRLF)
    finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 13
0
def birthday_magic(begin_date, end_date):
    def check_date(dt, desc="datetime"):
        if len(dt) != 8 or not dt.isdigit():
            exit(
                cool.fuchsia(
                    "[!] {} format:[YYYYMMDD], such as:19900512{}".format(
                        desc, pyoptions.CRLF)))
        elif int(dt[4:6]) > 12 or int(dt[4:6]) < 1 or int(dt[6:8]) > 31 or int(
                dt[6:8]) < 1:
            exit(
                cool.fuchsia(
                    "[!] {} date format: 1<= month <=12 and 1<= day <=31{}".
                    format(desc, pyoptions.CRLF)))
        else:
            return int(dt[:4]), int(dt[4:6]), int(dt[6:])

    def check_range(s, e):
        if s[0] > e[0] or (s[0] == e[0] and s[1] > e[1]) or (s[1] == e[1]
                                                             and s[2] > e[2]):
            exit(
                cool.fuchsia("[!] Start date should later than End date" +
                             pyoptions.CRLF))
        else:
            return True

    start_valid = check_date(begin_date, desc="Start datetime")
    end_valid = check_date(end_date, desc="End datetime")
    valid = check_range(start_valid,
                        end_valid) if start_valid and end_valid else False
    storepath = finalsavepath(paths.results_path, pystrs.BIRTHDAY_prefix,
                              mybuildtime(), pyoptions.filextension,
                              paths.results_file_name)
    if valid:
        res = []
        begin = datetime.datetime.strptime(begin_date, "%Y%m%d")
        end = datetime.datetime.strptime(end_date, "%Y%m%d")
        while begin <= end:
            date_str = begin.strftime("%Y%m%d")
            res.extend(dateshaper(date_str))
            begin += datetime.timedelta(days=1)
        with open(storepath, "a") as f:
            for item in unique(res):
                item = filterforfun(
                    item,
                    head=pyoptions.head,
                    tail=pyoptions.tail,
                    lenght_is_filter=pyoptions.args_pick,
                    minlen=pyoptions.minlen,
                    maxlen=pyoptions.maxlen,
                    encode_is_filter=True,
                    encode=pyoptions.encode,
                )
                if item:
                    f.write(item + pyoptions.CRLF)
        finishprinter(finishcounter(storepath), storepath)
def idcard_magic(posflag):
    storepath = finalsavepath(paths.results_path, pystrs.IDCARD_prefix,
                              mybuildtime(), pyoptions.filextension,
                              paths.results_file_name)

    posrule = lambda _: str(_) if _ >= 10 else "0" + str(_)
    # month
    value1112 = " ".join(posrule(x) for x in range_compatible(1, 13))
    # day
    value1314 = " ".join(posrule(x) for x in range_compatible(1, 32))
    value1516 = " ".join(posrule(x) for x in range_compatible(1, 100))
    post18 = ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "X")
    value1718 = ""
    if pystrs.default_sex == pystrs.sex_range[0]:
        rand = ("1", "3", "5", "7", "9")
        for _ in rand:
            for _p in post18:
                value1718 += _ + _p + " "
    elif pystrs.default_sex == pystrs.sex_range[1]:
        rand = ("0", "2", "4", "6", "8")
        for _ in rand:
            for _p in post18:
                value1718 += _ + _p + " "
    elif pystrs.default_sex == pystrs.sex_range[2]:
        rand = " ".join(str(_) for _ in range_compatible(0, 10))
        for _ in rand.split(" "):
            for _p in post18:
                value1718 += _ + _p + " "

    with open(storepath, "a") as f:
        if posflag == pystrs.plug_range[1]:
            for v1112 in value1112.split(" "):
                for v1314 in value1314.split(" "):
                    for v1516 in value1516.split(" "):
                        for v1718 in value1718.split(" "):
                            if v1718 != "":
                                f.write(
                                    pyoptions.operator.get(pyoptions.encode)
                                    (pyoptions.head +
                                     "".join(v1112 + v1314 + v1516 + v1718) +
                                     pyoptions.tail) + pyoptions.CRLF)

        elif posflag == pystrs.plug_range[0]:
            for v1314 in value1314.split(" "):
                for v1516 in value1516.split(" "):
                    for v1718 in value1718.split(" "):
                        if v1718 != "":
                            f.write(
                                pyoptions.operator.get(pyoptions.encode)
                                (pyoptions.head +
                                 "".join(v1314 + v1516 + v1718) +
                                 pyoptions.tail) + pyoptions.CRLF)

    finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 15
0
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 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())
Exemplo n.º 17
0
def uniqifer_enter(original_file_path, from_combiner=False):
    prefix = pystrs.UNIQIFER_prefix
    if from_combiner:
        prefix = pystrs.UNIQBINER_prefix
    storepath = os.path.join(
        paths.results_path,
        "%s_%s%s" % (prefix, mybuildtime(), pyoptions.filextension))
    with open(original_file_path) as o_f:
        with open(storepath, "a") as s_f:
            for _ in unique(o_f.readlines()):
                s_f.write(_)
    print("[+] Source of  :{0} lines".format(
        cool.orange(finishcounter(original_file_path))))
    finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 18
0
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 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)
Exemplo n.º 20
0
def counter_operator(original_file_path,
                     justsave,
                     justview,
                     encodeflag,
                     head,
                     tail,
                     vs_count=pyoptions.default_vs_items):
    items = Counter(
        open(original_file_path,
             'r').read().replace(string.punctuation, "").split(
                 pyoptions.counter_split)).most_common(vs_count)
    items_length = len(items)
    storepath = os.path.join(
        paths.results_path, "%s_%s%s" %
        (pystrs.COUNTER_prefix, mybuildtime(), pyoptions.filextension))
    if vs_count > pyoptions.vs_counter_switcher:
        exit(pyoptions.CRLF +
             cool.fuchsia("[!] view items should Leq {0}".format(
                 pyoptions.vs_counter_switcher)))
    elif items_length < vs_count:
        exit(pyoptions.CRLF +
             cool.fuchsia("[!] max items is {0}".format(items_length)))
    print("{0}Welcome to the COUNTER tool".format("   " * 8))
    if justsave:
        with open(storepath, "a") as f:
            for _ in items:
                f.write(
                    pyoptions.operator.get(encodeflag)(head + _[0] + tail) +
                    pyoptions.CRLF)
        finishprinter(finishcounter(storepath), storepath)
    elif justview:
        print(pyoptions.CRLF * 2)
        for item in items:
            print("{0}Word:{2:20} -> {1:10} times".format(
                "     " * 5, cool.orange(item[1]), cool.orange(item[0])))
        print("[+] Cost:{} seconds".format(
            cool.orange(str(time.time() - pystrs.startime)[:6])))
    else:
        print(pyoptions.CRLF * 2)
        for item in items:
            print("{0}Word:{2:20} -> {1:10} times".format(
                "     " * 5, cool.orange(item[1]), cool.orange(item[0])))
        print(pyoptions.CRLF)
        with open(storepath, 'a') as f:
            for _ in items:
                f.write(
                    pyoptions.operator.get(encodeflag)(head + _[0] + tail) +
                    pyoptions.CRLF)
        finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 21
0
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)
Exemplo n.º 22
0
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)
Exemplo n.º 23
0
def build_pattern_dic(source=""):
    storepath = finalsavepath("pattern")
    pattern_set = patterncore(source)
    char_list = [sorted(set(i)) for i in pattern_set.values()]

    # count word list lines
    count = functools.reduce(operator.mul,
                             [len(i) for i in pattern_set.values()], 1)
    if count >= pyoptions.count_switcher:
        exit_msg = pyoptions.CRLF + cool.fuchsia(
            "[!] Build items more than pyoptions.count_switcher: %s%s"
            "[!] Modify /lib/data/data.py count_switcher to adjust it" %
            (str(pyoptions.count_switcher), pyoptions.CRLF))
        exit(exit_msg)

    # 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)

    try:
        with open(storepath, "w") as f:
            for item in map("".join, product(*char_list)):
                if encode_name == "none":
                    buffer.append(head + item + tail)
                else:
                    buffer.append(encode_fun(head + item + tail))
                if len(buffer) == buffer_size:
                    f.write(crlf.join(buffer) + crlf)
                    buffer = []
            f.write(crlf.join(buffer))
        finishprinter(storepath, count)
    except Exception as e:
        print(cool.red('[-] Exception as following:') + pyoptions.CRLF)
        print(traceback.print_exc())
    def do_run(self, args):
        pystrs.startime = time.time()
        results = []
        storepath = finalsavepath(paths.results_path, pystrs.SEDB_prefix,
                                  mybuildtime(), pyoptions.filextension,
                                  paths.results_file_name)
        paths.results_file_name = None
        # SingleRule
        for single in SingleRule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                                 pystrs.sedb_dict[pystrs.sedb_range[1]],
                                 pystrs.sedb_dict[pystrs.sedb_range[2]],
                                 pystrs.sedb_dict[pystrs.sedb_range[3]],
                                 pystrs.sedb_dict[pystrs.sedb_range[4]],
                                 pystrs.sedb_dict[pystrs.sedb_range[5]],
                                 pystrs.sedb_dict[pystrs.sedb_range[6]],
                                 pystrs.sedb_dict[pystrs.sedb_range[7]],
                                 pystrs.sedb_dict[pystrs.sedb_range[8]],
                                 pystrs.sedb_dict[pystrs.sedb_range[9]],
                                 pystrs.sedb_dict[pystrs.sedb_range[10]],
                                 pystrs.sedb_dict[pystrs.sedb_range[11]],
                                 pystrs.sedb_dict[pystrs.sedb_range[12]],
                                 pystrs.sedb_dict[pystrs.sedb_range[13]],
                                 pystrs.sedb_dict[pystrs.sedb_range[14]]):
            results.append(single)
        # SDrule
        for sd in SDrule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                         pystrs.sedb_dict[pystrs.sedb_range[3]]):
            results.append(sd)
        for sd in SDrule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                         pystrs.sedb_dict[pystrs.sedb_range[13]]):
            results.append(sd)
        # EB
        for eb in EB(pystrs.sedb_dict[pystrs.sedb_range[1]],
                     pystrs.sedb_dict[pystrs.sedb_range[3]]):
            results.append(eb)
        for eb in EB(pystrs.sedb_dict[pystrs.sedb_range[1]],
                     pystrs.sedb_dict[pystrs.sedb_range[13]]):
            results.append(eb)
        # Mailrule
        for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                           pystrs.sedb_dict[pystrs.sedb_range[0]]):
            results.append(mr)
        for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                           pystrs.sedb_dict[pystrs.sedb_range[1]]):
            results.append(mr)
        for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                           pystrs.sedb_dict[pystrs.sedb_range[2]]):
            results.append(mr)
        for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                           pystrs.sedb_dict[pystrs.sedb_range[4]]):
            results.append(mr)
        for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                           pystrs.sedb_dict[pystrs.sedb_range[10]]):
            results.append(mr)
        for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                           pystrs.sedb_dict[pystrs.sedb_range[14]]):
            results.append(mr)
        for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                           pystrs.sedb_dict[pystrs.sedb_range[3]],
                           isstrs=False):
            results.append(mr)
        for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                           pystrs.sedb_dict[pystrs.sedb_range[13]],
                           isstrs=False):
            results.append(mr)
        # NB
        for nn in NB(pystrs.sedb_dict[pystrs.sedb_range[10]],
                     pystrs.sedb_dict[pystrs.sedb_range[3]]):
            results.append(nn)
        for nn in NB(pystrs.sedb_dict[pystrs.sedb_range[10]],
                     pystrs.sedb_dict[pystrs.sedb_range[13]]):
            results.append(nn)

        # SB
        for sb in SB(pystrs.sedb_dict[pystrs.sedb_range[2]],
                     pystrs.sedb_dict[pystrs.sedb_range[3]]):
            results.append(sb)
        for sb in SB(pystrs.sedb_dict[pystrs.sedb_range[2]],
                     pystrs.sedb_dict[pystrs.sedb_range[13]]):
            results.append(sb)

        # NNrule
        for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[3]],
                         pystrs.sedb_dict[pystrs.sedb_range[5]]):
            results.append(nn)
        for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[3]],
                         pystrs.sedb_dict[pystrs.sedb_range[6]]):
            results.append(nn)
        for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[5]],
                         pystrs.sedb_dict[pystrs.sedb_range[13]]):
            results.append(nn)
        for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[6]],
                         pystrs.sedb_dict[pystrs.sedb_range[13]]):
            results.append(nn)
        for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[7]],
                         pystrs.sedb_dict[pystrs.sedb_range[13]]):
            results.append(nn)
        for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[9]],
                         pystrs.sedb_dict[pystrs.sedb_range[13]]):
            results.append(nn)
        for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[12]],
                         pystrs.sedb_dict[pystrs.sedb_range[13]]):
            results.append(nn)
        for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[3]],
                         pystrs.sedb_dict[pystrs.sedb_range[7]]):
            results.append(nn)
        for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[3]],
                         pystrs.sedb_dict[pystrs.sedb_range[9]]):
            results.append(nn)
        for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[3]],
                         pystrs.sedb_dict[pystrs.sedb_range[11]]):
            results.append(nn)
        for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[3]],
                         pystrs.sedb_dict[pystrs.sedb_range[12]]):
            results.append(nn)
        for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[3]],
                         pystrs.sedb_dict[pystrs.sedb_range[13]]):
            results.append(nn)

        # SNrule
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[4]],
                         pystrs.sedb_dict[pystrs.sedb_range[3]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[4]],
                         pystrs.sedb_dict[pystrs.sedb_range[5]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[4]],
                         pystrs.sedb_dict[pystrs.sedb_range[6]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[4]],
                         pystrs.sedb_dict[pystrs.sedb_range[7]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[4]],
                         pystrs.sedb_dict[pystrs.sedb_range[9]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[4]],
                         pystrs.sedb_dict[pystrs.sedb_range[11]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[4]],
                         pystrs.sedb_dict[pystrs.sedb_range[13]]):
            results.append(sn)

        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                         pystrs.sedb_dict[pystrs.sedb_range[3]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                         pystrs.sedb_dict[pystrs.sedb_range[5]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                         pystrs.sedb_dict[pystrs.sedb_range[6]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                         pystrs.sedb_dict[pystrs.sedb_range[7]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                         pystrs.sedb_dict[pystrs.sedb_range[9]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                         pystrs.sedb_dict[pystrs.sedb_range[11]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                         pystrs.sedb_dict[pystrs.sedb_range[13]]):
            results.append(sn)

        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[14]],
                         pystrs.sedb_dict[pystrs.sedb_range[3]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[14]],
                         pystrs.sedb_dict[pystrs.sedb_range[5]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[14]],
                         pystrs.sedb_dict[pystrs.sedb_range[6]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[14]],
                         pystrs.sedb_dict[pystrs.sedb_range[7]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[14]],
                         pystrs.sedb_dict[pystrs.sedb_range[9]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[14]],
                         pystrs.sedb_dict[pystrs.sedb_range[11]]):
            results.append(sn)
        for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[14]],
                         pystrs.sedb_dict[pystrs.sedb_range[13]]):
            results.append(sn)

        # SSrule
        for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                         pystrs.sedb_dict[pystrs.sedb_range[1]]):
            results.append(ss)
        for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                         pystrs.sedb_dict[pystrs.sedb_range[4]]):
            results.append(ss)
        for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                         pystrs.sedb_dict[pystrs.sedb_range[8]]):
            results.append(ss)
        for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                         pystrs.sedb_dict[pystrs.sedb_range[10]]):
            results.append(ss)
        for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                         pystrs.sedb_dict[pystrs.sedb_range[14]]):
            results.append(ss)
        for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[1]],
                         pystrs.sedb_dict[pystrs.sedb_range[4]]):
            results.append(ss)
        for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[1]],
                         pystrs.sedb_dict[pystrs.sedb_range[8]]):
            results.append(ss)
        for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[1]],
                         pystrs.sedb_dict[pystrs.sedb_range[10]]):
            results.append(ss)
        for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[1]],
                         pystrs.sedb_dict[pystrs.sedb_range[14]]):
            results.append(ss)
        for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                         pystrs.sedb_dict[pystrs.sedb_range[10]]):
            results.append(ss)
        for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                         pystrs.sedb_dict[pystrs.sedb_range[14]]):
            results.append(ss)
        for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                         pystrs.sedb_dict[pystrs.sedb_range[14]]):
            results.append(ss)

        # WeakPass
        for weakpwd in walks_all_files(paths.sedblist_path):
            results.append(weakpwd)
        readylist = []
        readylist.extend(pystrs.sedb_dict[pystrs.sedb_range[0]])
        readylist.extend(pystrs.sedb_dict[pystrs.sedb_range[1]])
        readylist.extend(pystrs.sedb_dict[pystrs.sedb_range[2]])
        readylist.extend(pystrs.sedb_dict[pystrs.sedb_range[4]])
        readylist.extend(pystrs.sedb_dict[pystrs.sedb_range[10]])
        readylist.extend(pystrs.sedb_dict[pystrs.sedb_range[14]])
        # Using extend_enter plug
        for extendstr in extend_enter(readylist, leet=pyoptions.sedb_leet):
            results.append(extendstr)
        with open(storepath, "a") as f:
            for ur in unique(results):
                item = filterforfun(
                    "".join(ur),
                    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)
Exemplo n.º 25
0
def extend_magic(rawlist, need_extendscratch=False):
    prefix = pystrs.EXTEND_prefix
    if rawlist == []:
        exit(pyoptions.CRLF +
             cool.red("[-] raw extend resource cannot be empty"))

    leet = pyoptions.extend_leet
    if need_extendscratch:
        prefix = pystrs.PASSCRAPER_prefix
        leet = pyoptions.passcraper_leet

    storepath = finalsavepath(paths.results_path, prefix, mybuildtime(),
                              pyoptions.filextension, paths.results_file_name)
    with open(storepath, "a") as f:
        for _ in walks_all_files(paths.weblist_path):
            item = filterforfun(
                "".join(_),
                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)
        if pyoptions.level <= 1:
            for _ in walks_all_files(paths.syslist_path):
                item = filterforfun(
                    "".join(_),
                    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)
        for _ in extend_enter(rawlist, leet=leet):
            item = filterforfun(
                "".join(_),
                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 counter_operator(original_file_path,
                     justsave,
                     justview,
                     encodeflag,
                     head,
                     tail,
                     vs_count=pyoptions.default_vs_items):
    items = Counter(
        open(original_file_path,
             'r').read().replace(string.punctuation, "").split(
                 pyoptions.counter_split)).most_common(vs_count)
    items_length = len(items)
    storepath = finalsavepath(paths.results_path, pystrs.COUNTER_prefix,
                              mybuildtime(), pyoptions.filextension,
                              paths.results_file_name)
    if vs_count > pyoptions.vs_counter_switcher:
        exit(pyoptions.CRLF +
             cool.fuchsia("[!] view items should Leq {0}".format(
                 pyoptions.vs_counter_switcher)))
    elif items_length < vs_count:
        exit(pyoptions.CRLF +
             cool.fuchsia("[!] max items is {0}".format(items_length)))
    print("{0}Welcome to the COUNTER tool".format("   " * 8))
    if justsave:
        with open(storepath, "a") as f:
            for _ in items:
                item = filterforfun(
                    _[0],
                    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)
    elif justview:
        print(pyoptions.CRLF * 2)
        for item in items:
            print("{0}Word:{2:20} -> {1:10} times".format(
                "     " * 5, cool.orange(item[1]), cool.orange(item[0])))
        print("[+] Cost:{} seconds".format(
            cool.orange(str(time.time() - pystrs.startime)[:6])))
    else:
        print(pyoptions.CRLF * 2)
        for item in items:
            print("{0}Word:{2:20} -> {1:10} times".format(
                "     " * 5, cool.orange(item[1]), cool.orange(item[0])))
        print(pyoptions.CRLF)
        with open(storepath, 'a') as f:
            for _ in items:
                f.write(
                    pyoptions.operator.get(encodeflag)(head + _[0] + tail) +
                    pyoptions.CRLF)
        finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 27
0
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)

    # 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

    with open(storepath, "a") as f:
        for item in minuend_list:
            if item not in subtrahend_list:
                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:
                    f.write(item + pyoptions.CRLF)

    finishprinter(storepath)
Exemplo n.º 28
0
    def do_run(self, args):
        pystrs.startime = time.time()
        results = []
        storepath = os.path.join(
            paths.results_path, '%s_%s%s' %
            (pystrs.SEDB_prefix, mybuildtime(), pyoptions.filextension))
        with open(storepath, "a") as f:
            # SingleRule
            for single in SingleRule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                                     pystrs.sedb_dict[pystrs.sedb_range[1]],
                                     pystrs.sedb_dict[pystrs.sedb_range[2]],
                                     pystrs.sedb_dict[pystrs.sedb_range[3]],
                                     pystrs.sedb_dict[pystrs.sedb_range[4]],
                                     pystrs.sedb_dict[pystrs.sedb_range[5]],
                                     pystrs.sedb_dict[pystrs.sedb_range[6]],
                                     pystrs.sedb_dict[pystrs.sedb_range[7]],
                                     pystrs.sedb_dict[pystrs.sedb_range[8]],
                                     pystrs.sedb_dict[pystrs.sedb_range[9]],
                                     pystrs.sedb_dict[pystrs.sedb_range[10]],
                                     pystrs.sedb_dict[pystrs.sedb_range[11]],
                                     pystrs.sedb_dict[pystrs.sedb_range[12]],
                                     pystrs.sedb_dict[pystrs.sedb_range[13]],
                                     pystrs.sedb_dict[pystrs.sedb_range[14]]):
                results.append(single)
            # SDrule
            for sd in SDrule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                             pystrs.sedb_dict[pystrs.sedb_range[3]]):
                results.append(sd)
            for sd in SDrule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                             pystrs.sedb_dict[pystrs.sedb_range[13]]):
                results.append(sd)
            # EB
            for eb in EB(pystrs.sedb_dict[pystrs.sedb_range[1]],
                         pystrs.sedb_dict[pystrs.sedb_range[3]]):
                results.append(eb)
            for eb in EB(pystrs.sedb_dict[pystrs.sedb_range[1]],
                         pystrs.sedb_dict[pystrs.sedb_range[13]]):
                results.append(eb)
            # Mailrule
            for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                               pystrs.sedb_dict[pystrs.sedb_range[0]]):
                results.append(mr)
            for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                               pystrs.sedb_dict[pystrs.sedb_range[1]]):
                results.append(mr)
            for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                               pystrs.sedb_dict[pystrs.sedb_range[2]]):
                results.append(mr)
            for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                               pystrs.sedb_dict[pystrs.sedb_range[4]]):
                results.append(mr)
            for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                               pystrs.sedb_dict[pystrs.sedb_range[10]]):
                results.append(mr)
            for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                               pystrs.sedb_dict[pystrs.sedb_range[14]]):
                results.append(mr)
            for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                               pystrs.sedb_dict[pystrs.sedb_range[3]],
                               isstrs=False):
                results.append(mr)
            for mr in Mailrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                               pystrs.sedb_dict[pystrs.sedb_range[13]],
                               isstrs=False):
                results.append(mr)
            # NB
            for nn in NB(pystrs.sedb_dict[pystrs.sedb_range[10]],
                         pystrs.sedb_dict[pystrs.sedb_range[3]]):
                results.append(nn)
            for nn in NB(pystrs.sedb_dict[pystrs.sedb_range[10]],
                         pystrs.sedb_dict[pystrs.sedb_range[13]]):
                results.append(nn)

            # SB
            for sb in SB(pystrs.sedb_dict[pystrs.sedb_range[2]],
                         pystrs.sedb_dict[pystrs.sedb_range[3]]):
                results.append(sb)
            for sb in SB(pystrs.sedb_dict[pystrs.sedb_range[2]],
                         pystrs.sedb_dict[pystrs.sedb_range[13]]):
                results.append(sb)

            # NNrule
            for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[3]],
                             pystrs.sedb_dict[pystrs.sedb_range[5]]):
                results.append(nn)
            for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[3]],
                             pystrs.sedb_dict[pystrs.sedb_range[6]]):
                results.append(nn)
            for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[5]],
                             pystrs.sedb_dict[pystrs.sedb_range[13]]):
                results.append(nn)
            for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[6]],
                             pystrs.sedb_dict[pystrs.sedb_range[13]]):
                results.append(nn)
            for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[7]],
                             pystrs.sedb_dict[pystrs.sedb_range[13]]):
                results.append(nn)
            for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[9]],
                             pystrs.sedb_dict[pystrs.sedb_range[13]]):
                results.append(nn)
            for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[12]],
                             pystrs.sedb_dict[pystrs.sedb_range[13]]):
                results.append(nn)
            for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[3]],
                             pystrs.sedb_dict[pystrs.sedb_range[7]]):
                results.append(nn)
            for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[3]],
                             pystrs.sedb_dict[pystrs.sedb_range[9]]):
                results.append(nn)
            for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[3]],
                             pystrs.sedb_dict[pystrs.sedb_range[11]]):
                results.append(nn)
            for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[3]],
                             pystrs.sedb_dict[pystrs.sedb_range[12]]):
                results.append(nn)
            for nn in NNrule(pystrs.sedb_dict[pystrs.sedb_range[3]],
                             pystrs.sedb_dict[pystrs.sedb_range[13]]):
                results.append(nn)

            # SNrule
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[4]],
                             pystrs.sedb_dict[pystrs.sedb_range[3]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[4]],
                             pystrs.sedb_dict[pystrs.sedb_range[5]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[4]],
                             pystrs.sedb_dict[pystrs.sedb_range[6]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[4]],
                             pystrs.sedb_dict[pystrs.sedb_range[7]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[4]],
                             pystrs.sedb_dict[pystrs.sedb_range[9]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[4]],
                             pystrs.sedb_dict[pystrs.sedb_range[11]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[4]],
                             pystrs.sedb_dict[pystrs.sedb_range[13]]):
                results.append(sn)

            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                             pystrs.sedb_dict[pystrs.sedb_range[3]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                             pystrs.sedb_dict[pystrs.sedb_range[5]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                             pystrs.sedb_dict[pystrs.sedb_range[6]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                             pystrs.sedb_dict[pystrs.sedb_range[7]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                             pystrs.sedb_dict[pystrs.sedb_range[9]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                             pystrs.sedb_dict[pystrs.sedb_range[11]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                             pystrs.sedb_dict[pystrs.sedb_range[13]]):
                results.append(sn)

            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[14]],
                             pystrs.sedb_dict[pystrs.sedb_range[3]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[14]],
                             pystrs.sedb_dict[pystrs.sedb_range[5]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[14]],
                             pystrs.sedb_dict[pystrs.sedb_range[6]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[14]],
                             pystrs.sedb_dict[pystrs.sedb_range[7]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[14]],
                             pystrs.sedb_dict[pystrs.sedb_range[9]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[14]],
                             pystrs.sedb_dict[pystrs.sedb_range[11]]):
                results.append(sn)
            for sn in SNrule(pystrs.sedb_dict[pystrs.sedb_range[14]],
                             pystrs.sedb_dict[pystrs.sedb_range[13]]):
                results.append(sn)

            # SSrule
            for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                             pystrs.sedb_dict[pystrs.sedb_range[1]]):
                results.append(ss)
            for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                             pystrs.sedb_dict[pystrs.sedb_range[4]]):
                results.append(ss)
            for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                             pystrs.sedb_dict[pystrs.sedb_range[8]]):
                results.append(ss)
            for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                             pystrs.sedb_dict[pystrs.sedb_range[10]]):
                results.append(ss)
            for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[0]],
                             pystrs.sedb_dict[pystrs.sedb_range[14]]):
                results.append(ss)
            for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[1]],
                             pystrs.sedb_dict[pystrs.sedb_range[4]]):
                results.append(ss)
            for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[1]],
                             pystrs.sedb_dict[pystrs.sedb_range[8]]):
                results.append(ss)
            for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[1]],
                             pystrs.sedb_dict[pystrs.sedb_range[10]]):
                results.append(ss)
            for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[1]],
                             pystrs.sedb_dict[pystrs.sedb_range[14]]):
                results.append(ss)
            for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                             pystrs.sedb_dict[pystrs.sedb_range[10]]):
                results.append(ss)
            for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[8]],
                             pystrs.sedb_dict[pystrs.sedb_range[14]]):
                results.append(ss)
            for ss in SSrule(pystrs.sedb_dict[pystrs.sedb_range[10]],
                             pystrs.sedb_dict[pystrs.sedb_range[14]]):
                results.append(ss)

            # WeakPass
            for weakpwd in walks_all_files(paths.sedblist_path):
                results.append(weakpwd)
            readylist = []
            readylist.extend(pystrs.sedb_dict[pystrs.sedb_range[0]])
            readylist.extend(pystrs.sedb_dict[pystrs.sedb_range[1]])
            readylist.extend(pystrs.sedb_dict[pystrs.sedb_range[2]])
            readylist.extend(pystrs.sedb_dict[pystrs.sedb_range[4]])
            readylist.extend(pystrs.sedb_dict[pystrs.sedb_range[10]])
            readylist.extend(pystrs.sedb_dict[pystrs.sedb_range[14]])
            # Using extend_enter plug
            for extendstr in extend_enter(readylist, leet=pyoptions.sedb_leet):
                results.append(extendstr)

            if not pyoptions.args_pick:
                for ur in unique(results):
                    f.write(ur + pyoptions.CRLF)
            else:
                for ur in unique(results):
                    if pyoptions.minlen <= len(ur) <= pyoptions.maxlen:
                        f.write(ur + pyoptions.CRLF)
        finishprinter(finishcounter(storepath), storepath)