master
2863616107@qq.com 3 years ago
parent f78b0e613d
commit 53778fd55c

Binary file not shown.

@ -1,42 +0,0 @@
# -*- coding: utf-8 -*-
import os
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from guis.jiemian import *
from guis.jiemian2 import *
from guis.jiemian3 import *
class Window1(QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(Window1, self).__init__(parent)
self.setupUi(self)
self.pushButton_2.clicked.connect(self.w2)
self.pushButton_3.clicked.connect(self.w3)
def w2(self):
self.window2=Window2()
self.window2.show()
def w3(self):
self.window3=Window3(
)
self.window3.show()
class Window2(QMainWindow, Ui_MainWindow2):
def __init__(self, parent=None):
super(Window2, self).__init__(parent)
self.setupUi(self)
class Window3(QMainWindow, Ui_MainWindow3):
def __init__(self, parent=None):
super(Window3, self).__init__(parent)
self.setupUi(self)
if __name__ == '__main__':
QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
app = QApplication(sys.argv)
win = Window1()
win.show()
sys.exit(app.exec_())

@ -0,0 +1,68 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style>
body{ background:#fff; font-family: microsoft yahei; color:#969696; font-size:14px;}
.online-desc-con { text-align:center; }
.r-tip01 { color: #333; font-size: 18px; display: block; text-align: center; width: 500px; padding: 0 10px; overflow: hidden; text-overflow: ellipsis; margin: 0 auto 15px; }
.r-tip02 { color: #585858; font-size: 14px; display: block; margin-top: 20px; margin-bottom: 20px; }
#notice-jiasule {
word-wrap: break-word;
word-break: normal;
color:#585858;
border:1px solid #ddd;
padding:0px 20px 0px 20px
}
img { border: 0; }
.u-ico{ vertical-align: middle; margin-right: 12px;}
.btn{ padding: 8px 22px; border-radius: 3px; border: 0; display: inline-block;vertical-align: middle;text-decoration: none;}
.btn-g{ background-color: #61b25e; color: #fff;}
.report {color: #858585; text-decoration: none;}
.report:hover {text-decoration: underline; color: #0088CC;}
hr{ border-top: 1px dashed #ddd;}
center{ line-height: 48px; color: #919191;}
</style>
<script type="text/template" id="content_tpl">
<span class="r-tip01"><%= error_403 %></span>
<div id='notice-jiasule'>
<p>当前网址:<%- url %></p>
<p>客户端特征:<%- user_agent %></p>
<p>拦截时间:<%- now %>&nbsp;&nbsp;本次事件ID&nbsp;<%- rule_id %></p>
</div>
<span class='r-tip02'>
<img class='u-ico' alt='' src='/cdn-cgi/image/guest.png' />如果您是网站管理员,请登录知道创宇云防御&nbsp;
<a class='btn btn-g' href='http://help.yunaq.com/feedback.html?from=<%- from %>&rule_id=<%- rule_id %>&client_ip=<%- client_ip %>&referrer=<%- ref %>#pus' target='_blank'>查看详情</a>
&nbsp;或者&nbsp;
<a class='report' href='http://help.yunaq.com/feedback.html?from=<%- from %>&rule_id=<%- rule_id %>&client_ip=<%- client_ip %>&referrer=<%- ref %>#hus' target='_blank'>反馈误报</a>
</span>
</script>
<script type="text/javascript" src="/cdn-cgi/js/underscore_min_1.8.3.js"></script>
</head>
<body>
<div class="online-desc-con" style="width:640px;padding-top:15px;margin:34px auto;" >
<img id="wafblock" alt="" style="margin: 0 auto 17px auto;" />
<script type="text/javascript">
var pic = '' || 'hacker';
document.getElementById("wafblock").src = '/cdn-cgi/image/' + pic + '.png';
</script>
<div id="content_rendered"></div>
<hr />
<center>client: 117.136.89.114, server: ff72b00, time: 29/Nov/2021:22:00:44 +0800</center>
</div>
<script>
void(function fuckie6(){if(location.hash && /MSIE 6/.test(navigator.userAgent) && !/jsl_sec/.test(location.href)){location.href = location.href.split('#')[0] + '&jsl_sec' + location.hash}})();
var content = _.template(document.getElementById('content_tpl').innerHTML)({
error_403: '' || '当前访问疑似黑客攻击,已被网站管理员设置为拦截',
url: document.URL.replace(/\</g,"%3C").replace(/\>/g,"%3E"),
user_agent: navigator.userAgent,
now: new Date(new Date() - -8 * 3600000).toISOString().substr(0, 19).replace('T', ' '),
rule_id: parseInt('[80001]'.replace(/\[|\]/g, '')) || '',
from: encodeURIComponent(document.referrer.substr(0, 1024)),
client_ip: '117.136.89.114',
ref: encodeURIComponent(document.URL.substr(0, 1024))
});
document.getElementById('content_rendered').innerHTML = content;
</script>
</body>
</html>

@ -14,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
MainWindow.resize(802, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
@ -37,13 +37,17 @@ class Ui_MainWindow(object):
self.pushButton_3.setMinimumSize(QtCore.QSize(141, 51))
self.pushButton_3.setObjectName("pushButton_3")
self.horizontalLayout.addWidget(self.pushButton_3)
self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_5.setObjectName("pushButton_5")
self.horizontalLayout.addWidget(self.pushButton_5)
self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)
self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
self.textEdit.setMinimumSize(QtCore.QSize(780, 0))
self.textEdit.setObjectName("textEdit")
self.gridLayout.addWidget(self.textEdit, 1, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22))
self.menubar.setGeometry(QtCore.QRect(0, 0, 802, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
@ -59,3 +63,4 @@ class Ui_MainWindow(object):
self.pushButton.setText(_translate("MainWindow", "漏洞信息更新"))
self.pushButton_2.setText(_translate("MainWindow", "漏洞信息检索"))
self.pushButton_3.setText(_translate("MainWindow", "漏洞信息统计"))
self.pushButton_5.setText(_translate("MainWindow", "设置"))

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<width>802</width>
<height>600</height>
</rect>
</property>
@ -82,10 +82,24 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_5">
<property name="text">
<string>设置</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QTextEdit" name="textEdit"/>
<widget class="QTextEdit" name="textEdit">
<property name="minimumSize">
<size>
<width>780</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
@ -94,8 +108,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
<width>802</width>
<height>26</height>
</rect>
</property>
</widget>

@ -14,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow2(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
MainWindow.resize(804, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
@ -24,92 +24,61 @@ class Ui_MainWindow2(object):
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setMinimumSize(QtCore.QSize(71, 41))
self.label.setMaximumSize(QtCore.QSize(16777215, 41))
font = QtGui.QFont()
font.setFamily("宋体")
font.setPointSize(16)
self.label.setFont(font)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setMinimumSize(QtCore.QSize(131, 21))
self.lineEdit.setMaximumSize(QtCore.QSize(16777215, 21))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(16)
self.lineEdit.setFont(font)
self.lineEdit.setObjectName("lineEdit")
self.horizontalLayout.addWidget(self.lineEdit)
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setMinimumSize(QtCore.QSize(111, 41))
self.label_2.setMaximumSize(QtCore.QSize(16777215, 41))
font = QtGui.QFont()
font.setFamily("宋体")
font.setPointSize(16)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.horizontalLayout.addWidget(self.label_2)
self.dateEdit = QtWidgets.QDateEdit(self.centralwidget)
self.dateEdit.setMinimumSize(QtCore.QSize(111, 21))
self.dateEdit.setMaximumSize(QtCore.QSize(16777215, 21))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
self.dateEdit.setFont(font)
self.dateEdit.setCalendarPopup(True)
self.dateEdit.setObjectName("dateEdit")
self.horizontalLayout.addWidget(self.dateEdit)
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setMinimumSize(QtCore.QSize(111, 41))
self.label_3.setMaximumSize(QtCore.QSize(16777215, 41))
font = QtGui.QFont()
font.setFamily("宋体")
font.setPointSize(16)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.horizontalLayout.addWidget(self.label_3)
self.dateEdit_2 = QtWidgets.QDateEdit(self.centralwidget)
self.dateEdit_2.setMinimumSize(QtCore.QSize(111, 21))
self.dateEdit_2.setMaximumSize(QtCore.QSize(16777215, 21))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
self.dateEdit_2.setFont(font)
self.dateEdit_2.setCalendarPopup(True)
self.dateEdit_2.setObjectName("dateEdit_2")
self.horizontalLayout.addWidget(self.dateEdit_2)
self.label_4 = QtWidgets.QLabel(self.centralwidget)
self.label_4.setMinimumSize(QtCore.QSize(102, 41))
font = QtGui.QFont()
font.setFamily("微软雅黑")
font.setBold(True)
font.setWeight(75)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.horizontalLayout.addWidget(self.label_4)
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setObjectName("pushButton")
self.horizontalLayout.addWidget(self.pushButton)
self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)
self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
self.tableWidget.setObjectName("tableWidget")
self.tableWidget.setColumnCount(6)
self.tableWidget.setColumnCount(0)
self.tableWidget.setRowCount(0)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(4, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(5, item)
self.tableWidget.horizontalHeader().setCascadingSectionResizes(False)
self.tableWidget.horizontalHeader().setSortIndicatorShown(False)
self.tableWidget.horizontalHeader().setStretchLastSection(False)
self.gridLayout.addWidget(self.tableWidget, 1, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22))
self.menubar.setGeometry(QtCore.QRect(0, 0, 804, 22))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
@ -125,16 +94,5 @@ class Ui_MainWindow2(object):
self.label.setText(_translate("MainWindow", "编号:"))
self.label_2.setText(_translate("MainWindow", "开始时间:"))
self.label_3.setText(_translate("MainWindow", "结束时间:"))
self.label_4.setText(_translate("MainWindow", "0条"))
item = self.tableWidget.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "漏洞标题"))
item = self.tableWidget.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "危害级别"))
item = self.tableWidget.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "点击数"))
item = self.tableWidget.horizontalHeaderItem(3)
item.setText(_translate("MainWindow", "评论"))
item = self.tableWidget.horizontalHeaderItem(4)
item.setText(_translate("MainWindow", "关注"))
item = self.tableWidget.horizontalHeaderItem(5)
item.setText(_translate("MainWindow", "时间"))
self.label_4.setText(_translate("MainWindow", "0条"))
self.pushButton.setText(_translate("MainWindow", "查找"))

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<width>804</width>
<height>600</height>
</rect>
</property>
@ -180,7 +180,14 @@
</font>
</property>
<property name="text">
<string> 共0条</string>
<string> 共0条</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>查找</string>
</property>
</widget>
</item>
@ -197,36 +204,6 @@
<attribute name="horizontalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>漏洞标题</string>
</property>
</column>
<column>
<property name="text">
<string>危害级别</string>
</property>
</column>
<column>
<property name="text">
<string>点击数</string>
</property>
</column>
<column>
<property name="text">
<string>评论</string>
</property>
</column>
<column>
<property name="text">
<string>关注</string>
</property>
</column>
<column>
<property name="text">
<string>时间</string>
</property>
</column>
</widget>
</item>
</layout>
@ -236,7 +213,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<width>804</width>
<height>22</height>
</rect>
</property>

@ -9,7 +9,7 @@
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtChart import QChartView
class Ui_MainWindow3(object):
def setupUi(self, MainWindow):
@ -67,6 +67,11 @@ class Ui_MainWindow3(object):
self.widget = QtWidgets.QWidget(self.tab)
self.widget.setMinimumSize(QtCore.QSize(731, 461))
self.widget.setObjectName("widget")
self.gridLayout_4 = QtWidgets.QGridLayout(self.widget)
self.gridLayout_4.setObjectName("gridLayout_4")
self.graphicsView = QChartView(self.widget)
self.graphicsView.setObjectName("graphicsView")
self.gridLayout_4.addWidget(self.graphicsView, 0, 0, 1, 1)
self.gridLayout_2.addWidget(self.widget, 1, 0, 1, 1)
self.tabWidget.addTab(self.tab, "")
self.tab_2 = QtWidgets.QWidget()
@ -80,6 +85,9 @@ class Ui_MainWindow3(object):
self.comboBox_2.setMaximumSize(QtCore.QSize(100, 22))
self.comboBox_2.setObjectName("comboBox_2")
self.comboBox_2.addItem("")
self.comboBox_2.addItem("")
self.comboBox_2.addItem("")
self.comboBox_2.addItem("")
self.horizontalLayout_2.addWidget(self.comboBox_2)
self.label_3 = QtWidgets.QLabel(self.tab_2)
self.label_3.setMinimumSize(QtCore.QSize(54, 12))
@ -115,6 +123,11 @@ class Ui_MainWindow3(object):
self.widget_2 = QtWidgets.QWidget(self.tab_2)
self.widget_2.setMinimumSize(QtCore.QSize(731, 461))
self.widget_2.setObjectName("widget_2")
self.gridLayout_5 = QtWidgets.QGridLayout(self.widget_2)
self.gridLayout_5.setObjectName("gridLayout_5")
self.graphicsView_2 = QChartView(self.widget_2)
self.graphicsView_2.setObjectName("graphicsView_2")
self.gridLayout_5.addWidget(self.graphicsView_2, 0, 0, 1, 1)
self.gridLayout_3.addWidget(self.widget_2, 1, 0, 1, 1)
self.tabWidget.addTab(self.tab_2, "")
self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1)
@ -140,7 +153,11 @@ class Ui_MainWindow3(object):
self.pushButton_2.setText(_translate("MainWindow", "查询"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("MainWindow", "漏洞分布"))
self.comboBox_2.setItemText(0, _translate("MainWindow", "全部"))
self.comboBox_2.setItemText(1, _translate("MainWindow", "高危"))
self.comboBox_2.setItemText(2, _translate("MainWindow", "中危"))
self.comboBox_2.setItemText(3, _translate("MainWindow", "低危"))
self.label_3.setText(_translate("MainWindow", "开始时间:"))
self.label_4.setText(_translate("MainWindow", "结束时间:"))
self.pushButton.setText(_translate("MainWindow", "查询"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("MainWindow", "漏洞趋势图"))

@ -159,6 +159,11 @@
<height>461</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QChartView" name="graphicsView"/>
</item>
</layout>
</widget>
</item>
</layout>
@ -189,6 +194,21 @@
<string>全部</string>
</property>
</item>
<item>
<property name="text">
<string>高危</string>
</property>
</item>
<item>
<property name="text">
<string>中危</string>
</property>
</item>
<item>
<property name="text">
<string>低危</string>
</property>
</item>
</widget>
</item>
<item>
@ -302,6 +322,11 @@
<height>461</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QChartView" name="graphicsView_2"/>
</item>
</layout>
</widget>
</item>
</layout>
@ -322,6 +347,13 @@
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<customwidgets>
<customwidget>
<class>QChartView</class>
<extends>QGraphicsView</extends>
<header location="global">qchartview.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'jiemian4.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow4(object):
def setupUi(self, MainWindow4):
MainWindow4.setObjectName("MainWindow4")
MainWindow4.resize(802, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow4)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setMinimumSize(QtCore.QSize(61, 21))
self.label.setMaximumSize(QtCore.QSize(61, 21))
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setMinimumSize(QtCore.QSize(71, 21))
self.lineEdit.setMaximumSize(QtCore.QSize(71, 21))
self.lineEdit.setObjectName("lineEdit")
self.gridLayout.addWidget(self.lineEdit, 0, 1, 1, 1)
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setMinimumSize(QtCore.QSize(61, 28))
self.pushButton.setMaximumSize(QtCore.QSize(61, 28))
self.pushButton.setObjectName("pushButton")
self.gridLayout.addWidget(self.pushButton, 0, 2, 1, 1)
self.progressBar = QtWidgets.QProgressBar(self.centralwidget)
self.progressBar.setProperty("value", 0)
self.progressBar.setObjectName("progressBar")
self.gridLayout.addWidget(self.progressBar, 0, 3, 1, 1)
self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_4.setObjectName("pushButton_4")
self.gridLayout.addWidget(self.pushButton_4, 0, 4, 1, 1)
self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_5.setObjectName("pushButton_5")
self.gridLayout.addWidget(self.pushButton_5, 0, 5, 1, 1)
self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
self.textEdit.setMinimumSize(QtCore.QSize(780, 0))
self.textEdit.setObjectName("textEdit")
self.gridLayout.addWidget(self.textEdit, 1, 0, 1, 6)
MainWindow4.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow4)
self.menubar.setGeometry(QtCore.QRect(0, 0, 802, 26))
self.menubar.setObjectName("menubar")
MainWindow4.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow4)
self.statusbar.setObjectName("statusbar")
MainWindow4.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow4)
QtCore.QMetaObject.connectSlotsByName(MainWindow4)
def retranslateUi(self, MainWindow4):
_translate = QtCore.QCoreApplication.translate
MainWindow4.setWindowTitle(_translate("MainWindow4", "漏洞管理系统"))
self.label.setText(_translate("MainWindow4", "验证码:"))
self.pushButton.setText(_translate("MainWindow4", "确定"))
self.pushButton_4.setText(_translate("MainWindow4", "开始"))
self.pushButton_5.setText(_translate("MainWindow4", "设置"))

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow4</class>
<widget class="QMainWindow" name="MainWindow4">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>802</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>漏洞管理系统</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>61</width>
<height>21</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>61</width>
<height>21</height>
</size>
</property>
<property name="font">
<font>
<family>宋体</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>验证码:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit">
<property name="minimumSize">
<size>
<width>71</width>
<height>21</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>71</width>
<height>21</height>
</size>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton">
<property name="minimumSize">
<size>
<width>61</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>61</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>开始</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="pushButton_5">
<property name="text">
<string>设置</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="6">
<widget class="QTextEdit" name="textEdit">
<property name="minimumSize">
<size>
<width>780</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>802</width>
<height>26</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'jiemian5.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow5(object):
def setupUi(self, MainWindow5):
MainWindow5.setObjectName("MainWindow5")
MainWindow5.resize(659, 714)
self.centralwidget = QtWidgets.QWidget(MainWindow5)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setScaledContents(False)
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
self.tableWidget.setObjectName("tableWidget")
self.tableWidget.setColumnCount(0)
self.tableWidget.setRowCount(0)
self.gridLayout.addWidget(self.tableWidget, 1, 0, 1, 1)
MainWindow5.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow5)
self.menubar.setGeometry(QtCore.QRect(0, 0, 659, 26))
self.menubar.setObjectName("menubar")
MainWindow5.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow5)
self.statusbar.setObjectName("statusbar")
MainWindow5.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow5)
QtCore.QMetaObject.connectSlotsByName(MainWindow5)
def retranslateUi(self, MainWindow5):
_translate = QtCore.QCoreApplication.translate
MainWindow5.setWindowTitle(_translate("MainWindow5", "MainWindow"))
self.label.setText(_translate("MainWindow5", "漏洞名称"))

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow5</class>
<widget class="QMainWindow" name="MainWindow5">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>659</width>
<height>714</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<family>楷体</family>
<pointsize>24</pointsize>
</font>
</property>
<property name="text">
<string>漏洞名称</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QTableWidget" name="tableWidget"/>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>659</width>
<height>26</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

@ -0,0 +1,455 @@
import threading
import requests
from lxml import etree
from PIL import Image
import xlsxwriter
from requests.utils import add_dict_to_cookiejar
import execjs
import hashlib
import json
import re
import time
import random
def get_UserAgents():
UserAgents = [
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AcooBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)",
"Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.5; AOLBuild 4337.35; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
"Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 2.0.50727; Media Center PC 6.0)",
"Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)",
"Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.30)",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 287 c9dfb30)",
"Mozilla/5.0 (X11; U; Linux; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.6",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2pre) Gecko/20070215 K-Ninja/2.1.1",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/20080705 Firefox/3.0 Kapiko/3.0",
"Mozilla/5.0 (X11; Linux i686; U;) Gecko/20070322 Kazehakase/0.4.5",
"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko Fedora/1.9.0.8-1.fc10 Kazehakase/0.5.6",
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.20 (KHTML, like Gecko) Chrome/19.0.1036.7 Safari/535.20",
"Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; fr) Presto/2.9.168 Version/11.52",
"Mozilla/5.0 (Windows; U; Windows NT 5.2) Gecko/2008070208 Firefox/3.0.1",
"Mozilla/5.0 (Windows; U; Windows NT 5.1) Gecko/20070309 Firefox/2.0.0.3",
"Mozilla/5.0 (Windows; U; Windows NT 5.1) Gecko/20070803 Firefox/1.5.0.12",
"Opera/9.27 (Windows NT 5.2; U; zh-cn)",
"Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13",
"Mozilla/5.0 (iPhone; U; CPU like Mac OS X) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 ",
"Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 ",
"Mozilla/5.0 (Linux; U; Android 3.2; ja-jp; F-01D Build/F0001) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13 ",
"Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; ja-jp) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7",
"Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; da-dk) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5 ",
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-US) AppleWebKit/530.9 (KHTML, like Gecko) Chrome/ Safari/530.9 ",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)",
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Ubuntu/11.10 Chromium/27.0.1453.93 Chrome/27.0.1453.93 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36",
"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36"
]
UserAgent = random.choice(UserAgents)
return UserAgent
session = requests.session()
session_ = requests.session()
link_list = []
class myThread(threading.Thread):
def __init__(self, threadID, name, counter, flag):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.counter = counter
self.flag = flag
def run(self):
spider(self.flag)
def get_proxy():
proxy = session_.get("http://127.0.0.1:5010/get/").json().get("proxy")
print(proxy)
return {"http": "http://{}".format(proxy)}
def login(email, password):
response = session.get('https://www.cnvd.org.cn/user/aesEncrypt?password=' + password)
passwd = re.findall(r'"data":"(.*?)\\r\\n"', response.text)[0]
captcha = get_captcha()
session.headers.update({
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Encoding': 'gzip,deflate,br',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0',
'Accept-Language': 'zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4',
'Content-Type': 'application/x-www-form-urlencoded',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
'Host': 'www.cnvd.org.cn',
'Origin': 'https://www.cnvd.org.cn',
'Referer': 'https://www.cnvd.org.cn/user/login',
'Upgrade-Insecure-Requests': '1',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-User': '?1'
})
form = {
'email': email,
'passwordHidden': passwd,
'myCode': captcha
}
r = session.post('https://www.cnvd.org.cn/user/doLogin/loginForm', data=form)
jsl_clearance_s = re.findall(r'cookie=(.*?);location', r.text)[0]
jsl_clearance_s = str(execjs.eval(jsl_clearance_s)).split('=')[1].split(';')[0]
add_dict_to_cookiejar(session.cookies, {'__jsl_clearance_s': jsl_clearance_s})
r = session.post('https://www.cnvd.org.cn/user/doLogin/loginForm', data=form)
data = json.loads(re.findall(r';go\((.*?)\)', r.text)[0])
jsl_clearance_s = get__jsl_clearance_s(data)
add_dict_to_cookiejar(session.cookies, {'__jsl_clearance_s': jsl_clearance_s})
r = session.post('https://www.cnvd.org.cn/user/doLogin/loginForm', data=form)
session.cookies.update(r.cookies)
jsl_clearance_s = re.findall(r'cookie=(.*?);location', r.text)[0]
jsl_clearance_s = str(execjs.eval(jsl_clearance_s))
add_dict_to_cookiejar(session.cookies, {'__jsluid_h': jsl_clearance_s})
r = session.get('https://www.cnvd.org.cn/user/reportManage')
print(r.text)
return 0
def get_captcha():
image = Image.open('captcha.png')
image.show()
captcha = input("验证码:")
return captcha
def get__jsl_clearance_s(data):
"""
通过加密对比得到正确cookie参数
:param data: 参数
:return: 返回正确cookie参数
"""
chars = len(data['chars'])
for i in range(chars):
for j in range(chars):
__jsl_clearance_s = data['bts'][0] + data['chars'][i] + data['chars'][j] + data['bts'][1]
encrypt = None
if data['ha'] == 'md5':
encrypt = hashlib.md5()
elif data['ha'] == 'sha1':
encrypt = hashlib.sha1()
elif data['ha'] == 'sha256':
encrypt = hashlib.sha256()
encrypt.update(__jsl_clearance_s.encode())
result = encrypt.hexdigest()
if result == data['ct']:
return __jsl_clearance_s
def setCookie(url):
response1 = session.get(url)
jsl_clearance_s = re.findall(r'cookie=(.*?);location', response1.text)[0]
jsl_clearance_s = str(execjs.eval(jsl_clearance_s)).split('=')[1].split(';')[0]
add_dict_to_cookiejar(session.cookies, {'__jsl_clearance_s': jsl_clearance_s})
response2 = session.get(url)
data = json.loads(re.findall(r';go\((.*?)\)', response2.text)[0])
jsl_clearance_s = get__jsl_clearance_s(data)
add_dict_to_cookiejar(session.cookies, {'__jsl_clearance_s': jsl_clearance_s})
response3 = session.get(url)
with open('captcha.png', 'wb') as f:
f.write(response3.content)
class CNVD(object):
def __init__(self):
self.host_url = "https://www.cnvd.org.cn"
self.base_url1 = "https://www.cnvd.org.cn/flaw/list?max={}&offset={}"
self.base_url2 = "https://www.cnvd.org.cn/webinfo/list?type=2&max={}&offset={}"
def get_list_page(self, max_page, max, flag):
"""
获取列表页html内容
Arguments: max_page {[int]} -- [最大分页页码]
"""
for page in range(max_page):
print("正在采集第<%s>页" % str(page + 1))
time.sleep(5)
offset = (page) * max
if flag == 1:
url = self.base_url1.format(max, offset)
else:
url = self.base_url2.format(max, offset)
response = session.get(url=url)
time.sleep(3)
content = response.text
yield content
def parse_list_page(self, content):
"""
获取列表页中的详情页href返回href列表
Arguments:
content {[str]} -- [列表页html内容]
Returns:
[list] -- [详情页href列表]
"""
html = etree.HTML(content)
href_list = html.xpath("//tbody/tr/td//a/@href")
return href_list
def handle_str(self, td_list):
"""
字符串去除空格\r\n\t等字符
Arguments:
td_list {[list]} -- [获取文本的列表]
Returns:
[type] -- [返回处理后的合并文本]
"""
result = ''
for td_str in td_list[1:]:
result += td_str.strip()
result = "".join(result.split())
# 去除"危害级别"中的括号
if result.endswith("()"):
result = result[:-2]
return result
def parse_detail_page1(self, content):
"""
从详情页中提取信息
Arguments:
content {[str]} -- [详情页html内容]
Returns:
[dict] -- [提取信息字典]
"""
html = etree.HTML(content)
# print(content)
item = {}
if "请检查您的操作是否正确!您访问的资源不存在或已被删除" in content:
return item
# print(html.xpath("//div[@class='blkContainerPblk']//div[@class='blkContainerSblk']//h1/text()")[0])
item['漏洞名称'] = '' if len(
html.xpath("//div[@class='blkContainerPblk']//div[@class='blkContainerSblk']//h1/text()")) == 0 else \
html.xpath("//div[@class='blkContainerPblk']//div[@class='blkContainerSblk']//h1/text()")[0]
tr_list = html.xpath("//div[@class='tableDiv']//table[@class='gg_detail']//tbody/tr")
# print(tr_list)
tr_list.pop(-1)
for tr in tr_list:
td_list = tr.xpath("./td/text()|./td/a/text()")
item[td_list[0]] = self.handle_str(td_list)
# print(item)
return item
def parse_detail_page2(self, content):
"""
从爬取到的一条新闻页中提取具体的新闻内容
Arguments:
content {[str]} -- [详情页html内容]
Returns:
[dict] -- [提取信息字典]
"""
html = etree.HTML(content)
item = {}
item['新闻标题'] = '' if len(
html.xpath("//div[@class='blkContainer']//div[@class='blkContainerSblk']/h1/text()")) == 0 else \
html.xpath("//div[@class='blkContainer']//div[@class='blkContainerSblk']/h1/text()")[0]
item['发布时间'] = '' if len(html.xpath(
"//div[@class='blkContainer']//div[@class='blkContainerSblk']//div[@ class='artInfo']/text()")) == 0 else \
html.xpath("//div[@class='blkContainer']//div[@class='blkContainerSblk']//div[@ class='artInfo']/text()")[0]
tmp_str = '' if len(html.xpath(
"//div[@class='blkContainer']//div[@class='blkContainerSblk']//div [@ class='blkContainerSblkCon clearfix']/p/text()")) == 0 else \
html.xpath(
"//div [@ class='blkContainerSblkCon clearfix']/p/text() | //div[@class='blkContainerSblkCon clearfix']/p/span/text()")
# print(self.handle_str(tmp_str)[:-5])
item['新闻内容'] = self.handle_str(tmp_str)[:-5]
tr_list = html.xpath("//div[@class='blkContainer']//div[@class='blkContainerSblk']")
for tr in tr_list:
td_list = tr.xpath(
"./div[@class='blkContainerSblkCon clearfix']/p/text()|./div[@class='blkContainerSblkCon clearfix']/p/a//text()")
# print(td_list)
if '参考链接:' in td_list[-1]:
item['参考链接'] = td_list[-1][5:]
item['新闻内容'] = td_list[0]
elif '参考链接:' in td_list:
item['新闻内容'] = td_list[0]
item['参考链接'] = td_list[-1]
else:
item['参考链接'] = td_list[-1]
# print(item)
return item
def get_detail_info(self, href, flag):
"""
通过详情页href获取详情页html内容
Arguments:
href {[str]} -- [详情页href]
Returns:
[调用详情页解析函数] -- [提取信息]
"""
url = self.host_url + href
print("正在采集详情页<%s>" % url)
if url == "https://www.cnvd.org.cn/flaw/show/":
return {}
__session = requests.session()
headers = {'User-Agent': get_UserAgents()}
try:
proxy = get_proxy()
response1 = __session.get(url=url, headers=headers, proxies=proxy)
except:
response1 = __session.get(url=url, headers=headers)
jsl_clearance_s = re.findall(r'cookie=(.*?);location', response1.text)[0]
jsl_clearance_s = str(execjs.eval(jsl_clearance_s)).split('=')[1].split(';')[0]
add_dict_to_cookiejar(__session.cookies, {'__jsl_clearance_s': jsl_clearance_s})
try:
response2 = __session.get(url=url, headers=headers, proxies=proxy)
except:
response2 = __session.get(url=url, headers=headers)
data = json.loads(re.findall(r';go\((.*?)\)', response2.text)[0])
jsl_clearance_s = get__jsl_clearance_s(data)
add_dict_to_cookiejar(__session.cookies, {'__jsl_clearance_s': jsl_clearance_s})
try:
response = __session.get(url=url, headers=headers, proxies=proxy)
except:
response = __session.get(url=url, headers=headers)
while "您访问频率太高,请稍候再试。" in response.content.decode():
time.sleep(3)
__session.close()
return self.get_detail_info(href, flag)
print(response.content.decode())
try:
response = __session.get(url=url, headers=headers, proxies=proxy)
except:
response = __session.get(url=url, headers=headers)
time.sleep(1)
__session.close()
if flag == 1:
return self.parse_detail_page1(response.content.decode())
elif flag == 2:
return self.parse_detail_page2(response.content.decode())
def vulnerability_xlsx1(vlist):
workbook = xlsxwriter.Workbook('vulnerabilities_data1.xlsx')
worksheet = workbook.add_worksheet()
column_names = ['漏洞名称', 'CNVD-ID', '公开日期', '危害级别', 'CVE ID', '漏洞描述', '漏洞类型', '参考链接', '厂商补丁', '来源链接', '影响产品']
for i in range(len(column_names)):
worksheet.write(0, i, column_names[i])
for i in range(len(vlist)):
for j in range(len(column_names)):
worksheet.write(i + 1, j, vlist[i][column_names[j]] if column_names[j] in vlist[i].keys() else '')
workbook.close()
def vulnerability_xlsx2(vlist):
workbook = xlsxwriter.Workbook('vulnerabilities_data2.xlsx')
worksheet = workbook.add_worksheet()
column0_names = ['新闻标题', '发布时间', '新闻内容', '参考链接']
for i in range(len(column0_names)):
worksheet.write(0, i, column0_names[i])
for i in range(len(vlist)):
for j in range(len(column0_names)):
worksheet.write(i + 1, j, vlist[i][column0_names[j]] if column0_names[j] in vlist[i].keys() else '')
workbook.close()
def spider(flag):
if flag == 1:
spider1()
elif flag == 2:
spider2()
def spider1():
vlist = []
cnvd = CNVD()
max_page = 10
max = 100
content_generator = cnvd.get_list_page(max_page, max, 1)
tmp = []
for content in content_generator:
href_list = cnvd.parse_list_page(content)
for href in href_list:
link_list.append(href)
item = cnvd.get_detail_info(href, 1)
vlist.append(item)
vulnerability_xlsx1(vlist)
def spider2():
vlist = []
cnvd = CNVD()
max_page = 1
max = 10
content_generator = cnvd.get_list_page(max_page, max, 2)
for content in content_generator:
href_list = cnvd.parse_list_page(content)
for href in href_list:
item = cnvd.get_detail_info(href, 2)
vlist.append(item)
vulnerability_xlsx2(vlist)
def check_new():
cnvd = CNVD()
max_page = 10
max = 100
content_generator = cnvd.get_list_page(max_page, max, 1)
for content in content_generator:
href_list = cnvd.parse_list_page(content)
# print(href_list)
if href_list[0] not in link_list:
return True
else:
return False
def pachon():
setCookie('https://www.cnvd.org.cn/common/myCodeNew')
login('lijieshi18@163.com', 'ig-srd8C24jPMgk')
threads = []
# 创建新线程
thread1 = myThread(1, "Thread-1", 1, 1)
thread2 = myThread(2, "Thread-2", 2, 2)
# 开启新线程
thread1.start()
thread2.start()
# 添加线程到线程列表
threads.append(thread1)
threads.append(thread2)
# 等待所有线程完成
for t in threads:
t.join()
while 1:
time.sleep(3600)
if check_new():
thread1 = myThread(1, "Thread-1", 1, 1)
thread2 = myThread(2, "Thread-2", 2, 2)
thread1.start()
thread2.start()
threads.append(thread1)
for t in threads:
t.join()
if __name__ == "__main__":
pachon()

