#coding: utf-8
import socket
import time
def scan(ip, port):
try:
socket.setdefaulttimeout(3)
s = socket.socket()
s.connect((ip, port))
return True
except:
return
def scanport():
print '作者:xiaoye'.decode('utf-8').encode('gbk')
print '--------------'
print 'blog: [url]http://blog.163.com/sy_butian/blog'[/url]
print '--------------'
ym = raw_input('请输入域名(只对未使用cdn的网站有效):'.decode('utf-8').encode('gbk'))
ips = socket.gethostbyname(ym)
print 'ip: %s' % ips
portlist = [80,8080,3128,8081,9080,1080,21,23,443,69,22,25,110,7001,9090,3389,1521,1158,2100,1433]
starttime = time.time()
for port in portlist:
res = scan(ips, port)
if res :
print 'this port:%s is on' % port
endtime = time.time()
print '本次扫描用了:%s秒'.decode('utf-8').encode('gbk') % (endtime-starttime)
if __name__ == '__main__':
scanport()