Created
November 22, 2020 16:05
-
-
Save 4d4c/455ebb1e773fffbad3185569733f4d18 to your computer and use it in GitHub Desktop.
ThreadPool Brute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import subprocess | |
import traceback | |
from concurrent.futures import ThreadPoolExecutor | |
from tqdm import tqdm | |
def passwords(wordlist: str) -> list: | |
with open(wordlist, 'r') as wl: | |
passwds = [x.strip() for x in wl.readlines()] | |
return passwds | |
def try_connect(password: str): | |
try: | |
p = subprocess.Popen(["command", "-pass", password], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
output, errors = p.communicate() | |
p.wait() | |
if "ERROR" not in output.decode() and "ERROR" not in errors.decode(): | |
print(output.decode().replace("\\n", "\n")) | |
print(errors.decode().replace("\\n", "\n")) | |
print(password) | |
except Exception as e: | |
print(traceback.format_exc()) | |
print(password) | |
print(e) | |
def brute(wordlist: list): | |
with ThreadPoolExecutor(max_workers=10) as executor: | |
results = list(tqdm(executor.map(try_connect, wordlist), total=len(wordlist), desc='Brute')) | |
def main(): | |
passwds = passwords('') | |
brute(passwds) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment