Пример #1
0
def tool_parser():
    if len(pyoptions.args_tool) >= 1:
        if pyoptions.args_tool[0] in pystrs.tool_range:
            # shredder
            if pyoptions.args_tool[0] == pystrs.tool_range[0]:
                if len(pyoptions.args_tool) == 1 and os.listdir(
                        paths.results_path):
                    shredder_enter(paths.results_path)
                elif len(pyoptions.args_tool) == 1:
                    exit(pyoptions.CRLF + cool.orange("[+] %s has been clean" %
                                                      paths.results_path))
                elif len(pyoptions.args_tool) == 2:
                    shredder_enter(pyoptions.args_tool[1])
                else:
                    exit(pyoptions.CRLF + cool.red("[-] %s arguments wrong" %
                                                   pystrs.tool_range[0]))
                print("[+] Cost    :{} seconds".format(
                    cool.orange(str(time.time() - pystrs.startime)[:6])))
            # uniqifer
            elif len(pyoptions.args_tool
                     ) == 2 and pyoptions.args_tool[0] == pystrs.tool_range[1]:
                if os.path.isfile(pyoptions.args_tool[1]):
                    uniqifer_enter(pyoptions.args_tool[1])
                else:
                    exit(pyoptions.CRLF +
                         "[-] Please specify the exists file for %s" %
                         cool.red(pystrs.tool_range[1]))
            # counter
            elif len(pyoptions.args_tool
                     ) >= 2 and pyoptions.args_tool[0] == pystrs.tool_range[2]:
                counter_enter(pyoptions.encode, pyoptions.head, pyoptions.tail,
                              pyoptions.args_tool)
            # combiner
            elif len(pyoptions.args_tool
                     ) == 2 and pyoptions.args_tool[0] == pystrs.tool_range[3]:
                combiner_enter(pyoptions.args_tool[1])
            # uniqbiner
            elif len(pyoptions.args_tool
                     ) == 2 and pyoptions.args_tool[0] == pystrs.tool_range[4]:
                uniqbiner_enter(pyoptions.args_tool[1])
            else:
                exit(pyoptions.CRLF +
                     cool.red("[-] Need other extra arguments"))
        else:
            exit(pyoptions.CRLF +
                 cool.red("[-] No tool named %s" % pyoptions.args_tool[0]) +
                 pyoptions.CRLF +
                 "[!] Choose tool from  ({0}, {1}, {2}, {3}, {4})".format(
                     cool.fuchsia(pystrs.tool_range[0]),
                     cool.fuchsia(pystrs.tool_range[1]),
                     cool.fuchsia(pystrs.tool_range[2]),
                     cool.fuchsia(pystrs.tool_range[3]),
                     cool.fuchsia(pystrs.tool_range[4])))
    else:
        exit(pyoptions.CRLF + cool.red("[-] Please specified tool name"))
Пример #2
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)
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)
Пример #4
0
    def uniqifer():
        with open(original_file_path) as o_f:
            for item in o_f:
                yield item.strip()

        print("[+] Source of  :{0} lines".format(
            cool.orange(finishcounter(original_file_path))))
Пример #5
0
def shreder_dir(directory, rewritecounts=pyoptions.dir_rewrite_count):
    filepaths = []
    dirpaths = []
    print(pyoptions.CRLF + "[+] Shredding '%s' ..." % cool.orange(directory))
    try:
        newdirectoryname = os.path.join(
            os.path.dirname(directory), "".join(
                chr(random.randint(97, 122)) for _ in range_compatible(1, 6)))
        os.rename(directory, newdirectoryname)
        directory = newdirectoryname
    except:
        traceback.print_exc()
        exit(pyoptions.CRLF + cool.red(
            "[-] Error: cannot rename root directory name, Please check permissions"
        ))

    subdir_files_path = get_subdir_files_path(directory, only_file_path=False)
    dirpaths.extend(subdir_files_path[0])
    filepaths.extend(subdir_files_path[1])

    for filepath in filepaths:
        try:
            os.chmod(filepath, stat.S_IREAD | stat.S_IWRITE)
        except:
            pass

    for _ in range_compatible(0, rewritecounts):
        print("[+] Rewrite count: %d" % (_ + 1))
        for filepath in filepaths:
            rewrite(filepath)
    for filepath in filepaths:
        truncating(filepath)
    for filepath in filepaths:
        renamefile(filepath)
    renamedir(dirpaths)
    os.chdir(os.path.join(directory, ".."))
    try:
        shutil.rmtree(directory)
    except OSError as ex:
        print(
            cool.fuchsia("[!] Error: Cannot removing directory: '%s' " %
                         directory))
        traceback.print_exc()
    print(cool.orange("[+] Done"))
Пример #6
0
def shreder_file(filepath, rewritecounts=pyoptions.file_rewrite_count):
    try:
        os.chmod(filepath, stat.S_IREAD | stat.S_IWRITE)
    except:
        pass
    for _ in range_compatible(0, rewritecounts):
        rewrite(filepath)
    truncating(filepath)
    newname = renamefile(filepath)
    os.remove(newname)
    print("[+] Shredded %s Completely!" % cool.orange(filepath))
Пример #7
0
def counter_operator(original_file_path,
                     justsave,
                     justview,
                     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)
    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)))

    if justsave:

        @magic
        def counter():
            for _ in items:
                yield _[0]
    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])))

        @magic
        def counter():
            for _ in items:
                yield _[0]
Пример #8
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)
Пример #9
0
 def do_show(self, key, setflag=False):
     if not setflag:
         if pyoptions.args_pick:
             print(
                 cool.orange("{pick:11}: minlen: {0} maxlen: {1}".format(
                     pyoptions.minlen, pyoptions.maxlen, pick="pick")))
         print(
             cool.orange("{level:11}: {0}".format(pyoptions.level,
                                                  level="level")))
         if pyoptions.sedb_leet:
             print(
                 cool.orange("{leet:11}: {0}".format(" ".join(
                     map(str, pyoptions.leetmode_code)),
                                                     leet="leet")))
     if key in pystrs.sedb_dict.keys():
         print(
             cool.blue("%-10s :%s" %
                       (key, ' '.join([x for x in pystrs.sedb_dict[key]]))))
     else:
         for key in pystrs.sedb_dict.keys():
             print(
                 cool.blue(
                     "%-10s :%s" %
                     (key, ' '.join([x for x in pystrs.sedb_dict[key]]))))
Пример #10
0
def shredder_enter(*args):
    fnum = 0
    _ = "".join(args)
    if _ and os.path.isdir(_):
        shreder_dir(_)
    elif _ and os.path.isfile(_):
        shreder_file(_)
    elif _ and _.upper() in pystrs.prefix_range:
        for filename in os.listdir(paths.results_path):
            if _.upper() in str(filename[0:10]).upper():
                fnum += 1
                shreder_file(os.path.join(paths.results_path, filename))
        if fnum == 0:
            exit(pyoptions.CRLF +
                 cool.orange("[+] prefix %s files has been clean" % _.upper()))
    else:
        exit(pyoptions.CRLF +
             cool.red("[-] invalid shredder path_or_dir arguments"))
Пример #11
0
 def uniqbiner():
     with open(tempath) as o_f:
         for item in o_f.readlines():
             yield item.strip()
     print("[+] Source of  :{0} lines".format(cool.orange(finishcounter(tempath))))
