函数---找了个编辑器sublime
import socket
def retBanner(ip,port): //函数
try:
socket.setdeffaulttimeout(2)
s=socket.socket()
s.connect((ip,port))
banner = s.recv(1024)
return bunner
except:
return
def main(): //main
ip1 = '
http://www.sina.com.cn'
ip2 = '192.168.95.149'
port1 = 80
port2 = 21
banner1 = retBanner(ip1,påort1)
print "[+]" + str(ip1) + ": " + str(banner1)
banner2 = retBanner(ip2,port2)
print "[+]" + str(ip2) + ": " + str(banner2)
if __name__ == '__main__':
main()
-------//在终端执行
# python hello.py
[+]
http://www.sina.com.cn: None
[+]192.168.95.149: None