1 Star 0 Fork 0

那少年和狗/CNVD-2020-10487

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
threading-find-port-8009.py 1.74 KB
Copy Edit Raw Blame History
Cheng authored 2020-03-27 17:06 . fixed
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from socket import *
import threading
import time
import os
import re
import requests
import sys
lock = threading.Lock()
http_URL = []
#网站url
http_website = []
#每个线程分配的url
urlSepList=[]
#分离文件名 给每个线程分一个
def read_file(file_path):
# 判断文件路径是否存在,如果不存在直接退出,否则读取文件内容
if not os.path.exists(file_path):
print('Please confirm correct filepath !')
sys.exit(0)
else:
with open(file_path, 'r') as source:
for line in source:
#print(line.rstrip('\r\n').rstrip('\n'))
http_website.append(line.rstrip('\r\n').rstrip('\n'))
#分离文件名 给每个线程分一个
def separateName(threadCount):
for i in range(0,len(http_website),int(len(http_website)/threadCount)):
urlSepList.append(http_website[i:i+int(len(http_website)/threadCount)])
#多线程函数
def multithreading(threadCount):
separateName(threadCount)#先分离
if threadCount == 1:
threadCount = 2
for i in range(0,threadCount-1):
t=threading.Thread(target=run_one_thread,args=(urlSepList[i],))
t.start()
#每个线程的运作 参数为文件名称的列表
def run_one_thread(url_list):
port=8009
for url in url_list:
ok_f=open("8009.txt","a+")
try:
s = socket(AF_INET,SOCK_STREAM)
s.settimeout(3)
s.connect((url,port))
lock.acquire()
print(url+" is open 8009")
ok_f.write(url+"\n")
#print('[+] %d open' % port)
lock.release()
s.close()
except Exception as e:
#raise e
pass
ok_f.close()
if __name__ == '__main__':
file_str="ip.txt"
read_file(file_str)
thread_num=20
if len(http_website)<thread_num:
thread_num=len(http_website)
print(thread_num)
multithreading(thread_num)
# print(urlSepList)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/dogecheng/CNVD-2020-10487.git
git@gitee.com:dogecheng/CNVD-2020-10487.git
dogecheng
CNVD-2020-10487
CNVD-2020-10487
master

Search

23e8dbc6 1850385 7e0993f3 1850385