Esempio n. 1
0
def main():
    scanners = ['any', 'all', 'numverify', 'ovh', 'footprints']

    banner()

    # Ensure the usage of Python3
    if sys.version_info[0] < 3:
        print("(!) Please run the tool using Python 3")
        sys.exit()

    # If any param is passed, execute help command
    if not len(sys.argv) > 1:
        parser.print_help()
        sys.exit()
    elif args.version:
        print("Version {}".format(__version__))
        sys.exit()

    if not configFile.is_file():
        error("The config file does not exist. Please create it.")
        sys.exit()

    if args.output:
        sys.stdout = Logger()

    # Verify scanner option
    if not args.scanner in scanners:
        print(("Error: scanner doesn't exist."))
        sys.exit()

    if args.number:
        scanNumber(args.number)
    elif args.input:
        for line in args.input.readlines():
            scanNumber(line)
    else:
        parser.print_help()
        sys.exit()

    if args.output:
        args.output.close()

    closeBrowser()
Esempio n. 2
0
def main():
    scanners = ['any', 'all', 'numverify', 'ovh', 'footprints']

    if args.update:
        os.system("cd ~ && chmod +x phonia/bin/phonia && phonia/bin/phonia -u")
        sys.exit()

    banner()

    # Ensure the usage of Python3
    if sys.version_info[0] < 3:
        print("(!) Please run the tool using Python 3")
        sys.exit()

    # If any param is passed, execute help command
    if not len(sys.argv) > 1:
        parser.print_help()
        sys.exit()
    elif args.info:
        os.system("cat banner/banner1.txt")
        sys.exit()

    if args.output:
        sys.stdout = Logger()

    # Verify scanner option
    if not args.scanner in scanners:
        print(("Error: scanner doesn't exists."))
        sys.exit()

    if args.number:
        scanNumber(args.number)
    elif args.input:
        for line in args.input.readlines():
            scanNumber(line)
    else:
        parser.print_help()
        sys.exit()

    if args.output:
        args.output.close()

    closeBrowser()
Esempio n. 3
0
def main():
    # Ensure the usage of Python3
    if sys.version_info[0] < 3:
        print("(!) Please run the tool using Python 3")
        sys.exit()

    # If any param is passed, execute help command
    if not len(sys.argv) > 1:
        parser.print_help()
        sys.exit()

    if args.output:
        sys.stdout = Logger()

    #reading phone numbers
    plist = loadtxt(args.input, dtype=str).tolist()
    total_cnt = len(plist)

    manager = Manager()
    proxies = manager.list()
    phonenum_list = manager.list()
    result_list = manager.list()
    procs = []
    fail_proxies = manager.list()
    used_proxies = manager.list()

    for n in plist:
        phonenum_list.append(n)

    print("Inputed phonenums:" + str(total_cnt))
    start = time.time()

    result_file = open('result.csv', 'w')
    csvwriter = csv.writer(result_file)
    csvwriter.writerow([
        "phone_number", 'valid', 'Country', 'Location', 'Carrier', 'Line type'
    ])

    lock = Lock()
    prox_up_t = Process(target=update_proxies,
                        args=(
                            MAX_THREAD_LIMIT * 3,
                            proxies,
                            phonenum_list,
                            fail_proxies,
                            used_proxies,
                            lock,
                        ))
    prox_up_t.start()

    prev_result_cnt = 0
    result_cnt = 0
    update_time = time.time()
    while 1:
        lock.acquire()
        for res in result_list:
            csvwriter.writerow(res.values())
            result_list.remove(res)
            result_cnt += 1
        lock.release()

        if result_cnt > prev_result_cnt:
            result_file.flush()
            update_time = time.time()
            prev_result_cnt = result_cnt
            plus("{} phone numbers has been processed".format(result_cnt))

        else:  #long time failed during getting proxies
            hours, rem = divmod(time.time() - update_time, 3600)
            minutes, seconds = divmod(rem, 60)
            if minutes > 3:  #over 3 min
                lock.acquire()
                for x in fail_proxies:
                    fail_proxies.remove(x)
                lock.release()

        if result_cnt >= total_cnt:
            prox_up_t.terminate()
            break

        #lock.acquire()
        for p in procs:
            if not p.is_alive():
                p.terminate()
                procs.remove(p)

        remains = total_cnt - result_cnt
        #lock.release()
        if len(phonenum_list) > 0 and len(procs) < min(MAX_THREAD_LIMIT,
                                                       remains):
            proxyaddr = ""
            lock.acquire()
            if len(proxies) > 0:
                proxyaddr = proxies.pop()
                used_proxies.append(proxyaddr)
            lock.release()
            if proxyaddr != "":
                bunch_size = Value(
                    'i',
                    min(MAX_NUMBERS_PER_THREAD,
                        max(1, int(remains / MAX_THREAD_LIMIT))))
                t = Process(target=scanNumbersWithProxy,
                            args=(
                                {
                                    'https': proxyaddr
                                },
                                phonenum_list,
                                result_list,
                                bunch_size,
                                fail_proxies,
                                used_proxies,
                                lock,
                            ))
                t.start()
                procs.append(t)
        else:
            time.sleep(1)

    for p in procs:
        p.terminate()
    end = time.time()
    hours, rem = divmod(end - start, 3600)
    minutes, seconds = divmod(rem, 60)

    result_file.close()

    print("Ellapsed time: {:0>2}:{:0>2}:{:05.2f}".format(
        int(hours), int(minutes), seconds))

    if args.output:
        args.output.close()