Exemplo n.º 1
0
    def do_run(self, args):
        results = []
        storepath = os.path.join(get_result_store_path(), '%s_%s%s' % (SEDB_prefix, get_buildtime(), filextension))
        with open(storepath, 'w') as f:
            # SingleRule
            for single in SingleRule(settings_dict['cname'], settings_dict['ename'], settings_dict['sname'],
                                     settings_dict['birth'], settings_dict['usedpwd'], settings_dict['phone'],
                                     settings_dict['uphone'], settings_dict['hphone'], settings_dict['email'],
                                     settings_dict['postcode'], settings_dict['nickname'], settings_dict['idcard'],
                                     settings_dict['jobnum'], settings_dict['otherdate'], settings_dict['usedchar']):
                results.append(single)
            # CBrule
            for cb in CBrule(settings_dict['cname'], settings_dict['birth']):
                results.append(cb)
            # EBrule
            for eb in EBrule(settings_dict['ename'], settings_dict['birth']):
                results.append(eb)
            # SBrule
            for sb in SBrule(settings_dict['sname'], settings_dict['birth']):
                results.append(sb)
            # WeakPass
            for weakpwd in weak_pass_set:
                results.append(weakpwd)

            # de-duplication
            for _ in reduce(lambda x, y: x if y in x else x + [y], [[], ] + results):
                f.write(_ + CRLF)
        finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 2
0
 def do_run(self, args):
     results = []
     storepath = os.path.join(get_result_store_path(), '%s_%s%s' % (SEDB_prefix, get_buildtime(), filextension))
     with open(storepath, "a") as f:
         # SingleRule
         for single in SingleRule(settings_dict[sedb_range[0]], settings_dict[sedb_range[1]],
                                  settings_dict[sedb_range[2]], settings_dict[sedb_range[3]],
                                  settings_dict[sedb_range[4]], settings_dict[sedb_range[5]],
                                  settings_dict[sedb_range[6]], settings_dict[sedb_range[7]],
                                  settings_dict[sedb_range[8]], settings_dict[sedb_range[9]],
                                  settings_dict[sedb_range[10]], settings_dict[sedb_range[11]],
                                  settings_dict[sedb_range[12]], settings_dict[sedb_range[13]],
                                  settings_dict[sedb_range[14]]):
             results.append(single)
         # CBrule
         for cb in CBrule(settings_dict[sedb_range[0]], settings_dict[sedb_range[3]]):
             results.append(cb)
         # EBrule
         for eb in EBrule(settings_dict[sedb_range[1]], settings_dict[sedb_range[3]]):
             results.append(eb)
         # SBrule
         for sb in SBrule(settings_dict[sedb_range[2]], settings_dict[sedb_range[3]]):
             results.append(sb)
         # WeakPass
         for weakpwd in weak_pass_set:
             results.append(weakpwd)
         # Using extend_enter plug
         for extendstr in extend_enter(settings_dict[sedb_range[0]], settings_dict[sedb_range[1]],
                                       settings_dict[sedb_range[2]], settings_dict[sedb_range[4]],
                                       settings_dict[sedb_range[10]], settings_dict[sedb_range[14]]):
             results.append(extendstr)
         # de-duplication
         for _ in reduce(lambda x, y: x if y in x else x + [y], [[], ] + results):
             f.write(_ + CRLF)
     finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 3
0
def get_chunk_dic(objflag, encodeflag, head, tail):
    countchecker(len(objflag))
    storepath = os.path.join(get_result_store_path(), "%s_%s_%s%s" %
                             (CHUNK_prefix, get_buildtime(), encodeflag, filextension))
    with open(storepath, "a") as f:
        for item in itertools.permutations(objflag, len(objflag)):
            f.write(operator.get(encodeflag)(head + "".join(item) + tail) + CRLF)
    finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 4