@ -0,0 +1,818 @@
# -*- coding: utf-8 -*-
import os
import sys
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtChart import QChart, QChartView, QPieSeries, QPieSlice,QLineSeries
from PyQt5.QtGui import QPainter, QPen
from PyQt5.QtCore import Qt
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtChart import *
import xlwt
import xlrd
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from guis.jiemian import *
from guis.jiemian2 import *
from guis.jiemian3 import *
from guis.jiemian4 import *
from guis.jiemian5 import *
from pythonProject.main import pachon
import time
import sys
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtCore import QThread
import threading
import requests
from lxml import etree
from PIL import Image
import xlsxwriter
from requests.utils import add_dict_to_cookiejar
import execjs
import hashlib
import json
import re
import time
import random
def get_UserAgents():
UserAgents = [
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AcooBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)",
"Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.5; AOLBuild 4337.35; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
"Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 2.0.50727; Media Center PC 6.0)",
"Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)",
"Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.30)",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 287 c9dfb30)",
"Mozilla/5.0 (X11; U; Linux; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.6",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2pre) Gecko/20070215 K-Ninja/2.1.1",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/20080705 Firefox/3.0 Kapiko/3.0",
"Mozilla/5.0 (X11; Linux i686; U;) Gecko/20070322 Kazehakase/0.4.5",
"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko Fedora/1.9.0.8-1.fc10 Kazehakase/0.5.6",
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.20 (KHTML, like Gecko) Chrome/19.0.1036.7 Safari/535.20",
"Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; fr) Presto/2.9.168 Version/11.52",
"Mozilla/5.0 (Windows; U; Windows NT 5.2) Gecko/2008070208 Firefox/3.0.1",
"Mozilla/5.0 (Windows; U; Windows NT 5.1) Gecko/20070309 Firefox/2.0.0.3",
"Mozilla/5.0 (Windows; U; Windows NT 5.1) Gecko/20070803 Firefox/1.5.0.12",
"Opera/9.27 (Windows NT 5.2; U; zh-cn)",
"Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13",
"Mozilla/5.0 (iPhone; U; CPU like Mac OS X) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 ",
"Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 ",
"Mozilla/5.0 (Linux; U; Android 3.2; ja-jp; F-01D Build/F0001) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13 ",
"Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; ja-jp) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7",
"Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; da-dk) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5 ",
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-US) AppleWebKit/530.9 (KHTML, like Gecko) Chrome/ Safari/530.9 ",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)",
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Ubuntu/11.10 Chromium/27.0.1453.93 Chrome/27.0.1453.93 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36",
"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36"
]
UserAgent = random.choice(UserAgents)
return UserAgent
session = requests.session()
session_ = requests.session()
link_list = []
class myThread(threading.Thread):
def __init__(self, threadID, name, counter, flag):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.counter = counter
self.flag = flag
def run(self):
spider(self.flag)
def get_proxy():
proxy = session_.get("http://127.0.0.1:5010/get/").json().get("proxy")
print(proxy)
return {"http": "http://{}".format(proxy)}
def login(email, password):
response = session.get('https://www.cnvd.org.cn/user/aesEncrypt?password=' + password)
passwd = re.findall(r'"data":"(.*?)\\r\\n"', response.text)[0]
captcha = get_captcha()
session.headers.update({
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Encoding': 'gzip,deflate,br',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0',
'Accept-Language': 'zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4',
'Content-Type': 'application/x-www-form-urlencoded',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
'Host': 'www.cnvd.org.cn',
'Origin': 'https://www.cnvd.org.cn',
'Referer': 'https://www.cnvd.org.cn/user/login',
'Upgrade-Insecure-Requests': '1',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-User': '?1'
})
form = {
'email': email,
'passwordHidden': passwd,
'myCode': captcha
}
r = session.post('https://www.cnvd.org.cn/user/doLogin/loginForm', data=form)
jsl_clearance_s = re.findall(r'cookie=(.*?);location', r.text)[0]
jsl_clearance_s = str(execjs.eval(jsl_clearance_s)).split('=')[1].split(';')[0]
add_dict_to_cookiejar(session.cookies, {'__jsl_clearance_s': jsl_clearance_s})
r = session.post('https://www.cnvd.org.cn/user/doLogin/loginForm', data=form)
data = json.loads(re.findall(r';go\((.*?)\)', r.text)[0])
jsl_clearance_s = get__jsl_clearance_s(data)
add_dict_to_cookiejar(session.cookies, {'__jsl_clearance_s': jsl_clearance_s})
r = session.post('https://www.cnvd.org.cn/user/doLogin/loginForm', data=form)
session.cookies.update(r.cookies)
jsl_clearance_s = re.findall(r'cookie=(.*?);location', r.text)[0]
jsl_clearance_s = str(execjs.eval(jsl_clearance_s))
add_dict_to_cookiejar(session.cookies, {'__jsluid_h': jsl_clearance_s})
r = session.get('https://www.cnvd.org.cn/user/reportManage')
print(r.text)
return 0
def get_captcha():
image = Image.open('captcha.png')
image.show()
captcha = input("验证码:")
return captcha
def get__jsl_clearance_s(data):
"""
通过加密对比得到正确cookie参数
:param data: 参数
:return: 返回正确cookie参数
"""
chars = len(data['chars'])
for i in range(chars):
for j in range(chars):
__jsl_clearance_s = data['bts'][0] + data['chars'][i] + data['chars'][j] + data['bts'][1]
encrypt = None
if data['ha'] == 'md5':
encrypt = hashlib.md5()
elif data['ha'] == 'sha1':
encrypt = hashlib.sha1()
elif data['ha'] == 'sha256':
encrypt = hashlib.sha256()
encrypt.update(__jsl_clearance_s.encode())
result = encrypt.hexdigest()
if result == data['ct']:
return __jsl_clearance_s
def setCookie(url):
response1 = session.get(url)
jsl_clearance_s = re.findall(r'cookie=(.*?);location', response1.text)[0]
jsl_clearance_s = str(execjs.eval(jsl_clearance_s)).split('=')[1].split(';')[0]
add_dict_to_cookiejar(session.cookies, {'__jsl_clearance_s': jsl_clearance_s})
response2 = session.get(url)
data = json.loads(re.findall(r';go\((.*?)\)', response2.text)[0])
jsl_clearance_s = get__jsl_clearance_s(data)
add_dict_to_cookiejar(session.cookies, {'__jsl_clearance_s': jsl_clearance_s})
response3 = session.get(url)
with open('captcha.png', 'wb') as f:
f.write(response3.content)
class CNVD(object):
def __init__(self):
self.host_url = "https://www.cnvd.org.cn"
self.base_url1 = "https://www.cnvd.org.cn/flaw/list?max={}&offset={}"
self.base_url2 = "https://www.cnvd.org.cn/webinfo/list?type=2&max={}&offset={}"
def get_list_page(self, max_page, max, flag):
"""
获取列表页html内容
Arguments: max_page {[int]} -- [最大分页页码]
"""
for page in range(max_page):
print("正在采集第<%s>页" % str(page + 1))
time.sleep(5)
offset = (page) * max
if flag == 1:
url = self.base_url1.format(max, offset)
else:
url = self.base_url2.format(max, offset)
response = session.get(url=url)
time.sleep(3)
content = response.text
yield content
def parse_list_page(self, content):
"""
获取列表页中的详情页href返回href列表
Arguments:
content {[str]} -- [列表页html内容]
Returns:
[list] -- [详情页href列表]
"""
html = etree.HTML(content)
href_list = html.xpath("//tbody/tr/td//a/@href")
return href_list
def handle_str(self, td_list):
"""
字符串去除空格\r\n\t等字符
Arguments:
td_list {[list]} -- [获取文本的列表]
Returns:
[type] -- [返回处理后的合并文本]
"""
result = ''
for td_str in td_list[1:]:
result += td_str.strip()
result = "".join(result.split())
# 去除"危害级别"中的括号
if result.endswith("()"):
result = result[:-2]
return result
def parse_detail_page1(self, content):
"""
从详情页中提取信息
Arguments:
content {[str]} -- [详情页html内容]
Returns:
[dict] -- [提取信息字典]
"""
html = etree.HTML(content)
# print(content)
item = {}
if "请检查您的操作是否正确!您访问的资源不存在或已被删除" in content:
return item
# print(html.xpath("//div[@class='blkContainerPblk']//div[@class='blkContainerSblk']//h1/text()")[0])
item['漏洞名称'] = '' if len(
html.xpath("//div[@class='blkContainerPblk']//div[@class='blkContainerSblk']//h1/text()")) == 0 else \
html.xpath("//div[@class='blkContainerPblk']//div[@class='blkContainerSblk']//h1/text()")[0]
tr_list = html.xpath("//div[@class='tableDiv']//table[@class='gg_detail']//tbody/tr")
# print(tr_list)
tr_list.pop(-1)
for tr in tr_list:
td_list = tr.xpath("./td/text()|./td/a/text()")
item[td_list[0]] = self.handle_str(td_list)
# print(item)
return item
def parse_detail_page2(self, content):
"""
从爬取到的一条新闻页中提取具体的新闻内容
Arguments:
content {[str]} -- [详情页html内容]
Returns:
[dict] -- [提取信息字典]
"""
html = etree.HTML(content)
item = {}
item['新闻标题'] = '' if len(
html.xpath("//div[@class='blkContainer']//div[@class='blkContainerSblk']/h1/text()")) == 0 else \
html.xpath("//div[@class='blkContainer']//div[@class='blkContainerSblk']/h1/text()")[0]
item['发布时间'] = '' if len(html.xpath(
"//div[@class='blkContainer']//div[@class='blkContainerSblk']//div[@ class='artInfo']/text()")) == 0 else \
html.xpath("//div[@class='blkContainer']//div[@class='blkContainerSblk']//div[@ class='artInfo']/text()")[0]
tmp_str = '' if len(html.xpath(
"//div[@class='blkContainer']//div[@class='blkContainerSblk']//div [@ class='blkContainerSblkCon clearfix']/p/text()")) == 0 else \
html.xpath(
"//div [@ class='blkContainerSblkCon clearfix']/p/text() | //div[@class='blkContainerSblkCon clearfix']/p/span/text()")
# print(self.handle_str(tmp_str)[:-5])
item['新闻内容'] = self.handle_str(tmp_str)[:-5]
tr_list = html.xpath("//div[@class='blkContainer']//div[@class='blkContainerSblk']")
for tr in tr_list:
td_list = tr.xpath(
"./div[@class='blkContainerSblkCon clearfix']/p/text()|./div[@class='blkContainerSblkCon clearfix']/p/a//text()")
# print(td_list)
if '参考链接:' in td_list[-1]:
item['参考链接'] = td_list[-1][5:]
item['新闻内容'] = td_list[0]
elif '参考链接:' in td_list:
item['新闻内容'] = td_list[0]
item['参考链接'] = td_list[-1]
else:
item['参考链接'] = td_list[-1]
# print(item)
return item
def get_detail_info(self, href, flag):
"""
通过详情页href获取详情页html内容
Arguments:
href {[str]} -- [详情页href]
Returns:
[调用详情页解析函数] -- [提取信息]
"""
url = self.host_url + href
print("正在采集详情页<%s>" % url)
if url == "https://www.cnvd.org.cn/flaw/show/":
return {}
__session = requests.session()
headers = {'User-Agent': get_UserAgents()}
try:
proxy = get_proxy()
response1 = __session.get(url=url, headers=headers, proxies=proxy)
except:
response1 = __session.get(url=url, headers=headers)
jsl_clearance_s = re.findall(r'cookie=(.*?);location', response1.text)[0]
jsl_clearance_s = str(execjs.eval(jsl_clearance_s)).split('=')[1].split(';')[0]
add_dict_to_cookiejar(__session.cookies, {'__jsl_clearance_s': jsl_clearance_s})
try:
response2 = __session.get(url=url, headers=headers, proxies=proxy)
except:
response2 = __session.get(url=url, headers=headers)
data = json.loads(re.findall(r';go\((.*?)\)', response2.text)[0])
jsl_clearance_s = get__jsl_clearance_s(data)
add_dict_to_cookiejar(__session.cookies, {'__jsl_clearance_s': jsl_clearance_s})
try:
response = __session.get(url=url, headers=headers, proxies=proxy)
except:
response = __session.get(url=url, headers=headers)
while "您访问频率太高,请稍候再试。" in response.content.decode():
time.sleep(3)
__session.close()
return self.get_detail_info(href, flag)
print(response.content.decode())
try:
response = __session.get(url=url, headers=headers, proxies=proxy)
except:
response = __session.get(url=url, headers=headers)
time.sleep(1)
__session.close()
if flag == 1:
return self.parse_detail_page1(response.content.decode())
elif flag == 2:
return self.parse_detail_page2(response.content.decode())
def vulnerability_xlsx1(vlist):
workbook = xlsxwriter.Workbook('vulnerabilities_data1.xlsx')
worksheet = workbook.add_worksheet()
column_names = ['漏洞名称', 'CNVD-ID', '公开日期', '危害级别', 'CVE ID', '漏洞描述', '漏洞类型', '参考链接', '厂商补丁', '来源链接', '影响产品']
for i in range(len(column_names)):
worksheet.write(0, i, column_names[i])
for i in range(len(vlist)):
for j in range(len(column_names)):
worksheet.write(i + 1, j, vlist[i][column_names[j]] if column_names[j] in vlist[i].keys() else '')
workbook.close()
def vulnerability_xlsx2(vlist):
workbook = xlsxwriter.Workbook('vulnerabilities_data2.xlsx')
worksheet = workbook.add_worksheet()
column0_names = ['新闻标题', '发布时间', '新闻内容', '参考链接']
for i in range(len(column0_names)):
worksheet.write(0, i, column0_names[i])
for i in range(len(vlist)):
for j in range(len(column0_names)):
worksheet.write(i + 1, j, vlist[i][column0_names[j]] if column0_names[j] in vlist[i].keys() else '')
workbook.close()
def spider(flag):
if flag == 1:
spider1()
elif flag == 2:
spider2()
def spider1():
vlist = []
cnvd = CNVD()
max_page = 10
max = 100
content_generator = cnvd.get_list_page(max_page, max, 1)
tmp = []
for content in content_generator:
href_list = cnvd.parse_list_page(content)
for href in href_list:
link_list.append(href)
item = cnvd.get_detail_info(href, 1)
vlist.append(item)
vulnerability_xlsx1(vlist)
def spider2():
vlist = []
cnvd = CNVD()
max_page = 1
max = 10
content_generator = cnvd.get_list_page(max_page, max, 2)
for content in content_generator:
href_list = cnvd.parse_list_page(content)
for href in href_list:
item = cnvd.get_detail_info(href, 2)
vlist.append(item)
vulnerability_xlsx2(vlist)
def check_new():
cnvd = CNVD()
max_page = 10
max = 100
content_generator = cnvd.get_list_page(max_page, max, 1)
for content in content_generator:
href_list = cnvd.parse_list_page(content)
# print(href_list)
if href_list[0] not in link_list:
return True
else:
return False
def pachon():
setCookie('https://www.cnvd.org.cn/common/myCodeNew')
login('lijieshi18@163.com', 'ig-srd8C24jPMgk')
threads = []
# 创建新线程
thread1 = myThread(1, "Thread-1", 1, 1)
thread2 = myThread(2, "Thread-2", 2, 2)
# 开启新线程
thread1.start()
thread2.start()
# 添加线程到线程列表
threads.append(thread1)
threads.append(thread2)
# 等待所有线程完成
for t in threads:
t.join()
while 1:
time.sleep(3600)
if check_new():
thread1 = myThread(1, "Thread-1", 1, 1)
thread2 = myThread(2, "Thread-2", 2, 2)
thread1.start()
thread2.start()
threads.append(thread1)
for t in threads:
t.join()
class One_Thread(QThread):
"""
多线程应用:开启多线程在主界面调用线程开启主界面的函数放卡死
"""
signal = QtCore.pyqtSignal(str) # str int 都可以
# *args:列表参数**kwargs:字典参数
def __init__(self, *args, **kwargs):
super(One_Thread, self).__init__()
self.main_win = kwargs.get('main_win') # 获取主函数对象
self.signal.connect(self.refresh) # 调用返回的数据
def run(self):
pachon()
def refresh(self, m):
self.main_win.line_edit.setText(str(m))
class Window1(QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(Window1, self).__init__(parent)
self.setupUi(self)
self.textEdit.append('>>欢迎使用本系统')
self.pushButton.clicked.connect(self.w1)
self.pushButton_2.clicked.connect(self.w2)
self.pushButton_3.clicked.connect(self.w3)
self.pushButton_5.clicked.connect(self.setting_time)
def setting_time(self):
#设置时间
value, ok = QInputDialog.getText(self, "输入更新时间", "时间00:00\n\n请输入时间:", QLineEdit.Normal, "00:00")
def w1(self):
self.window1 = Window4()
self.window1.show()
def w2(self):
self.window2=Window2()
self.window2.show()
def w3(self):
self.window3=Window3(
)
self.window3.show()
def read_excel(path):
#读取excel
datas = []
workBook = xlrd.open_workbook(path)
sheet = workBook.sheet_by_index(0)
for i in range(sheet.nrows):
data = []
for j in range(sheet.ncols):
data.append(sheet.cell(i,j).value)
datas.append(data)
return datas
def write_excel(datas,file_name):
"""将数据保存在excel中"""
try:
# todo 创建excel文件
xl = xlwt.Workbook()
# todo 添加sheet
sheet = xl.add_sheet('sheet1')
datas = datas
for i in range(0,len(datas)):
for j in range(len(datas[0])):
try:
sheet.write(i,j,str(datas[i][j]))
except Exception as e:
print(e)
else:
continue
# todo 关闭文件
xl.save(r'{}{}.xls'.format(file_name,str(time.strftime("%Y%m%d%H%M%S", time.localtime()))))
except Exception as e:
pass
class Window2(QMainWindow, Ui_MainWindow2):
def __init__(self, parent=None):
super(Window2, self).__init__(parent)
self.setupUi(self)
self.dateEdit.setDate(QDate.currentDate())
self.dateEdit_2.setDate(QDate.currentDate())
self.tableWidget.setSelectionBehavior(QAbstractItemView.SelectRows)
self.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers) # 禁止编辑
self.tableWidget.doubleClicked.connect(self.show_one)
self.get_data()
self.pushButton.clicked.connect(self.search)
def show_one(self):
#显示数据
data = self.datas[self.tableWidget.selectionModel().selection().indexes()[0].row() + 1]
self.w = Window5()
self.w.get_data(data)
self.w.show()
def get_data(self):
excel_list = []
for a,b,c in os.walk('pythonProject'):
for i in c:
if 'data' in i or 'xl' in i:
excel_list.append(i)
break
self.datas = read_excel(os.path.join('pythonProject',excel_list[-1]))
def search(self):
new_data1 = []
title = self.datas[0]
id = self.lineEdit.text()
if id != '':
for i in self.datas[1:]:
if id in i:
new_data1.append(i)
else:
new_data1 = self.datas[1:]
date1 = self.dateEdit.date().toString(Qt.ISODate).replace('-','')
date2 = self.dateEdit_2.date().toString(Qt.ISODate).replace('-','')
new_data2 = []
if date1 == date2:
new_data2 = new_data1
else:
for i in new_data1:
nd = i[2].replace('-' ,'')
if nd <= date2 and nd >= date1:
new_data2.append(i)
tbale_datas = new_data2
self.tableWidget.setColumnCount(len(title)) # 设置好列数
self.tableWidget.setHorizontalHeaderLabels(title)
row = len(tbale_datas)
self.tableWidget.setRowCount(row) # 设置好行数
self.tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
try:
for i in range(0,row):
for j in range(len(title)):
S = QTableWidgetItem(str(tbale_datas[i][j]))
S.setTextAlignment(Qt.AlignCenter) # 居中显示
self.tableWidget.setItem(i, j, S)
except Exception as e:
print(e)
class Window3(QMainWindow, Ui_MainWindow3):
def __init__(self, parent=None):
super(Window3, self).__init__(parent)
self.setupUi(self)
self.dateEdit.setDate(QDate.currentDate())
self.dateEdit_2.setDate(QDate.currentDate())
self.dateEdit_3.setDate(QDate.currentDate())
self.dateEdit_4.setDate(QDate.currentDate())
self.pushButton_2.clicked.connect(self.search1)
self.pushButton.clicked.connect(self.search2)
self.get_datas()
def get_datas(self):
#获取数据
self.datas = read_excel('数据.xlsx')
def search1(self):
#饼图
date1 = self.dateEdit.date().toString(Qt.ISODate).replace('-', '')
date2 = self.dateEdit_2.date().toString(Qt.ISODate).replace('-', '')
data = {}
for i in self.datas[1:]:
if date1 != date2:
da = (i[3] + '00').replace('-', '')
if da>date2 or da<date1:
continue
if i[0] not in data:
data[i[0]] = 1
else:
data[i[0]] += 1
series = QPieSeries()
for k,v in data.items():
series.append(k, int(v))
for i in range(len(data.keys())):
slice = series.slices()[i]
slice.setLabelVisible(True) # 标注
chart = QChart()
# QLegend类是显示图表的图例先隐藏掉
chart.legend().hide()
chart.addSeries(series)
# chart.addSeries(self.series_1)
chart.createDefaultAxes()
# 设置动画效果
chart.setAnimationOptions(QChart.SeriesAnimations)
# 设置标题
chart.setTitle("漏洞分布")
chart.legend().setVisible(True)
# 对齐方式
chart.legend().setAlignment(Qt.AlignBottom)
# 创建ChartView它是显示图表的控件
self.graphicsView.setChart(chart)
self.graphicsView.setRenderHint(QPainter.Antialiasing)
def search2(self):
#柱状图
date1 = self.dateEdit_3.date().toString(Qt.ISODate).replace('-', '')
date2 = self.dateEdit_4.date().toString(Qt.ISODate).replace('-', '')
flag = self.comboBox_2.currentText()
data = {}
for i in self.datas[1:]:
if flag != '全部':
if i[4] not in flag:
continue
if date1 != date2:
da = (i[3] + '00').replace('-', '')
if da>date2 or da<date1:
continue
if i[3] not in data:
data[i[3]] = 1
else:
data[i[3]] += 1
categories = list(data.keys())
categories.sort()
X = [int(data[i]) for i in categories ]
set0 = QBarSet("漏洞趋势图")
for x in X:
set0.append(x)
set0.setBrush(Qt.red)
series = QBarSeries()
series.append(set0)
series.setLabelsPosition(QAbstractBarSeries.LabelsInsideEnd)
series.setLabelsVisible(True)
# create chart and add the series in the chart
chart = QChart()
chart.addSeries(series)
chart.setTitle("漏洞趋势图")
chart.setAnimationOptions(QChart.SeriesAnimations)
axis = QBarCategoryAxis()
axis.append(categories)
chart.createDefaultAxes()
chart.setAxisX(axis, series)
#折线图
self.series_1 = QLineSeries() # 定义LineSerise将类QLineSeries实例化
for i in categories:
self.series_1.append(categories.index(i)+1, int(data[i])) # 折线添加坐标点清单
self.series_1.setName("漏洞趋势图折线") # 折线命名
chart.addSeries(self.series_1)
self.graphicsView_2.setChart(chart)
self.graphicsView_2.setRenderHint(QPainter.Antialiasing)
class Window4(QMainWindow, Ui_MainWindow4):
def __init__(self, parent=None):
super(Window4, self).__init__(parent)
self.setupUi(self)
self.pushButton_4.clicked.connect(self.get_datas)
self.pushButton_5.clicked.connect(self.setting_time)
def setting_time(self):
# 设置时间
value, ok = QInputDialog.getText(self, "输入更新时间", "时间00:00\n\n请输入时间:", QLineEdit.Normal, "00:00")
def get_datas(self):
#获取数据爬虫
if self.pushButton_4.text() == '开始':
self.pushButton_4.setText('停止')
self.start_thread()
else:
self.pushButton_4.setText('开始')
# self.stop_thread()
def start_thread(self):
# 开始cma线程
try:
self.p = One_Thread(main_win=self) # 把主函数对象传给服务,方便服务操作控件
self.p.start()
self.p.signal.connect(self.func) # 调用返回的数据
except Exception as e:
print(e)
def func(self, data):
print(data)
def stop_thread(self):
try:
self.p.terminate()
self.p.wait()
QtWidgets.QMessageBox.warning(self, '提示', "爬虫停止!", buttons=QtWidgets.QMessageBox.Ok)
except:
pass
class Window5(QMainWindow, Ui_MainWindow5):
def __init__(self, parent=None):
super(Window5, self).__init__(parent)
self.setupUi(self)
def get_data(self,data):
column_names = ['漏洞名称', 'CNVD-ID', '公开日期', '危害级别', 'CVE ID', '漏洞描述', '漏洞类型', '参考链接', '厂商补丁', '来源链接', '影响产品']
datas = data
self.label.setText(datas[0])
self.data = []
for x,y in zip(column_names,datas):
self.data.append([x,y])
row = len(self.data)
col = len(self.data[0])
self.tableWidget.setRowCount(row) # 设置好行数
self.tableWidget.setColumnCount(col) # 设置好列数
self.tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.tableWidget.verticalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.tableWidget.verticalHeader().setVisible(False) # 隐藏垂直表头
self.tableWidget.horizontalHeader().setVisible(False) # 隐藏水平表头
for i in range(row):
for j in range(col):
S = QTableWidgetItem(self.data[i][j])
S.setTextAlignment(QtCore.Qt.AlignCenter) # 居中显示
self.tableWidget.setItem(i, j, S)
print(self.data)
if __name__ == '__main__':
QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
app = QApplication(sys.argv)
win = Window1()
win.show()
sys.exit(app.exec_())
Loading…
Cancel
Save