def 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)
Пример #13
0
def parse_args():
    parser = argparse.ArgumentParser(
        prog='pydictor',
        formatter_class=argparse.RawTextHelpFormatter,
        description=cool.green(
            '*[+] A Useful Hacker Dictionary  Builder. [+]*') +
        pyoptions.CRLF +
        cool.green(' [+] Build by LandGrey    email:[email protected]') +
        pyoptions.CRLF,
        usage=cool.orange('''
pydictor.py [options]
           -base     [type]
           -char     [custom_char]
           -chunk    [chunk1] [chunk2] ...
           -extend   [str_or_file]
           -plug     [{plug0},{plug1},{plug2}]
           --conf    [config_file]
           --sedb
           -o        [output_path]
           -tool     [{tool0},{tool1},{tool2},{tool3},{tool4}] [args] ...
           --len     [minlen] [maxlen]
           --head    [prefix_string]
           --tail    [suffix_string]
           --encode  [{en0},{en1},{en2},{en3},{en4},{en5},{en6},{en7}]
           --level   [code]
           --leet    [code]'''.format(plug0=pystrs.plug_range[0],
                                      plug1=pystrs.plug_range[1],
                                      plug2=pystrs.plug_range[2],
                                      tool0=pystrs.tool_range[0],
                                      tool1=pystrs.tool_range[1],
                                      tool2=pystrs.tool_range[2],
                                      tool3=pystrs.tool_range[3],
                                      tool4=pystrs.tool_range[4],
                                      en0=pystrs.encode_range[0],
                                      en1=pystrs.encode_range[1],
                                      en2=pystrs.encode_range[2],
                                      en3=pystrs.encode_range[3],
                                      en4=pystrs.encode_range[4],
                                      en5=pystrs.encode_range[5],
                                      en6=pystrs.encode_range[6],
                                      en7=pystrs.encode_range[7])))

    parser.add_argument(
        '-base',
        dest='base',
        choices=[
            pystrs.base_dic_type[0], pystrs.base_dic_type[1],
            pystrs.base_dic_type[2], pystrs.base_dic_type[3],
            pystrs.base_dic_type[4], pystrs.base_dic_type[5],
            pystrs.base_dic_type[6]
        ],
        metavar='Type',
        default='',
        help=cool.yellow('''Choose from  ({0}, {1}, {2}, {3}, {4}, {5}, {6})
    {0}     digital             [0 - 9]
    {1}     lowercase letters   [a - z]
    {2}     capital letters     [A - Z]
    {3}    Mix {0} and {1}         [0-9 a-z]
    {4}    Mix {0} and {2}         [0-9 A-Z]
    {5}    Mix {1} and {2}         [a-z A-Z]
    {6}   Mix {0}, {1} and {3}     [0-9 a-z A-Z]'''.format(
            pystrs.base_dic_type[0], pystrs.base_dic_type[1],
            pystrs.base_dic_type[2], pystrs.base_dic_type[3],
            pystrs.base_dic_type[4], pystrs.base_dic_type[5],
            pystrs.base_dic_type[6])))

    parser.add_argument(
        '-char',
        dest='char',
        metavar='character',
        default='',
        help=cool.yellow('Use Custom Character build the dictionary'))

    parser.add_argument(
        '-chunk',
        dest='chunk',
        metavar='arg',
        nargs='+',
        type=str,
        default='',
        help=cool.yellow('Use the multi-chunk build the dictionary'))

    parser.add_argument('-extend',
                        dest='extend',
                        metavar='arg',
                        nargs='+',
                        type=str,
                        default='',
                        help=cool.yellow('Extend the string list or file'))

    parser.add_argument('-plug',
                        dest='plug',
                        metavar='arg',
                        nargs='+',
                        type=str,
                        default='',
                        help=cool.yellow('''Choose from    ({0}, {1}, {2}, {3})
    {0:10} [idcard_last_6_digit]   default sex:{3}
    {1:10} [idcard_last_8_digit]   default sex:{3}
    {2:10} [url_or_file_path]'''.format(pystrs.plug_range[0],
                                        pystrs.plug_range[1],
                                        pystrs.plug_range[2],
                                        pystrs.default_sex)))

    parser.add_argument('--conf',
                        dest='conf',
                        nargs='?',
                        metavar='file_path',
                        default='default',
                        const='const',
                        help=cool.yellow(
                            '''Use the configuration file build the dictionary
    Default: %s''' % paths.buildconf_path))

    parser.add_argument(
        '--sedb',
        dest='sedb',
        default='',
        action="store_true",
        help=cool.yellow('Enter the Social Engineering Dictionary Builder'))

    parser.add_argument('-o',
                        '-output',
                        dest='output',
                        metavar='path',
                        type=str,
                        default=paths.results_path,
                        help=cool.yellow('''Set the output directory path
    default: %s''' % paths.results_path))

    parser.add_argument('-tool',
                        dest='tool',
                        metavar='arg',
                        nargs='+',
                        type=str,
                        default='',
                        help=cool.yellow('''Choose from    ({0}, {1}, {2},
                {3}, {4})
    {0:10} [file_or_dir]
    {1:10} [file_path]
    {2:10} ['{5}','{6}','{7}'] [file_path] [view_num]
    {3:10} [dir]
    {4:10} [dir]'''.format(pystrs.tool_range[0], pystrs.tool_range[1],
                           pystrs.tool_range[2], pystrs.tool_range[3],
                           pystrs.tool_range[4], pystrs.just_view_counter,
                           pystrs.just_save_counter, pystrs.save_and_view)))

    parser.add_argument('--len',
                        dest='len',
                        metavar=('minlen', 'maxlen'),
                        nargs=2,
                        type=int,
                        default=(pyoptions.minlen, pyoptions.maxlen),
                        help=cool.yellow('''[Minimun_Length]  [Maximun_Length]
    Default: min=%s  max=%s''' % (pyoptions.minlen, pyoptions.maxlen)))

    parser.add_argument('--head',
                        dest='head',
                        metavar='prefix',
                        type=str,
                        default='',
                        help=cool.yellow('Add string head for the items'))

    parser.add_argument('--tail',
                        dest='tail',
                        metavar='suffix',
                        type=str,
                        default='',
                        help=cool.yellow('Add string tail for the items'))

    parser.add_argument(
        '--encode',
        dest='encode',
        metavar='encode',
        default='none',
        choices=[
            pystrs.encode_range[0], pystrs.encode_range[1],
            pystrs.encode_range[2], pystrs.encode_range[3],
            pystrs.encode_range[4], pystrs.encode_range[5],
            pystrs.encode_range[6], pystrs.encode_range[7]
        ],
        help=cool.yellow('''From (%s, %s, %s, %s, %s, %s, %s, %s)''' %
                         (pystrs.encode_range[0], pystrs.encode_range[1],
                          pystrs.encode_range[2], pystrs.encode_range[3],
                          pystrs.encode_range[4], pystrs.encode_range[5],
                          pystrs.encode_range[6], pystrs.encode_range[7])))

    parser.add_argument(
        '--level',
        dest='level',
        metavar='code',
        default=pyoptions.level,
        type=int,
        help=cool.yellow(
            '''Use code [1-5] to filter results, default: {0}'''.format(
                pyoptions.level)))

    parser.add_argument(
        '--leet',
        dest='leet',
        metavar='code',
        nargs='+',
        type=int,
        default=pyoptions.leetmode_code,
        help=cool.yellow('Choose leet mode code (0, 1, 2, 11-19, 21-29)'))

    if len(sys.argv) == 1:
        sys.argv.append('-h')
    args = parser.parse_args()
    check_args(args)
    return args