0
def getIDCardPost(posflag, encodeflag, head, tail, sex):
    storepath = os.path.join(
        get_result_store_path(),
        "%s_%s_%s_%s%s" % (IDCARD_prefix, str(posflag)[-1:], get_buildtime(),
                           encodeflag, filextension))
    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 sex == 'm':
        rand = "1 3 5 7 9"
        for _ in rand.split(' '):
            for _p in post18.split(' '):
                value1718 += _ + _p + " "
    elif sex == 'f':
        rand = "0 2 4 6 8"
        for _ in rand.split(' '):
            for _p in post18.split(' '):
                value1718 += _ + _p + " "
    else:
        rand = " ".join(str(_) for _ in range_compatible(0, 10))
        for _ in rand.split(' '):
            for _p in post18.split(' '):
                value1718 += _ + _p + " "
    with open(storepath, "w") as f:
        if posflag == 'pid8':
            for v1112 in value1112.split(' '):
                for v1314 in value1314.split(' '):
                    for v1516 in value1516.split(' '):
                        for v1718 in value1718.split(' '):
                            if v1718 != "":
                                if encodeflag == "":
                                    f.write(head + v1112 + v1314 + v1516 +
                                            v1718 + tail + CRLF)
                                else:
                                    f.write(
                                        operator.get(encodeflag)
                                        (head + v1112 + v1314 + v1516 + v1718 +
                                         tail) + CRLF)
        elif posflag == 'pid6':
            for v1314 in value1314.split(' '):
                for v1516 in value1516.split(' '):
                    for v1718 in value1718.split(' '):
                        if v1718 != "":
                            if encodeflag == "":
                                f.write(head + v1314 + v1516 + v1718 + tail +
                                        CRLF)
                            else:
                                f.write(
                                    operator.get(encodeflag)
                                    (head + v1314 + v1516 + v1718 + tail) +
                                    CRLF)
    finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 5
0
def uniqify_enter(original_file_path):
    storepath = os.path.join(
        get_result_store_path(),
        "%s_%s%s" % (tool_fun_str[1].upper(), get_buildtime(), filextension))
    with open(original_file_path) as o_f:
        with open(storepath, 'a') as s_f:
            for _ in fast_uniqify(o_f.readlines()):
                s_f.write(_)
    print("[+] Start   : {0:10} lines".format(
        cool.orange(finishcounter(original_file_path))))
    print("[+] Current : {0:10} lines".format(
        cool.orange(finishcounter(storepath))))
    print("[+] Cost    : {0:} seconds".format(
        cool.orange(str(time.time() - start)[:6])))
    print("[+] Store in: {0}".format(cool.orange(storepath)))
Exemplo n.º 6
0
def get_base_dic(minlength, maxlength, objflag, encodeflag, head, tail):
    countchecker(len(objflag), minlength, maxlength)
    global description
    storepath = os.path.join(
        get_result_store_path(), "%s_%s_%s_%s_%s_%s%s" %
        (BASE_prefix, minlength, maxlength, description, get_buildtime(),
         encodeflag, filextension))
    with open(storepath, "w") as f:
        for i in range_compatible(minlength, maxlength + 1):
            for item in itertools.product(objflag, repeat=i):
                if encodeflag == "":
                    f.write(head + "".join(item) + tail + CRLF)
                else:
                    f.write(
                        operator.get(encodeflag)(head + "".join(item) + tail) +
                        CRLF)
    finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 7
0
def get_extend_dic(rawlist, encodeflag='none', need_passcratch=False):
    prefix = EXTEND_prefix
    if rawlist == []:
        exit(CRLF + cool.red("[-] raw extend_enter file cannot be empty"))
    if need_passcratch:
        prefix = PASSCRAPER_prefix
    storepath = os.path.join(
        get_result_store_path(),
        "%s_%s_%s%s" % (prefix, get_buildtime(), encodeflag, filextension))
    with open(storepath, "a") as f:
        try:
            for _ in extend_enter(rawlist):
                f.write(operator.get(encodeflag)(str(_) + CRLF))
        except:
            traceback.print_exc()
            exit(CRLF + cool.red("[-] Some error"))
    finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 8
0
def getExtendDic(rawlist, encodeflag=""):
    if rawlist == []:
        exit(CRLF + cool.red("[-] raw extend file cannot be empty"))
    storepath = os.path.join(
        get_result_store_path(), "%s_%s_%s%s" %
        (EXTEND_prefix, get_buildtime(), encodeflag, filextension))
    with open(storepath, 'w') as f:
        try:
            for _ in extend(rawlist):
                _ = str(_)
                if encodeflag == "":
                    f.write(_ + CRLF)
                else:
                    f.write(operator.get(encodeflag)(_ + CRLF))
        except:
            exit(CRLF + cool.red("[-] File's character encoding maybe error"))
    finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 9
