Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PacketSniffer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#-------------------------------------------------

QT += core gui

QT += network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = PacketSniffer
Expand Down
205 changes: 112 additions & 93 deletions PacketSniffer.pro.user

Large diffs are not rendered by default.

336 changes: 336 additions & 0 deletions PacketSniffer.pro.user.bd8350d.4.8-pre1

Large diffs are not rendered by default.

33 changes: 25 additions & 8 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#include <stdlib.h>
#include <stdio.h>

#include <string.h>
#include <QMessageBox>
#include <QFileDialog>
#include <QStandardPaths>
#include <QDialogButtonBox>

#include<QNetworkInterface>

#include <QStandardItem>
#include <QDebug>
#include <QRegExp>

#include "mainwindow.h"
#include "ui_mainwindow.h"

extern
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
Expand Down Expand Up @@ -53,6 +55,13 @@ MainWindow::MainWindow(QWidget *parent) :
ui->pauseCaptureButton->setEnabled(false);
ui->deleteCaptureButton->setEnabled(false);

QNetworkInterface interface;
QList<QNetworkInterface> IpList = interface.allInterfaces();
for (int i = 0; i < IpList.size(); i++){

qDebug() << "Interface " << i << ":" << IpList.at(i).humanReadableName();
ui->deviceBox->addItem(IpList.at(i).humanReadableName());
}
packetSnifferThread = NULL;
isSaved = false;
}
Expand All @@ -69,17 +78,18 @@ MainWindow::~MainWindow(){
}

