예제 #1
0
def checkOption(options, run_options):

    finalOption = {}
    global MODE, DEF_WORDLIST
    # Modify URL value to correct format
    # Read password list
    # Read userlist
    # Convert to int(threads)

    try:
        finalOption["threads"] = int(options["-t"])
        if finalOption["threads"] < 1:
            utils.die("Argument error", "Threads must be > 1")
    except Exception as ConvertError:
        utils.die("Invalid threads", ConvertError)

    if MODE == "--sqli":
        finalOption["passlist"] = "MyP@ssW0rd"
        finalOption["userlist"] = data.getSQL()

    else:
        # WARNING eval() is called. It can be unsafe
        finalOption["passlist"] = eval(
            "data.%s_pass()" % (options["-p"])).replace(
                "\t", "") if options["-p"] in DEF_WORDLIST else actions.fread(
                    options["-p"])

        if options["-U"]:
            finalOption["userlist"] = actions.lread(options["-U"])

        else:
            finalOption["userlist"] = eval(
                "data.%s_user()" % (options["-u"])).replace(
                    "\t",
                    "") if options["-u"] in DEF_WORDLIST else actions.fread(
                        options["-u"])

    finalOption["falsekey"] = options["-k"]

    if run_options["--proxy"]:
        try:
            import data
            run_options["--proxy"] = actions.fread(
                "%s/liveproxy.txt" % (data.__path__[0])).split("\n")
        except Exception as err:
            utils.printf("Argument error", err)

    return finalOption, run_options
예제 #2
0
def checkOption(url, options, r_options):

    finalOption = {}
    global MODE
    # Modify URL value to correct format
    # Read password list
    # Read userlist
    # Convert to int(threads)

    try:
        finalOption["threads"] = int(options["-t"])
    except Exception as ConvertError:
        utils.die("Invalid threads", ConvertError)

    if MODE == "--sqli":
        finalOption["passlist"] = "MyP@ssW0rd"
        finalOption["userlist"] = data.getSQL()

    else:
        finalOption["passlist"] = data.getPass(
        ) if options["-p"] == "default" else actions.fread(options["-p"])

        if options["-U"]:
            finalOption["userlist"] = actions.lread(options["-U"])
        else:
            finalOption["userlist"] = data.getUser(
            ) if options["-u"] == "default" else actions.fread(options["-u"])

    finalOption["falsekey"] = options["-k"]

    if "http" not in url:
        url = "http://%s" % (url)
    if url[-1] != "/":
        url += "/"

    if r_options["--proxy"]:
        r_options["--proxy"] = actions.getProxyList()

    return url, finalOption, r_options
예제 #3
0
def check(target, threads, verbose, PROXY_PATH):
    def do_job(jobs):
        for job in jobs:
            job.start()
        for job in jobs:
            job.join()

    def checProxyConn(proxyAddr, target, result, verbose):
        try:
            proxyTest = tbrowser.startBrowser()
            user_agent = tbrowser.useragent()
            proxyTest.addheaders = [('User-Agent', user_agent)]
            proxyTest.set_proxies({"http": proxyAddr})

            if verbose:
                utils.printf("Trying: %s" % (proxyAddr))

            proxyTest.open(target)

            if verbose:
                utils.printf("Success: %s" % (proxyAddr), "good")
            result.put(proxyAddr)

        except Exception as error:
            if verbose:
                utils.printf("%s %s" % (proxyAddr, error), "bad")
        finally:
            try:
                proxyTest.close()
            except:
                pass

    try:

        proxylist = actions.fread(PROXY_PATH).split("\n")

        workers = []
        result = Queue()
        for tryProxy in proxylist:
            if len(workers) == threads:
                do_job(workers)
                del workers[:]

            worker = threading.Thread(target=checProxyConn,
                                      args=(tryProxy, target, result, verbose))

            worker.daemon = True
            workers.append(worker)

        do_job(workers)
        del workers[:]

    except KeyboardInterrupt as error:
        utils.die("GetProxy: Terminated by user!", error)
    except Exception as error:
        utils.die("GetProxy: Error while checking proxy connection to target",
                  error)

    finally:
        try:
            utils.printf("GetProxy: Write working proxies")
            actions.fwrite(PROXY_PATH, "\n".join(list(result.queue)))
            utils.printf("Write working proxies completed", "good")
        except Exception as err:
            utils.die("GetProxy: Error while writing result", err)
예제 #4
0
def check(options):
    def do_job(jobs):
        for job in jobs:
            job.start()
        for job in jobs:
            job.join()

    def checProxyConn(proxyAddr, target, result, verbose):
        try:
            proxyTest = startBrowser(options.timeout)
            proxyTest.set_proxies({"http": proxyAddr})

            if verbose:
                printf("[+] Trying: %s" % (proxyAddr))

            proxyTest.open(options.url)

            if verbose:
                printf("[*] Success: %s" % (proxyAddr), "good")
            result.put(proxyAddr)

        except Exception as error:
            if verbose:
                printf("[x] %s %s" % (proxyAddr, error), "bad")
        finally:
            try:
                proxyTest.close()
            except:
                pass

    try:
        proxylist = fread(PROXY_PATH).split("\n")

        workers = []
        result = Queue()
        for tryProxy in proxylist:
            if len(workers) == options.threads:
                do_job(workers)
                del workers[:]

            worker = threading.Thread(target=checProxyConn,
                                      args=(tryProxy, options.url, result,
                                            options.verbose))

            worker.daemon = True
            workers.append(worker)

        do_job(workers)
        del workers[:]

    except KeyboardInterrupt as error:
        printf("[x] Terminated by user!", "bad")
        import os
        os._exit(0)

    except Exception as error:
        die("[x] GetProxy: Error while checking proxy connection to target",
            error)

    finally:
        try:
            _data = "\n".join(list(result.queue))
            printf("[*] Get %s proxies." % (len(_data)), "good")
            printf("[+] Write working proxies")
            fwrite(LIVE_PATH, _data)
            printf("[*] Write working proxies completed", "good")
        except Exception as err:
            die("[x] GetProxy: Error while writing result", err)
예제 #5
0
def getlist():
    return fread(PROXY_PATH).split("\n")
예제 #6
0
def livelist():
    return fread(LIVE_PATH).split("\n")