本站vip特权 - 全站资源免费下载

限时特惠

fofa自动多线程异步协程爬取验证url存活(gui版)

1:前言

最近学了pyqt5,就把以前的那个fofa多线程的改写了。采用了多线程爬取,异步协程验证url的方式。整个程序用了pyqt编写(附源码和成品),分享出来给大家参考学习。技术不咋地,还望海涵。

%title插图%num

2:需要用到的包

from PyQt5 import QtCore, QtGui, QtWidgets
import base64
from threading import Thread
import re
import time
import grequests #高性能异步协程框架
import requests
requests.packages.urllib3.disable_warnings() #消除ssl警告

3:多线程爬取fofa信息

class SearchThread(QtCore.QThread):
        sinout = QtCore.pyqtSignal(object) #定义sinout信号,传递爬取url信息
        finish = QtCore.pyqtSignal(object) #定义finish信号,完成后传递给check验证

        def __init__(self,key,auth,flag,check):
            super().__init__()
            self.Authorization = auth #认证信息
            self.key = key #搜索关键字
            self.flag = flag #定义是否由一键完成调用
            self.check = check #调用check

        def run(self): #多线程执行的地方
            threads= []
            surl = "https://api.fofa.so/v1/search" #搜索的网址

            headers = {   #定义头信息
                # 会员登录后获取Authorization(googl浏览器)
                'Authorization': self.Authorization,
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'
            }
            url = "https://www.fofa.so/result?qbase64=" + str(base64.b64encode(self.key.encode("utf-8")),'utf-8') #定义一个搜索结果url获取页数
            resp = requests.get(url, headers=headers, verify=False, timeout=10)
#正则匹配总的数据量
            res = re.findall('<span class="el-pagination__total">共 (\d+) 条</span>', resp.text)
#因为fofa限定每天爬取10000条数据,超过就10000
            if res[0] != "":
                sum = int(res[0])
                if sum/10>1000:
                    sum = 1000
                else:
                    sum = sum/10
#使用set数据类型可以自动去重
            url_lst = set()
            # 设置爬取页码
            b64_keyword = str(base64.b64encode(self.key.encode('utf-8')), 'utf-8')
            total = set()
#打开文件句柄,爬取url就写入文件中
            with open("tmp.txt","w",encoding="utf-8") as f:
                for i in range(1, sum):
                    params = {
                        'q': self.key,
                        'qbase64': b64_keyword,
                        'full': 'false',
                        'pn': i,
                        'ps': 10
                    }
                    t = Thread(target=self.spider,args=(surl,params,url_lst,headers,f))
                    time.sleep(1)
                    threads.append(t)
                    t.start()
                for i in range(len(threads)):
#阻塞调用线程
                    threads[i].join()
#执行完成发射finish信号
            self.finish.emit(True)

        #多线程爬虫
        def spider(self,surl,params,url_lst,headers,f):
            try:
                resp = requests.get(surl,params=params,headers=headers,timeout=10)
                if resp.text.strip() != "":
                    for i in range(10):
#json解析,可以自定义解析更多信息
                        url = resp.json()['data']['assets'][i]['link'].strip()
                        f.write(url+"\n")
                        url_lst.add(url)
#给调用线程发送信号,更新主GUI信息(res文本编辑)
                        self.sinout.emit("发现了 {}".format(url))
                    self.sinout.emit("当前总计:{}".format(str(len(url_lst))))
                else:
                    pass
            except:
                pass

4:主GUI进程

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1000, 750)
#在主窗口设置窗口样式
        MainWindow.setStyleSheet("QPushButton:hover{\n"
"    color:red;\n"
"    boder:2px solid green;\n"
"    background-color: rgb(255, 255, 127);\n"
"\n"
"}\n"
"QPushButton{\n"
"    font-size:30px;\n"
"    color: rgb(255, 0, 255);\n"
"}\n"
"*{\n"
"font-size:30px;\n"
"}\n"
"#res{background-image:url(./明哥.jpg)}")
        self.win = MainWindow
        self.win.setWindowIcon(QtGui.QIcon("ming.ico"))
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout_3.setContentsMargins(-1, -1, -1, 0)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout()
        self.verticalLayout_2.setContentsMargins(10, 0, 10, 0)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setContentsMargins(-1, 11, -1, 0)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setStyleSheet("color: rgb(255, 85, 0);")
        self.label.setObjectName("label")
        self.horizontalLayout_2.addWidget(self.label)