Пример #14
0
from __future__ import unicode_literals

from collections import OrderedDict
from lib.fun.fun import cool
from lib.data.data import pystrs


pydictor_art_text = \
'''                              _ _      _
              _ __  _   _  __| (_) ___| |_ ___  _ __
             | '_ \| | | |/ _` | |/ __| __/ _ \| '__|
             | |_) | |_| | (_| | | (__| || (_) | |
             | .__/ \__, |\__,_|_|\___|\__\___/|_|
             |_|    |___/                            {0}
'''.format(cool.orange(pystrs.version))


helpmsg = \
'''                   {0}
                                            {1}
    ----------------------------[ {2} ]---------------------------
    [+]help desc             [+]exit/quit            [+]clear/cls
    [+]show option           [+]set option arguments [+]rm option
    [+]len minlen maxlen     [+]head prefix          [+]tail suffix
    [+]encode type           [+]occur L d s          [+]types L d s
    [+]repeat L d s          [+]regex string         [+]level code
    [+]leet code             [+]output directory     [+]run

    ----------------------------[ {3} ]----------------------------
    [+]{4}                 [+]{5}                [+]{6}
Пример #15
0
def parse_args():
    parser = argparse.ArgumentParser(
        prog='pydictor',
        formatter_class=argparse.RawTextHelpFormatter,
        description=cool.green(
            '*[+] A Useful Hacker Dictionary  Builder. [+]*') +
        pyoptions.CRLF +
        cool.green(' [+] Build by LandGrey    email:[email protected]') +
        pyoptions.CRLF,
        usage=cool.orange('''
pydictor.py [options]
           -base        [type]
           -char        [custom_char]
           -chunk       [chunk1] [chunk2] ...
           -extend      [str_or_file]
           -plug        [{p0},{p1},{p2},{p3},{p4},{p5}]
           --conf       [expression_or_file]
           --sedb
           -o,--output  [directory]
           -tool        [{t5},{t0},{t1},{t2},{t3},{t4}]
           --len        [minlen] [maxlen]
           --head       [prefix_string]
           --tail       [suffix_string]
           --encode     [{e0},{e1},{e2},{e3},{e4},{e5},{e6},{e7}]
           --occur      [letter] [digital] [special]
           --types      [letter] [digital] [special]
           --regex      [regex]
           --level      [code]
           --leet       [code]'''.format(p0=pystrs.plug_range[0],
                                         p1=pystrs.plug_range[1],
                                         p2=pystrs.plug_range[2],
                                         p3=pystrs.plug_range[3],
                                         p4=pystrs.plug_range[4],
                                         p5=pystrs.plug_range[5],
                                         t0=pystrs.tool_range[0],
                                         t1=pystrs.tool_range[1],
                                         t2=pystrs.tool_range[2],
                                         t3=pystrs.tool_range[3],
                                         t4=pystrs.tool_range[4],
                                         t5=pystrs.tool_range[5],
                                         e0=pystrs.encode_range[0],
                                         e1=pystrs.encode_range[1],
                                         e2=pystrs.encode_range[2],
                                         e3=pystrs.encode_range[3],
                                         e4=pystrs.encode_range[4],
                                         e5=pystrs.encode_range[5],
                                         e6=pystrs.encode_range[6],
                                         e7=pystrs.encode_range[7])))

    parser.add_argument(
        '-base',
        dest='base',
        choices=[
            pystrs.base_dic_type[0], pystrs.base_dic_type[1],
            pystrs.base_dic_type[2], pystrs.base_dic_type[3],
            pystrs.base_dic_type[4], pystrs.base_dic_type[5],
            pystrs.base_dic_type[6]
        ],
        metavar='Type',
        default='',
        help=cool.yellow('''Choose from  ({0}, {1}, {2}, {3}, {4}, {5}, {6})
    {0}     digital             [0 - 9]
    {1}     lowercase letters   [a - z]
    {2}     capital letters     [A - Z]
    {3}    Mix {0} and {1}         [0-9 a-z]
    {4}    Mix {0} and {2}         [0-9 A-Z]
    {5}    Mix {1} and {2}         [a-z A-Z]
    {6}   Mix {0}, {1} and {3}     [0-9 a-z A-Z]'''.format(
            pystrs.base_dic_type[0], pystrs.base_dic_type[1],
            pystrs.base_dic_type[2], pystrs.base_dic_type[3],
            pystrs.base_dic_type[4], pystrs.base_dic_type[5],
            pystrs.base_dic_type[6])))

    parser.add_argument(
        '-char',
        dest='char',
        metavar='character',
        default='',
        help=cool.yellow('Use Custom Character build the dictionary'))

    parser.add_argument(
        '-chunk',
        dest='chunk',
        metavar='arg',
        nargs='+',
        type=str,
        default='',
        help=cool.yellow('Use the multi-chunk build the dictionary'))

    parser.add_argument('-extend',
                        dest='extend',
                        metavar='arg',
                        nargs='+',
                        type=str,
                        default='',
                        help=cool.yellow('Extend the string list or file'))

    parser.add_argument('-plug',
                        dest='plug',
                        metavar='arg',
                        nargs='+',
                        type=str,
                        default='',
                        help=cool.yellow(
                            '''Choose from    ({1}, {2}, {3}, {4}, {5}, {6})
    {1:10} [idcard_last_4_digit]
    {2:10} [idcard_last_6_digit]   default sex:{0}
    {3:10} [idcard_last_8_digit]   default sex:{0}
    {4:10} [url_or_file_path]
    {5:10} [url_or_file_path]
    {6:10} [YYYYMMDD] [YYYYMMDD]'''.format(
                                pystrs.default_sex,
                                pystrs.plug_range[0],
                                pystrs.plug_range[1],
                                pystrs.plug_range[2],
                                pystrs.plug_range[3],
                                pystrs.plug_range[4],
                                pystrs.plug_range[5],
                            )))

    parser.add_argument('--conf',
                        dest='conf',
                        nargs='?',
                        metavar='file_path',
                        default='default',
                        const='const',
                        help=cool.yellow(
                            '''Use the configuration file build the dictionary
    Default: %s''' % paths.buildconf_path))

    parser.add_argument(
        '--sedb',
        dest='sedb',
        default='',
        action="store_true",
        help=cool.yellow('Enter the Social Engineering Dictionary Builder'))

    parser.add_argument('-o',
                        '--output',
                        dest='output',
                        metavar='path',
                        type=str,
                        default=paths.results_path,
                        help=cool.yellow('''Set the output directory path
    default: %s''' % paths.results_path))

    parser.add_argument('-tool',
                        dest='tool',
                        metavar='arg',
                        nargs='+',
                        type=str,
                        default='',
                        help=cool.yellow('''Choose from    ({0}, {1}, {2},
                {3}, {4})
    {0:10} [file_or_dir]
    {1:10} [file_path]
    {2:10} ['{5}','{6}','{7}'] [file_path] [view_num]
    {3:10} [dir]
    {4:10} [dir]'''.format(pystrs.tool_range[0], pystrs.tool_range[1],
                           pystrs.tool_range[2], pystrs.tool_range[3],
                           pystrs.tool_range[4], pystrs.just_view_counter,
                           pystrs.just_save_counter, pystrs.save_and_view)))

    parser.add_argument('--len',
                        dest='len',
                        metavar=('minlen', 'maxlen'),
                        nargs=2,
                        type=int,
                        default=(pyoptions.minlen, pyoptions.maxlen),
                        help=cool.yellow('''Default: min=%s  max=%s''' %
                                         (pyoptions.minlen, pyoptions.maxlen)))

    parser.add_argument('--head',
                        dest='head',
                        metavar='prefix',
                        type=str,
                        default='',
                        help=cool.yellow('Add string head for the items'))

    parser.add_argument('--tail',
                        dest='tail',
                        metavar='suffix',
                        type=str,
                        default='',
                        help=cool.yellow('Add string tail for the items'))

    parser.add_argument(
        '--encode',
        dest='encode',
        metavar='encode',
        default='none',
        choices=[
            pystrs.encode_range[0], pystrs.encode_range[1],
            pystrs.encode_range[2], pystrs.encode_range[3],
            pystrs.encode_range[4], pystrs.encode_range[5],
            pystrs.encode_range[6], pystrs.encode_range[7],
            pystrs.encode_range[8]
        ],
        help=cool.yellow(
            '''From ({e0}, {e1}, {e2}, {e3}, {e4}, {e5}, {e6}, {e7}, {e8})'''.
            format(
                e0=pystrs.encode_range[0],
                e1=pystrs.encode_range[1],
                e2=pystrs.encode_range[2],
                e3=pystrs.encode_range[3],
                e4=pystrs.encode_range[4],
                e5=pystrs.encode_range[5],
                e6=pystrs.encode_range[6],
                e7=pystrs.encode_range[7],
                e8=pystrs.encode_range[8],
            )))

    parser.add_argument(
        '--occur',
        dest='occur',
        metavar=('letter', 'digital', 'special'),
        nargs=3,
        type=str,
        default=(pyoptions.letter_occur, pyoptions.digital_occur,
                 pyoptions.special_occur),
        help=cool.yellow('''Default: letter "%s" digital "%s" special "%s"''' %
                         (pyoptions.letter_occur, pyoptions.digital_occur,
                          pyoptions.special_occur)))

    parser.add_argument(
        '--types',
        dest='types',
        metavar=('letter', 'digital', 'special'),
        nargs=3,
        type=str,
        default=(pyoptions.letter_types, pyoptions.digital_types,
                 pyoptions.special_types),
        help=cool.yellow(
            '''Default: letter "%s"  digital "%s"  special "%s"''' %
            (pyoptions.letter_types, pyoptions.digital_types,
             pyoptions.special_types)))

    parser.add_argument('--regex',
                        dest='regex',
                        metavar='regex',
                        nargs=1,
                        type=str,
                        default=pyoptions.filter_regex,
                        help=cool.yellow('''Filter by regex, Default: (%s)''' %
                                         pyoptions.filter_regex))

    parser.add_argument(
        '--level',
        dest='level',
        metavar='code',
        default=pyoptions.level,
        type=int,
        help=cool.yellow(
            '''Use code [1-5] to filter results, default: {0}'''.format(
                pyoptions.level)))

    parser.add_argument(
        '--leet',
        dest='leet',
        metavar='code',
        nargs='+',
        type=int,
        default=pyoptions.leetmode_code,
        help=cool.yellow('Choose leet mode code (0, 1, 2, 11-19, 21-29)'))

    if len(sys.argv) == 1:
        sys.argv.append('-h')
    args = parser.parse_args()
    check_args(args)
    return args
Пример #16
0
def parse_args():
    parser = argparse.ArgumentParser(
        prog='pydictor',
        formatter_class=argparse.RawTextHelpFormatter,
        description=cool.green(
            '*[+] A Useful Hacker Dictionary  Builder. [+]*') +
        pyoptions.CRLF +
        cool.green(' [+] Build by LandGrey    email:[email protected]') +
        pyoptions.CRLF,
        usage=cool.orange('''
