MCPcopy Create free account
hub / github.com/Adaptix-Framework/AdaptixC2 / onButtonLoad

Method onButtonLoad

AdaptixClient/Source/UI/Dialogs/DialogAgent.cpp:368–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366// }
367
368void DialogAgent::onButtonLoad()
369{
370 QString baseDir = authProfile.GetProjectDir();
371 QPointer<DialogAgent> safeThis = this;
372 QString currentListenerType = listenerType;
373
374 NonBlockingDialogs::getOpenFileName(this, "Select file", baseDir, "JSON files (*.json)",
375 [safeThis, currentListenerType](const QString& filePath) {
376 if (filePath.isEmpty())
377 return;
378
379 QFile file(filePath);
380 if (!file.open(QIODevice::ReadOnly))
381 return;
382
383 QByteArray fileContent = file.readAll();
384 file.close();
385
386 QJsonParseError parseError;
387 QJsonDocument document = QJsonDocument::fromJson(fileContent, &parseError);
388 if (parseError.error != QJsonParseError::NoError || !document.isObject()) {
389 MessageError("Error JSON parse");
390 return;
391 }
392 QJsonObject jsonObject = document.object();
393
394 if ( !jsonObject.contains("listener_type") || !jsonObject["listener_type"].isString() ) {
395 MessageError("Required parameter 'listener_type' is missing");
396 return;
397 }
398 if ( !jsonObject.contains("agent") || !jsonObject["agent"].isString() ) {
399 MessageError("Required parameter 'agent' is missing");
400 return;
401 }
402 if ( !jsonObject.contains("config") || !jsonObject["config"].isString() ) {
403 MessageError("Required parameter 'config' is missing");
404 return;
405 }
406
407 if(currentListenerType != jsonObject["listener_type"].toString()) {
408 MessageError("Listener type mismatch");
409 return;
410 }
411
412 if (!safeThis)
413 return;
414
415 QString agentType = jsonObject["agent"].toString();
416 int typeIndex = safeThis->agentCombobox->findText( agentType );
417 if ( typeIndex == -1 ) {
418 MessageError("No such agent exists");
419 return;
420 }
421 safeThis->agentCombobox->setCurrentIndex(typeIndex);
422 safeThis->changeConfig(agentType);
423
424 QString configData = jsonObject["config"].toString();
425

Callers

nothing calls this directly

Calls 9

MessageErrorFunction · 0.85
GetProjectDirMethod · 0.80
isEmptyMethod · 0.45
openMethod · 0.45
closeMethod · 0.45
containsMethod · 0.45
setCurrentIndexMethod · 0.45
changeConfigMethod · 0.45
fromJsonMethod · 0.45

Tested by

no test coverage detected