#读取搜索关键字
        self.skey = QtWidgets.QLineEdit(self.centralwidget)
        self.skey.setStyleSheet("*{\n"
"    height:30px\n"
"}")
self.skey.setObjectName("skey")
        self.skey.setPlaceholderText("输入Fofa搜索关键字")
        self.horizontalLayout_2.addWidget(self.skey)
        self.horizontalLayout_2.setStretch(0, 2)
        self.horizontalLayout_2.setStretch(1, 8)
        self.verticalLayout_2.addLayout(self.horizontalLayout_2)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setContentsMargins(-1, 9, -1, 9)
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setObjectName("label_2")
        self.horizontalLayout_3.addWidget(self.label_2)

#读取auth认证信息
        self.auth = QtWidgets.QTextEdit(self.centralwidget)
        self.auth.setObjectName("auth")
        self.auth.setPlaceholderText("Google浏览器登录fofa,获取anthorithon!")
        self.horizontalLayout_3.addWidget(self.auth)
        self.horizontalLayout_3.setStretch(0, 2)
        self.horizontalLayout_3.setStretch(1, 8)
        self.verticalLayout_2.addLayout(self.horizontalLayout_3)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setContentsMargins(-1, 4, -1, 2)
        self.horizontalLayout.setSpacing(32)
        self.horizontalLayout.setObjectName("horizontalLayout")
#触发搜索
        self.search_btn = QtWidgets.QPushButton(self.centralwidget)
        self.search_btn.setStyleSheet("")
        self.search_btn.setObjectName("search_btn")
        self.search_btn.clicked.connect(self.start_search)
        self.search_btn.setToolTip("点击进行搜索")
        self.horizontalLayout.addWidget(self.search_btn)

#清理三个输入输出窗口
        self.clear_btn = QtWidgets.QPushButton(self.centralwidget)
        self.clear_btn.setObjectName("clear_btn")
        self.clear_btn.setToolTip("点击清除三个框里的内容")
        self.horizontalLayout.addWidget(self.clear_btn)

#点击触发去重
        self.uniq_btn = QtWidgets.QPushButton(self.centralwidget)
        self.uniq_btn.setObjectName("uniq_btn")
        self.horizontalLayout.addWidget(self.uniq_btn)
        self.uniq_btn.setToolTip("去除重复,可以获取输出框里的内容,或者tmp.txt的内容")

#点击触发url验证存活
        self.check_btn = QtWidgets.QPushButton(self.centralwidget)
        self.check_btn.setObjectName("check_btn")
        self.check_btn.clicked.connect(self.check)
        self.check_btn.setToolTip("对url的存活进行验证,一般2xx,3xx,4xx,5xx的响应都是存活的")

        self.horizontalLayout.addWidget(self.check_btn)

#点击触发一键搜索及验证存活
        self.quick_btn = QtWidgets.QPushButton(self.centralwidget)
        self.quick_btn.setObjectName("quick_btn")
        self.quick_btn.clicked.connect(self.quick)
        self.quick_btn.setToolTip("输入key和auth后自动进行url爬取,去重和验证,文件保存在tmp.txt里面")

        self.horizontalLayout.addWidget(self.quick_btn)
        self.verticalLayout_2.addLayout(self.horizontalLayout)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setContentsMargins(-1, 19, -1, 9)
        self.verticalLayout.setObjectName("verticalLayout")
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setObjectName("label_4")
        self.verticalLayout.addWidget(self.label_4)