pydictor.py [options]
           -base        [type]
           -char        [custom_char]
           -chunk       [chunk1] [chunk2] ...
           -extend      [string_or_file]
           -plug        [{plugin}]
           --conf       [expression_or_file]
           --sedb
           -o,--output  [directory]
           -tool        [{tool}]
           --len        [minlen] [maxlen]
           --head       [prefix_string]
           --tail       [suffix_string]
           --encode     [{encode}]
           --occur      [letter] [digital] [special]
           --types      [letter] [digital] [special]
           --repeat     [letter] [digital] [special]
           --regex      [regex]
           --level      [code]
           --leet       [code]
           --dmy'''.format(plugin=",".join(pyoptions.plug_range),
                           encode=",".join(pyoptions.encode_range),
                           tool=",".join(pyoptions.tool_range))))

    parser.add_argument(
        '-base',
        dest='base',
        choices=[
            pystrs.base_dic_type[0], pystrs.base_dic_type[1],
            pystrs.base_dic_type[2], pystrs.base_dic_type[3],
            pystrs.base_dic_type[4], pystrs.base_dic_type[5],
            pystrs.base_dic_type[6]
        ],
        metavar='Type',
        default='',
        help=cool.yellow('''Choose from  ({0}, {1}, {2}, {3}, {4}, {5}, {6})
    {0}     digital             [0 - 9]
    {1}     lowercase letters   [a - z]
    {2}     capital letters     [A - Z]
    {3}    Mix {0} and {1}         [0-9 a-z]
    {4}    Mix {0} and {2}         [0-9 A-Z]
    {5}    Mix {1} and {2}         [a-z A-Z]
    {6}   Mix {0}, {1} and {3}     [0-9 a-z A-Z]'''.format(
            pystrs.base_dic_type[0], pystrs.base_dic_type[1],
            pystrs.base_dic_type[2], pystrs.base_dic_type[3],
            pystrs.base_dic_type[4], pystrs.base_dic_type[5],
            pystrs.base_dic_type[6])))

    parser.add_argument(
        '-char',
        dest='char',
        metavar='character',
        default='',
        help=cool.yellow('Use Custom Character build the dictionary'))

    parser.add_argument(
        '-chunk',
        dest='chunk',
        metavar='arg',
        nargs='+',
        type=str,
        default='',
        help=cool.yellow('Use the multi-chunk build the dictionary'))

    parser.add_argument('-extend',
                        dest='extend',
                        metavar='arg',
                        nargs='+',
                        type=str,
                        default='',
                        help=cool.yellow('Extend the string list or file'))

    parser.add_argument('-plug',
                        dest='plug',
                        metavar='arg',
                        nargs='+',
                        type=str,
                        default='',
                        help=cool.yellow('''{plugins_desc}'''.format(
                            plugins_desc=pyoptions.plugins_desc)))

    parser.add_argument(
        '--conf',
        dest='conf',
        nargs='?',
        metavar='file_path',
        default='default',
        const='const',
        help=cool.yellow(
            "Use the configuration string or file build the dictionary"))

    parser.add_argument(
        '--sedb',
        dest='sedb',
        default='',
        action="store_true",
        help=cool.yellow('Enter the Social Engineering Dictionary Builder'))

    parser.add_argument('-o',
                        '--output',
                        dest='output',
                        metavar='path',
                        type=str,
                        default=paths.results_path,
                        help=cool.yellow('''Set the output directory path
    default: %s''' % paths.results_path))

    parser.add_argument('-tool',
                        dest='tool',
                        metavar='arg',
                        nargs='+',
                        type=str,
                        default='',
                        help=cool.yellow('''{tools_desc}'''.format(
                            tools_desc=pyoptions.tools_desc)))

    parser.add_argument('--len',
                        dest='len',
                        metavar=('minlen', 'maxlen'),
                        nargs=2,
                        type=int,
                        default=(pyoptions.minlen, pyoptions.maxlen),
                        help=cool.yellow('''Default: min=%s  max=%s''' %
                                         (pyoptions.minlen, pyoptions.maxlen)))

    parser.add_argument('--head',
                        dest='head',
                        metavar='prefix',
                        type=str,
                        default='',
                        help=cool.yellow('Add string head for the items'))

    parser.add_argument('--tail',
                        dest='tail',
                        metavar='suffix',
                        type=str,
                        default='',
                        help=cool.yellow('Add string tail for the items'))

    parser.add_argument('--encode',
                        dest='encode',
                        metavar='encode',
                        default='none',
                        choices=pyoptions.encode_range,
                        help=cool.yellow('''{encode_desc}'''.format(
                            encode_desc=pyoptions.encode_desc)))

    parser.add_argument(
        '--occur',
        dest='occur',
        metavar=('letter', 'digital', 'special'),
        nargs=3,
        type=str,
        default=(pyoptions.letter_occur, pyoptions.digital_occur,
                 pyoptions.special_occur),
        help=cool.yellow('''Default: letter "%s" digital "%s" special "%s"''' %
                         (pyoptions.letter_occur, pyoptions.digital_occur,
                          pyoptions.special_occur)))

    parser.add_argument(
        '--types',
        dest='types',
        metavar=('letter', 'digital', 'special'),
        nargs=3,
        type=str,
        default=(pyoptions.letter_types, pyoptions.digital_types,
                 pyoptions.special_types),
        help=cool.yellow(
            '''Default: letter "%s"  digital "%s"  special "%s"''' %
            (pyoptions.letter_types, pyoptions.digital_types,
             pyoptions.special_types)))

    parser.add_argument(
        '--repeat',
        dest='repeat',
        metavar=('letter', 'digital', 'special'),
        nargs=3,
        type=str,
        default=(pyoptions.letter_repeat, pyoptions.digital_repeat,
                 pyoptions.special_repeat),
        help=cool.yellow(
            '''Default: letter "%s"  digital "%s"  special "%s"''' %
            (pyoptions.letter_repeat, pyoptions.digital_repeat,
             pyoptions.special_repeat)))

    parser.add_argument('--regex',
                        dest='regex',
                        metavar='regex',
                        nargs=1,
                        type=str,
                        default=pyoptions.filter_regex,
                        help=cool.yellow('''Filter by regex, Default: (%s)''' %
                                         pyoptions.filter_regex))

    parser.add_argument(
        '--level',
        dest='level',
        metavar='code',
        default=pyoptions.level,
        type=int,
        help=cool.yellow(
            '''Use code [1-5] to filter results, default: {0}'''.format(
                pyoptions.level)))

    parser.add_argument(
        '--leet',
        dest='leet',
        metavar='code',
        nargs='+',
        type=int,
        default=pyoptions.leetmode_code,
        help=cool.yellow('Choose leet mode code (0, 1, 2, 11-19, 21-29)'))

    parser.add_argument(
        '--more',
        dest='more',
        default='',
        action="store_true",
        help=cool.yellow(
            'Append more simple word list to extend function results, default: false'
        ))

    parser.add_argument(
        '--dmy',
        dest='dmy',
        default='',
        action="store_true",
        help=cool.yellow(
            'Use ddMMyyyy format date, default date format: yyyyMMdd'))

    if len(sys.argv) == 1:
        sys.argv.append('-h')
    args = parser.parse_args()
    check_args(args)
    return args
    def do_show(self, key, setflag=False):
        if not setflag:
            if pyoptions.args_pick:
                print(
                    cool.orange(
                        "{description:11}: minlen: [{0}] maxlen: [{1}]".format(
                            pyoptions.minlen,
                            pyoptions.maxlen,
                            description="lenght")))
            else:
                print(
                    cool.orange(
                        "{description:11}: minlen: [{0}] maxlen: [{0}]".format(
                            "no-limited", description="len")))
            if pyoptions.head:
                print(
                    cool.orange("{description:11}: [{0}]".format(
                        pyoptions.head, description="head")))
            else:
                print(
                    cool.orange("{description:11}: [{0}]".format(
                        "none", description="head")))

            if pyoptions.tail:
                print(
                    cool.orange("{description:11}: [{0}]".format(
                        pyoptions.tail, description="tail")))
            else:
                print(
                    cool.orange("{description:11}: [{0}]".format(
                        "none", description="tail")))

            print(
                cool.orange("{description:11}: [{0}]".format(
                    pyoptions.encode, description="encode")))

            print(
                cool.orange(
                    "{description:11}: letter: [ {0:5}] digital: [ {1:5}] special: [ {2:5} ]"
                    .format(pyoptions.letter_occur,
                            pyoptions.digital_occur,
                            pyoptions.special_occur,
                            description="occur")))

            print(
                cool.orange(
                    "{description:11}: letter: [ {0:5}] digital: [ {1:5}] special: [ {2:5} ]"
                    .format(pyoptions.letter_types,
                            pyoptions.digital_types,
                            pyoptions.special_types,
                            description="types")))

            print(
                cool.orange("{description:11}: [{0}]".format(
                    pyoptions.level, description="level")))

            if pyoptions.sedb_leet:
                print(
                    cool.orange("{description:11}: [{0}]".format(
                        " ".join(map(str, pyoptions.leetmode_code)),
                        description="leet")))
            else:
                print(
                    cool.orange("{description:11}: [{0}]".format(
                        "none", description="leet")))

            print(
                cool.orange("{description:11}: [{0}]".format(
                    pyoptions.filter_regex, description="regex")))

        if key in pystrs.sedb_dict.keys():
            print(
                cool.blue("%-10s :%s" %
                          (key, ' '.join([x for x in pystrs.sedb_dict[key]]))))
        else:
            for key in pystrs.sedb_dict.keys():
                print(
                    cool.blue(
                        "%-10s :%s" %
                        (key, ' '.join([x for x in pystrs.sedb_dict[key]]))))