Exemplo n.º 1
0
 def do_birth(self, args):
     for item in str(args).split(' '):
         if len(item) != 8 or str(item).isdigit() is False:
             print(cool.fuchsia("[!] Input format:[YYYYMMDD] exp:19900512"))
         elif int(item[4:6]) > 12 or int(item[4:6]) < 1 or int(item[6:8]) > 31 or int(item[6:8]) < 1:
             print(cool.fuchsia("[!] Date format {1 <= month <= 12} and {1 <= day <=31}"))
         else:
             settings_dict['birth'].append(item)
Exemplo n.º 2
0
def init_target(target_choice):
    # target choice
    # file
    if os.path.isfile(target_choice):
        target_use_file(target_choice)
    # dir
    elif os.path.exists(target_choice):
        for _ in get_all_file(target_choice):
            target_use_file(_)
    # other
    else:
        specify_targets = target_choice.split(',')
        for targetschunk in specify_targets:
            if targetschunk.startswith("http"):
                targetschunk = ((targetschunk.strip()).split("/")[2]).split(":")[0]
            else:
                targetschunk = (targetschunk.strip()).split(":")[0]
            t_dic = {1: [], 2: [], 3: [], 4: []}
            # range
            if "-" in targetschunk:
                sc_chunk = targetschunk.split(".")
                if len(sc_chunk) != 4:
                    exit(cool.red("[-] Targets Error\n"))
                else:
                    for r in range(0, 4):
                        if "-" in sc_chunk[r]:
                            sc_chunk_split = sc_chunk[r].split("-")
                            if not (len(sc_chunk_split) == 2 and sc_chunk_split[0].isdigit()
                                    and sc_chunk_split[1].isdigit() and int(sc_chunk_split[0]) <= int(sc_chunk_split[1])
                                    and 0 <= int(sc_chunk_split[0]) <= 255 and 0 <= int(sc_chunk_split[1]) <= 255):
                                exit(cool.red("[-] Targets range error\n"))
                            else:
                                if len(sc_chunk_split) == 1:
                                    t_dic[r + 1].append(sc_chunk[0])
                                for _ in range(int(sc_chunk_split[0]), int(sc_chunk_split[1]) + 1):
                                    t_dic[r + 1].append(_)
                        else:
                            if not (sc_chunk[r].isdigit() and 0 <= int(sc_chunk[r]) <= 255):
                                exit(cool.red("[-] Specify error ip address\n"))
                            t_dic[r + 1].append(sc_chunk[r])
                for item in itertools.product(t_dic[1], t_dic[2], t_dic[3], t_dic[4]):
                    targets_pool.append(
                        "{0}.{1}.{2}.{3}".format(str(item[0]), str(item[1]), str(item[2]), str(item[3])))
            # single or multi
            else:
                if domain_pattern.findall(targetschunk):
                    domains_pool.append(targetschunk)
                    set_global_parse_flag(True)
                elif ip_pattern.findall(targetschunk):
                    targets_pool.append(targetschunk)
                else:
                    print(cool.fuchsia("[!] Invalid target %s" % targetschunk))
    if len(targets_pool) != 0 or len(domains_pool) != 0:
        print(cool.white("[+] Load {0} ip and {1} domain".format(len(targets_pool), len(domains_pool))))
    else:
        exit(cool.red("[-] Cannot find target\n"))
Exemplo n.º 3
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.º 4
0
def shreder_dir(directory, rewritecounts=dir_rewrite_count):
    filepaths = []
    dirpaths = []
    print(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(CRLF + cool.red(
            "[-] Error: cannot rename root directory name, Please check permissions"
        ))

    for rootpath, subdirsname, filenames in os.walk(directory):
        # get all directories
        dirpaths.extend(
            [os.path.abspath(os.path.join(rootpath, _)) for _ in subdirsname])
        # get all absolute file path
        filepaths.extend(
            [os.path.abspath(os.path.join(rootpath, _)) for _ in filenames])

    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("[+] Completely!"))
