切换风格

Wizard Sky California Sunset glow Black Cloud Beige Dragon Lavender NewYear City Snow Flowers London
收藏本站XSS平台字符串转换jsfuck
C段扫描,求改进多线程[复制链接]
发表于 2015-1-2 16:41:00 | 显示全部楼层 |!read_mode!
下面是一个C段扫描的代码,求改进成多线程!(不会多线程,不明白多线程和队列的区别)

#coding:utf8
import sys,socket

#PortList = [21, 22, 23, 25, 80, 135, 137, 139, 443, 445, 1433, 1502, 3306, 3389, 8080, 9015,873,3128,8081,9080,1080,7001,110,9090,1521,1158,2100]
PortList = [80,8080,443]
#超时时间
Timeout = 2.0
#打开的端口列表
OpenPort = []


#获取C段IP函数
def getips(host):
                ip = []
                ip_pre = ""
                for pre in host.split('.')[0:3]:
                        ip_pre = ip_pre + pre + '.'
                for i in range(1,49):
                        l = (ip_pre+str(i))
                        ip.append(l)                
                return ip
        
def Ping(ips):
        global Timeout,PortList,OpenPort
        for i in ips:
                for j in PortList:
                        #address = (i,j)
                        sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                        sk.settimeout(Timeout)
                        try:
                                sk.connect((i,j))
                                print('Server %s port %d OK!' % (i,j))
                        except Exception:
                                pass
                        sk.close()
                        


Ping(getips('10.10.10.48'))












发表于 2015-1-10 17:53:18 | 显示全部楼层
发表于 2015-1-11 14:38:07 | 显示全部楼层
SoEasy++ 发表于 2015-1-10 17:53
参考下:http://www.cnblogs.com/fnng/p/3670789.html | http://www.cnblogs.com/huxi/archive/2010/06/26/ ...

thank!

代码区

GMT+8, 2019-9-23 21:28

Powered by Discuz! X2

© 2001-2018 Comsenz Inc.

回顶部