void MainWindow::on_startCaptureButton_clicked(){
device = ui->deviceBox->currentText().toStdString();
//If this is the first capture, or if the previous capture was deleted, create a new PacketSnifferThread
if(packetSnifferThread == NULL){
packetSnifferThread = new PacketSnifferThread(packetModel, ui->statusBar);
packetSnifferThread = new PacketSnifferThread(packetModel, ui->statusBar,device);
}

//Disable and enable various buttons
ui->startCaptureButton->setEnabled(false);
ui->stopCaptureButton->setEnabled(true);
ui->pauseCaptureButton->setEnabled(true);
ui->deleteCaptureButton->setEnabled(false);

//Start the thread
packetSnifferThread->start();
ui->statusBar->showMessage(QString("Packet capture started."));
Expand Down Expand Up @@ -264,15 +274,15 @@ void MainWindow::on_actionSave_triggered(){

void MainWindow::on_actionNew_Capture_triggered(){
if(packetSnifferThread == NULL){ //No capture is running, and nothing to save
packetSnifferThread = new PacketSnifferThread(packetModel, ui->statusBar);
packetSnifferThread = new PacketSnifferThread(packetModel, ui->statusBar,device);
}
else if(packetSnifferThread->isRunning()){ //A capture is still running
ui->statusBar->showMessage("Please stop the current capture.");
ui->statusBar->showMessage("Please stop the capture.");
}
else if(isSaved == false){ //The capture is not running, but isnt saved
ui->deleteCaptureButton->click();
if(packetSnifferThread == NULL){
packetSnifferThread = new PacketSnifferThread(packetModel, ui->statusBar);
packetSnifferThread = new PacketSnifferThread(packetModel, ui->statusBar,device);
}
}
else{
Expand All @@ -298,7 +308,7 @@ void MainWindow::on_actionOpen_triggered(){
ui->statusBar->showMessage("No file selected.");
return;
}
packetSnifferThread = new PacketSnifferThread(packetModel, fileName, ui->statusBar);
packetSnifferThread = new PacketSnifferThread(packetModel, fileName, ui->statusBar,device);
isSaved = true;

/*
Expand Down Expand Up @@ -384,3 +394,10 @@ void MainWindow::on_actionPause_triggered(){
void MainWindow::on_actionClear_triggered(){
ui->deleteCaptureButton->click();
}

/*
void MainWindow::none(){


}
*/
1 change: 1 addition & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class MainWindow : public QMainWindow
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
std::string device = "wlo1";

private slots:
void on_startCaptureButton_clicked(); //Start the packet capture
Expand Down
140 changes: 74 additions & 66 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="8">
<item row="1" column="0" colspan="9">
<widget class="QTableView" name="packetTableView">
<property name="styleSheet">
<string notr="true">gridline-color:black;</string>
Expand All @@ -35,23 +35,6 @@
</attribute>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="filterLabel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter your filter text here, a regular expression can be used&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Filter:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="filterLineEdit">
<property name="placeholderText">
<string>Enter filter text here</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="startCaptureButton">
<property name="maximumSize">
Expand All @@ -72,86 +55,106 @@
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QPushButton" name="stopCaptureButton">
<item row="0" column="8">
<widget class="QPushButton" name="deleteCaptureButton">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Stop capturing packets&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Delete the current capture (not available when capturing or when there is nothing to delete)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/stop_capture_button.png</normaloff>:/images/stop_capture_button.png</iconset>
<normaloff>:/images/trash_button.png</normaloff>:/images/trash_button.png</iconset>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="clearFilterButton">
<item row="0" column="0">
<widget class="QLabel" name="filterLabel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter your filter text here, a regular expression can be used&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Filter:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="filterLineEdit">
<property name="placeholderText">
<string>Enter filter text here</string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QPushButton" name="pauseCaptureButton">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Clear Filter&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pause the capturing of packets, can be resumed later (To clear the current capture, click the garbage icon to the right of this button)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/clear_filter_button.png</normaloff>:/images/clear_filter_button.png</iconset>
<normaloff>:/images/pause_button.png</normaloff>:/images/pause_button.png</iconset>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="pauseCaptureButton">
<item row="0" column="2">
<widget class="QPushButton" name="clearFilterButton">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pause the capturing of packets, can be resumed later (To clear the current capture, click the garbage icon to the right of this button)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Clear Filter&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/pause_button.png</normaloff>:/images/pause_button.png</iconset>
<normaloff>:/images/clear_filter_button.png</normaloff>:/images/clear_filter_button.png</iconset>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QPushButton" name="deleteCaptureButton">
<widget class="QPushButton" name="stopCaptureButton">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Delete the current capture (not available when capturing or when there is nothing to delete)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Stop capturing packets&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/trash_button.png</normaloff>:/images/trash_button.png</iconset>
<normaloff>:/images/stop_capture_button.png</normaloff>:/images/stop_capture_button.png</iconset>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="deviceBox"/>
</item>
</layout>
</widget>
<widget class="QSplitter" name="splitter">
Expand Down Expand Up @@ -288,13 +291,45 @@
</item>
</layout>
</widget>
<widget class="QToolBar" name="mainToolBar">
<property name="movable">
<bool>true</bool>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="floatable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionSave"/>
<addaction name="actionSave_As"/>
<addaction name="actionOpen"/>
<addaction name="actionNew_Capture"/>
<addaction name="separator"/>
<addaction name="separator"/>
<addaction name="actionResize_Columns"/>
<addaction name="separator"/>
<addaction name="actionStart"/>
<addaction name="actionPause"/>
<addaction name="actionClear"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>605</width>
<height>25</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down Expand Up @@ -324,38 +359,6 @@
<addaction name="menuCapture"/>
<addaction name="menuView"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
<property name="movable">
<bool>true</bool>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="floatable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionSave"/>
<addaction name="actionSave_As"/>
<addaction name="actionOpen"/>
<addaction name="actionNew_Capture"/>
<addaction name="separator"/>
<addaction name="separator"/>
<addaction name="actionResize_Columns"/>
<addaction name="separator"/>
<addaction name="actionStart"/>
<addaction name="actionPause"/>
<addaction name="actionClear"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionResize_Columns">
<property name="icon">
<iconset resource="resources.qrc">
Expand Down Expand Up @@ -464,6 +467,11 @@
<string>Ctrl+X</string>
</property>
</action>
<action name="actionChoose_another_device">
<property name="text">
<string>Choose another device</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
Expand Down
Loading