1 Star 0 Fork 237

saiboy/python-learn

forked from mktime/python-learn 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
scan2.py 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
内部项目 提交于 2020-12-27 23:36 . 代码备份
from socket import *
import threading
import queue
threads = []
q = queue.Queue()
for i in range(1, 255):
ip_addr = '10.7.67.' + str(i)
for port in [21, 22, 20, 80, 8080, 8081, 3389, 443, 445, 3306, 445]:
q.put((ip_addr, port))
def portScanner(q):
while True:
addr = None
try:
addr = q.get_nowait()
except queue.Empty:
print("finished")
break
#print('[-] [%s] %d scanning' % (addr[0], addr[1]))
try:
s = socket(AF_INET,SOCK_STREAM)
s.connect((addr[0], addr[1]))
print('[+] [%s] %d open!!!' % (addr[0], addr[1]))
s.close()
except:
continue
def main():
setdefaulttimeout(2)
thread_num = 50
for i in range(thread_num):
args = {'q': q}
t = threading.Thread(target=portScanner, kwargs=args)
threads.append(t)
t.start()
for t in threads:
t.join()
print('[*] The scan is complete!')
if __name__ == '__main__':
main()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/youmayun/python-learn.git
git@gitee.com:youmayun/python-learn.git
youmayun
python-learn
python-learn
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385