ADD file via upload

master
pypksu3iv 3 years ago
parent 4342d761e3
commit 1d5dc4cd89

357
ui2.py

@ -0,0 +1,357 @@
# coding=utf-8
import sys
from PyQt5 import QtCore
from PyQt5.QtCore import *
from PyQt5.QtWidgets import QWidget, QFrame, QCheckBox, QLineEdit, QLabel, QPushButton, QTextBrowser, QTableWidget, \
QAbstractItemView, QTableWidgetItem, QMenuBar, QStatusBar, QApplication, QMainWindow
# mysql模块
import pymysql
import pygal
from fuzzywuzzy import fuzz, process
import re
import os
from PyQt5.QtWidgets import QApplication, QMainWindow
import sys
from PyQt5.QtChart import QChart, QChartView, QPieSeries, QPieSlice
from PyQt5.QtGui import QPainter, QPen
from PyQt5.QtCore import Qt
from PyQt5 import QtGui
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
self.conn = pymysql.connect(host='124.222.200.220', port=3306, user='root', password='Fei1912760', db='data',charset='utf8',)
self.cur = self.conn.cursor()
self.sqlstring = "select * from "
MainWindow.setObjectName("MainWindow")
MainWindow.resize(900, 700)
MainWindow.setWindowIcon(QtGui.QIcon('../test1.jpg'))
# 根据窗口的大小固定大小 这里相当于设置全屏
MainWindow.setFixedSize(MainWindow.width(), MainWindow.height())
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.frame = QFrame(self.centralwidget)
self.frame.setGeometry(QtCore.QRect(10, 10, 711, 141))
self.frame.setFrameShape( QFrame.StyledPanel)
self.frame.setFrameShadow( QFrame.Raised)
self.frame.setObjectName("frame")
#大框
self.Cname = QLineEdit(self.frame) #QLineEdit单行输入文本框
self.Cname.setGeometry(QtCore.QRect(280, 50, 200, 31))
self.Cname.setObjectName("Cname")
self.Cname.setPlaceholderText('请输入...')
#cnnvd
self.Cnnvd = QPushButton(self.frame)
self.Cnnvd.setGeometry(QtCore.QRect(1, 0, 70, 31))
self.Cnnvd.setObjectName("Cnnvd")
self.Cnnvd.clicked.connect(self.cnnvd_btn)
#wooyun
self.Wooyun = QPushButton(self.frame)
self.Wooyun.setGeometry(QtCore.QRect(71, 0, 70, 31))
self.Wooyun.setObjectName("Wooyun")
self.Wooyun.clicked.connect(self.wooyun_btn)
#seebug
self.Seebug = QPushButton(self.frame)
self.Seebug.setGeometry(QtCore.QRect(141, 0, 70, 31))
self.Seebug.setObjectName("Seebug")
self.Seebug.clicked.connect(self.seebug_btn)
#查询按钮
self.find = QPushButton(self.frame)
self.find.setGeometry(QtCore.QRect(630, 30, 75, 31))
self.find.setObjectName("find")
self.find.clicked.connect(self.find_btn)
#圆饼图按钮
self.yuan = QPushButton(self.frame)
self.yuan.setGeometry(QtCore.QRect(630, 70, 75, 31))
self.yuan.setObjectName("yuan")
self.yuan.clicked.connect(self.shuju_btn)
#结果框
self.result_out = QTableWidget(self.centralwidget)
# self.result_out = QTableWidget(4, 100)
self.result_out.setEditTriggers( QAbstractItemView.NoEditTriggers) # 不可编辑表格
self.result_out.setGeometry(QtCore.QRect(40, 150, 800, 448)) #左上宽高
self.result_out.setObjectName("result_out")
self.result_out.setColumnCount(4)
self.result_out.setRowCount(100)
self.result_out.setHorizontalHeaderLabels(['name','numbering','href','time'])
self.result_out.horizontalHeader().setDefaultSectionSize(171) #总列长
self.result_out.horizontalHeader().setMinimumSectionSize(43) #单个列的长度
self.result_out.verticalHeader().setDefaultSectionSize(20)
self.pushButton_2 = QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(765, 620, 75, 31))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_2.clicked.connect(self.p2_clicked)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 509, 23))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def p2_clicked(self):
self.pyqt_clicked1.emit()
def find_btn(self):
self.pyqt_clicked2.emit()
def cnnvd_btn(self):
self.pyqt_clicked3.emit()
def wooyun_btn(self):
self.pyqt_clicked4.emit()
def seebug_btn(self):
self.pyqt_clicked6.emit()
def shuju_btn(self):
self.pyqt_clicked5.emit()
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("v1.0", "v1.0", None))
#按钮名称
self.find.setText(_translate("MainWindow", "查询", None))
self.Cnnvd.setText(_translate("MainWindow","cnnvd",None))
self.Wooyun.setText(_translate("MainWindow", "Wuyun", None))
self.yuan.setText(_translate("MainWindow", "结果图", None))
self.Seebug.setText(_translate("MainWindow", "seebug", None))
self.pushButton_2.setText(_translate("MainWindow", "退出", None))
def mousePressEvent(self, event):
# if event.KeyWord == Qt.LeftButton:
print("nihao")
#点击cnnvd表
def buttonCnnvd(self):
print("1")
self.temp_sqlstring1 =self.sqlstring+"cnnvd where "
self.temp = "cnnvd"
# 点击wooyun表
def buttonWuyun(self):
print("2")
self.temp_sqlstring1 = self.sqlstring + "wooyun where "
self.temp = "wooyun"
# 点击seebug表
def buttonSeebug(self):
print("3")
self.temp_sqlstring1 = self.sqlstring + "seebug where "
self.temp = "seebug"
def buttonTest(self):
Ui_MainWindow.temp_sqlstring =self.temp_sqlstring1
is_first = True
mystr = self.Cname.text()
if is_first:
is_first = False
if mystr.find("%") == -1:
Ui_MainWindow.temp_sqlstring += "name like '" +"%"+self.Cname.text() +"%"+"'"
else:
Ui_MainWindow.temp_sqlstring += "name like '" +"%"+self.Cname.text() +"%"+"'"
else:
if mystr.find("%") == -1:
Ui_MainWindow.temp_sqlstring += " and name like '" +"%"+self.Cname.text() +"%"+"'"
else:
Ui_MainWindow.temp_sqlstring += " and name like '" +"%"+self.Cname.text() +"%"+"'"
self.result_out.clearContents() # 每一次查询时清除表格中信息
if not (is_first):
print(Ui_MainWindow.temp_sqlstring)
self.cur.execute(Ui_MainWindow.temp_sqlstring)
data = self.cur.fetchall()
print(data)
x = 0
for i in data:
y = 0
for j in i:
self.result_out.setItem(x, y, QTableWidgetItem(str(data[x][y])))
y = y + 1
x = x + 1
print("find button pressed")
#输出圆饼图
def fenXi(self):
print('3')
# self.temp = self.temp
Ui_MainWindow.temp_sql = "select name from cnnvd"
print(Ui_MainWindow.temp_sql)
# self.cur.execute("(select name from cnnvd where name like '%sql%') union all (select name from wooyun where name like '%sql%')")
self.cur.execute(Ui_MainWindow.temp_sql)
result=[]
d ={}
d1 ={}
for i in self.cur:
for j in i:
result.append(j)
for i in result:
x = i.split(" ")
for i in x:
chinese = re.findall('[\u4e00-\u9fa5]+',i)
# print(chinese)
for j in chinese:
if j in d:
d[j]+=1
else:
d[j]=1
lst= sorted(d.items(),key=lambda x:x[1],reverse=True)
# print(lst)
return lst
# print(lst[0])
def buttonExit(self):
self.conn.commit()
self.cur.close()
self.conn.close()
self.close()
def keyPressEvent(self, e):
if e.key() == QtCore.Qt.Key_Escape:
self.buttonExit()
class MyWindow(QMainWindow, Ui_MainWindow):
pyqt_clicked1 = pyqtSignal()
pyqt_clicked2 = pyqtSignal()
pyqt_clicked3 = pyqtSignal()
pyqt_clicked4 = pyqtSignal()
pyqt_clicked5 = pyqtSignal()
pyqt_clicked6 = pyqtSignal()
def __init__(self):
super(MyWindow, self).__init__()
self.setupUi(self)
self.pyqt_clicked1.connect(self.buttonExit)
self.pyqt_clicked2.connect(self.buttonTest)
self.pyqt_clicked3.connect(self.buttonCnnvd)
self.pyqt_clicked4.connect(self.buttonWuyun)
self.pyqt_clicked5.connect(self.fenXi)
self.pyqt_clicked6.connect(self.buttonSeebug)
self.show()
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("数据分析")
self.setGeometry(100, 100, 1280, 600)
self.create_piechart()
def create_piechart(self):
series = QPieSeries()
series.append("跨站脚本漏洞", 161)
series.append("缓冲区错误漏洞", 155)
series.append("输入验证错误漏洞", 143)
series.append("代码问题漏洞", 125)
series.append("SQL注入漏洞", 101)
series.append("资源管理错误漏洞", 91)
series.append("路径遍历漏洞", 32)
series.append("信息泄露漏洞", 30)
series.append("权限许可和访问控制问题漏洞", 28)
series.append("跨站请求伪造漏洞", 27)
slice0 = QPieSlice()
slice0 = series.slices()[0]
slice0.setLabelVisible(True)
slice1 = QPieSlice()
slice1 = series.slices()[1]
slice1.setLabelVisible(True)
slice2 = QPieSlice()
slice2 = series.slices()[2]
slice2.setLabelVisible(True)
slice3 = QPieSlice()
slice3 = series.slices()[3]
slice3.setLabelVisible(True)
slice4 = QPieSlice()
slice4 = series.slices()[4]
slice4.setLabelVisible(True)
slice5 = QPieSlice()
slice5 = series.slices()[5]
slice5.setLabelVisible(True)
slice6 = QPieSlice()
slice6 = series.slices()[6]
slice6.setLabelVisible(True)
slice7 = QPieSlice()
slice7 = series.slices()[7]
slice7.setLabelVisible(True)
slice8 = QPieSlice()
slice8 = series.slices()[8]
slice8.setLabelVisible(True)
slice9 = QPieSlice()
slice9 = series.slices()[9]
slice9.setLabelVisible(True)
chart = QChart()
chart.legend().hide()
chart.addSeries(series)
chart.createDefaultAxes()
chart.setAnimationOptions(QChart.SeriesAnimations)
chart.setTitle("Pie Chart Example")
chart.legend().setVisible(True)
chart.legend().setAlignment(Qt.AlignBottom)
chartview = QChartView(chart)
chartview.setRenderHint(QPainter.Antialiasing)
self.setCentralWidget(chartview)
if __name__ == "__main__":
app = QApplication(sys.argv)
app.aboutToQuit.connect(app.deleteLater)
myshow = MyWindow()
b = Window()
myshow.yuan.clicked.connect(b.show)
sys.exit(app.exec_())
# app.exec_()
# sys.exit(0)
Loading…
Cancel
Save