0
def counter_operator(original_file_path,
                     justsave,
                     justview,
                     encodeflag,
                     head,
                     tail,
                     view_count=default_view_items):
    items = Counter(
        open(original_file_path, 'r').read().replace(
            string.punctuation,
            "").split(counter_split)).most_common(view_count)
    items_length = len(items)
    storepath = os.path.join(
        get_result_store_path(),
        "%s_%s%s" % (COUNTER_prefix, get_buildtime(), filextension))
    if view_count > view_counter_switcher:
        exit(CRLF + cool.fuchsia("[!] view items should Leq {0}".format(
            view_counter_switcher)))
    elif items_length < view_count:
        exit(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(operator.get(encodeflag)(head + _[0] + tail) + CRLF)
        finishprinter(finishcounter(storepath), storepath)
    elif justview:
        print(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() - startime)[:6])))
    else:
        print(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(CRLF)
        with open(storepath, 'a') as f:
            for _ in items:
                f.write(operator.get(encodeflag)(head + _[0] + tail) + CRLF)
        finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 10
0
def get_idcard_post(posflag, encodeflag, head, tail, sex):
    storepath = os.path.join(get_result_store_path(), "%s_%s_%s_%s%s" %
                             (IDCARD_prefix, str(posflag)[-1:], get_buildtime(), encodeflag, filextension))
    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 sex == sex_range[0]:
        rand = ("1", "3", "5", "7", "9")
        for _ in rand:
            for _p in post18:
                value1718 += _ + _p + " "
    elif sex == sex_range[1]:
        rand = ("0", "2", "4", "6", "8")
        for _ in rand:
            for _p in post18:
                value1718 += _ + _p + " "
    elif sex == 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 == 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(operator.get(encodeflag)(head + v1112 + v1314 + v1516 + v1718 + tail) + CRLF)
        elif posflag == plug_range[0]:
                for v1314 in value1314.split(" "):
                    for v1516 in value1516.split(" "):
                        for v1718 in value1718.split(" "):
                            if v1718 != "":
                                f.write(operator.get(encodeflag)(head + v1314 + v1516 + v1718 + tail) + CRLF)
    finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 11
0
def get_base_dic(minlength,
                 maxlength,
                 objflag,
                 encodeflag,
                 head,
                 tail,
                 need_char_dic=False):
    objflag = getchars(objflag, need_char=need_char_dic)
    countchecker(len(objflag), minlength, maxlength)
    global description
    dict_prefix = BASE_prefix
    if need_char_dic:
        dict_prefix = CHAR_prefix
    storepath = os.path.join(
        get_result_store_path(), "%s_%s_%s_%s_%s_%s%s" %
        (dict_prefix, minlength, maxlength, description, get_buildtime(),
         encodeflag, filextension))
    with open(storepath, "a") as f:
        for i in range_compatible(minlength, maxlength + 1):
            for item in itertools.product(objflag, repeat=i):
                f.write(
                    operator.get(encodeflag)(head + "".join(item) + tail) +
                    CRLF)
    finishprinter(finishcounter(storepath), storepath)
Exemplo n.º 12
0
def combiner_enter(directory=os.path.abspath(sys.argv[0]), need_uniqifer=False):
    if not os.path.isdir(os.path.abspath(directory)):
        exit(CRLF + cool.red("[-] path: {} don't exists".format(directory)))
    filepaths = []
    combine_list = []
    storepath = os.path.join(get_result_store_path(), "%s_%s%s" % (COMBINER_prefix, get_buildtime(), filextension))
    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(CRLF + cool.red("[-] Combine file failed, Looking: "))
        exit(CRLF + traceback.print_exc())
Exemplo n.º 13
0
def build_conf_dic():
    confdicts = confparser(confmatcher(get_conf_path()))
    finalen = len(confdicts[head])
    alllist = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    storepath = os.path.join(
        get_result_store_path(),
        "%s_%s%s" % (CONF_prefix, get_buildtime(), filextension))
    for x in range(0, finalen):
        lengthchecker(confdicts[minlen][x], confdicts[maxlen][x])
        alllist[x] = get_conf_dic(int(confdicts[minlen][x]),
                                  int(confdicts[maxlen][x]),
                                  confdicts[char][x], confdicts[encode][x],
                                  confdicts[head][x], confdicts[tail][x])
    if finalen == 1:
        countchecker(-1, len(alllist[0]))
        with open(storepath, "a") as f:
            for item in itertools.product(alllist[0]):
                f.write("".join(item) + CRLF)
    elif finalen == 2:
        countchecker(-1, len(alllist[0]), len(alllist[1]))
        with open(storepath, "a") as f:
            for item in itertools.product(alllist[0], alllist[1]):
                f.write("".join(item) + CRLF)
    elif finalen == 3:
        countchecker(-1, len(alllist[0]), len(alllist[1]), len(alllist[2]))
        with open(storepath, "a") as f:
            for item in itertools.product(alllist[0], alllist[1], alllist[2]):
                f.write("".join(item) + CRLF)
    elif finalen == 4:
        countchecker(-1, len(alllist[0]), len(alllist[1]), len(alllist[2]),
                     len(alllist[3]))
        with open(storepath, "a") as f:
            for item in itertools.product(alllist[0], alllist[1], alllist[2],
                                          alllist[3]):
                f.write("".join(item) + CRLF)
    elif finalen == 5:
        countchecker(-1, len(alllist[0]), len(alllist[1]), len(alllist[2]),
                     len(alllist[3]), len(alllist[4]))
        with open(storepath, "a") as f:
            for item in itertools.product(alllist[0], alllist[1], alllist[2],
                                          alllist[3], alllist[4]):
                f.write("".join(item) + CRLF)
    elif finalen == 6:
        countchecker(-1, len(alllist[0]), len(alllist[1]), len(alllist[2]),
                     len(alllist[3]), len(alllist[4]), len(alllist[5]))
        with open(storepath, "a") as f:
            for item in itertools.product(alllist[0], alllist[1], alllist[2],
                                          alllist[3], alllist[4], alllist[5]):
                f.write("".join(item) + CRLF)
    elif finalen == 7:
        countchecker(-1, len(alllist[0]), len(alllist[1]), len(alllist[2]),
                     len(alllist[3]), len(alllist[4]), len(alllist[5]),
                     len(alllist[6]))
        with open(storepath, "a") as f:
            for item in itertools.product(alllist[0], alllist[1], alllist[2],
                                          alllist[3], alllist[4], alllist[5],
                                          alllist[6]):
                f.write("".join(item) + CRLF)
    elif finalen == 8:
        countchecker(-1, len(alllist[0]), len(alllist[1]), len(alllist[2]),
                     len(alllist[3]), len(alllist[4]), len(alllist[5]),
                     len(alllist[6]), len(alllist[7]))
        with open(storepath, "a") as f:
            for item in itertools.product(alllist[0], alllist[1], alllist[2],
                                          alllist[3], alllist[4], alllist[5],
                                          alllist[6], alllist[7]):
                f.write("".join(item) + CRLF)
    elif finalen == 9:
        countchecker(-1, len(alllist[0]), len(alllist[1]), len(alllist[2]),
                     len(alllist[3]), len(alllist[4]), len(alllist[5]),
                     len(alllist[6]), len(alllist[7]), len(alllist[8]))
        with open(storepath, "a") as f:
            for item in itertools.product(alllist[0], alllist[1], alllist[2],
                                          alllist[3], alllist[4], alllist[5],
                                          alllist[6], alllist[7], alllist[8]):
                f.write("".join(item) + CRLF)
    elif finalen == 10:
        countchecker(-1, len(alllist[0]), len(alllist[1]), len(alllist[2]),
                     len(alllist[3]), len(alllist[4]), len(alllist[5]),
                     len(alllist[6]), len(alllist[7]), len(alllist[8]),
                     len(alllist[9]))
        with open(storepath, "a") as f:
            for item in itertools.product(alllist[0], alllist[1], alllist[2],
                                          alllist[3], alllist[4], alllist[5],
                                          alllist[6], alllist[7], alllist[8],
                                          alllist[9]):
                f.write("".join(item) + CRLF)

    finishprinter(finishcounter(storepath), storepath)