#结果输出
        self.res = QtWidgets.QTextEdit(self.centralwidget)
        self.res.setObjectName("res")

        self.verticalLayout.addWidget(self.res)
        self.verticalLayout_2.addLayout(self.verticalLayout)
        self.verticalLayout_2.setStretch(0, 1)
        self.verticalLayout_2.setStretch(1, 1)
        self.verticalLayout_2.setStretch(2, 1)
        self.verticalLayout_2.setStretch(3, 3)
        self.verticalLayout_3.addLayout(self.verticalLayout_2)
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)

#绑定清除按钮
        self.clear_btn.clicked.connect(self.auth.clear)
        self.clear_btn.clicked.connect(self.skey.clear)
        self.clear_btn.clicked.connect(self.res.clear)
        self.uniq_btn.clicked.connect(self.doUniq)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
    
#定义一键完成执行逻辑
    def quick(self):
        Authorization = self.auth.toPlainText()
        key = self.skey.text()
        if Authorization.strip() !="" and key.strip() !="":
#标识位True是为了让start_search执行完调用check
            self.start_search(Authorization,key,True)
        else:
            QtWidgets.QMessageBox.information(self.win,"温馨提示","关键字或者Auth不能为空!")

#定义验证存活执行逻辑
    def check(self,flag=False):
        headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'
        }
        if flag:
            with open("tmp.txt","r") as f:
                self.url_lst = f.readlines()
        else:
#因为结果输出框里的数据以“发现”开头,如果读取无法验证网址;如果是用户吧url放入结果输入框也可以正常读取验证的
            if self.res.toPlainText().strip() == "" or self.res.toPlainText().startswith("发现"):
#url_file返回一个数组,包含文本的path
                url_file = QtWidgets.QFileDialog.getOpenFileName(self.win, "选择一个URL文件", "./")
                if url_file[0].strip() != "":
                    with open(url_file[0].strip(), "r") as f:
                        self.url_lst = f.readlines()
            else:
                self.url_lst = self.res.toPlainText().split("\n")
        #grequest异步协程,timeout=10,防止响应过长而没法验证url,verify是为了去除ssl验证
        re = (grequests.get(url.strip(), timeout=10, headers=headers, verify=False) for url in self.url_lst)
        resp_list = grequests.imap(re, size=50,exception_handler=lambda req, excp: print("url {} is {}!".format(req.url, excp)))
        page_num = 1
        if resp_list is not None:
#清除结果输出框
            self.res.clear()
        for resp in resp_list:
#append是为了不让输出被覆盖
            self.res.append("url {} : {} 的响应码是 :{}".format(str(page_num), resp.url, resp.status_code))
            page_num += 1

#定义去重执行逻辑
    def doUniq(self):
        self.urls = self.res.toPlainText()
#结果输出框没有url或者是有以“发现了开头的”(不是用户输入的url),去不读取tmp.txt来验证
        if self.urls.strip() == "" or self.urls.startswith("发现了"):
            with open("tmp.txt","r") as f:
#读取1024个字节如果为空就说明tmp.txt为空
                if f.readline(1024).strip() =="":
                    QtWidgets.QMessageBox.information(self.win,"温馨提示!","请输入网址!")
                    return
                else:
                    self.urls = f.readlines()
        else:
            self.urls = self.urls.split("\n")
        s = set()
        s.update(self.urls)
        self.res.clear()
        for url in s:
            self.res.append(url.strip())
#定义搜索逻辑
    def start_search(self,Authorization="",key="",flag=False,check=None):
        if Authorization =="" or key == "":
            Authorization = self.auth.toPlainText()
            key = self.skey.text()
        if Authorization.strip() !="" and key.strip()!="":
            self.thread = SearchThread(key,Authorization,flag,check)
            self.thread.sinout.connect(self.res.append)
            self.thread.start()
            if flag:
                self.thread.finish.connect(self.doCheck)

        else:
            QtWidgets.QMessageBox.information(self.win,"温馨提示!","Auth or keyworld 不能为空!")
            return
    def doCheck(self,flag):
        if flag:
            self.check(flag)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Fofa下载及网址批量验证"))
        self.label.setText(_translate("MainWindow", " 搜索关键字:"))
        self.label_2.setText(_translate("MainWindow", "<html><head/><body><p><span style=\" font-weight:600; color:#5555ff;\">Authorithon:</span></p></body></html>"))
        self.search_btn.setText(_translate("MainWindow", "搜索"))
        self.clear_btn.setText(_translate("MainWindow", "清除"))
        self.uniq_btn.setText(_translate("MainWindow", "去重"))
        self.check_btn.setText(_translate("MainWindow", "验证"))
        self.quick_btn.setText(_translate("MainWindow", "一键完成"))
        self.label_4.setText(_translate("MainWindow", "<html><head/><body><p><span style=\" font-size:16pt; font-weight:600; color:#00ff00;\">结果显示:</span></p></body></html>"))

