1 Star 0 Fork 1

云时之间/hbuComputerNetworkCourseProject-ScanPort

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
scanport4_tcpok.py 969 Bytes
一键复制 编辑 原始数据 按行查看 历史
dulaladuladula 提交于 2018-05-15 09:17 . All File
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from socket import *
import threading
from datetime import datetime
lock = threading.Lock()
openNum = 0
threads = []
def portScanner(host,port):
global openNum
try:
s = socket(AF_INET,SOCK_STREAM)
s.connect((host,port))
lock.acquire()
openNum+=1
print('[+] %d open' % port)
lock.release()
s.close()
except:
pass
def main():
host = "103.79.76.177"
setdefaulttimeout(0.5)
print('Scanning the host:%s......' % (host))
t1 = datetime.now()
for p in range(0,65535):
t = threading.Thread(target=portScanner,args=(host,p))
threads.append(t)
t.start()
for t in threads:
t.join()
print('[*] The host:%s scan is complete!' % (host))
print('[*] A total of %d open port ' % (openNum))
print('Multiprocess Scanning Completed in ', datetime.now() - t1)
if __name__ == '__main__':
main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/yunshizhijian/hbuComputerNetworkCourseProject-ScanPort.git
git@gitee.com:yunshizhijian/hbuComputerNetworkCourseProject-ScanPort.git
yunshizhijian
hbuComputerNetworkCourseProject-ScanPort
hbuComputerNetworkCourseProject-ScanPort
master

搜索帮助