Exemplo n.º 5
0
def select_by_port(original_path, port_num):
    save_path = get_select_result_path(port_num)
    with open(save_path, 'a') as s:
        with open(original_path, 'r') as f:
            for line in f.readlines():
                chunk = line.strip().split(',')
                for status in port_selection:
                    if len(chunk) == 5 and chunk[1] == port_num and chunk[
                            3] == status:
                        print(cool.white("[+] %s" % chunk[0]))
                        s.write(chunk[0] + '\n')
    if os.path.getsize(save_path) > 0:
        print(cool.orange("\n[+] Store in: %s" % save_path))
    else:
        os.remove(save_path)
        exit(cool.fuchsia("\n[!] Select nothing"))
Exemplo n.º 6
0
 if args.base:
     get_base_dic(args.len[0], args.len[1], args.base, args.encode,
                  args.head, args.tail)
 elif args.customchar:
     get_char_dic(args.len[0], args.len[1], args.customchar, args.encode,
                  args.head, args.tail)
 elif args.chunk:
     chunk = []
     for item in args.chunk:
         if item != '':
             chunk.append(item)
     get_chunk_dic(chunk, args.encode, args.head, args.tail)
 elif args.plugins:
     if args.plugins[0] not in plug_range:
         exit("[!] Choose plug from ({0}, {1}, {2}, {3})".format(
             cool.fuchsia(plug_range[0]), cool.fuchsia(plug_range[1]),
             cool.fuchsia(plug_range[2]), cool.fuchsia(plug_range[3])))
     else:
         # id card plugin
         if len(args.plugins) == 1 and args.plugins[0] == plug_range[0]:
             get_idcard_post(plug_range[0], args.encode, args.head,
                             args.tail, args.sex)
         elif len(args.plugins) == 1 and args.plugins[0] == plug_range[1]:
             get_idcard_post(plug_range[1], args.encode, args.head,
                             args.tail, args.sex)
         # extend_enter plugin
         elif len(args.plugins) == 2 and args.plugins[0] == plug_range[2]:
             if os.path.isfile(args.plugins[1]):
                 with open(args.plugins[1], 'r') as f:
                     get_extend_dic(f.readlines(), encodeflag=args.encode)
             else:
Exemplo n.º 7
0
    if str(arg.threads).isdigit() and int(arg.threads) >= 1:
        set_threads(int(arg.threads))

    if arg.analyse != '':
        if os.path.exists(arg.analyse):
            result_handler(arg.analyse, result_file_path)
            if os.path.getsize(result_file_path) > 0:
                print(
                    cool.orange(
                        "\n[+] Store in: {0}".format(result_file_path)))
            else:
                try:
                    os.remove(result_file_path)
                except:
                    pass
                print(cool.fuchsia("\n[!] analyse output nothing"))
            print(
                cool.orange("[+] Cost : {0:.6} seconds".format(time.time() -
                                                               start_time)))
        else:
            exit(cool.red("[-] Directory:%s don't exists" % arg.analyse))
    elif arg.select[0] != '':
        if os.path.isfile(arg.select[0]):
            if str(arg.select[1]).isdigit():
                select_by_port(arg.select[0], arg.select[1])
            else:
                select_by_service(arg.select[0], arg.select[1])
        else:
            exit(cool.red("[-] File:%s don't exists" % arg.select[0]))
    else:
        if arg.rmself != 'default':
Exemplo n.º 8
0
 def do_otherdate(self, args):
     for item in str(args).split(' '):
         if len(item) != 8 or str(item).isdigit() is False:
             print(cool.fuchsia("[!] Input format:[YYYYMMDD] exp:19900512"))
         else:
             settings_dict['otherdate'].append(item)
Exemplo n.º 9
0
 def do_idcard(self, args):
     for item in str(args).split(' '):
         if len(item) < 15:
             print(cool.fuchsia("[!] Identity card number length too short (should >=15)"))
         else:
             settings_dict['idcard'].append(item)