mirror of
https://github.com/Adaptix-Framework/AdaptixC2
synced 2026-06-08 10:20:39 +00:00
agents tick upgrade
This commit is contained in:
@@ -368,6 +368,28 @@ public:
|
||||
Q_EMIT dataChanged(index(row, 0), index(row, SC_ColumnCount - 1), { Qt::DisplayRole, Qt::ForegroundRole, Qt::BackgroundRole });
|
||||
}
|
||||
|
||||
void updateLastColumn(const QStringList &agentIds) {
|
||||
if (agentIds.isEmpty())
|
||||
return;
|
||||
|
||||
int minRow = INT_MAX;
|
||||
int maxRow = -1;
|
||||
|
||||
for (const QString &agentId : agentIds) {
|
||||
auto it = idToRow.find(agentId);
|
||||
if (it == idToRow.end())
|
||||
continue;
|
||||
|
||||
int row = it.value();
|
||||
if (row < minRow) minRow = row;
|
||||
if (row > maxRow) maxRow = row;
|
||||
}
|
||||
|
||||
if (maxRow >= 0) {
|
||||
Q_EMIT dataChanged(index(minRow, 0), index(maxRow, SC_ColumnCount - 1), { Qt::DisplayRole, Qt::ForegroundRole, Qt::BackgroundRole });
|
||||
}
|
||||
}
|
||||
|
||||
void remove(const QString &agentId) {
|
||||
auto it = idToRow.find(agentId);
|
||||
if (it == idToRow.end())
|
||||
@@ -402,7 +424,6 @@ Q_OBJECT
|
||||
QMenu* menuSessions = nullptr;
|
||||
QShortcut* shortcutSearch = nullptr;
|
||||
|
||||
AgentsTableModel* agentsModel = nullptr;
|
||||
AgentsFilterProxyModel* proxyModel = nullptr;
|
||||
|
||||
QWidget* searchWidget = nullptr;
|
||||
@@ -416,8 +437,7 @@ Q_OBJECT
|
||||
void createUI();
|
||||
|
||||
public:
|
||||
QTimer* refreshTimer = nullptr;
|
||||
|
||||
AgentsTableModel* agentsModel = nullptr;
|
||||
explicit SessionsTableWidget( AdaptixWidget* w );
|
||||
~SessionsTableWidget() override;
|
||||
|
||||
@@ -433,8 +453,6 @@ public:
|
||||
void UpdateAgentTypeComboBox() const;
|
||||
void Clear() const;
|
||||
|
||||
void start() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void toggleSearchPanel() const;
|
||||
void onFilterChanged() const;
|
||||
|
||||
@@ -117,6 +117,9 @@ AdaptixWidget::AdaptixWidget(AuthProfile* authProfile, QThread* channelThread, W
|
||||
connect( reconnectButton, &QPushButton::clicked, this, &AdaptixWidget::OnReconnect);
|
||||
|
||||
connect( TickThread, &QThread::started, TickWorker, &LastTickWorker::run );
|
||||
connect( TickWorker, &LastTickWorker::agentsUpdated, this, [this](const QStringList &agentIds) {
|
||||
SessionsTableDock->agentsModel->updateLastColumn(agentIds);
|
||||
}, Qt::QueuedConnection);
|
||||
|
||||
connect( ChannelWsWorker, &WebSocketWorker::received_data, this, &AdaptixWidget::DataHandler );
|
||||
connect( ChannelWsWorker, &WebSocketWorker::websocket_closed, this, &AdaptixWidget::ChannelClose );
|
||||
@@ -140,7 +143,6 @@ AdaptixWidget::AdaptixWidget(AuthProfile* authProfile, QThread* channelThread, W
|
||||
dialogSyncPacket->splashScreen->close();
|
||||
});
|
||||
|
||||
SessionsTableDock->start();
|
||||
TickThread->start();
|
||||
ChannelThread->start();
|
||||
|
||||
|
||||
@@ -51,13 +51,6 @@ SessionsTableWidget::SessionsTableWidget( AdaptixWidget* w ) : DockTab("Sessions
|
||||
connect(shortcutEsc, &QShortcut::activated, this, [this]() { searchWidget->setVisible(false); });
|
||||
|
||||
this->dockWidget->setWidget(this);
|
||||
|
||||
this->refreshTimer = new QTimer(this);
|
||||
connect(refreshTimer, &QTimer::timeout, this, [this]() {
|
||||
if (tableView && tableView->isVisible()) {
|
||||
tableView->viewport()->update();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
SessionsTableWidget::~SessionsTableWidget() = default;
|
||||
@@ -138,11 +131,6 @@ void SessionsTableWidget::createUI()
|
||||
mainGridLayout->addWidget( tableView, 1, 0, 1, 1);
|
||||
}
|
||||
|
||||
void SessionsTableWidget::start() const
|
||||
{
|
||||
this->refreshTimer->start(1000);
|
||||
}
|
||||
|
||||
void SessionsTableWidget::AddAgentItem( Agent* newAgent ) const
|
||||
{
|
||||
if ( adaptixWidget->AgentsMap.contains(newAgent->data.Id) )
|
||||
@@ -241,8 +229,6 @@ void SessionsTableWidget::UpdateAgentTypeComboBox() const
|
||||
|
||||
void SessionsTableWidget::Clear() const
|
||||
{
|
||||
refreshTimer->stop();
|
||||
|
||||
for (auto agentId : adaptixWidget->AgentsMap.keys()) {
|
||||
Agent* agent = adaptixWidget->AgentsMap[agentId];
|
||||
adaptixWidget->AgentsMap.remove(agentId);
|
||||
|
||||
@@ -22,6 +22,8 @@ void LastTickWorker::run()
|
||||
|
||||
void LastTickWorker::updateLastItems()
|
||||
{
|
||||
QStringList updatedAgents;
|
||||
|
||||
for ( auto agent : mainWidget->AgentsMap ) {
|
||||
if ( agent->data.Async && agent->active ) {
|
||||
int current = QDateTime::currentSecsSinceEpoch();
|
||||
@@ -59,6 +61,7 @@ void LastTickWorker::updateLastItems()
|
||||
if (agent->data.Mark != "No response")
|
||||
agent->MarkItem("No response");
|
||||
|
||||
updatedAgents.append(agent->data.Id);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
@@ -66,7 +69,10 @@ void LastTickWorker::updateLastItems()
|
||||
}
|
||||
}
|
||||
agent->LastMark = FormatSecToStr(diff);
|
||||
updatedAgents.append(agent->data.Id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!updatedAgents.isEmpty())
|
||||
Q_EMIT agentsUpdated(updatedAgents);
|
||||
}
|
||||
@@ -28,6 +28,7 @@ void WebSocketWorker::run()
|
||||
connect( webSocket, &QWebSocket::connected, this, &WebSocketWorker::is_connected );
|
||||
connect( webSocket, &QWebSocket::disconnected, this, &WebSocketWorker::is_disconnected );
|
||||
connect( webSocket, &QWebSocket::binaryMessageReceived, this, &WebSocketWorker::is_binaryMessageReceived );
|
||||
connect( webSocket, &QWebSocket::pong, this, &WebSocketWorker::is_pong );
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
connect( webSocket, &QWebSocket::errorOccurred, this, &WebSocketWorker::is_error);
|
||||
|
||||
Reference in New Issue
Block a user