mirror of
https://github.com/20kaushik02/AUNMS---Network-Monitoring-System.git
synced 2025-12-06 06:24:07 +00:00
Minor bug fixes
This commit is contained in:
parent
0fbe3017aa
commit
57cae217b8
@ -97,7 +97,6 @@ class NetworkMonitor(QMainWindow):
|
|||||||
self.menubar.addAction(self.actionScroll)
|
self.menubar.addAction(self.actionScroll)
|
||||||
|
|
||||||
def autoScrollSet(self):
|
def autoScrollSet(self):
|
||||||
print(self.actionScroll.isChecked())
|
|
||||||
if (self.actionScroll.isChecked() == True):
|
if (self.actionScroll.isChecked() == True):
|
||||||
self.tableWidget.scrollToBottom()
|
self.tableWidget.scrollToBottom()
|
||||||
self.actionScroll.setText('Disable Auto Scroll')
|
self.actionScroll.setText('Disable Auto Scroll')
|
||||||
@ -108,10 +107,6 @@ class NetworkMonitor(QMainWindow):
|
|||||||
if self.interfaceSelected == None:
|
if self.interfaceSelected == None:
|
||||||
self.interfaceDialog()
|
self.interfaceDialog()
|
||||||
|
|
||||||
print("Monitoring - {}".format(
|
|
||||||
self.interfaceSelected
|
|
||||||
))
|
|
||||||
|
|
||||||
self.actionStart.setEnabled(False)
|
self.actionStart.setEnabled(False)
|
||||||
self.actionStop.setEnabled(True)
|
self.actionStop.setEnabled(True)
|
||||||
self.actionClear.setEnabled(True)
|
self.actionClear.setEnabled(True)
|
||||||
@ -120,7 +115,7 @@ class NetworkMonitor(QMainWindow):
|
|||||||
self.thread = QThread()
|
self.thread = QThread()
|
||||||
self.worker = NetworkMonitorThread(interface = self.interfaceSelected)
|
self.worker = NetworkMonitorThread(interface = self.interfaceSelected)
|
||||||
self.worker.moveToThread(self.thread)
|
self.worker.moveToThread(self.thread)
|
||||||
|
|
||||||
self.thread.started.connect(self.worker.startSniff)
|
self.thread.started.connect(self.worker.startSniff)
|
||||||
self.actionStop.triggered.connect(self.worker.endSniff)
|
self.actionStop.triggered.connect(self.worker.endSniff)
|
||||||
|
|
||||||
@ -130,18 +125,15 @@ class NetworkMonitor(QMainWindow):
|
|||||||
|
|
||||||
quitBool = pyqtSignal()
|
quitBool = pyqtSignal()
|
||||||
def stopSniff(self, quitBool):
|
def stopSniff(self, quitBool):
|
||||||
print(quitBool)
|
|
||||||
if(quitBool == 1):
|
if(quitBool == 1):
|
||||||
self.thread.quit()
|
self.thread.quit()
|
||||||
self.actionStart.setEnabled(True)
|
self.actionStart.setEnabled(True)
|
||||||
self.actionStop.setEnabled(False)
|
self.actionStop.setEnabled(False)
|
||||||
self.actionPickInterface.setEnabled(True)
|
self.actionPickInterface.setEnabled(True)
|
||||||
|
|
||||||
print("Terminating thread")
|
|
||||||
self.thread.quit()
|
|
||||||
|
|
||||||
def packetClear(self):
|
def packetClear(self):
|
||||||
self.thread.terminate()
|
if hasattr(self.thread, 'quit'):
|
||||||
|
self.thread.quit()
|
||||||
self.tableWidget.clearContents()
|
self.tableWidget.clearContents()
|
||||||
self.tableWidget.setRowCount(0)
|
self.tableWidget.setRowCount(0)
|
||||||
|
|
||||||
@ -150,7 +142,6 @@ class NetworkMonitor(QMainWindow):
|
|||||||
self.interfaceDiag.exec_()
|
self.interfaceDiag.exec_()
|
||||||
if hasattr(self.interfaceDiag, 'interfaceName'):
|
if hasattr(self.interfaceDiag, 'interfaceName'):
|
||||||
self.interfaceSelected = self.interfaceDiag.interfaceName
|
self.interfaceSelected = self.interfaceDiag.interfaceName
|
||||||
print(self.interfaceSelected)
|
|
||||||
|
|
||||||
packetData = pyqtSignal()
|
packetData = pyqtSignal()
|
||||||
def addPacketToTableWidget(self, packetData):
|
def addPacketToTableWidget(self, packetData):
|
||||||
@ -179,29 +170,32 @@ class NetworkMonitor(QMainWindow):
|
|||||||
|
|
||||||
def savePacketsPCAP(self):
|
def savePacketsPCAP(self):
|
||||||
path = QFileDialog.getSaveFileName(self, 'Save File', '', 'pcap(*.pcap)')
|
path = QFileDialog.getSaveFileName(self, 'Save File', '', 'pcap(*.pcap)')
|
||||||
path = str(path[0])
|
if path[0] is not '':
|
||||||
wrpcap(path, self.worker.packetList)
|
path = str(path[0])
|
||||||
|
wrpcap(path, self.worker.packetList)
|
||||||
|
|
||||||
def savePacketsBLIP(self):
|
def savePacketsBLIP(self):
|
||||||
path = QFileDialog.getSaveFileName(self, 'Save File', '', 'pcap(*.pcap)')
|
path = QFileDialog.getSaveFileName(self, 'Save File', '', 'pcap(*.pcap)')
|
||||||
path = str(path[0])
|
if path[0] is not '':
|
||||||
wrpcap(path, self.worker.blackListAccess)
|
path = str(path[0])
|
||||||
self.worker.blackListAccess = []
|
wrpcap(path, self.worker.blackListAccess)
|
||||||
|
self.worker.blackListAccess = []
|
||||||
|
|
||||||
def savePacketsCSV(self):
|
def savePacketsCSV(self):
|
||||||
path = QFileDialog.getSaveFileName(self, 'Save File', '', 'CSV(*.csv)')
|
path = QFileDialog.getSaveFileName(self, 'Save File', '', 'CSV(*.csv)')
|
||||||
with open(path[0], 'w') as stream:
|
if path[0] is not '':
|
||||||
writer = csv.writer(stream, lineterminator='\n')
|
with open(path[0], 'w') as stream:
|
||||||
for row in range(self.tableWidget.rowCount()):
|
writer = csv.writer(stream, lineterminator='\n')
|
||||||
rowdata = []
|
for row in range(self.tableWidget.rowCount()):
|
||||||
for column in range(self.tableWidget.columnCount()):
|
rowdata = []
|
||||||
item = self.tableWidget.item(row, column)
|
for column in range(self.tableWidget.columnCount()):
|
||||||
if item is not None:
|
item = self.tableWidget.item(row, column)
|
||||||
rowdata.append(item.text())
|
if item is not None:
|
||||||
else:
|
rowdata.append(item.text())
|
||||||
rowdata.append('')
|
else:
|
||||||
|
rowdata.append('')
|
||||||
|
|
||||||
writer.writerow(rowdata)
|
writer.writerow(rowdata)
|
||||||
|
|
||||||
class InterfacePick(QDialog):
|
class InterfacePick(QDialog):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
|||||||
@ -10,7 +10,6 @@ class NetworkMonitorThread(QObject):
|
|||||||
def __init__(self, interface, parent=None):
|
def __init__(self, interface, parent=None):
|
||||||
|
|
||||||
self.IP_blacklist = set(line.strip() for line in open('IP_Blacklist.txt'))
|
self.IP_blacklist = set(line.strip() for line in open('IP_Blacklist.txt'))
|
||||||
print(self.IP_blacklist)
|
|
||||||
QObject.__init__(self, parent=parent)
|
QObject.__init__(self, parent=parent)
|
||||||
self.interface = interface
|
self.interface = interface
|
||||||
self.packetList = []
|
self.packetList = []
|
||||||
@ -21,7 +20,6 @@ class NetworkMonitorThread(QObject):
|
|||||||
|
|
||||||
def endSniff(self):
|
def endSniff(self):
|
||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
print("Ending")
|
|
||||||
self.end = True
|
self.end = True
|
||||||
self.quitBool.emit(1)
|
self.quitBool.emit(1)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user