Ejemplo n.º 1
0
def check_tasks(options, loginInfo):
    """
		This fucntion check options for each brute force task
	"""

    _, formField = loginInfo
    import data

    # CHECK username list options
    if len(formField) == 1:
        options.username = [""]
    elif options.options["-U"]:
        options.username = list(set(lread(options.options["-U"])))
    else:
        if options.options["-u"] in options.WORDLISTS:
            if options.options["-u"] == "sqli":
                options.username = tuple(
                    eval("data.%s_user()" % (options.options["-u"])))
            else:
                options.username = tuple(
                    eval("data.%s_user()" % (options.options["-u"])).replace(
                        "\t", "").split("\n"))
        else:
            options.username = tuple(fread(options.options["-u"]).split("\n"))
            options.username = filter(None, options.username)

    # CHECK passlist option
    if options.options["-p"] in options.WORDLISTS:
        options.passwd = tuple(
            eval("data.%s_pass()" % (options.options["-p"])).replace(
                "\t", "").split("\n"))
    else:
        options.passwd = tuple(fread(options.options["-p"]).split("\n"))
        options.passwd = filter(None, options.passwd)

    if "--replacement" in options.extras:
        from data.passgen import replacement
        final_passwd = ""
        for line in options.passwd:
            final_passwd += "\n".join(list(replacement(line)))
        options.passwd = final_passwd.split("\n")

    elif "--toggle_case" in options.extras:
        from data.passgen import toggle_case
        final_passwd = ""
        for line in options.passwd:
            final_passwd += "\n".join(list(toggle_case(line)))
        options.passwd = final_passwd.split("\n")

    options.report = options.run_options["--report"]
    options.verbose = options.run_options["--verbose"]
Ejemplo n.º 2
0
def check_options(options):
    """
		This function checks main options before create tasks, ...
	"""
    # Read URL from list (file_path) or get URL from option
    try:
        options.target = fread(
            options.options["-l"]).split("\n") if options.options["-l"] else [
                options.url
            ]
        options.target = filter(None, options.target)
    except Exception as error:
        die("[x] Options: URL error", error)
        # CHECK threads option
    try:
        options.threads = int(options.options["-t"])
        if options.threads < 1:
            die("[x] Options: Invalid option \"threads\"",
                "Thread number must be larger than 1")
    except Exception as error:
        die("[x] Options: Invalid option \"threads\"", error)

    # CHECK timeout option
    try:
        options.timeout = int(options.options["-T"])
        if options.timeout < 1:
            die("[x] Options: Invalid option \"timeout\"",
                "Thread number must be larger than 1")
    except Exception as error:
        die("[x] Options: Invalid option \"timeout\"", error)
    if options.attack_mode == "--sqli":
        options.options["-u"], options.options["-p"] = "sqli", "sqli"
Ejemplo n.º 3
0
def getlist():
	return fread(PROXY_PATH).split("\n")
Ejemplo n.º 4
0
def check(options):
	
	def run_threads(threads, sending, completed, total):
		# Run threads
		for thread in threads:
			sending += 1 # Sending
			progress_bar(sending, completed, total)
			thread.start()

		# Wait for threads completed
		for thread in threads:
			completed += 1
			progress_bar(sending, completed, total)
			thread.join()
		
		return sending, completed

	def checProxyConn(proxyAddr, target, result, verbose):
		try:
			proxyTest = mBrowser(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()
		trying, completed, total = 0, 0, len(proxylist)

		for tryProxy in proxylist:
			if len(workers) == options.threads:
				trying, completed = run_threads(workers, trying, completed, total)
				del workers[:]
			
			worker = threading.Thread(
				target = checProxyConn,
				args = (tryProxy, options.url, result, options.verbose)
			)

			worker.daemon = True
			workers.append(worker)
			
		trying, completed = run_threads(workers, trying, completed, total)
		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)
Ejemplo n.º 5
0
def livelist():
	return fread(LIVE_PATH).split("\n")