5:ui调用

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

6:注意事项及完整源码

打包用的是pyinstaller,简易创建个虚拟环境安装依赖包,不然打包时间长且依赖包过多会导致异响不到的问题,比如打包占满我c盘的90GB。

推荐使用anaconda3,简单执行

conda create -n python3 python=3

conda activate python3

pip install package

就可以了

接着是打包命令:

pyinstaller -Fw -i ./ming.ico fofa.py

-F是生成独立的exe文件

-w是不需要console界面

-i指定程序logo

#coding:utf-8

from PyQt5 import QtCore, QtGui, QtWidgets
import base64
from threading import Thread
import re
import time
import grequests
import requests
requests.packages.urllib3.disable_warnings()

class SearchThread(QtCore.QThread):
        sinout = QtCore.pyqtSignal(object)
        finish = QtCore.pyqtSignal(object)

        def __init__(self,key,auth,flag,check):
            super().__init__()
            self.Authorization = auth
            self.key = key
            self.flag = flag
            self.check = check

        def run(self):
            threads= []
            surl = "https://api.fofa.so/v1/search"

            headers = {
                # 会员登录后获取Authorization(googl浏览器)
                'Authorization': self.Authorization,
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'
            }
            url = "https://www.fofa.so/result?qbase64=" + str(base64.b64encode(self.key.encode("utf-8")),'utf-8')
            resp = requests.get(url, headers=headers, verify=False, timeout=10)
            res = re.findall('<span class="el-pagination__total">共 (\d+) 条</span>', resp.text)
            if res[0] != "":
                sum = int(res[0])
                if sum/10>1000:
                    sum = 1000
                else:
                    sum = sum/10
            url_lst = set()
            # 设置爬取页码
            b64_keyword = str(base64.b64encode(self.key.encode('utf-8')), 'utf-8')
            total = set()
            with open("tmp.txt","w",encoding="utf-8") as f:
                for i in range(1, sum):
                    params = {
                        'q': self.key,
                        'qbase64': b64_keyword,
                        'full': 'false',
                        'pn': i,
                        'ps': 10
                    }
                    t = Thread(target=self.spider,args=(surl,params,url_lst,headers,f))
                    time.sleep(1)
                    threads.append(t)
                    t.start()
                for i in range(len(threads)):
                    threads[i].join()
            self.finish.emit(True)


        def spider(self,surl,params,url_lst,headers,f):
            try:
                resp = requests.get(surl,params=params,headers=headers,timeout=10)
                if resp.text.strip() != "":
                    for i in range(10):
                        url = resp.json()['data']['assets'][i]['link'].strip()
                        f.write(url+"\n")
                        url_lst.add(url)
                        self.sinout.emit("发现了 {}".format(url))
                    self.sinout.emit("当前总计:{}".format(str(len(url_lst))))
                else:
                    pass
            except:
                pass


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1000, 750)
        MainWindow.setStyleSheet("QPushButton:hover{\n"
"    color:red;\n"
"    boder:2px solid green;\n"
"    background-color: rgb(255, 255, 127);\n"
"\n"
"}\n"
"QPushButton{\n"
"    font-size:30px;\n"
"    color: rgb(255, 0, 255);\n"
"}\n"
"*{\n"
"font-size:30px;\n"
"}\n"
"#res{background-image:url(./明哥.jpg)}")
        self.win = MainWindow
        self.win.setWindowIcon(QtGui.QIcon("ming.ico"))
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout_3.setContentsMargins(-1, -1, -1, 0)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout()
        self.verticalLayout_2.setContentsMargins(10, 0, 10, 0)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setContentsMargins(-1, 11, -1, 0)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setStyleSheet("color: rgb(255, 85, 0);")
        self.label.setObjectName("label")
        self.horizontalLayout_2.addWidget(self.label)
        self.skey = QtWidgets.QLineEdit(self.centralwidget)
        self.skey.setStyleSheet("*{\n"
"    height:30px\n"
"}")
        self.skey.setObjectName("skey")
        self.skey.setPlaceholderText("输入Fofa搜索关键字")
        self.horizontalLayout_2.addWidget(self.skey)
        self.horizontalLayout_2.setStretch(0, 2)
        self.horizontalLayout_2.setStretch(1, 8)
        self.verticalLayout_2.addLayout(self.horizontalLayout_2)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setContentsMargins(-1, 9, -1, 9)
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setObjectName("label_2")
        self.horizontalLayout_3.addWidget(self.label_2)
        self.auth = QtWidgets.QTextEdit(self.centralwidget)
        self.auth.setObjectName("auth")
        self.auth.setPlaceholderText("Google浏览器登录fofa,获取anthorithon!")
        self.horizontalLayout_3.addWidget(self.auth)
        self.horizontalLayout_3.setStretch(0, 2)
        self.horizontalLayout_3.setStretch(1, 8)
        self.verticalLayout_2.addLayout(self.horizontalLayout_3)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setContentsMargins(-1, 4, -1, 2)
        self.horizontalLayout.setSpacing(32)
        self.horizontalLayout.setObjectName("horizontalLayout")

        self.search_btn = QtWidgets.QPushButton(self.centralwidget)
        self.search_btn.setStyleSheet("")
        self.search_btn.setObjectName("search_btn")
        self.search_btn.clicked.connect(self.start_search)
        self.search_btn.setToolTip("点击进行搜索")

        self.horizontalLayout.addWidget(self.search_btn)
        self.clear_btn = QtWidgets.QPushButton(self.centralwidget)
        self.clear_btn.setObjectName("clear_btn")
        self.clear_btn.setToolTip("点击清除三个框里的内容")

        self.horizontalLayout.addWidget(self.clear_btn)
        self.uniq_btn = QtWidgets.QPushButton(self.centralwidget)
        self.uniq_btn.setObjectName("uniq_btn")
        self.horizontalLayout.addWidget(self.uniq_btn)
        self.uniq_btn.setToolTip("去除重复,可以获取输出框里的内容,或者tmp.txt的内容")

        self.check_btn = QtWidgets.QPushButton(self.centralwidget)
        self.check_btn.setObjectName("check_btn")
        self.check_btn.clicked.connect(self.check)
        self.check_btn.setToolTip("对url的存活进行验证,一般2xx,3xx,4xx,5xx的响应都是存活的")

        self.horizontalLayout.addWidget(self.check_btn)
        self.quick_btn = QtWidgets.QPushButton(self.centralwidget)
        self.quick_btn.setObjectName("quick_btn")
        self.quick_btn.clicked.connect(self.quick)
        self.quick_btn.setToolTip("输入key和auth后自动进行url爬取,去重和验证,文件保存在tmp.txt里面")

        self.horizontalLayout.addWidget(self.quick_btn)
        self.verticalLayout_2.addLayout(self.horizontalLayout)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setContentsMargins(-1, 19, -1, 9)
        self.verticalLayout.setObjectName("verticalLayout")
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setObjectName("label_4")
        self.verticalLayout.addWidget(self.label_4)
        self.res = QtWidgets.QTextEdit(self.centralwidget)
        self.res.setObjectName("res")

        self.verticalLayout.addWidget(self.res)
        self.verticalLayout_2.addLayout(self.verticalLayout)
        self.verticalLayout_2.setStretch(0, 1)
        self.verticalLayout_2.setStretch(1, 1)
        self.verticalLayout_2.setStretch(2, 1)
        self.verticalLayout_2.setStretch(3, 3)
        self.verticalLayout_3.addLayout(self.verticalLayout_2)
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        self.clear_btn.clicked.connect(self.auth.clear)
        self.clear_btn.clicked.connect(self.skey.clear)
        self.clear_btn.clicked.connect(self.res.clear)
        self.uniq_btn.clicked.connect(self.doUniq)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def quick(self):
        Authorization = self.auth.toPlainText()
        key = self.skey.text()
        if Authorization.strip() !="" and key.strip() !="":
            self.start_search(Authorization,key,True)
        else:
            QtWidgets.QMessageBox.information(self.win,"温馨提示","关键字或者Auth不能为空!")

    def check(self,flag=False):
        headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'
        }
        if flag:
            with open("tmp.txt","r") as f:
                self.url_lst = f.readlines()
        else:
            if self.res.toPlainText().strip() == "" or self.res.toPlainText().startswith("发现"):
                url_file = QtWidgets.QFileDialog.getOpenFileName(self.win, "选择一个URL文件", "./")
                if url_file[0].strip() != "":
                    with open(url_file[0].strip(), "r") as f:
                        self.url_lst = f.readlines()
            else:
                self.url_lst = self.res.toPlainText().split("\n")

        re = (grequests.get(url.strip(), timeout=10, headers=headers, verify=False) for url in self.url_lst)
        resp_list = grequests.imap(re, size=50,exception_handler=lambda req, excp: print("url {} is {}!".format(req.url, excp)))
        page_num = 1
        if resp_list is not None:
            self.res.clear()
        for resp in resp_list:
            self.res.append("url {} : {} 的响应码是 :{}".format(str(page_num), resp.url, resp.status_code))
            page_num += 1

    def doUniq(self):
        self.urls = self.res.toPlainText()

        if self.urls.strip() == "" or self.urls.startswith("发现了"):
            with open("tmp.txt","r") as f:
                if f.readline(1024).strip() =="":
                    QtWidgets.QMessageBox.information(self.win,"温馨提示!","请输入网址!")
                    return
                else:
                    self.urls = f.readlines()
        else:
            self.urls = self.urls.split("\n")
        s = set()
        s.update(self.urls)
        self.res.clear()
        for url in s:
            self.res.append(url.strip())

    def start_search(self,Authorization="",key="",flag=False,check=None):
        if Authorization =="" or key == "":
            Authorization = self.auth.toPlainText()
            key = self.skey.text()
        if Authorization.strip() !="" and key.strip()!="":
            self.thread = SearchThread(key,Authorization,flag,check)
            self.thread.sinout.connect(self.res.append)
            self.thread.start()
            if flag:
                self.thread.finish.connect(self.doCheck)

        else:
            QtWidgets.QMessageBox.information(self.win,"温馨提示!","Auth or keyworld 不能为空!")
            return
    def doCheck(self,flag):
        if flag:
            self.check(flag)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Fofa下载及网址批量验证"))
        self.label.setText(_translate("MainWindow", " 搜索关键字:"))
        self.label_2.setText(_translate("MainWindow", "<html><head/><body><p><span style=\" font-weight:600; color:#5555ff;\">Authorithon:</span></p></body></html>"))
        self.search_btn.setText(_translate("MainWindow", "搜索"))
        self.clear_btn.setText(_translate("MainWindow", "清除"))
        self.uniq_btn.setText(_translate("MainWindow", "去重"))
        self.check_btn.setText(_translate("MainWindow", "验证"))
        self.quick_btn.setText(_translate("MainWindow", "一键完成"))
        self.label_4.setText(_translate("MainWindow", "<html><head/><body><p><span style=\" font-size:16pt; font-weight:600; color:#00ff00;\">结果显示:</span></p></body></html>"))


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())
工具

手机模拟门禁卡研究

2021-5-28 14:50:59

工具

监测 Github 中新增的 CVE 利用代码

2021-5-29 13:32:16

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索