mirror of
https://github.com/Adaptix-Framework/AdaptixC2
synced 2026-06-08 10:20:39 +00:00
@@ -21,6 +21,7 @@ find_package(Qt6
|
||||
Network
|
||||
WebSockets
|
||||
Sql
|
||||
Qml
|
||||
)
|
||||
|
||||
include_directories(
|
||||
@@ -95,7 +96,6 @@ SET( HEADERS
|
||||
Headers/UI/Dialogs/DialogSyncPacket.h
|
||||
Headers/UI/Widgets/ListenersWidget.h
|
||||
Headers/UI/Dialogs/DialogListener.h
|
||||
Headers/Client/WidgetBuilder.h
|
||||
Headers/UI/Widgets/SessionsTableWidget.h
|
||||
Headers/UI/Dialogs/DialogAgent.h
|
||||
Headers/UI/Widgets/ConsoleWidget.h
|
||||
@@ -131,6 +131,17 @@ SET( HEADERS
|
||||
Headers/Workers/DownloaderWorker.h
|
||||
Headers/Workers/UploaderWorker.h
|
||||
Headers/UI/Dialogs/DialogUploader.h
|
||||
Headers/Client/AxScript/AxScriptManager.h
|
||||
Headers/Client/AxScript/AxScriptEngine.h
|
||||
Headers/Client/AxScript/BridgeApp.h
|
||||
Headers/Client/AxScript/BridgeEvent.h
|
||||
Headers/Client/AxScript/BridgeForm.h
|
||||
Headers/Client/AxScript/BridgeMenu.h
|
||||
Headers/Client/AxScript/AxCommandWrappers.h
|
||||
Headers/Client/AxScript/AxElementWrappers.h
|
||||
Headers/UI/Widgets/CredentialsWidget.h
|
||||
Headers/UI/Dialogs/DialogCredential.h
|
||||
Headers/UI/Widgets/AxConsoleWidget.h
|
||||
)
|
||||
|
||||
add_executable(AdaptixClient
|
||||
@@ -159,7 +170,6 @@ add_executable(AdaptixClient
|
||||
Source/Client/ProcessSyncPacket.cpp
|
||||
Source/UI/Widgets/ListenersWidget.cpp
|
||||
Source/UI/Dialogs/DialogListener.cpp
|
||||
Source/Client/WidgetBuilder.cpp
|
||||
Source/UI/Widgets/SessionsTableWidget.cpp
|
||||
Source/UI/Dialogs/DialogAgent.cpp
|
||||
Source/UI/Widgets/ConsoleWidget.cpp
|
||||
@@ -194,6 +204,17 @@ add_executable(AdaptixClient
|
||||
Source/Workers/DownloaderWorker.cpp
|
||||
Source/Workers/UploaderWorker.cpp
|
||||
Source/UI/Dialogs/DialogUploader.cpp
|
||||
Source/Client/AxScript/AxScriptManager.cpp
|
||||
Source/Client/AxScript/AxScriptEngine.cpp
|
||||
Source/Client/AxScript/BridgeApp.cpp
|
||||
Source/Client/AxScript/BridgeEvent.cpp
|
||||
Source/Client/AxScript/BridgeForm.cpp
|
||||
Source/Client/AxScript/BridgeMenu.cpp
|
||||
Source/Client/AxScript/AxCommandWrappers.cpp
|
||||
Source/Client/AxScript/AxElementWrappers.cpp
|
||||
Source/UI/Widgets/CredentialsWidget.cpp
|
||||
Source/UI/Dialogs/DialogCredential.cpp
|
||||
Source/UI/Widgets/AxConsoleWidget.cpp
|
||||
)
|
||||
|
||||
target_compile_definitions(AdaptixClient PRIVATE QT_DEPRECATED_WARNINGS )
|
||||
@@ -207,6 +228,7 @@ if(UNIX)
|
||||
Qt6::Network
|
||||
Qt6::WebSockets
|
||||
Qt6::Sql
|
||||
Qt6::Qml
|
||||
OpenSSL::Crypto
|
||||
|
||||
pthread dl
|
||||
@@ -220,6 +242,7 @@ elseif(APPLE)
|
||||
Qt6::Network
|
||||
Qt6::WebSockets
|
||||
Qt6::Sql
|
||||
Qt6::Qml
|
||||
OpenSSL::Crypto
|
||||
|
||||
pthread dl
|
||||
@@ -233,6 +256,7 @@ else()
|
||||
Qt6::Network
|
||||
Qt6::WebSockets
|
||||
Qt6::Sql
|
||||
Qt6::Qml
|
||||
|
||||
wsock32 ws2_32 crypt32 iphlpapi netapi32 version winmm userenv
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <main.h>
|
||||
|
||||
class Commander;
|
||||
class ConsoleWidget;
|
||||
class BrowserFilesWidget;
|
||||
class BrowserProcessWidget;
|
||||
@@ -17,13 +18,13 @@ public:
|
||||
AdaptixWidget* adaptixWidget = nullptr;
|
||||
|
||||
AgentData data = {};
|
||||
BrowsersConfig browsers = {};
|
||||
|
||||
QImage imageActive = QImage();
|
||||
QImage imageInactive = QImage();
|
||||
|
||||
QString connType = QString();
|
||||
QString parentId = QString();
|
||||
QString connType = QString();
|
||||
QString listenerType = QString();
|
||||
QString parentId = QString();
|
||||
QVector<QString> childsId;
|
||||
|
||||
AgentTableWidgetItem* item_Id = nullptr;
|
||||
@@ -44,6 +45,7 @@ public:
|
||||
GraphItem* graphItem = nullptr;
|
||||
QImage graphImage = QImage();
|
||||
|
||||
Commander* commander = nullptr;
|
||||
ConsoleWidget* Console = nullptr;
|
||||
BrowserFilesWidget* FileBrowser = nullptr;
|
||||
BrowserProcessWidget* ProcessBrowser = nullptr;
|
||||
@@ -60,19 +62,13 @@ public:
|
||||
void MarkItem(const QString &mark);
|
||||
void SetColor(const QString &color) const;
|
||||
void UpdateImage();
|
||||
QString TasksStop(const QStringList &tasks) const;
|
||||
QString TasksCancel(const QStringList &tasks) const;
|
||||
QString TasksDelete(const QStringList &tasks) const;
|
||||
|
||||
void SetParent(const PivotData &pivotData);
|
||||
void UnsetParent(const PivotData &pivotData);
|
||||
void AddChild(const PivotData &pivotData);
|
||||
void RemoveChild(const PivotData &pivotData);
|
||||
|
||||
QString BrowserDisks() const;
|
||||
QString BrowserProcess() const;
|
||||
QString BrowserList(const QString &path) const;
|
||||
QString BrowserUpload(const QString &path, const QString &content) const;
|
||||
QString BrowserDownload(const QString &path) const;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_AGENT_H
|
||||
#endif
|
||||
|
||||
@@ -17,4 +17,4 @@ public:
|
||||
void SetColor(QColor bg, QColor fg);
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_TABLEWIDGETITEMAGENT_H
|
||||
#endif
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
#ifndef ADAPTIXCLIENT_COMMANDER_H
|
||||
#define ADAPTIXCLIENT_COMMANDER_H
|
||||
|
||||
#include <main.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonParseError>
|
||||
#include <QJsonDocument>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QJsonObject>
|
||||
#include <QJSValue>
|
||||
|
||||
struct Argument
|
||||
{
|
||||
QString type;
|
||||
QString name;
|
||||
bool required;
|
||||
bool flag;
|
||||
QString mark;
|
||||
QString description;
|
||||
QString defaultValue;
|
||||
bool defaultUsed;
|
||||
bool valid;
|
||||
QString type;
|
||||
QString name;
|
||||
bool required;
|
||||
bool flag;
|
||||
QString mark;
|
||||
QString description;
|
||||
bool defaultUsed;
|
||||
QVariant defaultValue;
|
||||
};
|
||||
|
||||
struct Command
|
||||
@@ -24,61 +29,66 @@ struct Command
|
||||
QString example;
|
||||
QList<Argument> args;
|
||||
QList<Command> subcommands;
|
||||
QString exec;
|
||||
bool is_pre_hook;
|
||||
QJSValue pre_hook;
|
||||
};
|
||||
|
||||
struct Constant
|
||||
struct CommandsGroup
|
||||
{
|
||||
QString Name;
|
||||
QMap<QString,QString> Map;
|
||||
QString groupName;
|
||||
QString filepath;
|
||||
QList<Command> commands;
|
||||
QJSEngine* engine;
|
||||
};
|
||||
|
||||
struct ExtModule
|
||||
struct PostHook
|
||||
{
|
||||
QString Name;
|
||||
QString FilePath;
|
||||
QList<Command> Commands;
|
||||
QMap<QString, Constant> Constants;
|
||||
bool isSet;
|
||||
QString engineName;
|
||||
QJSValue hook;
|
||||
};
|
||||
|
||||
struct CommanderResult
|
||||
{
|
||||
bool output;
|
||||
QString message;
|
||||
bool error;
|
||||
bool error;
|
||||
bool output;
|
||||
QString message;
|
||||
QJsonObject data;
|
||||
bool is_pre_hook;
|
||||
PostHook post_hook;
|
||||
};
|
||||
|
||||
class BofPacker
|
||||
{
|
||||
public:
|
||||
QByteArray data;
|
||||
void Pack(const QString &type, const QJsonValue &jsonValue);
|
||||
QString Build() const;
|
||||
};
|
||||
|
||||
class Commander
|
||||
|
||||
class Commander : public QObject
|
||||
{
|
||||
QList<Command> commands;
|
||||
QMap<QString, ExtModule> extModules;
|
||||
Q_OBJECT
|
||||
|
||||
QString agentType;
|
||||
QString listenerType;
|
||||
QString error;
|
||||
|
||||
Constant ParseConstant(QJsonObject jsonObject);
|
||||
Command ParseCommand(QJsonObject jsonObject);
|
||||
Argument ParseArgument(const QString &argString);
|
||||
CommanderResult ProcessCommand(AgentData agentData, Command command, QStringList args, ExtModule extMod);
|
||||
QString ProcessExecExtension(const AgentData &agentData, ExtModule extMod, QString ExecString, QList<Argument> args, QJsonObject jsonObj);
|
||||
CommandsGroup regCommandsGroup;
|
||||
QVector<CommandsGroup> axCommandsGroup;
|
||||
|
||||
QString ProcessPreHook(QJSEngine *engine, const Command &command, const QString &agentId, const QString &cmdline, const QJsonObject &jsonObj, QStringList args);
|
||||
CommanderResult ProcessCommand(Command command, QStringList args, QJsonObject jsonObj);
|
||||
CommanderResult ProcessHelp(QStringList commandParts);
|
||||
|
||||
public:
|
||||
explicit Commander();
|
||||
~Commander();
|
||||
~Commander() override;
|
||||
|
||||
void AddRegCommands(const CommandsGroup &group);
|
||||
void AddAxCommands(const CommandsGroup &group);
|
||||
void RemoveAxCommands(const QString &filepath);
|
||||
|
||||
bool AddRegCommands(const QByteArray &jsonData);
|
||||
bool AddExtModule(const QString &filepath, const QString &extName, QList<QJsonObject> extCommands, QList<QJsonObject> extConstants);
|
||||
void RemoveExtModule(const QString &filepath);
|
||||
QString GetError();
|
||||
QStringList GetCommands();
|
||||
CommanderResult ProcessInput(AgentData agentData, QString input);
|
||||
CommanderResult ProcessInput(QString agentId, QString cmdline);
|
||||
|
||||
signals:
|
||||
void commandsUpdated();
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_COMMANDER_H
|
||||
#endif
|
||||
|
||||
@@ -28,4 +28,4 @@ public:
|
||||
void Update(QJsonObject jsonObjTaskData);
|
||||
};
|
||||
|
||||
#endif //TASK_H
|
||||
#endif
|
||||
|
||||
@@ -14,4 +14,4 @@ public:
|
||||
~TaskTableWidgetItem() override;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_TABLEWIDGETITEMTASK_H
|
||||
#endif
|
||||
|
||||
@@ -34,4 +34,4 @@ public:
|
||||
void SetRefreshToken(const QString &token);
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_AUTHPROFILE_H
|
||||
#endif
|
||||
@@ -0,0 +1,67 @@
|
||||
#ifndef AXCOMMANDWRAPPERS_H
|
||||
#define AXCOMMANDWRAPPERS_H
|
||||
|
||||
#include <QJSEngine>
|
||||
#include <QObject>
|
||||
#include <QJSValue>
|
||||
#include <Agent/Commander.h>
|
||||
|
||||
class AxCommandWrappers : public QObject {
|
||||
Q_OBJECT
|
||||
Command command;
|
||||
|
||||
public:
|
||||
explicit AxCommandWrappers(const QString &name, const QString &description, const QString &example, const QString &message, QObject* parent = nullptr);
|
||||
|
||||
Command getCommand() const;
|
||||
|
||||
Q_INVOKABLE void addSubCommands(const QJSValue& array);
|
||||
|
||||
Q_INVOKABLE void addArgBool(const QString &flag, const QString &description = "");
|
||||
Q_INVOKABLE void addArgBool(const QString &flag, const QString &description, const QJSValue &value);
|
||||
|
||||
Q_INVOKABLE void addArgInt(const QString &name, bool required = false, const QString &description = "");
|
||||
Q_INVOKABLE void addArgInt(const QString &name, const QString &description, const QJSValue &value);
|
||||
Q_INVOKABLE void addArgFlagInt(const QString &flag, const QString &name, bool required = false, const QString &description = "");
|
||||
Q_INVOKABLE void addArgFlagInt(const QString &flag, const QString &name, const QString &description, const QJSValue &value);
|
||||
|
||||
Q_INVOKABLE void addArgString(const QString &name, bool required = false, const QString &description = "");
|
||||
Q_INVOKABLE void addArgString(const QString &name, const QString &description, const QJSValue &value);
|
||||
Q_INVOKABLE void addArgFlagString(const QString &flag, const QString &name, bool required = false, const QString &description = "");
|
||||
Q_INVOKABLE void addArgFlagString(const QString &flag, const QString &name, const QString &description, const QJSValue &value);
|
||||
|
||||
Q_INVOKABLE void addArgFile(const QString &name, bool required = false, const QString &description = "");
|
||||
Q_INVOKABLE void addArgFlagFile(const QString &flag, const QString &name, bool required = false, const QString &description = "");
|
||||
|
||||
Q_INVOKABLE void setPreHook(const QJSValue& handler);
|
||||
|
||||
signals:
|
||||
void scriptError(const QString &msg);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class AxCommandGroupWrapper : public QObject {
|
||||
Q_OBJECT
|
||||
QObject* parent;
|
||||
QString name;
|
||||
QList<Command> commands;
|
||||
QJSEngine* engine;
|
||||
|
||||
public:
|
||||
explicit AxCommandGroupWrapper(QJSEngine* engine, QObject* parent = nullptr);
|
||||
|
||||
void SetParams(const QString &name, const QJSValue& array);
|
||||
QString getName() const;
|
||||
QList<Command> getCommands() const;
|
||||
QJSEngine* getEngine() const;
|
||||
|
||||
Q_INVOKABLE void add(const QJSValue& array);
|
||||
|
||||
signals:
|
||||
void scriptError(const QString &msg);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,794 @@
|
||||
#ifndef AXELEMENTWRAPPERS_H
|
||||
#define AXELEMENTWRAPPERS_H
|
||||
|
||||
#include <QVariant>
|
||||
#include <QJSValue>
|
||||
#include <QBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QSpacerItem>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QSpinBox>
|
||||
#include <QTimeEdit>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QCheckBox>
|
||||
#include <QTabWidget>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QDialogButtonBox>
|
||||
#include <Utils/CustomElements.h>
|
||||
|
||||
class AxScriptEngine;
|
||||
|
||||
inline const QMap<QString, QString> FIELD_MAP_CREDS = {
|
||||
{"username", "Username"},
|
||||
{"password", "Password"},
|
||||
{"realm", "Realm"},
|
||||
{"type", "Type"},
|
||||
{"tag", "Tag"},
|
||||
{"date", "Date"},
|
||||
{"storage", "Storage"},
|
||||
{"agent_id", "Agent"},
|
||||
{"host", "Host"}
|
||||
};
|
||||
|
||||
/// ABSTRACT
|
||||
|
||||
class AbstractAxLayout {
|
||||
public:
|
||||
virtual ~AbstractAxLayout() = default;
|
||||
virtual QLayout* layout() const = 0;
|
||||
};
|
||||
|
||||
|
||||
class AbstractAxMenuItem : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AbstractAxMenuItem(QObject* parent = nullptr) : QObject(parent) {}
|
||||
virtual void setContext(QVariantList context) = 0;
|
||||
};
|
||||
|
||||
|
||||
class AbstractAxElement {
|
||||
public:
|
||||
virtual ~AbstractAxElement() = default;
|
||||
virtual QVariant jsonMarshal() const = 0;
|
||||
virtual void jsonUnmarshal(const QVariant& value) = 0;
|
||||
};
|
||||
|
||||
|
||||
class AbstractAxSelector {
|
||||
public:
|
||||
virtual QJSValue selected_data() const = 0;
|
||||
};
|
||||
|
||||
|
||||
class AbstractAxVisualElement {
|
||||
public:
|
||||
virtual ~AbstractAxVisualElement() = default;
|
||||
|
||||
virtual QWidget* widget() const = 0;
|
||||
virtual void setEnabled(const bool enable) const = 0;
|
||||
virtual void setVisible(const bool enable) const = 0;
|
||||
virtual bool getEnabled() const = 0;
|
||||
virtual bool getVisible() const = 0;
|
||||
};
|
||||
|
||||
|
||||
// /// BYTES
|
||||
//
|
||||
// class AxByteArrayWrapper : public QObject {
|
||||
// Q_OBJECT
|
||||
// QByteArray data;
|
||||
//
|
||||
// public:
|
||||
// explicit AxByteArrayWrapper(QString str, QObject* parent = nullptr);
|
||||
//
|
||||
// Q_INVOKABLE QString toHex() const;
|
||||
// Q_INVOKABLE QString toBase64() const;
|
||||
// Q_INVOKABLE QString toString() const;
|
||||
// Q_INVOKABLE QVariantList toIntArray() const;
|
||||
// Q_INVOKABLE int at(int index) const;
|
||||
// Q_INVOKABLE void clear();
|
||||
// Q_INVOKABLE int size() const;
|
||||
// Q_INVOKABLE bool contains(QObject* other) const;
|
||||
//
|
||||
// Q_INVOKABLE int compare(QObject* other) const;
|
||||
// Q_INVOKABLE void trimmed();
|
||||
// Q_INVOKABLE void prepend(QObject* value);
|
||||
// Q_INVOKABLE void append(QObject* value);
|
||||
// Q_INVOKABLE void insert(int index, QObject* value);
|
||||
// Q_INVOKABLE AxByteArrayWrapper* slice(int start, int length = -1) const;
|
||||
// };
|
||||
|
||||
|
||||
|
||||
// MENU
|
||||
|
||||
class AxActionWrapper : public AbstractAxMenuItem {
|
||||
Q_OBJECT
|
||||
QJSValue handler;
|
||||
QPointer<QAction> pAction;
|
||||
QJSEngine* engine;
|
||||
|
||||
public:
|
||||
explicit AxActionWrapper(const QString& text, const QJSValue& handler, QJSEngine* engine, QObject* parent = nullptr);
|
||||
QAction* action() const;
|
||||
void setContext(QVariantList context) override;
|
||||
|
||||
void triggerWithContext(const QVariantList& arg) const;
|
||||
};
|
||||
|
||||
|
||||
class AxSeparatorWrapper : public AbstractAxMenuItem {
|
||||
Q_OBJECT
|
||||
QPointer<QAction> pAction;
|
||||
|
||||
public:
|
||||
explicit AxSeparatorWrapper(QObject* parent = nullptr);
|
||||
QAction* action() const;
|
||||
void setContext(QVariantList context) override;
|
||||
};
|
||||
|
||||
|
||||
class AxMenuWrapper : public AbstractAxMenuItem {
|
||||
Q_OBJECT
|
||||
QPointer<QMenu> pMenu;
|
||||
QList<AbstractAxMenuItem*> items;
|
||||
|
||||
public:
|
||||
explicit AxMenuWrapper(const QString& title, QObject* parent = nullptr);
|
||||
QMenu* menu() const;
|
||||
void setContext(QVariantList context) override;
|
||||
|
||||
Q_INVOKABLE void addItem(AbstractAxMenuItem* item);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// LAYOUT
|
||||
|
||||
class AxBoxLayoutWrapper : public QObject, public AbstractAxLayout {
|
||||
Q_OBJECT
|
||||
QBoxLayout* boxLayout;
|
||||
|
||||
public:
|
||||
explicit AxBoxLayoutWrapper(QBoxLayout::Direction dir, QObject* parent = nullptr);
|
||||
|
||||
QBoxLayout* layout() const override;
|
||||
|
||||
Q_INVOKABLE void addWidget(QObject* widgetWrapper) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class AxGridLayoutWrapper : public QObject, public AbstractAxLayout {
|
||||
Q_OBJECT
|
||||
QGridLayout* gridLayout;
|
||||
|
||||
public:
|
||||
explicit AxGridLayoutWrapper(QObject* parent = nullptr);
|
||||
|
||||
QGridLayout* layout() const override;
|
||||
|
||||
Q_INVOKABLE void addWidget(QObject* widgetWrapper, int row, int col, int rowSpan = 1, int colSpan = 1) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// LINE
|
||||
|
||||
class AxLineWrapper : public QObject, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QFrame* line;
|
||||
|
||||
public:
|
||||
explicit AxLineWrapper(QFrame::Shape dir, QObject* parent = nullptr);
|
||||
|
||||
QFrame* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// SPACER
|
||||
|
||||
class AxSpacerWrapper : public QObject {
|
||||
Q_OBJECT
|
||||
QSpacerItem* spacer;
|
||||
|
||||
public:
|
||||
explicit AxSpacerWrapper(int w, int h, QSizePolicy::Policy hData, QSizePolicy::Policy vData, QObject* parent = nullptr);
|
||||
|
||||
QSpacerItem* widget() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// TEXTLINE
|
||||
|
||||
class AxTextLineWrapper : public QObject, public AbstractAxElement, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QLineEdit* lineedit;
|
||||
|
||||
public:
|
||||
explicit AxTextLineWrapper(QLineEdit* edit, QObject* parent = nullptr);
|
||||
|
||||
QVariant jsonMarshal() const override;
|
||||
void jsonUnmarshal(const QVariant& value) override;
|
||||
|
||||
QLineEdit* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE QString text() const;
|
||||
Q_INVOKABLE void setText(const QString& text) const;
|
||||
Q_INVOKABLE void setPlaceholder(const QString& text) const;
|
||||
Q_INVOKABLE void setReadOnly(const bool& readonly) const;
|
||||
|
||||
signals:
|
||||
void textChanged(const QString &text);
|
||||
void textEdited(const QString &text);
|
||||
void returnPressed();
|
||||
void editingFinished();
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// COMBO
|
||||
|
||||
class AxComboBoxWrapper : public QObject, public AbstractAxElement, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QComboBox* comboBox;
|
||||
|
||||
public:
|
||||
explicit AxComboBoxWrapper(QComboBox* comboBox, QObject* parent = nullptr);
|
||||
|
||||
QVariant jsonMarshal() const override;
|
||||
void jsonUnmarshal(const QVariant& value) override;
|
||||
|
||||
QComboBox* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE void addItem(const QString& text) const;
|
||||
Q_INVOKABLE void addItems(const QJSValue& array) const;
|
||||
Q_INVOKABLE void setItems(const QJSValue& array) const;
|
||||
Q_INVOKABLE void clear() const;
|
||||
Q_INVOKABLE QString currentText() const;
|
||||
Q_INVOKABLE void setCurrentIndex(int index) const;
|
||||
Q_INVOKABLE int currentIndex() const;
|
||||
|
||||
signals:
|
||||
void currentTextChanged(const QString &text);
|
||||
void currentIndexChanged(int index);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// SPIN
|
||||
|
||||
class AxSpinBoxWrapper : public QObject, public AbstractAxElement, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QSpinBox* spin;
|
||||
|
||||
public:
|
||||
explicit AxSpinBoxWrapper(QSpinBox* spin, QObject* parent = nullptr);
|
||||
|
||||
QVariant jsonMarshal() const override;
|
||||
void jsonUnmarshal(const QVariant& value) override;
|
||||
|
||||
QSpinBox* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE int value() const;
|
||||
Q_INVOKABLE void setValue(int value) const;
|
||||
Q_INVOKABLE void setRange(int min, int max) const;
|
||||
|
||||
signals:
|
||||
void valueChanged(int);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// DATE
|
||||
|
||||
class AxDateEditWrapper : public QObject, public AbstractAxElement, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QDateEdit* dateedit;
|
||||
|
||||
public:
|
||||
explicit AxDateEditWrapper(QDateEdit* edit, const QString &format, QObject* parent = nullptr);
|
||||
|
||||
QVariant jsonMarshal() const override;
|
||||
void jsonUnmarshal(const QVariant& value) override;
|
||||
|
||||
QDateEdit* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE QString dateString() const;
|
||||
Q_INVOKABLE void setDateString(const QString& date) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// TEXTEDIT
|
||||
|
||||
class AxTimeEditWrapper : public QObject, public AbstractAxElement, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QTimeEdit* timeedit;
|
||||
|
||||
public:
|
||||
explicit AxTimeEditWrapper(QTimeEdit* edit, const QString &format, QObject* parent = nullptr);
|
||||
|
||||
QVariant jsonMarshal() const override;
|
||||
void jsonUnmarshal(const QVariant& value) override;
|
||||
|
||||
QTimeEdit* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE QString timeString() const;
|
||||
Q_INVOKABLE void setTimeString(const QString& time) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// TEXTMULTI
|
||||
|
||||
class AxTextMultiWrapper : public QObject, public AbstractAxElement, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QPlainTextEdit* textedit;
|
||||
|
||||
public:
|
||||
explicit AxTextMultiWrapper(QPlainTextEdit* edit, QObject* parent = nullptr);
|
||||
|
||||
QVariant jsonMarshal() const override;
|
||||
void jsonUnmarshal(const QVariant& value) override;
|
||||
|
||||
QPlainTextEdit* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE QString text() const;
|
||||
Q_INVOKABLE void setText(const QString& text) const;
|
||||
Q_INVOKABLE void appendText(const QString& text) const;
|
||||
Q_INVOKABLE void setPlaceholder(const QString& text) const;
|
||||
Q_INVOKABLE void setReadOnly(const bool& readonly) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// CHECK
|
||||
|
||||
class AxCheckBoxWrapper : public QObject, public AbstractAxElement, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QCheckBox* check;
|
||||
|
||||
public:
|
||||
explicit AxCheckBoxWrapper(QCheckBox* box, QObject* parent = nullptr);
|
||||
|
||||
QVariant jsonMarshal() const override;
|
||||
void jsonUnmarshal(const QVariant& value) override;
|
||||
|
||||
QCheckBox* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE bool isChecked() const;
|
||||
Q_INVOKABLE void setChecked(bool checked) const;
|
||||
|
||||
signals:
|
||||
void stateChanged();
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// LABEL
|
||||
|
||||
class AxLabelWrapper : public QObject, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QLabel* label;
|
||||
|
||||
public:
|
||||
explicit AxLabelWrapper(QLabel* label, QObject* parent = nullptr);
|
||||
|
||||
QLabel* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE void setText(const QString& text) const;
|
||||
Q_INVOKABLE QString text() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// TAB
|
||||
|
||||
class AxTabWrapper : public QObject, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QTabWidget* tabs;
|
||||
|
||||
public:
|
||||
explicit AxTabWrapper(QTabWidget* tabs, QObject* parent = nullptr);
|
||||
|
||||
QTabWidget* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE void addTab(QObject* wrapper, const QString &title) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// TABLE
|
||||
|
||||
class AxTableWidgetWrapper : public QObject, public AbstractAxElement, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QTableWidget* table;
|
||||
QJSEngine* engine;
|
||||
|
||||
explicit AxTableWidgetWrapper(const QJSValue &headers, QTableWidget* tableWidget, QJSEngine* jsEngine, QObject* parent = nullptr);
|
||||
|
||||
QVariant jsonMarshal() const override;
|
||||
void jsonUnmarshal(const QVariant& value) override;
|
||||
|
||||
QTableWidget* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE void addColumn(const QString &header) const;
|
||||
Q_INVOKABLE void setColumns(const QJSValue &headers) const;
|
||||
Q_INVOKABLE void addItem(const QJSValue &items) const;
|
||||
Q_INVOKABLE int rowCount() const;
|
||||
Q_INVOKABLE int columnCount() const;
|
||||
Q_INVOKABLE void setRowCount(int rows);
|
||||
Q_INVOKABLE void setColumnCount(int cols);
|
||||
Q_INVOKABLE int currentRow() const;
|
||||
Q_INVOKABLE int currentColumn() const;
|
||||
Q_INVOKABLE void setSortingEnabled(bool enable);
|
||||
Q_INVOKABLE void resizeToContent(int column);
|
||||
Q_INVOKABLE QString text(int row, int column) const;
|
||||
Q_INVOKABLE void setText(int row, int column, const QString &text) const;
|
||||
Q_INVOKABLE void setReadOnly(bool read);
|
||||
Q_INVOKABLE void hideColumn(int column);
|
||||
Q_INVOKABLE void setHeadersVisible(bool enable);
|
||||
Q_INVOKABLE void setColumnAlign(int column, const QString &align);
|
||||
Q_INVOKABLE void clear();
|
||||
Q_INVOKABLE QJSValue selectedRows();
|
||||
|
||||
signals:
|
||||
void cellChanged(int row, int column);
|
||||
void cellClicked(int row, int column);
|
||||
void cellDoubleClicked(int row, int column);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// LIST
|
||||
|
||||
class AxListWidgetWrapper : public QObject, public AbstractAxElement, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QListWidget* list;
|
||||
QJSEngine* engine;
|
||||
|
||||
bool readonly = false;
|
||||
|
||||
public:
|
||||
explicit AxListWidgetWrapper(QListWidget* widget, QJSEngine* engine, QObject* parent = nullptr);
|
||||
|
||||
QVariant jsonMarshal() const override;
|
||||
void jsonUnmarshal(const QVariant& value) override;
|
||||
|
||||
QListWidget* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE QJSValue items();
|
||||
Q_INVOKABLE void addItem(const QString& text);
|
||||
Q_INVOKABLE void addItems(const QJSValue &items);
|
||||
Q_INVOKABLE void removeItem(int index);
|
||||
Q_INVOKABLE QString itemText(int index) const;
|
||||
Q_INVOKABLE void setItemText(int index, const QString& text);
|
||||
Q_INVOKABLE void clear();
|
||||
Q_INVOKABLE int count() const;
|
||||
Q_INVOKABLE int currentRow() const;
|
||||
Q_INVOKABLE void setCurrentRow(int row);
|
||||
Q_INVOKABLE QJSValue selectedRows() const;
|
||||
Q_INVOKABLE void setReadOnly(bool readonly);
|
||||
|
||||
signals:
|
||||
void currentTextChanged(const QString ¤tText);
|
||||
void currentRowChanged(int currentRow);
|
||||
void itemClickedText(const QString& text);
|
||||
void itemDoubleClickedText(const QString& text);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// BUTTON
|
||||
|
||||
class AxButtonWrapper : public QObject, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QPushButton* button;
|
||||
|
||||
public:
|
||||
explicit AxButtonWrapper(QPushButton* btn, QObject* parent = nullptr);
|
||||
|
||||
QPushButton* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// GROUPBOX
|
||||
|
||||
|
||||
class AxGroupBoxWrapper : public QObject, public AbstractAxElement, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QGroupBox* groupBox;
|
||||
|
||||
public:
|
||||
explicit AxGroupBoxWrapper(const bool checkable, QGroupBox* box, QObject* parent = nullptr);
|
||||
|
||||
QVariant jsonMarshal() const override;
|
||||
void jsonUnmarshal(const QVariant& value) override;
|
||||
|
||||
QGroupBox* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE void setTitle(const QString& title);
|
||||
Q_INVOKABLE bool isCheckable() const;
|
||||
Q_INVOKABLE void setCheckable(bool checkable);
|
||||
Q_INVOKABLE bool isChecked() const;
|
||||
Q_INVOKABLE void setChecked(bool checked);
|
||||
Q_INVOKABLE void setPanel(QObject* panel) const;
|
||||
|
||||
signals:
|
||||
void clicked(bool checked = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// SCROLLAREA
|
||||
|
||||
class AxScrollAreaWrapper : public QObject, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QScrollArea* scrollArea;
|
||||
|
||||
public:
|
||||
explicit AxScrollAreaWrapper(QScrollArea* area, QObject* parent = nullptr);
|
||||
|
||||
QScrollArea* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE void setPanel(QObject* panel) const;
|
||||
Q_INVOKABLE void setWidgetResizable(bool resizable);
|
||||
};
|
||||
|
||||
|
||||
/// SPLITTER
|
||||
|
||||
class AxSplitterWrapper : public QObject, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QSplitter* splitter;
|
||||
|
||||
public:
|
||||
explicit AxSplitterWrapper(QSplitter* splitter, QObject* parent = nullptr);
|
||||
|
||||
QSplitter* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE void addPage(QObject* w);
|
||||
Q_INVOKABLE void setSizes(const QVariantList& sizes);
|
||||
|
||||
signals:
|
||||
void splitterMoved(int pos, int index);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// STACK
|
||||
|
||||
class AxStackedWidgetWrapper : public QObject, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QStackedWidget* stack;
|
||||
|
||||
public:
|
||||
explicit AxStackedWidgetWrapper(QStackedWidget* widget, QObject* parent = nullptr);
|
||||
|
||||
QStackedWidget* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE int addPage(QObject* page);
|
||||
Q_INVOKABLE int insertPage(int index, QObject* page);
|
||||
Q_INVOKABLE void removePage(int index);
|
||||
Q_INVOKABLE void setCurrentIndex(int index);
|
||||
Q_INVOKABLE int currentIndex() const;
|
||||
Q_INVOKABLE int count() const;
|
||||
|
||||
signals:
|
||||
void currentChanged(int index);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// PANEL
|
||||
|
||||
class AxPanelWrapper : public QObject, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
QWidget* panel;
|
||||
|
||||
public:
|
||||
explicit AxPanelWrapper(QWidget* w, QObject* parent = nullptr);
|
||||
|
||||
QWidget* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE void setLayout(QObject* layoutWrapper) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// CONTAINER
|
||||
|
||||
class AxContainerWrapper : public QObject {
|
||||
Q_OBJECT
|
||||
QJSEngine* engine;
|
||||
QMap<QString, QObject*> widgets;
|
||||
|
||||
public:
|
||||
explicit AxContainerWrapper(QJSEngine* jsEngine, QObject* parent = nullptr);
|
||||
|
||||
Q_INVOKABLE void put(const QString& id, QObject* wrapper);
|
||||
Q_INVOKABLE QObject* get(const QString& id);
|
||||
Q_INVOKABLE bool contains(const QString& id) const;
|
||||
Q_INVOKABLE void remove(const QString& id);
|
||||
Q_INVOKABLE QString toJson();
|
||||
Q_INVOKABLE void fromJson(const QString& jsonString);
|
||||
Q_INVOKABLE QJSValue toProperty();
|
||||
Q_INVOKABLE void fromProperty(const QJSValue& obj);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// DIALOG
|
||||
|
||||
class AxDialogWrapper : public QObject {
|
||||
Q_OBJECT
|
||||
QDialog* dialog;
|
||||
QVBoxLayout* layout;
|
||||
QLayout* userLayout = nullptr;
|
||||
QDialogButtonBox* buttons;
|
||||
|
||||
public:
|
||||
explicit AxDialogWrapper(const QString& title, QWidget* parent = nullptr);
|
||||
|
||||
Q_INVOKABLE void setLayout(QObject* layoutWrapper);
|
||||
Q_INVOKABLE void setSize(int w, int h) const;
|
||||
Q_INVOKABLE bool exec() const;
|
||||
Q_INVOKABLE void close() const;
|
||||
Q_INVOKABLE void setButtonsText(const QString& ok_text, const QString& cancel_text) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// SELECTOR FILE
|
||||
|
||||
class AxSelectorFile : public QObject, public AbstractAxElement, public AbstractAxVisualElement {
|
||||
Q_OBJECT
|
||||
FileSelector* selector;
|
||||
|
||||
public:
|
||||
explicit AxSelectorFile(FileSelector* selector, QObject* parent = nullptr);
|
||||
|
||||
QVariant jsonMarshal() const override;
|
||||
void jsonUnmarshal(const QVariant& value) override;
|
||||
|
||||
FileSelector* widget() const override;
|
||||
Q_INVOKABLE void setEnabled(const bool enable) const override { widget()->setEnabled(enable); }
|
||||
Q_INVOKABLE void setVisible(const bool enable) const override { widget()->setVisible(enable); }
|
||||
Q_INVOKABLE bool getEnabled() const override { return widget()->isEnabled(); }
|
||||
Q_INVOKABLE bool getVisible() const override { return widget()->isVisible(); }
|
||||
|
||||
Q_INVOKABLE void setPlaceholder(const QString& text) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// SELECTOR CREDENTIALS
|
||||
|
||||
class AxDialogCreds : public QDialog {
|
||||
Q_OBJECT
|
||||
QVBoxLayout* mainLayout = nullptr;
|
||||
QTableWidget* tableWidget = nullptr;
|
||||
QHBoxLayout* bottomLayout = nullptr;
|
||||
QPushButton* chooseButton = nullptr;
|
||||
QSpacerItem* spacer_1 = nullptr;
|
||||
QSpacerItem* spacer_2 = nullptr;
|
||||
|
||||
QWidget* searchWidget = nullptr;
|
||||
QHBoxLayout* searchLayout = nullptr;
|
||||
QLineEdit* searchLineEdit = nullptr;
|
||||
ClickableLabel* hideButton = nullptr;
|
||||
|
||||
QVector<QString> table_headers;
|
||||
QVector<QMap<QString, QString> > credList;
|
||||
QMap<QString, CredentialData> allData;
|
||||
QVector<CredentialData> selectedData;
|
||||
|
||||
public:
|
||||
explicit AxDialogCreds(const QJSValue &headers, QVector<CredentialData> vecCreds, QTableWidget* tableWidget, QPushButton* button, QWidget* parent = nullptr);
|
||||
|
||||
QVector<CredentialData> data();
|
||||
|
||||
public slots:
|
||||
void onClicked();
|
||||
void handleSearch();
|
||||
void clearSearch();
|
||||
};
|
||||
|
||||
class AxSelectorCreds : public QObject {
|
||||
Q_OBJECT
|
||||
AxDialogCreds* dialog;
|
||||
AxScriptEngine* scriptEngine;
|
||||
QMap<QString, CredentialData> creds;
|
||||
|
||||
public:
|
||||
explicit AxSelectorCreds(const QJSValue &headers, QTableWidget* tableWidget, QPushButton* button, AxScriptEngine* jsEngine, QWidget* parent = nullptr);
|
||||
|
||||
Q_INVOKABLE void setSize(int w, int h) const;
|
||||
Q_INVOKABLE QJSValue exec() const;
|
||||
Q_INVOKABLE void close() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,95 @@
|
||||
#ifndef AXSCRIPTENGINE_H
|
||||
#define AXSCRIPTENGINE_H
|
||||
|
||||
#include <QAction>
|
||||
#include <QJSValue>
|
||||
#include <QJSEngine>
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
|
||||
class BridgeApp;
|
||||
class BridgeForm;
|
||||
class BridgeEvent;
|
||||
class BridgeMenu;
|
||||
class AbstractAxMenuItem;
|
||||
class AxScriptManager;
|
||||
|
||||
struct AxEvent {
|
||||
QJSValue handler;
|
||||
QString event_id;
|
||||
QSet<QString> agents;
|
||||
QSet<QString> listenerts;
|
||||
QSet<int> os;
|
||||
QJSEngine* jsEngine;
|
||||
};
|
||||
|
||||
struct AxMenuItem {
|
||||
AbstractAxMenuItem* menu;
|
||||
QSet<QString> agents;
|
||||
QSet<QString> listenerts;
|
||||
QSet<int> os;
|
||||
};
|
||||
|
||||
struct ScriptContext {
|
||||
QString name;
|
||||
QJSValue scriptObject;
|
||||
QList<QObject*> objects;
|
||||
QList<QAction*> actions;
|
||||
|
||||
QList<AxEvent> eventFileBroserDisks;
|
||||
QList<AxEvent> eventFileBroserList;
|
||||
QList<AxEvent> eventFileBroserUpload;
|
||||
QList<AxEvent> eventProcessBrowserList;
|
||||
|
||||
QList<AxMenuItem> menuSessionMain;
|
||||
QList<AxMenuItem> menuSessionAgent;
|
||||
QList<AxMenuItem> menuSessionBrowser;
|
||||
QList<AxMenuItem> menuSessionAccess;
|
||||
QList<AxMenuItem> menuFileBrowser;
|
||||
QList<AxMenuItem> menuProcessBrowser;
|
||||
QList<AxMenuItem> menuDownloadRunning;
|
||||
QList<AxMenuItem> menuDownloadFinished;
|
||||
QList<AxMenuItem> menuTasks;
|
||||
QList<AxMenuItem> menuTasksJob;
|
||||
};
|
||||
|
||||
class AxScriptEngine : public QObject {
|
||||
Q_OBJECT
|
||||
AxScriptManager* scriptManager;
|
||||
|
||||
std::unique_ptr<QJSEngine> jsEngine;
|
||||
std::unique_ptr<BridgeApp> bridgeApp;
|
||||
std::unique_ptr<BridgeForm> bridgeForm;
|
||||
std::unique_ptr<BridgeEvent> bridgeEvent;
|
||||
std::unique_ptr<BridgeMenu> bridgeMenu;
|
||||
|
||||
public:
|
||||
ScriptContext context;
|
||||
|
||||
explicit AxScriptEngine(AxScriptManager* script_manager, const QString &name = "", QObject *parent = nullptr);
|
||||
~AxScriptEngine() override;
|
||||
|
||||
QJSEngine* engine() const;
|
||||
BridgeApp* app() const;
|
||||
BridgeForm* form() const;
|
||||
BridgeEvent* event() const;
|
||||
BridgeMenu* menu() const;
|
||||
|
||||
AxScriptManager* manager() const;
|
||||
|
||||
void registerObject(QObject* obj);
|
||||
void registerAction(QAction* action);
|
||||
void registerEvent(const QString &type, const QJSValue &handler, const QSet<QString> &list_agents, const QSet<QString> &list_os, const QSet<QString> &list_listeners, const QString &id);
|
||||
void removeEvent(const QString &id);
|
||||
void registerMenu(const QString &type, AbstractAxMenuItem* menu, const QSet<QString> &list_agents, const QSet<QString> &list_os, const QSet<QString> &list_listeners);
|
||||
bool execute(const QString &code);
|
||||
|
||||
QList<AxEvent> getEvents(const QString &type);
|
||||
QList<AxMenuItem> getMenuItems(const QString &type);
|
||||
|
||||
public slots:
|
||||
void engineError(const QString &message);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,105 @@
|
||||
#ifndef AXSCRIPTMANAGER_H
|
||||
#define AXSCRIPTMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMenu>
|
||||
#include <QJSValue>
|
||||
#include <Agent/Commander.h>
|
||||
#include <main.h>
|
||||
|
||||
struct ExtensionFile;
|
||||
struct AxMenuItem;
|
||||
struct AxEvent;
|
||||
class AxScriptEngine;
|
||||
class AdaptixWidget;
|
||||
class Agent;
|
||||
|
||||
struct DataMenuFileBrowser {
|
||||
QString agentId;
|
||||
QString path;
|
||||
QString name;
|
||||
QString type;
|
||||
};
|
||||
|
||||
struct DataMenuProcessBrowser {
|
||||
QString agentId;
|
||||
QString pid;
|
||||
QString ppid;
|
||||
QString arch;
|
||||
QString session_id;
|
||||
QString context;
|
||||
QString process;
|
||||
};
|
||||
|
||||
struct DataMenuDownload {
|
||||
QString agentId;
|
||||
QString fileId;
|
||||
QString path;
|
||||
QString state;
|
||||
};
|
||||
|
||||
class AxScriptManager : public QObject {
|
||||
Q_OBJECT
|
||||
AdaptixWidget* adaptixWidget = nullptr;
|
||||
AxScriptEngine* mainScript = nullptr;
|
||||
QMap<QString, AxScriptEngine*> scripts;
|
||||
QMap<QString, AxScriptEngine*> listeners_scripts;
|
||||
QMap<QString, AxScriptEngine*> agents_scripts;
|
||||
|
||||
public:
|
||||
AxScriptManager(AdaptixWidget* main_widget, QObject *parent = nullptr);
|
||||
~AxScriptManager() override;
|
||||
|
||||
QJSEngine* MainScriptEngine();
|
||||
void ResetMain();
|
||||
void Clear();
|
||||
|
||||
QJSEngine* GetEngine(const QString &name);
|
||||
AdaptixWidget* GetAdaptix() const;
|
||||
QMap<QString, Agent*> GetAgents() const;
|
||||
QVector<CredentialData> GetCredentials() const;
|
||||
QStringList GetInterfaces() const;
|
||||
|
||||
QStringList ListenerScriptList();
|
||||
void ListenerScriptAdd(const QString &name, const QString &ax_script);
|
||||
QJSEngine* ListenerScriptEngine(const QString &name);
|
||||
|
||||
QStringList AgentScriptList();
|
||||
void AgentScriptAdd(const QString &name, const QString &ax_script);
|
||||
QJSEngine* AgentScriptEngine(const QString &name);
|
||||
QJSValue AgentScriptExecute(const QString &name, const QString &code);
|
||||
|
||||
QStringList ScriptList();
|
||||
bool ScriptAdd(ExtensionFile* ext);
|
||||
void ScriptRemove(const ExtensionFile &ext);
|
||||
|
||||
void GlobalScriptLoad(const QString &path);
|
||||
void GlobalScriptUnload(const QString &path);
|
||||
|
||||
void RegisterCommandsGroup(const CommandsGroup &group, const QStringList &listeners, const QStringList &agents, const QList<int> &os);
|
||||
void RemoveEvent(const QString &event_id);
|
||||
QList<AxMenuItem> FilterMenuItems(const QStringList &agentIds, const QString &menuType);
|
||||
QList<AxEvent> FilterEvents(const QString &agentId, const QString &eventType);
|
||||
|
||||
void AppAgentSetColor(const QStringList &agents, const QString &background, const QString &foreground, const bool reset);
|
||||
void AppAgentSetImpersonate(const QString &id, const QString &impersonate, const bool elevated);
|
||||
void AppAgentSetMark(const QStringList &agents, const QString &mark);
|
||||
void AppAgentSetTag(const QStringList &agents, const QString &tag);
|
||||
|
||||
int AddMenuSession(QMenu* menu, const QString &menuType, QStringList agentIds);
|
||||
int AddMenuFileBrowser(QMenu* menu, QVector<DataMenuFileBrowser> files);
|
||||
int AddMenuProcessBrowser(QMenu* menu, QVector<DataMenuProcessBrowser> processes);
|
||||
int AddMenuDownload(QMenu* menu, const QString &menuType, QVector<DataMenuDownload> files);
|
||||
int AddMenuTask(QMenu* menu, const QString &menuType, const QStringList &tasks);
|
||||
|
||||
public slots:
|
||||
void consolePrintMessage(const QString &message);
|
||||
void consolePrintError(const QString &message);
|
||||
|
||||
void emitFileBrowserDisks(const QString &agentId);
|
||||
void emitFileBrowserList(const QString &agentId, const QString &path);
|
||||
void emitFileBrowserUpload(const QString &agentId, const QString &path, const QString &localFilename);
|
||||
void emitProcessBrowserList(const QString &agentId);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
#ifndef BRIDGEAPP_H
|
||||
#define BRIDGEAPP_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QJSValue>
|
||||
|
||||
class AxScriptEngine;
|
||||
class Command;
|
||||
|
||||
class BridgeApp : public QObject {
|
||||
Q_OBJECT
|
||||
AxScriptEngine* scriptEngine;
|
||||
QWidget* widget;
|
||||
|
||||
public:
|
||||
explicit BridgeApp(AxScriptEngine* scriptEngine, QObject* parent = nullptr);
|
||||
~BridgeApp() override;
|
||||
AxScriptEngine* GetScriptEngine() const;
|
||||
|
||||
public slots:
|
||||
QJSValue agents() const;
|
||||
QJSValue agent_info(const QString &id, const QString &property) const;
|
||||
void agent_set_color(const QJSValue& agents, const QString &background, const QString &foreground, const bool reset);
|
||||
void agent_set_impersonate(const QString &id, const QString &impersonate, const bool elevated);
|
||||
void agent_set_mark(const QJSValue& agents, const QString &mark);
|
||||
void agent_set_tag(const QJSValue& agents, const QString &tag);
|
||||
QString arch(const QString &id) const;
|
||||
QString bof_pack(const QString &types, const QJSValue &args);
|
||||
void copy_to_clipboard(const QString &text);
|
||||
void console_message(const QString &id, const QString &message, const QString &type = "", const QString &text = "");
|
||||
QJSValue credentials() const;
|
||||
void credentials_add(const QString &username, const QString &password, const QString &realm = "", const QString &type = "password", const QString &tag = "", const QString &storage = "manual", const QString &host = "");
|
||||
QObject* create_command(const QString &name, const QString &description, const QString &example = "", const QString &message = "");
|
||||
QObject* create_commands_group(const QString &name, const QJSValue& array);
|
||||
void execute_alias(const QString &id, const QString &cmdline, const QString &command, const QString &message = "", const QJSValue &hook = QJSValue()) const;
|
||||
void execute_browser(const QString &id, const QString &command) const;
|
||||
void execute_command(const QString &id, const QString &command, const QJSValue &hook = QJSValue()) const;
|
||||
QString file_basename(const QString &path) const;
|
||||
bool file_exists(const QString &path) const;
|
||||
QString file_read(QString path) const;
|
||||
QString format_time(const QString &format, const int &time) const;
|
||||
QJSValue interfaces() const;
|
||||
bool is64(const QString &id) const;
|
||||
bool isadmin(const QString &id) const;
|
||||
void log(const QString &text);
|
||||
void log_error(const QString &text);
|
||||
void open_agent_console(const QString &id);
|
||||
void open_access_tunnel(const QString &id, bool socks4, bool socks5, bool lportfwd, bool rportfwd);
|
||||
void open_browser_files(const QString &id);
|
||||
void open_browser_process(const QString &id);
|
||||
void open_remote_terminal(const QString &id);
|
||||
QString prompt_open_file(const QString &caption = "Select file", const QString &filter = QString());
|
||||
QString prompt_open_dir(const QString &caption = "Select directory");
|
||||
QString prompt_save_file(const QString &filename, const QString &caption = "Select file", const QString &filter = QString());
|
||||
void register_commands_group(QObject* obj, const QJSValue& agents, const QJSValue& os, const QJSValue& listeners);
|
||||
void script_import(const QString &path);
|
||||
void script_load(const QString &path);
|
||||
void script_unload(const QString &path);
|
||||
QString script_dir();
|
||||
void show_message(const QString &title, const QString &text);
|
||||
int ticks();
|
||||
|
||||
signals:
|
||||
void consoleMessage(const QString &msg);
|
||||
void consoleError(const QString &msg);
|
||||
void engineError(const QString &msg);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef BRIDGEEVENT_H
|
||||
#define BRIDGEEVENT_H
|
||||
|
||||
#include <QJSEngine>
|
||||
#include <QJSValue>
|
||||
#include <QList>
|
||||
#include <QWidget>
|
||||
|
||||
class AxScriptEngine;
|
||||
|
||||
class BridgeEvent : public QObject {
|
||||
Q_OBJECT
|
||||
AxScriptEngine* scriptEngine;
|
||||
|
||||
public:
|
||||
explicit BridgeEvent(AxScriptEngine* scriptEngine, QObject* parent = nullptr);
|
||||
~BridgeEvent() override;
|
||||
|
||||
void reg(const QString &event, const QString &type, const QJSValue &handler, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners, const QString &event_id);
|
||||
|
||||
public slots:
|
||||
void on_filebrowser_disks(const QJSValue &handler, const QJSValue &agents, const QJSValue &os = QJSValue(), const QJSValue &listeners = QJSValue(), const QString &event_id = "");
|
||||
void on_filebrowser_list(const QJSValue &handler, const QJSValue &agents, const QJSValue &os = QJSValue(), const QJSValue &listeners = QJSValue(), const QString &event_id = "");
|
||||
void on_filebrowser_upload(const QJSValue &handler, const QJSValue &agents, const QJSValue &os = QJSValue(), const QJSValue &listeners = QJSValue(), const QString &event_id = "");
|
||||
void on_processbrowser_list(const QJSValue &handler, const QJSValue &agents, const QJSValue &os = QJSValue(), const QJSValue &listeners = QJSValue(), const QString &event_id = "");
|
||||
void remove(const QString &event_id);
|
||||
|
||||
signals:
|
||||
void scriptError(const QString &msg);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,112 @@
|
||||
#ifndef BRIDGEFORM_H
|
||||
#define BRIDGEFORM_H
|
||||
|
||||
#include <QJSEngine>
|
||||
#include <QJSValue>
|
||||
#include <QList>
|
||||
#include <QWidget>
|
||||
|
||||
class AxScriptEngine;
|
||||
|
||||
class BridgeForm : public QObject {
|
||||
Q_OBJECT
|
||||
AxScriptEngine* scriptEngine;
|
||||
QWidget* widget;
|
||||
|
||||
public:
|
||||
BridgeForm(AxScriptEngine* scriptEngine, QObject* parent = nullptr);
|
||||
~BridgeForm() override;
|
||||
|
||||
public slots:
|
||||
void connect(QObject* sender, const QString& signal, const QJSValue& handler);
|
||||
|
||||
/// Elements
|
||||
QObject* create_vlayout();
|
||||
QObject* create_hlayout();
|
||||
QObject* create_gridlayout();
|
||||
QObject* create_vline();
|
||||
QObject* create_hline();
|
||||
QObject* create_vspacer();
|
||||
QObject* create_hspacer();
|
||||
QObject* create_label(const QString &text = "");
|
||||
QObject* create_textline(const QString &text = "");
|
||||
QObject* create_combo();
|
||||
QObject* create_check(const QString& label= "");
|
||||
QObject* create_spin();
|
||||
QObject* create_dateline(const QString& format = "dd.MM.yyyy");
|
||||
QObject* create_timeline(const QString& format = "HH:mm:ss");
|
||||
QObject* create_button(const QString& text= "");
|
||||
QObject* create_textmulti(const QString& text= "");
|
||||
QObject* create_list();
|
||||
QObject* create_table(const QJSValue &headers);
|
||||
|
||||
QObject* create_tabs();
|
||||
QObject* create_groupbox(const QString& title = "", const bool checkable = false);
|
||||
QObject* create_hsplitter();
|
||||
QObject* create_vsplitter();
|
||||
QObject* create_scrollarea();
|
||||
QObject* create_panel();
|
||||
QObject* create_stack();
|
||||
QObject* create_container();
|
||||
QObject* create_dialog(const QString &title) const;
|
||||
|
||||
QObject* create_selector_file();
|
||||
QObject* create_selector_credentials(const QJSValue &headers) const;
|
||||
|
||||
signals:
|
||||
void scriptError(const QString &msg);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class SignalProxy : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QJSEngine* engine;
|
||||
QJSValue handler;
|
||||
|
||||
explicit SignalProxy(QJSEngine* engine, QJSValue handler, QObject* parent = nullptr) : QObject(parent), engine(engine), handler(std::move(handler)) {}
|
||||
|
||||
public slots:
|
||||
void call() const {
|
||||
if (handler.isCallable())
|
||||
handler.call();
|
||||
}
|
||||
|
||||
void callWithArg(const bool &arg) const {
|
||||
if (handler.isCallable()) {
|
||||
QJSValueList args;
|
||||
args << engine->toScriptValue(arg);
|
||||
handler.call(args);
|
||||
}
|
||||
}
|
||||
|
||||
void callWithArg(const int &arg) const {
|
||||
if (handler.isCallable()) {
|
||||
QJSValueList args;
|
||||
args << engine->toScriptValue(arg);
|
||||
handler.call(args);
|
||||
}
|
||||
}
|
||||
|
||||
void callWithArg(const QString& arg) const {
|
||||
if (handler.isCallable()) {
|
||||
QJSValueList args;
|
||||
args << engine->toScriptValue(arg);
|
||||
handler.call(args);
|
||||
}
|
||||
}
|
||||
|
||||
void callWithArgs(const int &arg1, const int &arg2) const {
|
||||
if (handler.isCallable()) {
|
||||
QJSValueList args;
|
||||
args << engine->toScriptValue(arg1);
|
||||
args << engine->toScriptValue(arg2);
|
||||
handler.call(args);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef BRIDGEMENU_H
|
||||
#define BRIDGEMENU_H
|
||||
|
||||
#include <QJSValue>
|
||||
#include <QObject>
|
||||
|
||||
class AxScriptEngine;
|
||||
class AbstractAxMenuItem;
|
||||
class AxActionWrapper;
|
||||
class AxMenuWrapper;
|
||||
class AxSeparatorWrapper;
|
||||
|
||||
class BridgeMenu : public QObject {
|
||||
Q_OBJECT
|
||||
AxScriptEngine* scriptEngine;
|
||||
QWidget* widget;
|
||||
QList<AbstractAxMenuItem*> menuItems;
|
||||
|
||||
QList<AbstractAxMenuItem*> items() const;
|
||||
void clear();
|
||||
|
||||
public:
|
||||
explicit BridgeMenu(AxScriptEngine* scriptEngine, QObject* parent = nullptr);
|
||||
~BridgeMenu() override;
|
||||
|
||||
void reg(const QString &type, AbstractAxMenuItem *item, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners);
|
||||
|
||||
public slots:
|
||||
AxActionWrapper* create_action(const QString& text, const QJSValue& handler);
|
||||
AxMenuWrapper* create_menu(const QString& title);
|
||||
AxSeparatorWrapper* create_separator();
|
||||
|
||||
void add_session_main(AbstractAxMenuItem* item, const QJSValue &agents, const QJSValue &os = QJSValue(), const QJSValue &listeners = QJSValue());
|
||||
void add_session_agent(AbstractAxMenuItem* item, const QJSValue &agents, const QJSValue &os = QJSValue(), const QJSValue &listeners = QJSValue());
|
||||
void add_session_browser(AbstractAxMenuItem* item, const QJSValue &agents, const QJSValue &os = QJSValue(), const QJSValue &listeners = QJSValue());
|
||||
void add_session_access(AbstractAxMenuItem* item, const QJSValue &agents, const QJSValue &os = QJSValue(), const QJSValue &listeners = QJSValue());
|
||||
|
||||
void add_filebrowser(AbstractAxMenuItem* item, const QJSValue &agents, const QJSValue &os = QJSValue(), const QJSValue &listeners = QJSValue());
|
||||
void add_processbrowser(AbstractAxMenuItem* item, const QJSValue &agents, const QJSValue &os = QJSValue(), const QJSValue &listeners = QJSValue());
|
||||
|
||||
void add_downloads_running(AbstractAxMenuItem* item, const QJSValue &agents, const QJSValue &os = QJSValue(), const QJSValue &listeners = QJSValue());
|
||||
void add_downloads_finished(AbstractAxMenuItem* item, const QJSValue &agents, const QJSValue &os = QJSValue(), const QJSValue &listeners = QJSValue());
|
||||
|
||||
void add_tasks(AbstractAxMenuItem* item, const QJSValue &agents, const QJSValue &os = QJSValue(), const QJSValue &listeners = QJSValue());
|
||||
void add_tasks_job(AbstractAxMenuItem* item, const QJSValue &agents, const QJSValue &os = QJSValue(), const QJSValue &listeners = QJSValue());
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -6,23 +6,29 @@
|
||||
class DialogExtender;
|
||||
class MainAdaptix;
|
||||
|
||||
class Extender
|
||||
class Extender : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
MainAdaptix* mainAdaptix = nullptr;
|
||||
|
||||
public:
|
||||
explicit Extender(MainAdaptix* m);
|
||||
~Extender();
|
||||
~Extender() override;
|
||||
|
||||
DialogExtender* dialogExtender = nullptr;
|
||||
QMap<QString, ExtensionFile> extenderFiles;
|
||||
|
||||
void LoadFromDB();
|
||||
void LoadFromFile(QString path, bool enabled);
|
||||
void SetExtension(const ExtensionFile &extFile );
|
||||
void LoadFromFile(const QString &path, bool enabled);
|
||||
void SetExtension(ExtensionFile extFile );
|
||||
void EnableExtension(const QString &path);
|
||||
void DisableExtension(const QString &path);
|
||||
void RemoveExtension(const QString &path);
|
||||
|
||||
public slots:
|
||||
void syncedOnReload(const QString &project);
|
||||
void loadGlobalScript(const QString &path);
|
||||
void unloadGlobalScript(const QString &path);
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_EXTENDER_H
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,7 @@ QJsonObject HttpReq(const QString &sUrl, const QByteArray &jsonData, const QStri
|
||||
|
||||
QJsonObject HttpReqTimeout( int timeout, const QString &sUrl, const QByteArray &jsonData, const QString &token );
|
||||
|
||||
/// CLIENT
|
||||
///CLIENT
|
||||
|
||||
bool HttpReqLogin(AuthProfile* profile);
|
||||
|
||||
@@ -19,7 +19,7 @@ bool HttpReqJwtUpdate(AuthProfile* profile);
|
||||
|
||||
bool HttpReqGetOTP(const QString &type, const QString &objectId, AuthProfile profile, QString* message, bool* ok);
|
||||
|
||||
/// LISTENER
|
||||
///LISTENER
|
||||
|
||||
bool HttpReqListenerStart(const QString &listenerName, const QString &configType, const QString &configData, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
@@ -27,13 +27,11 @@ bool HttpReqListenerEdit(const QString &listenerName, const QString &configType,
|
||||
|
||||
bool HttpReqListenerStop(const QString &listenerName, const QString &listenerType, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
/// AGENT
|
||||
///AGENT
|
||||
|
||||
bool HttpReqAgentGenerate(const QString &listenerName, const QString &listenerType, const QString &agentName, const QString &os, const QString &configData, AuthProfile profile, QString* message, bool* ok );
|
||||
bool HttpReqAgentGenerate(const QString &listenerName, const QString &listenerType, const QString &agentName, const QString &configData, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
bool HttpReqAgentCommand(const QString &agentName, const QString &agentId, const QString &cmdLine, const QString &data, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
bool HttpReqAgentExit( QStringList agentsId, AuthProfile profile, QString* message, bool* ok );
|
||||
bool HttpReqAgentCommand(const QByteArray &jsonData, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
bool HttpReqConsoleRemove( QStringList agentsId, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
@@ -45,26 +43,20 @@ bool HttpReqAgentSetMark( QStringList agentsId, const QString &mark, AuthProfile
|
||||
|
||||
bool HttpReqAgentSetColor( QStringList agentsId, const QString &background, const QString &foreground, bool reset, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
bool HttpReqTaskStop(const QString &agentId, QStringList tasksId, AuthProfile profile, QString* message, bool* ok );
|
||||
bool HttpReqAgentSetImpersonate(const QString &agentId, const QString &impersonate, bool elevated, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
///TASK
|
||||
|
||||
bool HttpReqTaskCancel(const QString &agentId, QStringList tasksId, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
bool HttpReqTasksDelete(const QString &agentId, QStringList tasksId, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
bool HttpReqTasksHook(const QByteArray &jsonData, AuthProfile profile, QString* message, bool* ok);
|
||||
|
||||
///DOWNLOAD
|
||||
|
||||
bool HttpReqDownloadStart(const QString &agentId, const QString &path, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
bool HttpReqDownloadAction(const QString &action, const QString &fileId, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
///BROWSER
|
||||
|
||||
bool HttpReqBrowserDisks(const QString &agentId, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
bool HttpReqBrowserProcess(const QString &agentId, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
bool HttpReqBrowserList(const QString &agentId, const QString &path, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
bool HttpReqBrowserUpload(const QString &agentId, const QString &path, const QString &content, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
///TUNNEL
|
||||
|
||||
bool HttpReqTunnelStartServer(const QString &tunnelType, const QByteArray &jsonData, AuthProfile profile, QString* message, bool* ok);
|
||||
@@ -73,10 +65,18 @@ bool HttpReqTunnelStop(const QString &tunnelId, AuthProfile profile, QString* me
|
||||
|
||||
bool HttpReqTunnelSetInfo(const QString &tunnelId, const QString &info, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
/// SCREEN
|
||||
///SCREEN
|
||||
|
||||
bool HttpReqScreenSetNote( QStringList scrensId, const QString ¬e, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
bool HttpReqScreenRemove( QStringList scrensId, AuthProfile profile, QString* message, bool* ok );
|
||||
|
||||
#endif //ADAPTIXCLIENT_REQUESTOR_H
|
||||
///CREDS
|
||||
|
||||
bool HttpReqCredentialsCreate(const QByteArray &jsonData, AuthProfile profile, QString* message, bool* ok);
|
||||
|
||||
bool HttpReqCredentialsEdit(const QByteArray &jsonData, AuthProfile profile, QString* message, bool* ok);
|
||||
|
||||
bool HttpReqCredentialsRemove(const QString &credsId, AuthProfile profile, QString* message, bool* ok);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,4 +23,4 @@ public:
|
||||
void SaveToDB() const;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_SETTINGS_H
|
||||
#endif
|
||||
|
||||
@@ -47,4 +47,4 @@ public:
|
||||
static void UpdateSettingsTasks(const SettingsData &settingsData);
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_STORAGE_H
|
||||
#endif
|
||||
@@ -48,4 +48,4 @@ private slots:
|
||||
void onStartSocks5AuthChannel();
|
||||
};
|
||||
|
||||
#endif //TUNNELENDPOINT_H
|
||||
#endif
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
#ifndef ADAPTIXCLIENT_WIDGETBUILDER_H
|
||||
#define ADAPTIXCLIENT_WIDGETBUILDER_H
|
||||
|
||||
#include <main.h>
|
||||
|
||||
class WidgetBuilder
|
||||
{
|
||||
QWidget* widget = nullptr;
|
||||
|
||||
QMap<QString, QWidget*> widgetMap;
|
||||
QVector<void*> lpVector;
|
||||
QJsonObject qJsonObject;
|
||||
QString error;
|
||||
|
||||
public:
|
||||
bool valid = false;
|
||||
|
||||
explicit WidgetBuilder(const QByteArray& jsonData);
|
||||
~WidgetBuilder();
|
||||
|
||||
void BuildWidget(bool editable);
|
||||
QLayout* BuildLayout(QString layoutType, QJsonObject rootObj, bool editable);
|
||||
QString GetError();
|
||||
QWidget* GetWidget() const;
|
||||
void ClearWidget() const;
|
||||
void FillData(const QString &jsonString);
|
||||
QString CollectData();
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_WIDGETBUILDER_H
|
||||
@@ -31,4 +31,4 @@ public:
|
||||
|
||||
extern MainAdaptix* GlobalClient;
|
||||
|
||||
#endif //ADAPTIXCLIENT_MAINADAPTIX_H
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <UI/Widgets/AdaptixWidget.h>
|
||||
#include <Client/AuthProfile.h>
|
||||
|
||||
class AxContainerWrapper;
|
||||
|
||||
class DialogAgent : public QDialog
|
||||
{
|
||||
QGridLayout* mainGridLayout = nullptr;
|
||||
@@ -18,8 +20,6 @@ class DialogAgent : public QDialog
|
||||
QLineEdit* listenerInput = nullptr;
|
||||
QLabel* agentLabel = nullptr;
|
||||
QComboBox* agentCombobox = nullptr;
|
||||
QLabel* osLabel = nullptr;
|
||||
QComboBox* osCombobox = nullptr;
|
||||
QPushButton* buttonLoad = nullptr;
|
||||
QPushButton* buttonSave = nullptr;
|
||||
QPushButton* closeButton = nullptr;
|
||||
@@ -27,30 +27,30 @@ class DialogAgent : public QDialog
|
||||
QGroupBox* agentConfigGroupbox = nullptr;
|
||||
QStackedWidget* configStackWidget = nullptr;
|
||||
|
||||
QVector<RegAgentConfig> regAgents;
|
||||
QMap<QString, QSet<QString>> agentsOs;
|
||||
|
||||
AuthProfile authProfile;
|
||||
QString listenerName;
|
||||
QString listenerType;
|
||||
|
||||
QStringList agents;
|
||||
QMap<QString, QWidget*> widgets;
|
||||
QMap<QString, AxContainerWrapper*> containers;
|
||||
|
||||
void createUI();
|
||||
|
||||
public:
|
||||
explicit DialogAgent(const QString &listenerName, const QString &listenerType);
|
||||
~DialogAgent() override;
|
||||
|
||||
void AddExAgents(const QVector<RegAgentConfig> ®Agents);
|
||||
void AddExAgents(const QStringList &agents, const QMap<QString, QWidget*> &widgets, const QMap<QString, AxContainerWrapper*> &containers);
|
||||
void SetProfile(const AuthProfile &profile);
|
||||
void Start();
|
||||
|
||||
protected slots:
|
||||
void changeConfig(const QString &fn);
|
||||
void changeOs(const QString &os);
|
||||
void onButtonLoad();
|
||||
void onButtonSave();
|
||||
void changeConfig(const QString &agentName);
|
||||
void onButtonGenerate();
|
||||
void onButtonClose();
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_DIALOGAGENT_H
|
||||
#endif
|
||||
|
||||
@@ -49,4 +49,4 @@ private slots:
|
||||
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_DIALOGCONNECT_H
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef DIALOGCREDENTIAL_H
|
||||
#define DIALOGCREDENTIAL_H
|
||||
|
||||
#include <main.h>
|
||||
|
||||
class DialogCredential : public QDialog
|
||||
{
|
||||
QGridLayout* mainGridLayout = nullptr;
|
||||
QLabel* usernameLabel = nullptr;
|
||||
QLineEdit* usernameInput = nullptr;
|
||||
QLabel* passwordLabel = nullptr;
|
||||
QLineEdit* passwordInput = nullptr;
|
||||
QLabel* realmLabel = nullptr;
|
||||
QLineEdit* realmInput = nullptr;
|
||||
QLabel* typeLabel = nullptr;
|
||||
QComboBox* typeCombo = nullptr;
|
||||
QLabel* tagLabel = nullptr;
|
||||
QLineEdit* tagInput = nullptr;
|
||||
QLabel* storageLabel = nullptr;
|
||||
QComboBox* storageCombo = nullptr;
|
||||
QLabel* hostLabel = nullptr;
|
||||
QLineEdit* hostInput = nullptr;
|
||||
QHBoxLayout* hLayoutBottom = nullptr;
|
||||
QSpacerItem* spacer_1 = nullptr;
|
||||
QSpacerItem* spacer_2 = nullptr;
|
||||
QPushButton* createButton = nullptr;
|
||||
QPushButton* cancelButton = nullptr;
|
||||
|
||||
bool valid = false;
|
||||
QString message = "";
|
||||
QString credsId = "";
|
||||
CredentialData data = {};
|
||||
|
||||
void createUI();
|
||||
|
||||
public:
|
||||
explicit DialogCredential();
|
||||
~DialogCredential() override;
|
||||
|
||||
void StartDialog();
|
||||
void SetEditmode(const CredentialData &credentialData);
|
||||
bool IsValid() const;
|
||||
QString GetMessage() const;
|
||||
CredentialData GetCredData() const;
|
||||
|
||||
protected slots:
|
||||
void onButtonCreate();
|
||||
void onButtonCancel();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -17,7 +17,7 @@ Q_OBJECT
|
||||
QLabel* speedLabel = nullptr;
|
||||
QLabel* statusLabel = nullptr;
|
||||
QLabel* labelPath = nullptr;
|
||||
QLineEdit* lineeditPash = nullptr;
|
||||
QLineEdit* lineeditPath = nullptr;
|
||||
|
||||
QThread* workerThread;
|
||||
DownloaderWorker* worker;
|
||||
@@ -27,4 +27,4 @@ public:
|
||||
~DialogDownloader() override;
|
||||
};
|
||||
|
||||
#endif //DIALOGDOWNLOADER_H
|
||||
#endif
|
||||
|
||||
@@ -12,8 +12,11 @@ Q_OBJECT
|
||||
Extender* extender = nullptr;
|
||||
QGridLayout* layout = nullptr;
|
||||
QTableWidget* tableWidget = nullptr;
|
||||
QSplitter* splitter = nullptr;
|
||||
QTextEdit* textComment = nullptr;
|
||||
QPushButton* buttonClose = nullptr;
|
||||
QSpacerItem* spacer1 = nullptr;
|
||||
QSpacerItem* spacer2 = nullptr;
|
||||
|
||||
void createUI();
|
||||
|
||||
@@ -35,4 +38,4 @@ public slots:
|
||||
void onRowSelect(int row, int column) const;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_DIALOGEXTENDER_H
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <main.h>
|
||||
#include <Client/AuthProfile.h>
|
||||
|
||||
class WidgetBuilder;
|
||||
class AxContainerWrapper;
|
||||
|
||||
class DialogListener : public QDialog
|
||||
{
|
||||
@@ -26,17 +26,20 @@ class DialogListener : public QDialog
|
||||
QGroupBox* listenerConfigGroupbox = nullptr;
|
||||
QStackedWidget* configStackWidget = nullptr;
|
||||
|
||||
QMap<QString, WidgetBuilder*> listenersUI;
|
||||
AuthProfile authProfile;
|
||||
bool editMode = false;
|
||||
QStringList listeners;
|
||||
QMap<QString, QWidget*> widgets;
|
||||
QMap<QString, AxContainerWrapper*> containers;
|
||||
|
||||
AuthProfile authProfile;
|
||||
bool editMode = false;
|
||||
|
||||
void createUI();
|
||||
|
||||
public:
|
||||
explicit DialogListener();
|
||||
explicit DialogListener(QWidget *parent = nullptr);
|
||||
~DialogListener() override;
|
||||
|
||||
void AddExListeners(const QMap<QString, WidgetBuilder*> &listeners);
|
||||
void AddExListeners(const QStringList &listeners, const QMap<QString, QWidget*> &widgets, const QMap<QString, AxContainerWrapper*> &containers);
|
||||
void SetProfile(const AuthProfile &profile);
|
||||
void Start();
|
||||
void SetEditMode(const QString &name);
|
||||
@@ -49,4 +52,4 @@ protected slots:
|
||||
void onButtonCancel();
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_DIALOGLISTENER_H
|
||||
#endif
|
||||
@@ -72,4 +72,4 @@ public slots:
|
||||
void onClose();
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_DIALOGSETTINGS_H
|
||||
#endif
|
||||
@@ -37,4 +37,4 @@ public:
|
||||
void finish() const;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_DIALOGSYNCPACKET_H
|
||||
#endif
|
||||
@@ -20,7 +20,7 @@ class DialogTunnel : public QDialog
|
||||
QPushButton* buttonCreate = nullptr;
|
||||
QSpacerItem* horizontalSpacer_1 = nullptr;
|
||||
QSpacerItem* horizontalSpacer_2 = nullptr;
|
||||
//Socks5
|
||||
|
||||
QWidget* socks5Widget = nullptr;
|
||||
QGridLayout* socks5GridLayout = nullptr;
|
||||
QLabel* socks5LocalAddrLabel = nullptr;
|
||||
@@ -31,13 +31,13 @@ class DialogTunnel : public QDialog
|
||||
QLineEdit* socks5AuthUserInput = nullptr;
|
||||
QLabel* socks5AuthPassLabel = nullptr;
|
||||
QLineEdit* socks5AuthPassInput = nullptr;
|
||||
//Socks4
|
||||
|
||||
QWidget* socks4Widget = nullptr;
|
||||
QGridLayout* socks4GridLayout = nullptr;
|
||||
QLabel* socks4LocalAddrLabel = nullptr;
|
||||
QLineEdit* socks4LocalAddrInput = nullptr;
|
||||
QSpinBox* socks4LocalPortSpin = nullptr;
|
||||
//LPF
|
||||
|
||||
QWidget* lpfWidget = nullptr;
|
||||
QGridLayout* lpfGridLayout = nullptr;
|
||||
QLabel* lpfLocalAddrLabel = nullptr;
|
||||
@@ -46,7 +46,7 @@ class DialogTunnel : public QDialog
|
||||
QLabel* lpfTargetAddrLabel = nullptr;
|
||||
QLineEdit* lpfTargetAddrInput = nullptr;
|
||||
QSpinBox* lpfTargetPortSpin = nullptr;
|
||||
//RPF
|
||||
|
||||
QWidget* rpfWidget = nullptr;
|
||||
QGridLayout* rpfGridLayout = nullptr;
|
||||
QLabel* rpfPortLabel = nullptr;
|
||||
@@ -65,10 +65,9 @@ class DialogTunnel : public QDialog
|
||||
void createUI();
|
||||
|
||||
public:
|
||||
explicit DialogTunnel();
|
||||
explicit DialogTunnel(const QString &agentId, bool s4, bool s5, bool lpf, bool rpf);
|
||||
~DialogTunnel() override;
|
||||
|
||||
void SetSettings(const QString &agentId, bool s5, bool s4, bool lpf, bool rpf);
|
||||
void StartDialog();
|
||||
bool IsValid() const;
|
||||
QString GetMessage() const;
|
||||
@@ -83,4 +82,4 @@ protected slots:
|
||||
void onButtonCancel();
|
||||
};
|
||||
|
||||
#endif //DIALOGTUNNEL_H
|
||||
#endif
|
||||
|
||||
@@ -26,4 +26,4 @@ public:
|
||||
~DialogUploader() override;
|
||||
};
|
||||
|
||||
#endif // DIALOGUPLOADER_H
|
||||
#endif
|
||||
|
||||
@@ -71,4 +71,4 @@ protected:
|
||||
void mouseMoveEvent( QGraphicsSceneMouseEvent* event ) override;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_GRAPHITEM_H
|
||||
#endif
|
||||
|
||||
@@ -32,4 +32,4 @@ protected:
|
||||
static void paintLineText( QPainter* painter, double angle, const QLineF &line, const QString &text, QColor textColor );
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_GRAPHITEMLINK_H
|
||||
#endif
|
||||
|
||||
@@ -20,4 +20,4 @@ private:
|
||||
void contextMenuEvent( QGraphicsSceneContextMenuEvent *event ) override;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_GRAPHSCENE_H
|
||||
#endif
|
||||
|
||||
@@ -29,4 +29,4 @@ public:
|
||||
static void executeShifts( GraphItem* item );
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_LAYOUTTREELEFT_H
|
||||
#endif
|
||||
|
||||
@@ -43,4 +43,4 @@ protected:
|
||||
void timerEvent( QTimerEvent* event ) override;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_SESSIONSGRAPH_H
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,7 @@ class MainUI : public QMainWindow
|
||||
{
|
||||
QTabWidget* mainuiTabWidget = nullptr;
|
||||
|
||||
QMap<QString, AdaptixWidget*> AdaptixProjects;
|
||||
QVector<AdaptixWidget*> AdaptixProjects;
|
||||
|
||||
public:
|
||||
explicit MainUI();
|
||||
@@ -19,13 +19,15 @@ public:
|
||||
|
||||
static void onNewProject();
|
||||
void onCloseProject();
|
||||
void onAxScriptConsole();
|
||||
|
||||
static void onExtender();
|
||||
static void onScriptManager();
|
||||
static void onSettings();
|
||||
|
||||
void AddNewProject(AuthProfile* profile, QThread* channelThread, WebSocketWorker* channelWsWorker);
|
||||
|
||||
void AddNewExtension(const ExtensionFile &extFile);
|
||||
bool AddNewExtension(ExtensionFile *extFile);
|
||||
bool SyncExtension(const QString &Project, ExtensionFile *extFile);
|
||||
void RemoveExtension(const ExtensionFile &extFile);
|
||||
|
||||
void UpdateSessionsTableColumns();
|
||||
@@ -36,4 +38,4 @@ protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_MAINUI_H
|
||||
#endif
|
||||
|
||||
@@ -1,35 +1,34 @@
|
||||
#ifndef ADAPTIXCLIENT_ADAPTIXWIDGET_H
|
||||
#define ADAPTIXCLIENT_ADAPTIXWIDGET_H
|
||||
|
||||
#include <Agent/Commander.h>
|
||||
#include <main.h>
|
||||
#include <QJSValue>
|
||||
|
||||
class Task;
|
||||
class Agent;
|
||||
class Commander;
|
||||
class LastTickWorker;
|
||||
class WebSocketWorker;
|
||||
class SessionsTableWidget;
|
||||
class SessionsGraph;
|
||||
class AxConsoleWidget;
|
||||
class LogsWidget;
|
||||
class ListenersWidget;
|
||||
class DownloadsWidget;
|
||||
class ScreenshotsWidget;
|
||||
class CredentialsWidget;
|
||||
class TasksWidget;
|
||||
class TunnelsWidget;
|
||||
class TunnelEndpoint;
|
||||
class WidgetBuilder;
|
||||
class DialogSyncPacket;
|
||||
class AuthProfile;
|
||||
class AxScriptManager;
|
||||
|
||||
typedef struct RegAgentConfig {
|
||||
QString agentName;
|
||||
QString watermark;
|
||||
QString listenerName;
|
||||
QString operatingSystem;
|
||||
QString handlerId;
|
||||
WidgetBuilder* builder;
|
||||
QString name;
|
||||
QString listenerType;
|
||||
int os;
|
||||
Commander* commander;
|
||||
BrowsersConfig browsers;
|
||||
bool valid;
|
||||
} RegAgentConfig;
|
||||
|
||||
@@ -77,6 +76,9 @@ public:
|
||||
QThread* TickThread = nullptr;
|
||||
LastTickWorker* TickWorker = nullptr;
|
||||
|
||||
AxScriptManager* ScriptManager = nullptr;
|
||||
|
||||
AxConsoleWidget* AxConsoleTab = nullptr;
|
||||
LogsWidget* LogsTab = nullptr;
|
||||
ListenersWidget* ListenersTab = nullptr;
|
||||
SessionsTableWidget* SessionsTablePage = nullptr;
|
||||
@@ -84,41 +86,62 @@ public:
|
||||
TunnelsWidget* TunnelsTab = nullptr;
|
||||
DownloadsWidget* DownloadsTab = nullptr;
|
||||
ScreenshotsWidget* ScreenshotsTab = nullptr;
|
||||
CredentialsWidget* CredentialsTab = nullptr;
|
||||
TasksWidget* TasksTab = nullptr;
|
||||
|
||||
QMap<QString, QMap<QString, Commander*>> Commanders; /// agentName -> (handlerId -> commander)
|
||||
QMap<QString, QMap<QString, BrowsersConfig>> AgentBrowserConfigs; /// agentName -> (handlerId -> BrowserConfigs)
|
||||
QVector<RegAgentConfig> RegisterAgents;
|
||||
QMap<QString, WidgetBuilder*> RegisterListeners; /// listenerName -> builder
|
||||
QVector<ListenerData> Listeners;
|
||||
QVector<TunnelData> Tunnels;
|
||||
QMap<QString, DownloadData> Downloads;
|
||||
QMap<QString, ScreenData> Screenshots;
|
||||
QVector<CredentialData> Credentials;
|
||||
QMap<QString, PivotData> Pivots;
|
||||
QVector<QString> TasksVector;
|
||||
QMap<QString, Task*> TasksMap;
|
||||
QVector<QString> AgentsVector;
|
||||
QMap<QString, Agent*> AgentsMap;
|
||||
QMap<QString, ExtensionFile> Extensions;
|
||||
QMap<QString, PostHook> PostHooksJS;
|
||||
QMap<QString, TunnelEndpoint*> ClientTunnels;
|
||||
QStringList addresses;
|
||||
|
||||
explicit AdaptixWidget(AuthProfile* authProfile, QThread* channelThread, WebSocketWorker* channelWsWorker);
|
||||
~AdaptixWidget() override;
|
||||
|
||||
AuthProfile* GetProfile() const;
|
||||
|
||||
void RegisterListenerConfig(const QString &fn, const QString &ui);
|
||||
void RegisterAgentConfig(const QString &agentName, const QString &watermark, const QString &handlersJson, const QString &listenersJson);
|
||||
void ClearAdaptix();
|
||||
RegAgentConfig GetRegAgent(const QString &agentName, const QString &listenerName, int os);
|
||||
void AddTab(QWidget* tab, const QString &title, const QString &icon = "" ) const;
|
||||
void RemoveTab(int index) const;
|
||||
void AddExtension(ExtensionFile ext);
|
||||
bool AddExtension(ExtensionFile* ext);
|
||||
void RemoveExtension(const ExtensionFile &ext);
|
||||
void Close();
|
||||
void ClearAdaptix();
|
||||
|
||||
void RegisterListenerConfig(const QString &fn, const QString &ax_script);
|
||||
void RegisterAgentConfig(const QString &agentName, const QString &ax_script, const QStringList &listeners);
|
||||
QList<QString> GetAgentNames(const QString &listenerType) const;
|
||||
RegAgentConfig GetRegAgent(const QString &agentName, const QString &listenerName, int os);
|
||||
QList<Commander*> GetCommanders(const QStringList &listeners, const QStringList &agents, const QList<int> &os) const;
|
||||
QList<Commander*> GetCommandersAll() const;
|
||||
|
||||
void PostHookProcess(QJsonObject jsonHookObj);
|
||||
|
||||
void LoadConsoleUI(const QString &AgentId);
|
||||
void LoadTasksOutput() const;
|
||||
void LoadFileBrowserUI(const QString &AgentId);
|
||||
void LoadProcessBrowserUI(const QString &AgentId);
|
||||
void LoadTerminalUI(const QString &AgentId);
|
||||
void ShowTunnelCreator(const QString &AgentId, bool socks4, bool socks5, bool lportfwd, bool rportfwd);
|
||||
|
||||
signals:
|
||||
void SyncedSignal();
|
||||
void SyncedOnReloadSignal(QString project);
|
||||
void LoadGlobalScriptSignal(QString path);
|
||||
void UnloadGlobalScriptSignal(QString path);
|
||||
|
||||
void eventFileBrowserDisks(QString agentId);
|
||||
void eventFileBrowserList(QString agentId, QString path);
|
||||
void eventFileBrowserUpload(QString agentId, QString path, QString localFilename);
|
||||
void eventProcessBrowserList(QString agentId);
|
||||
|
||||
public slots:
|
||||
void ChannelClose() const;
|
||||
@@ -128,18 +151,14 @@ public slots:
|
||||
void SetSessionsTableUI() const;
|
||||
void SetGraphUI() const;
|
||||
void SetTasksUI() const;
|
||||
void LoadAxConsoleUI() const;
|
||||
void LoadLogsUI() const;
|
||||
void LoadListenersUI() const;
|
||||
void LoadTunnelsUI() const;
|
||||
void LoadDownloadsUI() const;
|
||||
void LoadScreenshotsUI() const;
|
||||
void LoadTasksOutput() const;
|
||||
void LoadCredentialsUI() const;
|
||||
void OnReconnect();
|
||||
void LoadConsoleUI(const QString &AgentId);
|
||||
void LoadFileBrowserUI(const QString &AgentId);
|
||||
void LoadProcessBrowserUI(const QString &AgentId);
|
||||
void LoadTerminalUI(const QString &AgentId);
|
||||
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_ADAPTIXWIDGET_H
|
||||
#endif
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef AXCONSOLEWIDGET_H
|
||||
#define AXCONSOLEWIDGET_H
|
||||
|
||||
#include <main.h>
|
||||
|
||||
class AdaptixWidget;
|
||||
class AxScriptManager;
|
||||
class TextEditConsole;
|
||||
class ClickableLabel;
|
||||
class KPH_ConsoleInput;
|
||||
|
||||
class AxConsoleWidget : public QWidget
|
||||
{
|
||||
AdaptixWidget* adaptixWidget = nullptr;
|
||||
AxScriptManager* scriptManager = nullptr;
|
||||
|
||||
QGridLayout* MainGridLayout = nullptr;
|
||||
QLabel* CmdLabel = nullptr;
|
||||
QLineEdit* InputLineEdit = nullptr;
|
||||
TextEditConsole* OutputTextEdit = nullptr;
|
||||
QPushButton* ResetButton = nullptr;
|
||||
|
||||
QWidget* searchWidget = nullptr;
|
||||
QHBoxLayout* searchLayout = nullptr;
|
||||
ClickableLabel* prevButton = nullptr;
|
||||
ClickableLabel* nextButton = nullptr;
|
||||
QLabel* searchLabel = nullptr;
|
||||
QLineEdit* searchLineEdit = nullptr;
|
||||
ClickableLabel* hideButton = nullptr;
|
||||
QSpacerItem* spacer = nullptr;
|
||||
QShortcut* shortcutSearch = nullptr;
|
||||
|
||||
int currentIndex = -1;
|
||||
QVector<QTextEdit::ExtraSelection> allSelections;
|
||||
|
||||
KPH_ConsoleInput* kphInputLineEdit = nullptr;
|
||||
|
||||
void createUI();
|
||||
void findAndHighlightAll(const QString& pattern);
|
||||
void highlightCurrent() const;
|
||||
|
||||
public:
|
||||
explicit AxConsoleWidget(AxScriptManager* m, AdaptixWidget* w);
|
||||
~AxConsoleWidget() override;
|
||||
|
||||
void OutputClear() const;
|
||||
void InputFocus() const;
|
||||
void AddToHistory(const QString& command);
|
||||
void PrintMessage(const QString& message);
|
||||
void PrintError(const QString& message);
|
||||
|
||||
public slots:
|
||||
void processInput();
|
||||
void toggleSearchPanel();
|
||||
void handleSearch();
|
||||
void handleSearchBackward();
|
||||
void handleShowHistory();
|
||||
void onResetScript();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -90,10 +90,9 @@ public slots:
|
||||
void onParent();
|
||||
void onReload() const;
|
||||
void onUpload() const;
|
||||
void actionDownload() const;
|
||||
void handleTableDoubleClicked(const QModelIndex &index);
|
||||
void handleTreeDoubleClicked(QTreeWidgetItem* item, int column);
|
||||
void handleTableMenu(const QPoint &pos);
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_BROWSERFILESWIDGET_H
|
||||
#endif
|
||||
@@ -64,4 +64,4 @@ public slots:
|
||||
void onTreeSelect() const;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_BROWSERPROCESSWIDGET_H
|
||||
#endif
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
#include <main.h>
|
||||
#include <Utils/KeyPressHandler.h>
|
||||
#include <Utils/CustomElements.h>
|
||||
#include <Agent/Commander.h>
|
||||
|
||||
class Agent;
|
||||
class Commander;
|
||||
class AdaptixWidget;
|
||||
|
||||
#define CONSOLE_OUT_LOCAL 1
|
||||
#define CONSOLE_OUT_LOCAL_INFO 2
|
||||
@@ -15,9 +16,12 @@ class Commander;
|
||||
#define CONSOLE_OUT_INFO 5
|
||||
#define CONSOLE_OUT_ERROR 6
|
||||
#define CONSOLE_OUT_SUCCESS 7
|
||||
#define CONSOLE_OUT 10
|
||||
|
||||
class ConsoleWidget : public QWidget
|
||||
{
|
||||
AdaptixWidget* adaptixWidget = nullptr;
|
||||
|
||||
QGridLayout* MainGridLayout = nullptr;
|
||||
QLabel* CmdLabel = nullptr;
|
||||
QLabel* InfoLabel = nullptr;
|
||||
@@ -35,6 +39,7 @@ class ConsoleWidget : public QWidget
|
||||
ClickableLabel* hideButton = nullptr;
|
||||
QSpacerItem* spacer = nullptr;
|
||||
QShortcut* shortcutSearch = nullptr;
|
||||
KPH_SearchInput* searchInput = nullptr;
|
||||
|
||||
bool userSelectedCompletion = false;
|
||||
int currentIndex = -1;
|
||||
@@ -49,10 +54,11 @@ class ConsoleWidget : public QWidget
|
||||
void highlightCurrent() const;
|
||||
|
||||
public:
|
||||
explicit ConsoleWidget(Agent* a, Commander* c);
|
||||
explicit ConsoleWidget(AdaptixWidget* w, Agent* a, Commander* c);
|
||||
~ConsoleWidget() override;
|
||||
|
||||
void UpgradeCompleter() const;
|
||||
void ProcessCmdResult(const QString &commandLine, const CommanderResult &cmdResult, bool UI);
|
||||
|
||||
void InputFocus() const;
|
||||
void AddToHistory(const QString& command);
|
||||
void SetInput(const QString &command);
|
||||
@@ -62,6 +68,7 @@ public:
|
||||
void ConsoleOutputPrompt( qint64 timestamp, const QString &taskId, const QString &user, const QString &commandLine ) const;
|
||||
|
||||
public slots:
|
||||
void upgradeCompleter() const;
|
||||
void processInput();
|
||||
void onCompletionSelected(const QString &selectedText);
|
||||
void toggleSearchPanel();
|
||||
@@ -70,4 +77,4 @@ public slots:
|
||||
void handleShowHistory();
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_CONSOLEWIDGET_H
|
||||
#endif
|
||||
@@ -0,0 +1,49 @@
|
||||
#ifndef CREDENTIALSWIDGET_H
|
||||
#define CREDENTIALSWIDGET_H
|
||||
|
||||
#include <main.h>
|
||||
|
||||
class AdaptixWidget;
|
||||
class ClickableLabel;
|
||||
|
||||
class CredentialsWidget : public QWidget
|
||||
{
|
||||
AdaptixWidget* adaptixWidget = nullptr;
|
||||
QGridLayout* mainGridLayout = nullptr;
|
||||
QTableWidget* tableWidget = nullptr;
|
||||
QShortcut* shortcutSearch = nullptr;
|
||||
|
||||
QWidget* searchWidget = nullptr;
|
||||
QHBoxLayout* searchLayout = nullptr;
|
||||
QLineEdit* inputFilter = nullptr;
|
||||
ClickableLabel* hideButton = nullptr;
|
||||
|
||||
void createUI();
|
||||
bool filterItem(const CredentialData &credentials) const;
|
||||
void addTableItem(const CredentialData &newCredentials) const;
|
||||
|
||||
public:
|
||||
explicit CredentialsWidget(AdaptixWidget* w);
|
||||
~CredentialsWidget() override;
|
||||
|
||||
void Clear() const;
|
||||
void AddCredentialsItem(const CredentialData &newCredentials) const;
|
||||
void EditCredentialsItem(const CredentialData &newCredentials) const;
|
||||
void RemoveCredentialsItem(const QString &credId) const;
|
||||
|
||||
void SetData() const;
|
||||
void ClearTableContent() const;
|
||||
|
||||
void CredentialsAdd(const QString &username, const QString &password, const QString &realm, const QString &type, const QString &tag, const QString &storage, const QString &host);
|
||||
|
||||
public slots:
|
||||
void toggleSearchPanel() const;
|
||||
void onFilterUpdate() const;
|
||||
void handleCredentialsMenu( const QPoint &pos ) const;
|
||||
void onCreateCreds();
|
||||
void onEditCreds() const;
|
||||
void onRemoveCreds() const;
|
||||
void onExportCreds() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -3,16 +3,18 @@
|
||||
|
||||
#include <main.h>
|
||||
|
||||
class AdaptixWidget;
|
||||
|
||||
class DownloadsWidget : public QWidget
|
||||
{
|
||||
QWidget* mainWidget = nullptr;
|
||||
QTableWidget* tableWidget = nullptr;
|
||||
QGridLayout* mainGridLayout = nullptr;
|
||||
AdaptixWidget* adaptixWidget = nullptr;
|
||||
QTableWidget* tableWidget = nullptr;
|
||||
QGridLayout* mainGridLayout = nullptr;
|
||||
|
||||
void createUI();
|
||||
|
||||
public:
|
||||
DownloadsWidget(QWidget* w);
|
||||
DownloadsWidget(AdaptixWidget* w);
|
||||
~DownloadsWidget() override;
|
||||
|
||||
void Clear() const;
|
||||
@@ -26,9 +28,6 @@ public slots:
|
||||
void actionSyncCurl() const;
|
||||
void actionSyncWget() const;
|
||||
void actionDelete() const;
|
||||
void actionResume() const;
|
||||
void actionPause() const;
|
||||
void actionCancel() const;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_DOWNLOADSWIDGET_H
|
||||
#endif
|
||||
@@ -3,16 +3,18 @@
|
||||
|
||||
#include <main.h>
|
||||
|
||||
class AdaptixWidget;
|
||||
|
||||
class ListenersWidget : public QWidget
|
||||
{
|
||||
QWidget* mainWidget = nullptr;
|
||||
QGridLayout* mainGridLayout = nullptr;
|
||||
QTableWidget* tableWidget = nullptr;
|
||||
AdaptixWidget* adaptixWidget = nullptr;
|
||||
QGridLayout* mainGridLayout = nullptr;
|
||||
QTableWidget* tableWidget = nullptr;
|
||||
|
||||
void createUI();
|
||||
|
||||
public:
|
||||
explicit ListenersWidget( QWidget* w );
|
||||
explicit ListenersWidget(AdaptixWidget* w);
|
||||
~ListenersWidget() override;
|
||||
|
||||
void Clear() const;
|
||||
@@ -22,10 +24,10 @@ public:
|
||||
|
||||
public slots:
|
||||
void handleListenersMenu( const QPoint &pos ) const;
|
||||
void createListener() const;
|
||||
void editListener() const;
|
||||
void removeListener() const;
|
||||
void generateAgent() const;
|
||||
void onCreateListener() const;
|
||||
void onEditListener() const;
|
||||
void onRemoveListener() const;
|
||||
void onGenerateAgent() const;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_LISTENERSWIDGET_H
|
||||
#endif
|
||||
@@ -47,4 +47,4 @@ public slots:
|
||||
void handleSearchBackward();
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_LOGSWIDGET_H
|
||||
#endif
|
||||
|
||||
@@ -59,4 +59,4 @@ public slots:
|
||||
void actionDownload() const;
|
||||
};
|
||||
|
||||
#endif //SCREENSHOTSWIDGET_H
|
||||
#endif
|
||||
@@ -5,10 +5,12 @@
|
||||
#include <Utils/CustomElements.h>
|
||||
|
||||
class Agent;
|
||||
class AdaptixWidget;
|
||||
|
||||
class SessionsTableWidget : public QWidget
|
||||
{
|
||||
QWidget* mainWidget = nullptr;
|
||||
AdaptixWidget* adaptixWidget = nullptr;
|
||||
|
||||
QGridLayout* mainGridLayout = nullptr;
|
||||
QTableWidget* tableWidget = nullptr;
|
||||
QMenu* menuSessions = nullptr;
|
||||
@@ -44,7 +46,7 @@ public:
|
||||
int ColumnSleep = 14;
|
||||
int ColumnCount = 15;
|
||||
|
||||
explicit SessionsTableWidget( QWidget* w );
|
||||
explicit SessionsTableWidget( AdaptixWidget* w );
|
||||
~SessionsTableWidget() override;
|
||||
|
||||
void AddAgentItem(Agent* newAgent) const;
|
||||
@@ -58,18 +60,13 @@ public:
|
||||
|
||||
public slots:
|
||||
void toggleSearchPanel() const;
|
||||
void onFilterUpdate() const;
|
||||
void handleTableDoubleClicked( const QModelIndex &index ) const;
|
||||
void handleSessionsTableMenu(const QPoint &pos );
|
||||
void onFilterUpdate() const;
|
||||
|
||||
void actionConsoleOpen() const;
|
||||
void actionExecuteCommand();
|
||||
void actionTasksBrowserOpen() const;
|
||||
void actionTerminalOpen() const;
|
||||
void actionFileBrowserOpen() const;
|
||||
void actionProcessBrowserOpen() const;
|
||||
void actionCreateTunnel() const;
|
||||
void actionAgentExit() const;
|
||||
void actionMarkActive() const;
|
||||
void actionMarkInactive() const;
|
||||
void actionItemColor() const;
|
||||
@@ -82,4 +79,4 @@ public slots:
|
||||
void actionItemsShowAll() const;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_SESSIONSTABLEWIDGET_H
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <Utils/CustomElements.h>
|
||||
|
||||
class Task;
|
||||
class AdaptixWidget;
|
||||
|
||||
class TaskOutputWidget : public QWidget
|
||||
{
|
||||
@@ -26,10 +27,10 @@ public:
|
||||
|
||||
class TasksWidget : public QWidget
|
||||
{
|
||||
QWidget* mainWidget = nullptr;
|
||||
QGridLayout* mainGridLayout = nullptr;
|
||||
QTableWidget* tableWidget = nullptr;
|
||||
QShortcut* shortcutSearch = nullptr;
|
||||
AdaptixWidget* adaptixWidget = nullptr;
|
||||
QGridLayout* mainGridLayout = nullptr;
|
||||
QTableWidget* tableWidget = nullptr;
|
||||
QShortcut* shortcutSearch = nullptr;
|
||||
|
||||
QWidget* searchWidget = nullptr;
|
||||
QHBoxLayout* searchLayout = nullptr;
|
||||
@@ -59,7 +60,7 @@ public:
|
||||
|
||||
TaskOutputWidget* taskOutputConsole = nullptr;
|
||||
|
||||
explicit TasksWidget( QWidget* w );
|
||||
explicit TasksWidget( AdaptixWidget* w );
|
||||
~TasksWidget() override;
|
||||
|
||||
void AddTaskItem(Task* newTask) const;
|
||||
@@ -80,8 +81,8 @@ public slots:
|
||||
void actionCopyTaskId() const;
|
||||
void actionCopyCmd() const;
|
||||
void actionOpenConsole() const;
|
||||
void actionStop() const;
|
||||
void actionCancel() const;
|
||||
void actionDelete() const;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_TASKSWIDGET_H
|
||||
#endif
|
||||
|
||||
@@ -56,4 +56,4 @@ public slots:
|
||||
void recvDataFromSocket(const QByteArray &msg);
|
||||
};
|
||||
|
||||
#endif //TERMINALWIDGET_H
|
||||
#endif
|
||||
|
||||
@@ -26,4 +26,4 @@ public slots:
|
||||
void actionStopTunnel() const;
|
||||
};
|
||||
|
||||
#endif //TUNNELSWIDGET_H
|
||||
#endif
|
||||
|
||||
@@ -37,4 +37,4 @@ QString GenerateRandomString(const int length, const QString &setName);
|
||||
|
||||
QString GenerateHash(const QString &algorithm, int length, const QString &inputString);
|
||||
|
||||
#endif //ADAPTIXCLIENT_CONVERT_H
|
||||
#endif
|
||||
@@ -3,6 +3,24 @@
|
||||
|
||||
#include <main.h>
|
||||
|
||||
class ListDelegate : public QStyledItemDelegate {
|
||||
public:
|
||||
using QStyledItemDelegate::QStyledItemDelegate;
|
||||
|
||||
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override {
|
||||
QLineEdit* editor = new QLineEdit(parent);
|
||||
editor->setContentsMargins(1, 1, 1, 1);
|
||||
return editor;
|
||||
}
|
||||
|
||||
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override {
|
||||
QSize size = QStyledItemDelegate::sizeHint(option, index);
|
||||
return QSize(size.width(), size.height() + 10);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class PaddingDelegate : public QStyledItemDelegate {
|
||||
public:
|
||||
explicit PaddingDelegate(QObject* parent = nullptr) : QStyledItemDelegate(parent) {}
|
||||
@@ -18,13 +36,10 @@ public:
|
||||
if (hasBg)
|
||||
painter->fillRect(optFull.rect, bgBrush);
|
||||
|
||||
optFull.state &= ~QStyle::State_HasFocus;
|
||||
|
||||
QStyledItemDelegate::paint(painter, optFull, index);
|
||||
}
|
||||
|
||||
// QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override {
|
||||
// QSize originalSize = QStyledItemDelegate::sizeHint(option, index);
|
||||
// return QSize(originalSize.width() + 30, originalSize.height());
|
||||
// }
|
||||
};
|
||||
|
||||
|
||||
@@ -121,4 +136,4 @@ signals:
|
||||
void ctx_history();
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_CUSTOMELEMENTS_H
|
||||
#endif
|
||||
|
||||
@@ -28,4 +28,4 @@ QString GetParentPathUnix(const QString& path);
|
||||
|
||||
QIcon GetFileSystemIcon(int type, bool used);
|
||||
|
||||
#endif //ADAPTIXCLIENT_FILESYSTEM_H
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,34 @@
|
||||
|
||||
#include <main.h>
|
||||
|
||||
class KPH_SearchInput : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QLineEdit* inputLineEdit;
|
||||
|
||||
public:
|
||||
KPH_SearchInput(QLineEdit *input, QObject *parent = nullptr) : QObject(parent), inputLineEdit(input) {
|
||||
inputLineEdit->installEventFilter(this);
|
||||
}
|
||||
|
||||
signals:
|
||||
void escPressed();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override {
|
||||
if (watched == inputLineEdit && event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
|
||||
if ( keyEvent->key() == Qt::Key_Escape ) {
|
||||
emit escPressed();
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class KPH_ConsoleInput : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -66,6 +94,11 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
if (keyEvent->key() == Qt::Key_L && (keyEvent->modifiers() & Qt::ControlModifier)) {
|
||||
outputTextEdit->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (keyEvent->key() == Qt::Key_Tab) {
|
||||
if (keyEvent->modifiers() & Qt::ControlModifier) {
|
||||
QString filePath = QFileDialog::getOpenFileName(nullptr, "Select file");
|
||||
@@ -157,4 +190,4 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
#endif //KEYPRESSHANDLER_H
|
||||
#endif
|
||||
|
||||
@@ -16,4 +16,4 @@ void MessageError(const QString &message );
|
||||
|
||||
void MessageSuccess(const QString &message );
|
||||
|
||||
#endif //ADAPTIXCLIENT_LOGS_H
|
||||
#endif
|
||||
|
||||
@@ -41,4 +41,4 @@ public slots:
|
||||
void onError(QNetworkReply::NetworkError);
|
||||
};
|
||||
|
||||
#endif //DOWNLOADERWORKER_H
|
||||
#endif
|
||||
|
||||
@@ -21,4 +21,4 @@ public slots:
|
||||
void updateLastItems() const;
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_LASTTICKWORKER_H
|
||||
#endif
|
||||
|
||||
@@ -37,4 +37,4 @@ private slots:
|
||||
void onWsError(QAbstractSocket::SocketError error);
|
||||
};
|
||||
|
||||
#endif //TERMINALWORKER_H
|
||||
#endif
|
||||
|
||||
@@ -35,4 +35,4 @@ private slots:
|
||||
void onWsError(QAbstractSocket::SocketError error);
|
||||
};
|
||||
|
||||
#endif //TUNNELWORKER_H
|
||||
#endif
|
||||
|
||||
@@ -40,4 +40,4 @@ public slots:
|
||||
void onError(QNetworkReply::NetworkError);
|
||||
};
|
||||
|
||||
#endif //UPLOADERWORKER_H
|
||||
#endif
|
||||
|
||||
@@ -34,4 +34,4 @@ signals:
|
||||
void websocket_closed();
|
||||
};
|
||||
|
||||
#endif //ADAPTIXCLIENT_WEBSOCKETWORKER_H
|
||||
#endif
|
||||
@@ -67,7 +67,7 @@
|
||||
#include <Utils/FileSystem.h>
|
||||
#include <Utils/Convert.h>
|
||||
|
||||
#define FRAMEWORK_VERSION "Adaptix Framework v0.6"
|
||||
#define FRAMEWORK_VERSION "Adaptix Framework v0.7"
|
||||
|
||||
///////////
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
#define TYPE_AGENT_TASK_UPDATE 0x4a
|
||||
#define TYPE_AGENT_TASK_SEND 0x4b
|
||||
#define TYPE_AGENT_TASK_REMOVE 0x4c
|
||||
#define TYPE_AGENT_TASK_HOOK 0x4d
|
||||
|
||||
#define TYPE_DOWNLOAD_CREATE 0x51
|
||||
#define TYPE_DOWNLOAD_UPDATE 0x52
|
||||
@@ -134,6 +135,10 @@
|
||||
#define TYPE_PIVOT_CREATE 0x71
|
||||
#define TYPE_PIVOT_DELETE 0x72
|
||||
|
||||
#define TYPE_CREDS_CREATE 0x81
|
||||
#define TYPE_CREDS_EDIT 0x82
|
||||
#define TYPE_CREDS_DELETE 0x83
|
||||
|
||||
//////////
|
||||
|
||||
#define DOWNLOAD_STATE_RUNNING 0x1
|
||||
@@ -163,25 +168,6 @@
|
||||
|
||||
//////////
|
||||
|
||||
typedef struct BrowsersConfig {
|
||||
bool RemoteTerminal;
|
||||
bool FileBrowser;
|
||||
bool FileBrowserDisks;
|
||||
bool FileBrowserDownload;
|
||||
bool FileBrowserUpload;
|
||||
bool ProcessBrowser;
|
||||
bool DownloadsCancel;
|
||||
bool DownloadsResume;
|
||||
bool DownloadsPause;
|
||||
bool TasksJobKill;
|
||||
bool SessionsMenuExit;
|
||||
bool SessionsMenuTunnels;
|
||||
bool Socks4;
|
||||
bool Socks5;
|
||||
bool Lportfwd;
|
||||
bool Rportfwd;
|
||||
} BrowsersConfig;
|
||||
|
||||
typedef struct SettingsData {
|
||||
QString MainTheme;
|
||||
QString FontFamily;
|
||||
@@ -205,7 +191,7 @@ typedef struct SettingsData {
|
||||
typedef struct ListenerData
|
||||
{
|
||||
QString ListenerName;
|
||||
QString ListenerType;
|
||||
QString ListenerFullName;
|
||||
QString BindHost;
|
||||
QString BindPort;
|
||||
QString AgentAddresses;
|
||||
@@ -267,6 +253,20 @@ typedef struct ScreenData
|
||||
QByteArray Content;
|
||||
} ScreenData;
|
||||
|
||||
typedef struct CredentialData
|
||||
{
|
||||
QString CredId;
|
||||
QString Username;
|
||||
QString Password;
|
||||
QString Realm;
|
||||
QString Type;
|
||||
QString Tag;
|
||||
QString Date;
|
||||
QString Storage;
|
||||
QString AgentId;
|
||||
QString Host;
|
||||
} CredentialData;
|
||||
|
||||
typedef struct TunnelData
|
||||
{
|
||||
QString TunnelId;
|
||||
@@ -313,12 +313,13 @@ typedef struct ExtensionFile
|
||||
{
|
||||
QString Name;
|
||||
QString FilePath;
|
||||
QString Code;
|
||||
QString Description;
|
||||
QString Comment;
|
||||
QString Message;
|
||||
bool Enabled;
|
||||
bool NoSave;
|
||||
bool Valid;
|
||||
|
||||
QVector<QJsonObject> ExConstants;
|
||||
QMap<QString, QVector<QJsonObject> > ExCommands;
|
||||
} ExtensionFile;
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ void Emulation::setScreen(int n) {
|
||||
Screen *old = _currentScreen;
|
||||
_currentScreen = _screen[n & 1];
|
||||
if (_currentScreen != old) {
|
||||
// tell all windows onto this emulation to switch to the newly active screen
|
||||
for (ScreenWindow *window : std::as_const(_windows))
|
||||
window->setScreen(_currentScreen);
|
||||
checkScreenInUse();
|
||||
@@ -146,8 +145,6 @@ QString Emulation::keyBindings() const {
|
||||
return _keyTranslator->name();
|
||||
}
|
||||
|
||||
// process application unicode input to terminal
|
||||
// this is a trivial scanner
|
||||
void Emulation::receiveChar(wchar_t c) {
|
||||
c &= 0xff;
|
||||
switch (c) {
|
||||
@@ -175,7 +172,7 @@ void Emulation::receiveChar(wchar_t c) {
|
||||
void Emulation::sendKeyEvent(QKeyEvent *ev, bool) {
|
||||
emit stateSet(NOTIFYNORMAL);
|
||||
|
||||
if (!ev->text().isEmpty()) { // A block of text
|
||||
if (!ev->text().isEmpty()) {
|
||||
emit sendData(ev->text().toUtf8().constData(), ev->text().length());
|
||||
}
|
||||
}
|
||||
@@ -197,11 +194,9 @@ void Emulation::receiveData(const char *text, int length) {
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (text[i] == '\030') {
|
||||
// ZRQINIT 0 Request receive init
|
||||
if ((length - i - 1 > 3) && (strncmp(text + i + 1, "B00", 3) == 0)) {
|
||||
emit zmodemSendDetected();
|
||||
}
|
||||
// ZRINIT 1 Receive init
|
||||
if ((length - i - 1 > 5) && (strncmp(text + i + 1, "B0100", 5) == 0)) {
|
||||
emit zmodemRecvDetected();
|
||||
}
|
||||
@@ -237,7 +232,6 @@ void Emulation::writeToStream(TerminalCharacterDecoder *_decoder, int startLine,
|
||||
}
|
||||
|
||||
int Emulation::lineCount() const {
|
||||
// sum number of lines currently on _screen plus number of lines in history
|
||||
return _currentScreen->getLines() + _currentScreen->getHistLines();
|
||||
}
|
||||
|
||||
@@ -316,7 +310,7 @@ uint ExtendedCharTable::createExtendedChar(uint* unicodePoints , ushort length)
|
||||
const uint initialHash = hash;
|
||||
bool triedCleaningSolution = false;
|
||||
|
||||
while (extendedCharTable.contains(hash) && hash != 0) { // 0 has a special meaning for chars so we don't use it
|
||||
while (extendedCharTable.contains(hash) && hash != 0) {
|
||||
if (extendedCharMatch(hash, unicodePoints, length)) {
|
||||
return hash;
|
||||
} else {
|
||||
@@ -342,7 +336,6 @@ uint ExtendedCharTable::createExtendedChar(uint* unicodePoints , ushort length)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qWarning() << "Using all the extended char hashes, going to miss this extended character";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -374,7 +367,6 @@ ExtendedCharTable::ExtendedCharTable() {
|
||||
}
|
||||
|
||||
ExtendedCharTable::~ExtendedCharTable() {
|
||||
// free all allocated character buffers
|
||||
QHashIterator<uint,uint*> iter(extendedCharTable);
|
||||
while (iter.hasNext()) {
|
||||
iter.next();
|
||||
@@ -382,5 +374,4 @@ ExtendedCharTable::~ExtendedCharTable() {
|
||||
}
|
||||
}
|
||||
|
||||
// global instance
|
||||
ExtendedCharTable ExtendedCharTable::instance;
|
||||
|
||||
@@ -143,18 +143,18 @@ protected:
|
||||
LocaleCodec = 0,
|
||||
Utf8Codec = 1
|
||||
};
|
||||
void setCodec(EmulationCodec codec); // codec number, 0 = locale, 1=utf8
|
||||
void setCodec(EmulationCodec codec);
|
||||
|
||||
QList<ScreenWindow*> _windows;
|
||||
|
||||
Screen* _currentScreen; // pointer to the screen which is currently active,
|
||||
Screen* _currentScreen;
|
||||
|
||||
Screen* _screen[2];
|
||||
|
||||
QStringEncoder _fromUtf16;
|
||||
QStringDecoder _toUtf16;
|
||||
|
||||
const KeyboardTranslator* _keyTranslator; // the keyboard layout
|
||||
const KeyboardTranslator* _keyTranslator;
|
||||
|
||||
bool _enableHandleCtrlC;
|
||||
|
||||
@@ -181,4 +181,4 @@ private:
|
||||
QByteArray dupCache;
|
||||
};
|
||||
|
||||
#endif // EMULATION_H
|
||||
#endif
|
||||
@@ -136,7 +136,7 @@ void Screen::nextLine() {
|
||||
|
||||
void Screen::eraseChars(int n) {
|
||||
if (n == 0)
|
||||
n = 1; // Default
|
||||
n = 1;
|
||||
int p = qMax(0, qMin(cuX + n - 1, columns - 1));
|
||||
clearImage(loc(cuX, cuY), loc(p, cuY), ' ');
|
||||
}
|
||||
@@ -161,7 +161,7 @@ void Screen::deleteChars(int n) {
|
||||
|
||||
void Screen::insertChars(int n) {
|
||||
if (n == 0)
|
||||
n = 1; // Default
|
||||
n = 1;
|
||||
|
||||
if (screenLines[cuY].size() < cuX)
|
||||
screenLines[cuY].resize(cuX);
|
||||
@@ -249,16 +249,14 @@ void Screen::resizeImage(int new_lines, int new_columns) {
|
||||
if ((new_lines == lines) && (new_columns == columns))
|
||||
return;
|
||||
|
||||
if (cuY > new_lines - 1) { // attempt to preserve focus and lines
|
||||
_bottomMargin = lines - 1; // FIXME: margin lost
|
||||
if (cuY > new_lines - 1) {
|
||||
_bottomMargin = lines - 1;
|
||||
for (int i = 0; i < cuY - (new_lines - 1); i++) {
|
||||
addHistLine();
|
||||
scrollUp(0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// create new screen lines and copy from old to new
|
||||
|
||||
ImageLine *newScreenLines = new ImageLine[new_lines + 1];
|
||||
for (int i = 0; i < qMin(lines, new_lines + 1); i++)
|
||||
newScreenLines[i] = screenLines[i];
|
||||
@@ -279,7 +277,6 @@ void Screen::resizeImage(int new_lines, int new_columns) {
|
||||
cuX = qMin(cuX, columns - 1);
|
||||
cuY = qMin(cuY, lines - 1);
|
||||
|
||||
// FIXME: try to keep values, evtl.
|
||||
_topMargin = 0;
|
||||
_bottomMargin = lines - 1;
|
||||
initTabStops();
|
||||
@@ -329,7 +326,7 @@ void Screen::reverseRendition(Character &p) const {
|
||||
CharacterColor b = p.backgroundColor;
|
||||
|
||||
p.foregroundColor = b;
|
||||
p.backgroundColor = f; // p->r &= ~RE_TRANSPARENT;
|
||||
p.backgroundColor = f;
|
||||
}
|
||||
|
||||
void Screen::updateEffectiveRendition() {
|
||||
@@ -359,7 +356,6 @@ void Screen::copyFromHistory(Character *dest, int startLine, int count) const {
|
||||
for (int column = length; column < columns; column++)
|
||||
dest[destLineOffset + column] = defaultChar;
|
||||
|
||||
// invert selected text
|
||||
if (selBegin != -1) {
|
||||
for (int column = 0; column < columns; column++) {
|
||||
if (isSelected(column, line)) {
|
||||
@@ -384,7 +380,6 @@ void Screen::copyFromScreen(Character *dest, int startLine, int count) const {
|
||||
dest[destIndex] = screenLines[srcIndex / columns].value(
|
||||
srcIndex % columns, defaultChar);
|
||||
|
||||
// invert selected text
|
||||
if (selBegin != -1 && isSelected(column, line + history->getLines()))
|
||||
reverseRendition(dest[destIndex]);
|
||||
}
|
||||
@@ -405,23 +400,17 @@ void Screen::getImage(Character *dest, int size, int startLine,
|
||||
qBound(0, history->getLines() - startLine, mergedLines);
|
||||
const int linesInScreenBuffer = mergedLines - linesInHistoryBuffer;
|
||||
|
||||
// copy lines from history buffer
|
||||
if (linesInHistoryBuffer > 0)
|
||||
copyFromHistory(dest, startLine, linesInHistoryBuffer);
|
||||
|
||||
// copy lines from screen buffer
|
||||
if (linesInScreenBuffer > 0)
|
||||
copyFromScreen(dest + linesInHistoryBuffer * columns,
|
||||
startLine + linesInHistoryBuffer - history->getLines(),
|
||||
linesInScreenBuffer);
|
||||
copyFromScreen(dest + linesInHistoryBuffer * columns, startLine + linesInHistoryBuffer - history->getLines(), linesInScreenBuffer);
|
||||
|
||||
// invert display when in screen mode
|
||||
if (getMode(MODE_Screen)) {
|
||||
for (int i = 0; i < mergedLines * columns; i++)
|
||||
reverseRendition(dest[i]); // for reverse display
|
||||
reverseRendition(dest[i]);
|
||||
}
|
||||
|
||||
// mark the character at the current cursor position
|
||||
int cursorIndex = loc(cuX, cuY + linesInHistoryBuffer);
|
||||
if (getMode(MODE_Cursor) && cursorIndex < columns * mergedLines)
|
||||
dest[cursorIndex].rendition |= RE_CURSOR;
|
||||
@@ -440,16 +429,13 @@ QVector<LineProperty> Screen::getLineProperties(int startLine,
|
||||
QVector<LineProperty> result(mergedLines);
|
||||
int index = 0;
|
||||
|
||||
// copy properties for lines in history
|
||||
for (int line = startLine; line < startLine + linesInHistory; line++) {
|
||||
// TODO Support for line properties other than wrapped lines
|
||||
if (history->isWrappedLine(line)) {
|
||||
result[index] = (LineProperty)(result[index] | LINE_WRAPPED);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
// copy properties for lines in screen buffer
|
||||
const int firstScreenLine = startLine + linesInHistory - history->getLines();
|
||||
for (int line = firstScreenLine; line < firstScreenLine + linesInScreen;
|
||||
line++) {
|
||||
@@ -462,13 +448,13 @@ QVector<LineProperty> Screen::getLineProperties(int startLine,
|
||||
|
||||
void Screen::reset(bool clearScreen) {
|
||||
setMode(MODE_Wrap);
|
||||
saveMode(MODE_Wrap); // wrap at end of margin
|
||||
saveMode(MODE_Wrap);
|
||||
resetMode(MODE_Origin);
|
||||
saveMode(MODE_Origin); // position refers to [1,1]
|
||||
saveMode(MODE_Origin);
|
||||
resetMode(MODE_Insert);
|
||||
saveMode(MODE_Insert); // overstroke
|
||||
setMode(MODE_Cursor); // cursor visible
|
||||
resetMode(MODE_Screen); // screen not inverse
|
||||
saveMode(MODE_Insert);
|
||||
setMode(MODE_Cursor);
|
||||
resetMode(MODE_Screen);
|
||||
resetMode(MODE_NewLine);
|
||||
|
||||
_topMargin = 0;
|
||||
@@ -487,13 +473,12 @@ void Screen::clear() {
|
||||
}
|
||||
|
||||
void Screen::backspace() {
|
||||
cuX = qMin(columns - 1, cuX); // nowrap!
|
||||
cuX = qMin(columns - 1, cuX);
|
||||
cuX = qMax(0, cuX - 1);
|
||||
|
||||
if (screenLines[cuY].size() < cuX + 1)
|
||||
screenLines[cuY].resize(cuX + 1);
|
||||
#if 0 // TODO: implement when unicode_width is fixed, we need more
|
||||
// backspace/cursorMove
|
||||
#if 0
|
||||
wchar_t c = 0;
|
||||
if(cuX <= 0) {
|
||||
if(cuY > 0) {
|
||||
@@ -509,7 +494,7 @@ void Screen::backspace() {
|
||||
int ow = CharWidth::unicode_width(c,false);
|
||||
int w = CharWidth::unicode_width(c,true);
|
||||
if(w == 2 && ow == 1) {
|
||||
cuX = qMin(columns-1,cuX); // nowrap!
|
||||
cuX = qMin(columns-1,cuX);
|
||||
cuX = qMax(0,cuX-1);
|
||||
|
||||
if (screenLines[cuY].size() < cuX+1)
|
||||
@@ -520,7 +505,6 @@ void Screen::backspace() {
|
||||
}
|
||||
|
||||
void Screen::tab(int n) {
|
||||
// note that TAB is a format effector (does not write ' ');
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
while ((n > 0) && (cuX < columns - 1)) {
|
||||
@@ -532,7 +516,6 @@ void Screen::tab(int n) {
|
||||
}
|
||||
|
||||
void Screen::backtab(int n) {
|
||||
// note that TAB is a format effector (does not write ' ');
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
while ((n > 0) && (cuX > 0)) {
|
||||
@@ -557,9 +540,6 @@ void Screen::changeTabStop(bool set) {
|
||||
void Screen::initTabStops() {
|
||||
tabStops.resize(columns);
|
||||
|
||||
// Arrg! The 1st tabstop has to be one longer than the other.
|
||||
// i.e. the kids start counting from 0 instead of 1.
|
||||
// Other programs might behave correctly. Be aware.
|
||||
for (int i = 0; i < columns; i++)
|
||||
tabStops[i] = (i % 8 == 0 && i != 0);
|
||||
}
|
||||
@@ -574,17 +554,11 @@ void Screen::checkSelection(int from, int to) {
|
||||
if (selBegin == -1)
|
||||
return;
|
||||
int scr_TL = loc(0, history->getLines());
|
||||
// Clear entire selection if it overlaps region [from, to]
|
||||
if ((selBottomRight >= (from + scr_TL)) && (selTopLeft <= (to + scr_TL)))
|
||||
clearSelection();
|
||||
}
|
||||
|
||||
void Screen::displayCharacter(wchar_t c) {
|
||||
// Note that VT100 does wrapping BEFORE putting the character.
|
||||
// This has impact on the assumption of valid cursor positions.
|
||||
// We indicate the fact that a newline has to be triggered by
|
||||
// putting the cursor one right to the last column of the screen.
|
||||
|
||||
int w = CharWidth::unicode_width(c);
|
||||
if (w < 0)
|
||||
return;
|
||||
@@ -592,7 +566,6 @@ void Screen::displayCharacter(wchar_t c) {
|
||||
if (w == 0) {
|
||||
if (QChar(c).category() != QChar::Mark_NonSpacing)
|
||||
return;
|
||||
// Find previous "real character" to try to combine with
|
||||
int charToCombineWithX = qMin(cuX, screenLines[cuY].length());
|
||||
int charToCombineWithY = cuY;
|
||||
bool previousChar = true;
|
||||
@@ -600,16 +573,13 @@ void Screen::displayCharacter(wchar_t c) {
|
||||
if (charToCombineWithX > 0) {
|
||||
--charToCombineWithX;
|
||||
} else if (charToCombineWithY > 0 && lineProperties.at(charToCombineWithY - 1) & LINE_WRAPPED) {
|
||||
// Try previous line
|
||||
--charToCombineWithY;
|
||||
charToCombineWithX = screenLines[charToCombineWithY].length() - 1;
|
||||
} else {
|
||||
// Give up
|
||||
previousChar = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// Failsafe
|
||||
if (charToCombineWithX < 0) {
|
||||
previousChar = false;
|
||||
break;
|
||||
@@ -632,7 +602,7 @@ void Screen::displayCharacter(wchar_t c) {
|
||||
Q_ASSERT(oldChars);
|
||||
if (oldChars && extendedCharLength < 8) {
|
||||
Q_ASSERT(extendedCharLength > 1);
|
||||
Q_ASSERT(extendedCharLength < 65535); // redundant due to above check
|
||||
Q_ASSERT(extendedCharLength < 65535);
|
||||
auto chars = std::make_unique<uint[]>(extendedCharLength + 1);
|
||||
std::copy_n(oldChars, extendedCharLength, chars.get());
|
||||
chars[extendedCharLength] = c;
|
||||
@@ -652,7 +622,6 @@ notcombine:
|
||||
}
|
||||
}
|
||||
|
||||
// ensure current line vector has enough elements
|
||||
int size = screenLines[cuY].size();
|
||||
if (size < cuX + w) {
|
||||
screenLines[cuY].resize(cuX + w);
|
||||
@@ -663,7 +632,6 @@ notcombine:
|
||||
|
||||
lastPos = loc(cuX, cuY);
|
||||
|
||||
// check if selection is still valid.
|
||||
checkSelection(lastPos, lastPos);
|
||||
|
||||
Character ¤tChar = screenLines[cuY][cuX];
|
||||
@@ -702,7 +670,7 @@ void Screen::compose(const QString & /*compose*/) {
|
||||
|
||||
QChar c(image[lastPos].character);
|
||||
compose.prepend(c);
|
||||
//compose.compose(); ### FIXME!
|
||||
compose.compose(); ### FIXME!
|
||||
image[lastPos].character = compose[0].unicode();*/
|
||||
}
|
||||
|
||||
@@ -713,9 +681,9 @@ void Screen::resetScrolledLines() { _scrolledLines = 0; }
|
||||
|
||||
void Screen::scrollUp(int n) {
|
||||
if (n == 0)
|
||||
n = 1; // Default
|
||||
n = 1;
|
||||
if (_topMargin == 0)
|
||||
addHistLine(); // history.history
|
||||
addHistLine();
|
||||
scrollUp(_topMargin, n);
|
||||
}
|
||||
|
||||
@@ -733,7 +701,6 @@ void Screen::scrollUp(int from, int n) {
|
||||
_lastScrolledRegion =
|
||||
QRect(0, _topMargin, columns - 1, (_bottomMargin - _topMargin));
|
||||
|
||||
// FIXME: make sure `topMargin', `bottomMargin', `from', `n' is in bounds.
|
||||
moveImage(loc(0, from), loc(0, from + n), loc(columns, _bottomMargin));
|
||||
clearImage(loc(0, _bottomMargin - n + 1), loc(columns - 1, _bottomMargin),
|
||||
' ');
|
||||
@@ -741,14 +708,13 @@ void Screen::scrollUp(int from, int n) {
|
||||
|
||||
void Screen::scrollDown(int n) {
|
||||
if (n == 0)
|
||||
n = 1; // Default
|
||||
n = 1;
|
||||
scrollDown(_topMargin, n);
|
||||
}
|
||||
|
||||
void Screen::scrollDown(int from, int n) {
|
||||
_scrolledLines += n;
|
||||
|
||||
// FIXME: make sure `topMargin', `bottomMargin', `from', `n' is in bounds.
|
||||
if (n <= 0)
|
||||
return;
|
||||
if (from > _bottomMargin)
|
||||
@@ -767,15 +733,15 @@ void Screen::setCursorYX(int y, int x) {
|
||||
|
||||
void Screen::setCursorX(int x) {
|
||||
if (x == 0)
|
||||
x = 1; // Default
|
||||
x -= 1; // Adjust
|
||||
x = 1;
|
||||
x -= 1;
|
||||
cuX = qMax(0, qMin(columns - 1, x));
|
||||
}
|
||||
|
||||
void Screen::setCursorY(int y) {
|
||||
if (y == 0)
|
||||
y = 1; // Default
|
||||
y -= 1; // Adjust
|
||||
y = 1;
|
||||
y -= 1;
|
||||
cuY = qMax(0, qMin(lines - 1, y + (getMode(MODE_Origin) ? _topMargin : 0)));
|
||||
}
|
||||
|
||||
@@ -836,9 +802,7 @@ QString Screen::getScreenText(int row1, int col1, int row2, int col2, int mode)
|
||||
|
||||
void Screen::clearImage(int loca, int loce, char c) {
|
||||
int scr_TL = loc(0, history->getLines());
|
||||
// FIXME: check positions
|
||||
|
||||
// Clear entire selection if it overlaps region to be moved...
|
||||
if ((selBottomRight > (loca + scr_TL)) && (selTopLeft < (loce + scr_TL))) {
|
||||
clearSelection();
|
||||
}
|
||||
@@ -848,8 +812,6 @@ void Screen::clearImage(int loca, int loce, char c) {
|
||||
|
||||
Character clearCh(c, currentForeground, currentBackground, DEFAULT_RENDITION);
|
||||
|
||||
// if the character being used to clear the area is the same as the
|
||||
// default character, the affected lines can simply be shrunk.
|
||||
bool isDefaultCh = (clearCh == Character());
|
||||
|
||||
for (int y = topLine; y <= bottomLine; y++) {
|
||||
@@ -878,11 +840,6 @@ void Screen::moveImage(int dest, int sourceBegin, int sourceEnd) {
|
||||
|
||||
int lines = (sourceEnd - sourceBegin) / columns;
|
||||
|
||||
// move screen image and line properties:
|
||||
// the source and destination areas of the image may overlap,
|
||||
// so it matters that we do the copy in the right order -
|
||||
// forwards if dest < sourceBegin or backwards otherwise.
|
||||
//(search the web for 'memmove implementation' for details)
|
||||
if (dest < sourceBegin) {
|
||||
for (int i = 0; i <= lines; i++) {
|
||||
screenLines[(dest / columns) + i] =
|
||||
@@ -900,31 +857,30 @@ void Screen::moveImage(int dest, int sourceBegin, int sourceEnd) {
|
||||
}
|
||||
|
||||
if (lastPos != -1) {
|
||||
int diff = dest - sourceBegin; // Scroll by this amount
|
||||
int diff = dest - sourceBegin;
|
||||
lastPos += diff;
|
||||
if ((lastPos < 0) || (lastPos >= (lines * columns)))
|
||||
lastPos = -1;
|
||||
}
|
||||
|
||||
// Adjust selection to follow scroll.
|
||||
if (selBegin != -1) {
|
||||
bool beginIsTL = (selBegin == selTopLeft);
|
||||
int diff = dest - sourceBegin; // Scroll by this amount
|
||||
int diff = dest - sourceBegin;
|
||||
int scr_TL = loc(0, history->getLines());
|
||||
int srca = sourceBegin + scr_TL; // Translate index from screen to global
|
||||
int srce = sourceEnd + scr_TL; // Translate index from screen to global
|
||||
int srca = sourceBegin + scr_TL;
|
||||
int srce = sourceEnd + scr_TL;
|
||||
int desta = srca + diff;
|
||||
int deste = srce + diff;
|
||||
|
||||
if ((selTopLeft >= srca) && (selTopLeft <= srce))
|
||||
selTopLeft += diff;
|
||||
else if ((selTopLeft >= desta) && (selTopLeft <= deste))
|
||||
selBottomRight = -1; // Clear selection (see below)
|
||||
selBottomRight = -1;
|
||||
|
||||
if ((selBottomRight >= srca) && (selBottomRight <= srce))
|
||||
selBottomRight += diff;
|
||||
else if ((selBottomRight >= desta) && (selBottomRight <= deste))
|
||||
selBottomRight = -1; // Clear selection (see below)
|
||||
selBottomRight = -1;
|
||||
|
||||
if (selBottomRight < 0) {
|
||||
clearSelection();
|
||||
@@ -949,7 +905,6 @@ void Screen::clearToBeginOfScreen() {
|
||||
}
|
||||
|
||||
void Screen::clearEntireScreen() {
|
||||
// Add entire screen to history
|
||||
for (int i = 0; i < (lines - 1); i++) {
|
||||
addHistLine();
|
||||
scrollUp(0, 1);
|
||||
@@ -958,10 +913,6 @@ void Screen::clearEntireScreen() {
|
||||
clearImage(loc(0, 0), loc(columns - 1, lines - 1), ' ');
|
||||
}
|
||||
|
||||
/*! fill screen with 'E'
|
||||
This is to aid screen alignment
|
||||
*/
|
||||
|
||||
void Screen::helpAlign() {
|
||||
clearImage(loc(0, 0), loc(columns - 1, lines - 1), 'E');
|
||||
}
|
||||
@@ -1070,7 +1021,6 @@ void Screen::setSelectionEnd(const int x, const int y) {
|
||||
selBottomRight = endPos;
|
||||
}
|
||||
|
||||
// Normalize the selection in column mode
|
||||
if (blockSelectionMode) {
|
||||
int topRow = selTopLeft / columns;
|
||||
int topColumn = selTopLeft % columns;
|
||||
@@ -1138,12 +1088,6 @@ void Screen::writeToStream(TerminalCharacterDecoder *decoder, int startIndex,
|
||||
const bool appendNewLine = (y != bottom);
|
||||
int copied = copyLineToStream(y, start, count, decoder, appendNewLine,
|
||||
preserveLineBreaks);
|
||||
|
||||
// if the selection goes beyond the end of the last line then
|
||||
// append a new line character.
|
||||
//
|
||||
// this makes it possible to 'select' a trailing new line character after
|
||||
// the text on a line.
|
||||
if (y == bottom && copied < count) {
|
||||
Character newLineChar('\n');
|
||||
decoder->decodeLine(&newLineChar, 1, 0);
|
||||
@@ -1151,14 +1095,7 @@ void Screen::writeToStream(TerminalCharacterDecoder *decoder, int startIndex,
|
||||
}
|
||||
}
|
||||
|
||||
int Screen::copyLineToStream(int line, int start, int count,
|
||||
TerminalCharacterDecoder *decoder,
|
||||
bool appendNewLine,
|
||||
bool preserveLineBreaks) const {
|
||||
// buffer to hold characters for decoding
|
||||
// the buffer is static to avoid initialising every
|
||||
// element on each call to copyLineToStream
|
||||
//(which is unnecessary since all elements will be overwritten anyway)
|
||||
int Screen::copyLineToStream(int line, int start, int count, TerminalCharacterDecoder *decoder, bool appendNewLine, bool preserveLineBreaks) const {
|
||||
static const int MAX_CHARS = 1024;
|
||||
static Character characterBuffer[MAX_CHARS];
|
||||
|
||||
@@ -1166,23 +1103,17 @@ int Screen::copyLineToStream(int line, int start, int count,
|
||||
|
||||
LineProperty currentLineProperties = 0;
|
||||
|
||||
// determine if the line is in the history buffer or the screen image
|
||||
if (line < history->getLines()) {
|
||||
const int lineLength = history->getLineLen(line);
|
||||
|
||||
// ensure that start position is before end of line
|
||||
start = qMin(start, qMax(0, lineLength - 1));
|
||||
|
||||
// retrieve line from history buffer. It is assumed
|
||||
// that the history buffer does not store trailing white space
|
||||
// at the end of the line, so it does not need to be trimmed here
|
||||
if (count == -1) {
|
||||
count = lineLength - start;
|
||||
} else {
|
||||
count = qMin(start + count, lineLength) - start;
|
||||
}
|
||||
|
||||
// safety checks
|
||||
Q_ASSERT(start >= 0);
|
||||
Q_ASSERT(count >= 0);
|
||||
Q_ASSERT((start + count) <= history->getLineLen(line));
|
||||
@@ -1202,30 +1133,24 @@ int Screen::copyLineToStream(int line, int start, int count,
|
||||
Character *data = screenLines[screenLine].data();
|
||||
int length = screenLines[screenLine].count();
|
||||
|
||||
// retrieve line from screen image
|
||||
for (int i = start; i < qMin(start + count, length); i++) {
|
||||
characterBuffer[i - start] = data[i];
|
||||
}
|
||||
|
||||
// count cannot be any greater than length
|
||||
count = qBound(0, count, length >= start ? length - start : 0);
|
||||
|
||||
Q_ASSERT(screenLine < lineProperties.count());
|
||||
currentLineProperties |= lineProperties[screenLine];
|
||||
}
|
||||
|
||||
// add new line character at end
|
||||
const bool omitLineBreak =
|
||||
(currentLineProperties & LINE_WRAPPED) || !preserveLineBreaks;
|
||||
const bool omitLineBreak = (currentLineProperties & LINE_WRAPPED) || !preserveLineBreaks;
|
||||
|
||||
if (!omitLineBreak && appendNewLine && (count + 1 < MAX_CHARS)) {
|
||||
characterBuffer[count] = '\n';
|
||||
count++;
|
||||
}
|
||||
|
||||
// decode line and write to text stream
|
||||
decoder->decodeLine((Character *)characterBuffer, count,
|
||||
currentLineProperties);
|
||||
decoder->decodeLine((Character *)characterBuffer, count, currentLineProperties);
|
||||
|
||||
return count;
|
||||
}
|
||||
@@ -1236,8 +1161,6 @@ void Screen::writeLinesToStream(TerminalCharacterDecoder *decoder, int fromLine,
|
||||
}
|
||||
|
||||
void Screen::addHistLine() {
|
||||
// add line to history buffer
|
||||
// we have to take care about scrolling, too...
|
||||
|
||||
if (hasScroll()) {
|
||||
int oldHistLines = history->getLines();
|
||||
@@ -1249,12 +1172,9 @@ void Screen::addHistLine() {
|
||||
|
||||
bool beginIsTL = (selBegin == selTopLeft);
|
||||
|
||||
// If the history is full, increment the count
|
||||
// of dropped lines
|
||||
if (newHistLines == oldHistLines)
|
||||
_droppedLines++;
|
||||
|
||||
// Adjust selection for the new point of reference
|
||||
if (newHistLines > oldHistLines) {
|
||||
if (selBegin != -1) {
|
||||
selTopLeft += columns;
|
||||
@@ -1263,7 +1183,6 @@ void Screen::addHistLine() {
|
||||
}
|
||||
|
||||
if (selBegin != -1) {
|
||||
// Scroll selection in history up
|
||||
int top_BR = loc(0, 1 + newHistLines);
|
||||
|
||||
if (selTopLeft < top_BR)
|
||||
|
||||
@@ -172,8 +172,6 @@ void ScreenWindow::scrollTo(int line) {
|
||||
const int delta = line - _currentLine;
|
||||
_currentLine = line;
|
||||
|
||||
// keep track of number of lines scrolled by,
|
||||
// this can be reset by calling resetScrollCount()
|
||||
_scrollCount += delta;
|
||||
|
||||
_bufferNeedsUpdate = true;
|
||||
@@ -216,10 +214,8 @@ void ScreenWindow::notifyOutputChanged() {
|
||||
|
||||
void ScreenWindow::handleCommandFromKeyboard(
|
||||
KeyboardTranslator::Command command) {
|
||||
// Keyboard-based navigation
|
||||
bool update = false;
|
||||
|
||||
// EraseCommand is handled in Vt102Emulation
|
||||
if (command & KeyboardTranslator::ScrollPageUpCommand) {
|
||||
scrollBy(ScreenWindow::ScrollPages, -1);
|
||||
update = true;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -322,7 +322,6 @@ protected:
|
||||
|
||||
void mouseTripleClickEvent(QMouseEvent* ev);
|
||||
|
||||
// reimplemented
|
||||
void inputMethodEvent ( QInputMethodEvent* event ) override;
|
||||
QVariant inputMethodQuery( Qt::InputMethodQuery query ) const override;
|
||||
|
||||
@@ -337,7 +336,7 @@ protected slots:
|
||||
private slots:
|
||||
|
||||
void swapColorTable();
|
||||
void tripleClickTimeout(); // resets possibleTripleClick
|
||||
void tripleClickTimeout();
|
||||
|
||||
private:
|
||||
|
||||
@@ -384,7 +383,7 @@ private:
|
||||
bool isLineChar(Character c) const;
|
||||
bool isLineCharString(const std::wstring& string) const;
|
||||
|
||||
void hideStaleMouse() const; // conditionally hides the mouse cursor
|
||||
void hideStaleMouse() const;
|
||||
|
||||
QPointer<ScreenWindow> _screenWindow;
|
||||
|
||||
@@ -393,28 +392,28 @@ private:
|
||||
QGridLayout* _gridLayout;
|
||||
|
||||
CharWidth *_charWidth;
|
||||
bool _fixedFont; // has fixed pitch
|
||||
bool _fixedFont_original; // used only in textWidth()
|
||||
int _fontHeight; // height
|
||||
int _fontWidth; // width
|
||||
int _fontAscent; // ascend
|
||||
bool _boldIntense; // Whether intense colors should be rendered with bold font
|
||||
int _drawTextAdditionHeight; // additional height to prevent font trancation
|
||||
bool _drawTextTestFlag; // indicate it is a testing or not
|
||||
bool _fixedFont;
|
||||
bool _fixedFont_original;
|
||||
int _fontHeight;
|
||||
int _fontWidth;
|
||||
int _fontAscent;
|
||||
bool _boldIntense;
|
||||
int _drawTextAdditionHeight;
|
||||
bool _drawTextTestFlag;
|
||||
|
||||
int _leftMargin; // offset
|
||||
int _topMargin; // offset
|
||||
int _leftMargin;
|
||||
int _topMargin;
|
||||
|
||||
int _lines; // the number of lines that can be displayed in the widget
|
||||
int _columns; // the number of columns that can be displayed in the widget
|
||||
int _lines;
|
||||
int _columns;
|
||||
|
||||
int _usedLines; // the number of lines that are actually being used, this will be less
|
||||
int _usedLines;
|
||||
|
||||
int _usedColumns; // the number of columns that are actually being used, this will be less
|
||||
int _usedColumns;
|
||||
|
||||
int _contentHeight;
|
||||
int _contentWidth;
|
||||
Character* _image; // [lines][columns]
|
||||
Character* _image;
|
||||
|
||||
int _imageSize;
|
||||
QVector<LineProperty> _lineProperties;
|
||||
@@ -431,10 +430,10 @@ private:
|
||||
bool _disabledBracketedPasteMode;
|
||||
bool _showResizeNotificationEnabled;
|
||||
|
||||
QPoint _iPntSel; // initial selection point
|
||||
QPoint _pntSel; // current selection point
|
||||
QPoint _tripleSelBegin; // help avoid flicker
|
||||
int _actSel; // selection state
|
||||
QPoint _iPntSel;
|
||||
QPoint _pntSel;
|
||||
QPoint _tripleSelBegin;
|
||||
int _actSel;
|
||||
bool _wordSelectionMode;
|
||||
bool _lineSelectionMode;
|
||||
bool _preserveLineBreaks;
|
||||
@@ -446,23 +445,22 @@ private:
|
||||
QString _wordCharacters;
|
||||
int _bellMode;
|
||||
|
||||
bool _blinking; // hide text in paintEvent
|
||||
bool _hasBlinker; // has characters to blink
|
||||
bool _cursorBlinking; // hide cursor in paintEvent
|
||||
bool _hasBlinkingCursor; // has blinking cursor enabled
|
||||
bool _allowBlinkingText; // allow text to blink
|
||||
bool _ctrlDrag; // require Ctrl key for drag
|
||||
bool _blinking;
|
||||
bool _hasBlinker;
|
||||
bool _cursorBlinking;
|
||||
bool _hasBlinkingCursor;
|
||||
bool _allowBlinkingText;
|
||||
bool _ctrlDrag;
|
||||
TripleClickMode _tripleClickMode;
|
||||
bool _isFixedSize; //Columns / lines are locked.
|
||||
QTimer* _blinkTimer; // active when hasBlinker
|
||||
QTimer* _blinkCursorTimer; // active when hasBlinkingCursor
|
||||
bool _isFixedSize;
|
||||
QTimer* _blinkTimer;
|
||||
QTimer* _blinkCursorTimer;
|
||||
static std::shared_ptr<QTimer> _hideMouseTimer;
|
||||
|
||||
//QMenu* _drop;
|
||||
QString _dropText;
|
||||
int _dndFileCount;
|
||||
|
||||
bool _possibleTripleClick; // is set in mouseDoubleClickEvent and deleted
|
||||
bool _possibleTripleClick;
|
||||
|
||||
QLabel* _resizeWidget;
|
||||
QTimer* _resizeTimer;
|
||||
@@ -473,7 +471,7 @@ private:
|
||||
|
||||
uint _lineSpacing;
|
||||
|
||||
bool _colorsInverted; // true during visual bell
|
||||
bool _colorsInverted;
|
||||
|
||||
QSize _size;
|
||||
|
||||
@@ -481,9 +479,6 @@ private:
|
||||
|
||||
QPixmap *_backgroundPixmapRef = nullptr;
|
||||
QPixmap _backgroundImage;
|
||||
// QMovie *_backgroundMovie = nullptr;
|
||||
// QMediaPlayer* _backgroundVideoPlayer;
|
||||
// QVideoSink* _backgroundVideoSink;
|
||||
QPixmap _backgroundVideoFrame;
|
||||
bool _isLocked;
|
||||
QPixmap _lockbackgroundImage;
|
||||
@@ -510,7 +505,7 @@ private:
|
||||
};
|
||||
InputMethodData _inputMethodData;
|
||||
|
||||
static bool _antialiasText; // do we antialias or not
|
||||
static bool _antialiasText;
|
||||
|
||||
static const int TEXT_BLINK_DELAY = 500;
|
||||
|
||||
@@ -521,7 +516,7 @@ private:
|
||||
|
||||
int _mouseAutohideDelay;
|
||||
|
||||
int _preeditColorIndex = 16; //Color4Intense
|
||||
int _preeditColorIndex = 16;
|
||||
|
||||
int shiftSelectionStartX = -1;
|
||||
int shiftSelectionStartY = -1;
|
||||
@@ -595,4 +590,4 @@ private:
|
||||
QDialogButtonBox *buttonBox;
|
||||
};
|
||||
|
||||
#endif // TERMINALDISPLAY_H
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,12 +28,12 @@
|
||||
|
||||
struct CharCodes
|
||||
{
|
||||
char charset[4]; //
|
||||
int cu_cs; // actual charset.
|
||||
bool graphic; // Some VT100 tricks
|
||||
bool pound ; // Some VT100 tricks
|
||||
bool sa_graphic; // saved graphic
|
||||
bool sa_pound; // saved pound
|
||||
char charset[4];
|
||||
int cu_cs;
|
||||
bool graphic;
|
||||
bool pound ;
|
||||
bool sa_graphic;
|
||||
bool sa_pound;
|
||||
};
|
||||
|
||||
class Vt102Emulation : public Emulation
|
||||
@@ -87,9 +87,9 @@ private:
|
||||
void resetModes();
|
||||
|
||||
void resetTokenizer();
|
||||
#define MAX_TOKEN_LENGTH 100000 // Max length of tokens (e.g. window title)
|
||||
#define MAX_TOKEN_LENGTH 100000
|
||||
void addToCurrentToken(wchar_t cc);
|
||||
wchar_t tokenBuffer[MAX_TOKEN_LENGTH]; //FIXME: overflow?
|
||||
wchar_t tokenBuffer[MAX_TOKEN_LENGTH];
|
||||
int tokenBufferPos;
|
||||
#define MAXARGS 15
|
||||
void addDigit(int dig);
|
||||
@@ -140,12 +140,12 @@ private:
|
||||
bool _reportFocusEvents;
|
||||
QStringEncoder _toUtf8;
|
||||
|
||||
bool _isTitleChanged; ///< flag if the title/icon was changed by user
|
||||
bool _isTitleChanged;
|
||||
QString _userTitle;
|
||||
QString _iconText; // as set by: echo -en '\033]1;IconText\007
|
||||
QString _iconText;
|
||||
QString _nameTitle;
|
||||
QString _iconName;
|
||||
QColor _modifiedBackground; // as set by: echo -en '\033]11;Color\007
|
||||
QColor _modifiedBackground;
|
||||
};
|
||||
|
||||
#endif // VT102EMULATION_H
|
||||
#endif
|
||||
|
||||
@@ -77,7 +77,6 @@ QTermWidget::QTermWidget(QWidget *messageParentWidget, QWidget *parent)
|
||||
connect( m_emulation, &Emulation::changeTabTextColorRequest, this, &QTermWidget::changeTabTextColorRequest);
|
||||
connect( m_emulation, &Emulation::cursorChanged, this, &QTermWidget::cursorChanged);
|
||||
|
||||
// That's OK, FilterChain's dtor takes care of UrlFilter.
|
||||
m_urlFilter = new UrlFilter();
|
||||
connect(m_urlFilter, &UrlFilter::activated, this, &QTermWidget::urlActivated);
|
||||
m_terminalDisplay->filterChain()->addFilter(m_urlFilter);
|
||||
@@ -160,7 +159,6 @@ void QTermWidget::search(bool forwards, bool next) {
|
||||
new HistorySearch(m_emulation, regExp, forwards, startColumn, startLine, this);
|
||||
connect(historySearch, &HistorySearch::matchFound, this, [this](int startColumn, int startLine, int endColumn, int endLine){
|
||||
ScreenWindow* sw = m_terminalDisplay->screenWindow();
|
||||
//qDebug() << "Scroll to" << startLine;
|
||||
sw->scrollTo(startLine);
|
||||
sw->setTrackOutput(false);
|
||||
sw->notifyOutputChanged();
|
||||
@@ -226,13 +224,10 @@ void QTermWidget::setColorScheme(const QString& origName) {
|
||||
const bool isFile = QFile::exists(origName);
|
||||
const QString& name = isFile ? QFileInfo(origName).baseName() : origName;
|
||||
|
||||
// avoid legacy (int) solution
|
||||
if (!availableColorSchemes().contains(name)) {
|
||||
if (isFile) {
|
||||
if (ColorSchemeManager::instance()->loadCustomColorScheme(origName))
|
||||
cs = ColorSchemeManager::instance()->findColorScheme(name);
|
||||
else
|
||||
qWarning () << Q_FUNC_INFO << "cannot load color scheme from" << origName;
|
||||
}
|
||||
|
||||
if (!cs)
|
||||
@@ -323,7 +318,6 @@ void QTermWidget::sendKeyEvent(QKeyEvent *e) {
|
||||
}
|
||||
|
||||
void QTermWidget::resizeEvent(QResizeEvent*) {
|
||||
//qDebug("global window resizing...with %d %d", this->size().width(), this->size().height());
|
||||
m_terminalDisplay->resize(this->size());
|
||||
}
|
||||
|
||||
@@ -335,13 +329,9 @@ void QTermWidget::updateTerminalSize() {
|
||||
int minLines = -1;
|
||||
int minColumns = -1;
|
||||
|
||||
// minimum number of lines and columns that views require for
|
||||
// their size to be taken into consideration ( to avoid problems
|
||||
// with new view widgets which haven't yet been set to their correct size )
|
||||
const int VIEW_LINES_THRESHOLD = 2;
|
||||
const int VIEW_COLUMNS_THRESHOLD = 2;
|
||||
|
||||
//select largest number of lines and columns that will fit in all visible views
|
||||
if ( m_terminalDisplay->isHidden() == false &&
|
||||
m_terminalDisplay->lines() >= VIEW_LINES_THRESHOLD &&
|
||||
m_terminalDisplay->columns() >= VIEW_COLUMNS_THRESHOLD ) {
|
||||
@@ -349,21 +339,12 @@ void QTermWidget::updateTerminalSize() {
|
||||
minColumns = (minColumns == -1) ? m_terminalDisplay->columns() : qMin( minColumns , m_terminalDisplay->columns() );
|
||||
}
|
||||
|
||||
// backend emulation must have a _terminal of at least 1 column x 1 line in size
|
||||
if ( minLines > 0 && minColumns > 0 ) {
|
||||
m_emulation->setImageSize( minLines , minColumns );
|
||||
}
|
||||
}
|
||||
|
||||
void QTermWidget::monitorTimerDone() {
|
||||
//FIXME: The idea here is that the notification popup will appear to tell the user than output from
|
||||
//the terminal has stopped and the popup will disappear when the user activates the session.
|
||||
//
|
||||
//This breaks with the addition of multiple views of a session. The popup should disappear
|
||||
//when any of the views of the session becomes active
|
||||
|
||||
|
||||
//FIXME: Make message text for this notification and the activity notification more descriptive.
|
||||
if (m_monitorSilence) {
|
||||
emit silence();
|
||||
emit stateChanged(NOTIFYSILENCE);
|
||||
@@ -383,7 +364,6 @@ void QTermWidget::activityStateSet(int state) {
|
||||
}
|
||||
|
||||
if ( m_monitorActivity ) {
|
||||
//FIXME: See comments in monitorTimerDone()
|
||||
if (!m_notifiedActivity) {
|
||||
m_notifiedActivity=true;
|
||||
emit activity();
|
||||
|
||||
@@ -49,7 +49,6 @@ public:
|
||||
void setTerminalBackgroundVideo(const QString& backgroundVideo);
|
||||
void setTerminalBackgroundMode(int mode);
|
||||
|
||||
/// Text codec, default is UTF-8
|
||||
void setTextCodec(QStringEncoder codec);
|
||||
|
||||
void setColorScheme(const QString & name);
|
||||
|
||||
@@ -318,8 +318,6 @@ void ColorScheme::readColorEntry(QSettings *s, int index) {
|
||||
}
|
||||
}
|
||||
if (!ok) {
|
||||
qWarning().nospace() << "Invalid color value " << colorStr << " for "
|
||||
<< colorName << ". Fallback to black.";
|
||||
r = g = b = 0;
|
||||
}
|
||||
entry.color = QColor(r, g, b);
|
||||
@@ -516,7 +514,6 @@ const ColorScheme *ColorSchemeManager::findColorScheme(const QString &name) {
|
||||
if (_colorSchemes.contains(name)) {
|
||||
return _colorSchemes[name];
|
||||
} else {
|
||||
// look for this color scheme
|
||||
QString path = findColorSchemePath(name);
|
||||
if (!path.isEmpty() && loadColorScheme(path)) {
|
||||
return findColorScheme(name);
|
||||
|
||||
@@ -732,7 +732,7 @@ KeyboardTranslator::Entry KeyboardTranslator::findEntry(int keyCode, Qt::Keyboar
|
||||
if (it.value().matches(keyCode, modifiers, state))
|
||||
return *it;
|
||||
}
|
||||
return Entry(); // entry not found
|
||||
return Entry();
|
||||
}
|
||||
|
||||
void KeyboardTranslatorManager::addTranslator(KeyboardTranslator *translator) {
|
||||
@@ -745,7 +745,6 @@ void KeyboardTranslatorManager::addTranslator(KeyboardTranslator *translator) {
|
||||
bool KeyboardTranslatorManager::deleteTranslator(const QString &name) {
|
||||
Q_ASSERT(_translators.contains(name));
|
||||
|
||||
// locate and delete
|
||||
QString path = findTranslatorPath(name);
|
||||
if (QFile::remove(path)) {
|
||||
_translators.remove(name);
|
||||
|
||||
@@ -16967,9 +16967,6 @@ static const utf8proc_uint16_t utf8proc_combinations[] = {
|
||||
74, 77, 1, 53694, 1, 53696,
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
UTF8PROC_DLLEXPORT const utf8proc_int8_t utf8proc_utf8class[256] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
@@ -17049,18 +17046,17 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_iterate(
|
||||
*dst = uc;
|
||||
return 1;
|
||||
}
|
||||
// Must be between 0xc2 and 0xf4 inclusive to be valid
|
||||
|
||||
if ((utf8proc_uint32_t)(uc - 0xc2) > (0xf4-0xc2)) return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
if (uc < 0xe0) { // 2-byte sequence
|
||||
// Must have valid continuation character
|
||||
if (uc < 0xe0) {
|
||||
|
||||
if (str >= end || !utf_cont(*str)) return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
*dst = ((uc & 0x1f)<<6) | (*str & 0x3f);
|
||||
return 2;
|
||||
}
|
||||
if (uc < 0xf0) { // 3-byte sequence
|
||||
if (uc < 0xf0) {
|
||||
if ((str + 1 >= end) || !utf_cont(*str) || !utf_cont(str[1]))
|
||||
return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
// Check for surrogate chars
|
||||
if (uc == 0xed && *str > 0x9f)
|
||||
return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
uc = ((uc & 0xf)<<12) | ((*str & 0x3f)<<6) | (str[1] & 0x3f);
|
||||
@@ -17069,11 +17065,8 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_iterate(
|
||||
*dst = uc;
|
||||
return 3;
|
||||
}
|
||||
// 4-byte sequence
|
||||
// Must have 3 valid continuation characters
|
||||
if ((str + 2 >= end) || !utf_cont(*str) || !utf_cont(str[1]) || !utf_cont(str[2]))
|
||||
return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
// Make sure in correct range (0x10000 - 0x10ffff)
|
||||
if (uc == 0xf0) {
|
||||
if (*str < 0x90) return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
} else if (uc == 0xf4) {
|
||||
@@ -17097,8 +17090,6 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_encode_char(utf8proc_int32_t uc, ut
|
||||
dst[0] = (utf8proc_uint8_t)(0xC0 + (uc >> 6));
|
||||
dst[1] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
|
||||
return 2;
|
||||
// Note: we allow encoding 0xd800-0xdfff here, so as not to change
|
||||
// the API, however, these are actually invalid in UTF-8
|
||||
} else if (uc < 0x10000) {
|
||||
dst[0] = (utf8proc_uint8_t)(0xE0 + (uc >> 12));
|
||||
dst[1] = (utf8proc_uint8_t)(0x80 + ((uc >> 6) & 0x3F));
|
||||
@@ -17158,32 +17149,32 @@ UTF8PROC_DLLEXPORT const utf8proc_property_t *utf8proc_get_property(utf8proc_int
|
||||
|
||||
static utf8proc_bool grapheme_break_simple(int lbc, int tbc) {
|
||||
return
|
||||
(lbc == UTF8PROC_BOUNDCLASS_START) ? true : // GB1
|
||||
(lbc == UTF8PROC_BOUNDCLASS_CR && // GB3
|
||||
tbc == UTF8PROC_BOUNDCLASS_LF) ? false : // ---
|
||||
(lbc >= UTF8PROC_BOUNDCLASS_CR && lbc <= UTF8PROC_BOUNDCLASS_CONTROL) ? true : // GB4
|
||||
(tbc >= UTF8PROC_BOUNDCLASS_CR && tbc <= UTF8PROC_BOUNDCLASS_CONTROL) ? true : // GB5
|
||||
(lbc == UTF8PROC_BOUNDCLASS_L && // GB6
|
||||
(tbc == UTF8PROC_BOUNDCLASS_L || // ---
|
||||
tbc == UTF8PROC_BOUNDCLASS_V || // ---
|
||||
tbc == UTF8PROC_BOUNDCLASS_LV || // ---
|
||||
tbc == UTF8PROC_BOUNDCLASS_LVT)) ? false : // ---
|
||||
((lbc == UTF8PROC_BOUNDCLASS_LV || // GB7
|
||||
lbc == UTF8PROC_BOUNDCLASS_V) && // ---
|
||||
(tbc == UTF8PROC_BOUNDCLASS_V || // ---
|
||||
tbc == UTF8PROC_BOUNDCLASS_T)) ? false : // ---
|
||||
((lbc == UTF8PROC_BOUNDCLASS_LVT || // GB8
|
||||
lbc == UTF8PROC_BOUNDCLASS_T) && // ---
|
||||
tbc == UTF8PROC_BOUNDCLASS_T) ? false : // ---
|
||||
(tbc == UTF8PROC_BOUNDCLASS_EXTEND || // GB9
|
||||
tbc == UTF8PROC_BOUNDCLASS_ZWJ || // ---
|
||||
tbc == UTF8PROC_BOUNDCLASS_SPACINGMARK || // GB9a
|
||||
lbc == UTF8PROC_BOUNDCLASS_PREPEND) ? false : // GB9b
|
||||
(lbc == UTF8PROC_BOUNDCLASS_E_ZWG && // GB11 (requires additional handling below)
|
||||
tbc == UTF8PROC_BOUNDCLASS_EXTENDED_PICTOGRAPHIC) ? false : // ----
|
||||
(lbc == UTF8PROC_BOUNDCLASS_REGIONAL_INDICATOR && // GB12/13 (requires additional handling below)
|
||||
tbc == UTF8PROC_BOUNDCLASS_REGIONAL_INDICATOR) ? false : // ----
|
||||
true; // GB999
|
||||
(lbc == UTF8PROC_BOUNDCLASS_START) ? true :
|
||||
(lbc == UTF8PROC_BOUNDCLASS_CR &&
|
||||
tbc == UTF8PROC_BOUNDCLASS_LF) ? false :
|
||||
(lbc >= UTF8PROC_BOUNDCLASS_CR && lbc <= UTF8PROC_BOUNDCLASS_CONTROL) ? true :
|
||||
(tbc >= UTF8PROC_BOUNDCLASS_CR && tbc <= UTF8PROC_BOUNDCLASS_CONTROL) ? true :
|
||||
(lbc == UTF8PROC_BOUNDCLASS_L &&
|
||||
(tbc == UTF8PROC_BOUNDCLASS_L ||
|
||||
tbc == UTF8PROC_BOUNDCLASS_V ||
|
||||
tbc == UTF8PROC_BOUNDCLASS_LV ||
|
||||
tbc == UTF8PROC_BOUNDCLASS_LVT)) ? false :
|
||||
((lbc == UTF8PROC_BOUNDCLASS_LV ||
|
||||
lbc == UTF8PROC_BOUNDCLASS_V) &&
|
||||
(tbc == UTF8PROC_BOUNDCLASS_V ||
|
||||
tbc == UTF8PROC_BOUNDCLASS_T)) ? false :
|
||||
((lbc == UTF8PROC_BOUNDCLASS_LVT ||
|
||||
lbc == UTF8PROC_BOUNDCLASS_T) &&
|
||||
tbc == UTF8PROC_BOUNDCLASS_T) ? false :
|
||||
(tbc == UTF8PROC_BOUNDCLASS_EXTEND ||
|
||||
tbc == UTF8PROC_BOUNDCLASS_ZWJ ||
|
||||
tbc == UTF8PROC_BOUNDCLASS_SPACINGMARK ||
|
||||
lbc == UTF8PROC_BOUNDCLASS_PREPEND) ? false :
|
||||
(lbc == UTF8PROC_BOUNDCLASS_E_ZWG &&
|
||||
tbc == UTF8PROC_BOUNDCLASS_EXTENDED_PICTOGRAPHIC) ? false :
|
||||
(lbc == UTF8PROC_BOUNDCLASS_REGIONAL_INDICATOR &&
|
||||
tbc == UTF8PROC_BOUNDCLASS_REGIONAL_INDICATOR) ? false :
|
||||
true;
|
||||
}
|
||||
|
||||
static utf8proc_bool grapheme_break_extended(int lbc, int tbc, int licb, int ticb, utf8proc_int32_t *state)
|
||||
@@ -17195,13 +17186,13 @@ static utf8proc_bool grapheme_break_extended(int lbc, int tbc, int licb, int tic
|
||||
state_icb = licb == UTF8PROC_INDIC_CONJUNCT_BREAK_CONSONANT ? licb : UTF8PROC_INDIC_CONJUNCT_BREAK_NONE;
|
||||
}
|
||||
else { /* lbc and licb are already encoded in *state */
|
||||
state_bc = *state & 0xff; // 1st byte of state is bound class
|
||||
state_icb = *state >> 8; // 2nd byte of state is indic conjunct break
|
||||
state_bc = *state & 0xff;
|
||||
state_icb = *state >> 8;
|
||||
}
|
||||
|
||||
utf8proc_bool break_permitted = grapheme_break_simple(state_bc, tbc) &&
|
||||
!(state_icb == UTF8PROC_INDIC_CONJUNCT_BREAK_LINKER
|
||||
&& ticb == UTF8PROC_INDIC_CONJUNCT_BREAK_CONSONANT); // GB9c
|
||||
&& ticb == UTF8PROC_INDIC_CONJUNCT_BREAK_CONSONANT);
|
||||
|
||||
if (ticb == UTF8PROC_INDIC_CONJUNCT_BREAK_CONSONANT
|
||||
|| state_icb == UTF8PROC_INDIC_CONJUNCT_BREAK_CONSONANT
|
||||
@@ -17213,12 +17204,12 @@ static utf8proc_bool grapheme_break_extended(int lbc, int tbc, int licb, int tic
|
||||
|
||||
if (state_bc == tbc && tbc == UTF8PROC_BOUNDCLASS_REGIONAL_INDICATOR)
|
||||
state_bc = UTF8PROC_BOUNDCLASS_OTHER;
|
||||
// Special support for GB11 (emoji extend* zwj / emoji)
|
||||
|
||||
else if (state_bc == UTF8PROC_BOUNDCLASS_EXTENDED_PICTOGRAPHIC) {
|
||||
if (tbc == UTF8PROC_BOUNDCLASS_EXTEND) // fold EXTEND codepoints into emoji
|
||||
if (tbc == UTF8PROC_BOUNDCLASS_EXTEND)
|
||||
state_bc = UTF8PROC_BOUNDCLASS_EXTENDED_PICTOGRAPHIC;
|
||||
else if (tbc == UTF8PROC_BOUNDCLASS_ZWJ)
|
||||
state_bc = UTF8PROC_BOUNDCLASS_E_ZWG; // state to record emoji+zwg combo
|
||||
state_bc = UTF8PROC_BOUNDCLASS_E_ZWG;
|
||||
else
|
||||
state_bc = tbc;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
</qresource>
|
||||
|
||||
<qresource prefix="/icons">
|
||||
<file alias="code_blocks">icons/code_blocks_64dp.png</file>
|
||||
<file alias="listeners">icons/headphones_64dp.png</file>
|
||||
<file alias="logs">icons/notes_64dp.png</file>
|
||||
<file alias="format_list">icons/format_list_bulleted_64dp.png</file>
|
||||
@@ -61,8 +62,8 @@
|
||||
<file alias="arrow_right">icons/arrow_right_alt_64dp.png</file>
|
||||
<file alias="storage">icons/storage_64dp.png</file>
|
||||
|
||||
<file alias="archive">icons/archive_64dp.png</file>
|
||||
<file alias="unarchive">icons/unarchive_64dp.png</file>
|
||||
<file alias="file_open">icons/file_open_64dp.png</file>
|
||||
<file alias="save_as">icons/save_as_64dp.png</file>
|
||||
<file alias="start">icons/start_64dp.png</file>
|
||||
<file alias="restart">icons/restart_64dp.png</file>
|
||||
<file alias="stop">icons/stop_64dp.png</file>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 689 B |
Binary file not shown.
|
After Width: | Height: | Size: 752 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.1 KiB |
@@ -118,6 +118,7 @@ QTableWidget::item {
|
||||
QTableWidget::item:selected {
|
||||
background-color: #4A4A4A;
|
||||
color: #FFFFFF;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
QTableWidget:disabled {
|
||||
@@ -334,6 +335,20 @@ QProgressBar:disabled {
|
||||
|
||||
|
||||
|
||||
QScrollArea {
|
||||
background-color: #2A2A2A;
|
||||
border: 1px solid #4A4A4A;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
QScrollArea:disabled {
|
||||
background-color: #1A1A1A;
|
||||
border: 1px solid #3A3A3A;
|
||||
color: #4A4A4A;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QScrollBar:horizontal {
|
||||
border: none;
|
||||
background: #2A2A2A;
|
||||
@@ -737,7 +752,7 @@ QListWidget {
|
||||
}
|
||||
|
||||
QListWidget::item {
|
||||
padding: 4px;
|
||||
padding: 0px;
|
||||
border-radius: 4px;
|
||||
color: #E0E0E0;
|
||||
}
|
||||
@@ -751,6 +766,7 @@ QListWidget::item:selected {
|
||||
background-color: #4A4A4A;
|
||||
color: #FFFFFF;
|
||||
border: 1px solid #5A5A5A;
|
||||
margin: 1px;
|
||||
}
|
||||
|
||||
QListWidget:focus {
|
||||
|
||||
@@ -294,6 +294,18 @@ QProgressBar:disabled {
|
||||
border: 1px solid #44475a;
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
background-color: #44475a;
|
||||
border: 1px solid #6272a4;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
QScrollArea:disabled {
|
||||
background-color: #343746;
|
||||
border: 1px solid #44475a;
|
||||
color: #6272a4;
|
||||
}
|
||||
|
||||
QScrollBar:horizontal {
|
||||
border: none;
|
||||
background: #44475a;
|
||||
@@ -662,7 +674,7 @@ QListWidget {
|
||||
}
|
||||
|
||||
QListWidget::item {
|
||||
padding: 4px;
|
||||
padding: 2px;
|
||||
border-radius: 4px;
|
||||
color: #f8f8f2;
|
||||
}
|
||||
@@ -676,6 +688,7 @@ QListWidget::item:selected {
|
||||
background-color: #6272a4;
|
||||
color: #ffffff;
|
||||
border: 1px solid #bd93f9;
|
||||
margin: 1px;
|
||||
}
|
||||
|
||||
QListWidget:focus {
|
||||
|
||||
@@ -329,6 +329,18 @@ QProgressBar:disabled {
|
||||
|
||||
|
||||
|
||||
QScrollArea {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #D0D0D0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
QScrollArea:disabled {
|
||||
background-color: #E8E8E8;
|
||||
border: 1px solid #E0E0E0;
|
||||
color: #A0A0A0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QScrollBar:horizontal {
|
||||
@@ -429,7 +441,6 @@ QGroupBox {
|
||||
|
||||
QGroupBox::title {
|
||||
subcontrol-origin: margin;
|
||||
subcontrol-position: top center;
|
||||
padding: 0 3px;
|
||||
background-color: #FFFFFF;
|
||||
color: #2E3440;
|
||||
@@ -440,6 +451,7 @@ QGroupBox::title {
|
||||
|
||||
|
||||
|
||||
|
||||
QCheckBox {
|
||||
spacing: 5px;
|
||||
color: #2E3440;
|
||||
@@ -498,7 +510,7 @@ QListWidget {
|
||||
}
|
||||
|
||||
QListWidget::item {
|
||||
padding: 4px;
|
||||
padding: 2px;
|
||||
/*border-radius: 4px;*/
|
||||
background-color: #FFFFFF;
|
||||
color: #2E3440;
|
||||
@@ -512,7 +524,8 @@ QListWidget::item:hover {
|
||||
QListWidget::item:selected {
|
||||
background-color: #4A566A;
|
||||
color: #FFFFFF;
|
||||
border: 1px solid #D0D0D0;
|
||||
border: 1px solid #D0D0D0;
|
||||
margin: 1px;
|
||||
}
|
||||
|
||||
QListWidget:focus {
|
||||
|
||||
@@ -19,7 +19,6 @@ Agent::Agent(QJsonObject jsonObjAgentData, AdaptixWidget* w)
|
||||
this->data.Id = jsonObjAgentData["a_id"].toString();
|
||||
this->data.Name = jsonObjAgentData["a_name"].toString();
|
||||
this->data.Listener = jsonObjAgentData["a_listener"].toString();
|
||||
|
||||
this->data.Async = jsonObjAgentData["a_async"].toBool();
|
||||
this->data.ExternalIP = jsonObjAgentData["a_external_ip"].toString();
|
||||
this->data.InternalIP = jsonObjAgentData["a_internal_ip"].toString();
|
||||
@@ -54,8 +53,9 @@ Agent::Agent(QJsonObject jsonObjAgentData, AdaptixWidget* w)
|
||||
|
||||
for ( auto listenerData : this->adaptixWidget->Listeners) {
|
||||
if ( listenerData.ListenerName == this->data.Listener ) {
|
||||
QString listenerType = listenerData.ListenerType.split("/")[0];
|
||||
if (listenerType == "internal")
|
||||
QStringList parts = listenerData.ListenerFullName.split("/");
|
||||
this->listenerType = parts[2];
|
||||
if (parts[0] == "internal")
|
||||
this->connType = "internal";
|
||||
else
|
||||
this->connType = "external";
|
||||
@@ -123,26 +123,20 @@ Agent::Agent(QJsonObject jsonObjAgentData, AdaptixWidget* w)
|
||||
}
|
||||
|
||||
auto regAgnet = this->adaptixWidget->GetRegAgent(data.Name, data.Listener, data.Os);
|
||||
this->browsers = regAgnet.browsers;
|
||||
|
||||
this->Console = new ConsoleWidget(this, regAgnet.commander);
|
||||
|
||||
if (this->browsers.FileBrowser)
|
||||
this->FileBrowser = new BrowserFilesWidget(this);
|
||||
|
||||
if (this->browsers.ProcessBrowser)
|
||||
this->ProcessBrowser = new BrowserProcessWidget(this);
|
||||
|
||||
if (this->browsers.RemoteTerminal)
|
||||
this->Terminal = new TerminalWidget(this, adaptixWidget);
|
||||
this->commander = regAgnet.commander;
|
||||
this->Console = new ConsoleWidget(adaptixWidget, this, regAgnet.commander);
|
||||
this->FileBrowser = new BrowserFilesWidget(this);
|
||||
this->ProcessBrowser = new BrowserProcessWidget(this);
|
||||
this->Terminal = new TerminalWidget(this, adaptixWidget);
|
||||
}
|
||||
|
||||
Agent::~Agent() = default;
|
||||
|
||||
void Agent::Update(QJsonObject jsonObjAgentData)
|
||||
{
|
||||
int old_Sleep = this->data.Sleep;
|
||||
int old_Jitter = this->data.Jitter;
|
||||
int old_Sleep = this->data.Sleep;
|
||||
int old_Jitter = this->data.Jitter;
|
||||
QString old_Color = this->data.Color;
|
||||
|
||||
this->data.Sleep = jsonObjAgentData["a_sleep"].toDouble();
|
||||
@@ -336,11 +330,9 @@ void Agent::UpdateImage()
|
||||
}
|
||||
else {
|
||||
if (data.Elevated) {
|
||||
// this->item_Os->setIcon(QIcon(":/icons/unknown_red"));
|
||||
this->imageActive = QImage(":/graph/"+v+"/unknown_red");
|
||||
}
|
||||
else {
|
||||
// this->item_Os->setIcon(QIcon(":/icons/unknown_blue"));
|
||||
this->imageActive = QImage(":/graph/"+v+"/unknown_blue");
|
||||
}
|
||||
this->imageInactive = QImage(":/graph/"+v+"/unknown_grey");
|
||||
@@ -354,11 +346,11 @@ void Agent::UpdateImage()
|
||||
|
||||
/// TASK
|
||||
|
||||
QString Agent::TasksStop(const QStringList &tasks) const
|
||||
QString Agent::TasksCancel(const QStringList &tasks) const
|
||||
{
|
||||
QString message = QString();
|
||||
bool ok = false;
|
||||
bool result = HttpReqTaskStop( data.Id, tasks, *(adaptixWidget->GetProfile()), &message, &ok);
|
||||
bool result = HttpReqTaskCancel( data.Id, tasks, *(adaptixWidget->GetProfile()), &message, &ok);
|
||||
if (!result)
|
||||
return "Response timeout";
|
||||
|
||||
@@ -394,10 +386,7 @@ void Agent::UnsetParent(const PivotData &pivotData)
|
||||
this->item_Last->setText( QString::fromUtf8("\u221E \u221E") );
|
||||
}
|
||||
|
||||
void Agent::AddChild(const PivotData &pivotData)
|
||||
{
|
||||
this->childsId.push_back(pivotData.ChildAgentId);
|
||||
}
|
||||
void Agent::AddChild(const PivotData &pivotData) { this->childsId.push_back(pivotData.ChildAgentId); }
|
||||
|
||||
void Agent::RemoveChild(const PivotData &pivotData)
|
||||
{
|
||||
@@ -408,60 +397,3 @@ void Agent::RemoveChild(const PivotData &pivotData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// BROWSER
|
||||
|
||||
QString Agent::BrowserDisks() const
|
||||
{
|
||||
QString message = QString();
|
||||
bool ok = false;
|
||||
bool result = HttpReqBrowserDisks( data.Id, *(adaptixWidget->GetProfile()), &message, &ok);
|
||||
if (!result)
|
||||
return "Response timeout";
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
QString Agent::BrowserProcess() const
|
||||
{
|
||||
QString message = QString();
|
||||
bool ok = false;
|
||||
bool result = HttpReqBrowserProcess( data.Id, *(adaptixWidget->GetProfile()), &message, &ok);
|
||||
if (!result)
|
||||
return "Response timeout";
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
QString Agent::BrowserList(const QString &path) const
|
||||
{
|
||||
QString message = QString();
|
||||
bool ok = false;
|
||||
bool result = HttpReqBrowserList( data.Id, path, *(adaptixWidget->GetProfile()), &message, &ok);
|
||||
if (!result)
|
||||
return "Response timeout";
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
QString Agent::BrowserUpload(const QString &path, const QString &content) const
|
||||
{
|
||||
QString message = QString();
|
||||
bool ok = false;
|
||||
bool result = HttpReqBrowserUpload( data.Id, path, content, *(adaptixWidget->GetProfile()), &message, &ok);
|
||||
if (!result)
|
||||
return "Response timeout";
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
QString Agent::BrowserDownload(const QString &path) const
|
||||
{
|
||||
QString message = QString();
|
||||
bool ok = false;
|
||||
bool result = HttpReqDownloadStart( data.Id, path, *(adaptixWidget->GetProfile()), &message, &ok);
|
||||
if (!result)
|
||||
return "Response timeout";
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -71,9 +71,9 @@ Task::~Task() = default;
|
||||
|
||||
void Task::Update(QJsonObject jsonObjTaskData)
|
||||
{
|
||||
this->data.Completed = jsonObjTaskData["a_completed"].toBool();
|
||||
this->data.Completed = jsonObjTaskData["a_completed"].toBool();
|
||||
if (this->data.Completed) {
|
||||
this->data.FinishTime = jsonObjTaskData["a_finish_time"].toDouble();
|
||||
this->data.FinishTime = jsonObjTaskData["a_finish_time"].toDouble();
|
||||
QString finishTime = UnixTimestampGlobalToStringLocal(this->data.FinishTime);
|
||||
this->item_FinishTime->setText(finishTime);
|
||||
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
#include <Client/AxScript/AxCommandWrappers.h>
|
||||
|
||||
AxCommandWrappers::AxCommandWrappers(const QString &name, const QString &description, const QString &example, const QString &message, QObject* parent) : QObject(parent)
|
||||
{
|
||||
command = {};
|
||||
command.name = name;
|
||||
command.description = description;
|
||||
command.example = example;
|
||||
command.message = message;
|
||||
}
|
||||
|
||||
Command AxCommandWrappers::getCommand() const { return this->command; }
|
||||
|
||||
void AxCommandWrappers::addSubCommands(const QJSValue& value)
|
||||
{
|
||||
if (value.isUndefined() || value.isNull())
|
||||
return;
|
||||
|
||||
if (value.isArray()) {
|
||||
const int length = value.property("length").toInt();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
QJSValue item = value.property(i);
|
||||
|
||||
QObject* obj = item.toQObject();
|
||||
if (auto* commandWrapper = qobject_cast<AxCommandWrappers*>(obj)) {
|
||||
command.subcommands.append(commandWrapper->getCommand());
|
||||
}
|
||||
else {
|
||||
emit scriptError("Item at index " + QString::number(i) + " is not an Command");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
QObject* obj = value.toQObject();
|
||||
if (auto* commandWrapper = qobject_cast<AxCommandWrappers*>(obj)) {
|
||||
command.subcommands.append(commandWrapper->getCommand());
|
||||
}
|
||||
else {
|
||||
emit scriptError("Item is not an Command");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AxCommandWrappers::addArgBool(const QString &flag, const QString &description)
|
||||
{
|
||||
Argument arg = { "BOOL", "", false, true, flag, description, false, QVariant() };
|
||||
command.args.append(arg);
|
||||
}
|
||||
|
||||
void AxCommandWrappers::addArgBool(const QString &flag, const QString &description, const QJSValue &value)
|
||||
{
|
||||
Argument arg = { "BOOL", "", true, true, flag, description, false, QVariant() };
|
||||
|
||||
if ( !value.isUndefined() && !value.isNull() ) {
|
||||
arg.defaultUsed = true;
|
||||
arg.defaultValue = value.toVariant();
|
||||
}
|
||||
|
||||
command.args.append(arg);
|
||||
}
|
||||
|
||||
void AxCommandWrappers::addArgInt(const QString &name, const bool required, const QString &description)
|
||||
{
|
||||
Argument arg = { "INT", name, required, false, "", description, false, QVariant() };
|
||||
command.args.append(arg);
|
||||
}
|
||||
|
||||
void AxCommandWrappers::addArgInt(const QString &name, const QString &description, const QJSValue &value)
|
||||
{
|
||||
Argument arg = { "INT", name, true, false, "", description, false, QVariant() };
|
||||
|
||||
if ( !value.isUndefined() && !value.isNull() ) {
|
||||
arg.defaultUsed = true;
|
||||
arg.defaultValue = value.toVariant();
|
||||
}
|
||||
|
||||
command.args.append(arg);
|
||||
}
|
||||
|
||||
void AxCommandWrappers::addArgFlagInt(const QString &flag, const QString &name, const bool required, const QString &description)
|
||||
{
|
||||
Argument arg = { "INT", name, required, true, flag, description, false, QVariant() };
|
||||
command.args.append(arg);
|
||||
}
|
||||
|
||||
void AxCommandWrappers::addArgFlagInt(const QString &flag, const QString &name, const QString &description, const QJSValue &value)
|
||||
{
|
||||
Argument arg = { "INT", name, true, true, flag, description, false, QVariant() };
|
||||
|
||||
if ( !value.isUndefined() && !value.isNull() ) {
|
||||
arg.defaultUsed = true;
|
||||
arg.defaultValue = value.toVariant();
|
||||
}
|
||||
|
||||
command.args.append(arg);
|
||||
}
|
||||
|
||||
void AxCommandWrappers::addArgString(const QString &name, const bool required, const QString &description)
|
||||
{
|
||||
Argument arg = { "STRING", name, required, false, "", description, false, QVariant() };
|
||||
command.args.append(arg);
|
||||
}
|
||||
|
||||
void AxCommandWrappers::addArgString(const QString &name, const QString &description, const QJSValue &value)
|
||||
{
|
||||
Argument arg = { "STRING", name, true, false, "", description, false, QVariant() };
|
||||
|
||||
if ( !value.isUndefined() && !value.isNull() ) {
|
||||
arg.defaultUsed = true;
|
||||
arg.defaultValue = value.toVariant();
|
||||
}
|
||||
|
||||
command.args.append(arg);
|
||||
}
|
||||
|
||||
void AxCommandWrappers::addArgFlagString(const QString &flag, const QString &name, const bool required, const QString &description)
|
||||
{
|
||||
Argument arg = { "STRING", name, required, true, flag, description, false, QVariant() };
|
||||
command.args.append(arg);
|
||||
}
|
||||
|
||||
void AxCommandWrappers::addArgFlagString(const QString &flag, const QString &name, const QString &description, const QJSValue &value)
|
||||
{
|
||||
Argument arg = { "STRING", name, true, true, flag, description, false, QVariant() };
|
||||
|
||||
if ( !value.isUndefined() && !value.isNull() ) {
|
||||
arg.defaultUsed = true;
|
||||
arg.defaultValue = value.toVariant();
|
||||
}
|
||||
|
||||
command.args.append(arg);
|
||||
}
|
||||
|
||||
void AxCommandWrappers::addArgFile(const QString &name, const bool required, const QString &description)
|
||||
{
|
||||
Argument arg = { "FILE", name, required, false, "", description, false, QVariant() };
|
||||
command.args.append(arg);
|
||||
}
|
||||
|
||||
void AxCommandWrappers::addArgFlagFile(const QString &flag, const QString &name, const bool required, const QString &description)
|
||||
{
|
||||
Argument arg = { "FILE", name, required, true, flag, description, false, QVariant() };
|
||||
command.args.append(arg);
|
||||
}
|
||||
|
||||
void AxCommandWrappers::setPreHook(const QJSValue &handler)
|
||||
{
|
||||
if (!handler.isCallable()) {
|
||||
emit scriptError("handler is not function");
|
||||
return;
|
||||
}
|
||||
|
||||
command.is_pre_hook = true;
|
||||
command.pre_hook = handler;
|
||||
}
|
||||
|
||||
|
||||
AxCommandGroupWrapper::AxCommandGroupWrapper(QJSEngine* engine, QObject* parent) : QObject(parent), parent(parent), engine(engine) {}
|
||||
|
||||
void AxCommandGroupWrapper::SetParams(const QString &name, const QJSValue &array)
|
||||
{
|
||||
this->name = name;
|
||||
|
||||
if (array.isUndefined() || array.isNull() || !array.isArray()) {
|
||||
emit scriptError("array is not the Command[]");
|
||||
return;
|
||||
}
|
||||
|
||||
const int length = array.property("length").toInt();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
QJSValue item = array.property(i);
|
||||
|
||||
QObject* obj = item.toQObject();
|
||||
if (auto* commandWrapper = qobject_cast<AxCommandWrappers*>(obj)) {
|
||||
this->commands.append(commandWrapper->getCommand());
|
||||
} else {
|
||||
emit scriptError("Item at index " + QString::number(i) + " is not an Command");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString AxCommandGroupWrapper::getName() const { return name; }
|
||||
|
||||
QList<Command> AxCommandGroupWrapper::getCommands() const { return commands; }
|
||||
|
||||
QJSEngine* AxCommandGroupWrapper::getEngine() const { return this->engine; }
|
||||
|
||||
void AxCommandGroupWrapper::add(const QJSValue &value) {
|
||||
if (value.isUndefined() || value.isNull())
|
||||
return;
|
||||
|
||||
if (value.isArray()) {
|
||||
const int length = value.property("length").toInt();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
QJSValue item = value.property(i);
|
||||
|
||||
QObject* obj = item.toQObject();
|
||||
if (auto* commandWrapper = qobject_cast<AxCommandWrappers*>(obj)) {
|
||||
this->commands.append(commandWrapper->getCommand());
|
||||
} else {
|
||||
emit scriptError("Item at index " + QString::number(i) + " is not an Command");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
QObject* obj = value.toQObject();
|
||||
if (auto* commandWrapper = qobject_cast<AxCommandWrappers*>(obj)) {
|
||||
this->commands.append(commandWrapper->getCommand());
|
||||
} else {
|
||||
emit scriptError("Item is not an Command");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,157 @@
|
||||
#include <Client/AxScript/AxScriptEngine.h>
|
||||
#include <Client/AxScript/AxScriptManager.h>
|
||||
#include <Client/AxScript/BridgeApp.h>
|
||||
#include <Client/AxScript/BridgeForm.h>
|
||||
#include <Client/AxScript/BridgeEvent.h>
|
||||
#include <Client/AxScript/BridgeMenu.h>
|
||||
|
||||
AxScriptEngine::AxScriptEngine(AxScriptManager* script_manager, const QString &name, QObject *parent) : QObject(parent), scriptManager(script_manager)
|
||||
{
|
||||
jsEngine = std::make_unique<QJSEngine>();
|
||||
jsEngine->installExtensions(QJSEngine::ConsoleExtension);
|
||||
|
||||
bridgeApp = std::make_unique<BridgeApp>(this, this);
|
||||
bridgeForm = std::make_unique<BridgeForm>(this, this);
|
||||
bridgeEvent = std::make_unique<BridgeEvent>(this, this);
|
||||
bridgeMenu = std::make_unique<BridgeMenu>(this, this);
|
||||
|
||||
jsEngine->globalObject().setProperty("ax", jsEngine->newQObject(bridgeApp.get()));
|
||||
jsEngine->globalObject().setProperty("form", jsEngine->newQObject(bridgeForm.get()));
|
||||
jsEngine->globalObject().setProperty("event", jsEngine->newQObject(bridgeEvent.get()));
|
||||
jsEngine->globalObject().setProperty("menu", jsEngine->newQObject(bridgeMenu.get()));
|
||||
|
||||
connect(bridgeApp.get(), &BridgeApp::consoleError, script_manager, &AxScriptManager::consolePrintError);
|
||||
connect(bridgeApp.get(), &BridgeApp::consoleMessage, script_manager, &AxScriptManager::consolePrintMessage);
|
||||
connect(bridgeApp.get(), &BridgeApp::engineError, this, &AxScriptEngine::engineError);
|
||||
connect(bridgeForm.get(), &BridgeForm::scriptError, this, &AxScriptEngine::engineError);
|
||||
connect(bridgeEvent.get(), &BridgeEvent::scriptError, this, &AxScriptEngine::engineError);
|
||||
|
||||
context.name = name;
|
||||
}
|
||||
|
||||
AxScriptEngine::~AxScriptEngine()
|
||||
{
|
||||
for (auto action : context.actions) {
|
||||
if (action) delete action;
|
||||
}
|
||||
context.actions.clear();
|
||||
/*
|
||||
for (auto obj : context.objects){
|
||||
if (obj) delete obj;
|
||||
}
|
||||
*/
|
||||
context.objects.clear();
|
||||
|
||||
bridgeApp.reset();
|
||||
bridgeForm.reset();
|
||||
bridgeEvent.reset();
|
||||
bridgeMenu.reset();
|
||||
jsEngine.reset();
|
||||
}
|
||||
|
||||
QJSEngine* AxScriptEngine::engine() const { return jsEngine.get(); }
|
||||
|
||||
BridgeApp* AxScriptEngine::app() const { return bridgeApp.get(); }
|
||||
|
||||
BridgeForm* AxScriptEngine::form() const { return bridgeForm.get(); }
|
||||
|
||||
BridgeEvent* AxScriptEngine::event() const { return bridgeEvent.get(); }
|
||||
|
||||
BridgeMenu* AxScriptEngine::menu() const { return bridgeMenu.get(); }
|
||||
|
||||
AxScriptManager* AxScriptEngine::manager() const { return this->scriptManager; }
|
||||
|
||||
void AxScriptEngine::registerObject(QObject *obj) { context.objects.append(obj); }
|
||||
|
||||
void AxScriptEngine::registerAction(QAction *action) { context.actions.append(action); }
|
||||
|
||||
/////
|
||||
|
||||
void AxScriptEngine::registerEvent(const QString &type, const QJSValue &handler, const QSet<QString> &list_agents, const QSet<QString> &list_os, const QSet<QString> &list_listeners, const QString &id)
|
||||
{
|
||||
QSet<int> os;
|
||||
if (list_os.contains("windows")) os.insert(1);
|
||||
if (list_os.contains("linux")) os.insert(2);
|
||||
if (list_os.contains("macos")) os.insert(3);
|
||||
|
||||
AxEvent event = {handler, id, list_agents, list_listeners, os, jsEngine.get()};
|
||||
|
||||
if ( type == "FileBroserDisks") context.eventFileBroserDisks.append(event);
|
||||
else if (type == "FileBroserList") context.eventFileBroserList.append(event);
|
||||
else if (type == "FileBroserUpload") context.eventFileBroserUpload.append(event);
|
||||
else if (type == "ProcessBrowserList") context.eventProcessBrowserList.append(event);
|
||||
}
|
||||
|
||||
QList<AxEvent> AxScriptEngine::getEvents(const QString &type)
|
||||
{
|
||||
if ( type == "FileBroserDisks") return context.eventFileBroserDisks;
|
||||
else if (type == "FileBroserList") return context.eventFileBroserList;
|
||||
else if (type == "FileBroserUpload") return context.eventFileBroserUpload;
|
||||
else if (type == "ProcessBrowserList") return context.eventProcessBrowserList;
|
||||
|
||||
return QList<AxEvent>();
|
||||
}
|
||||
|
||||
void AxScriptEngine::removeEvent(const QString &id)
|
||||
{
|
||||
for (int i=0; i< context.eventFileBroserDisks.size(); i++) {
|
||||
if (id == context.eventFileBroserDisks[i].event_id) {
|
||||
context.eventFileBroserDisks.removeAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////
|
||||
|
||||
void AxScriptEngine::registerMenu(const QString &type, AbstractAxMenuItem *menu, const QSet<QString> &list_agents, const QSet<QString> &list_os, const QSet<QString> &list_listeners)
|
||||
{
|
||||
QSet<int> os;
|
||||
if (list_os.contains("windows")) os.insert(1);
|
||||
if (list_os.contains("linux")) os.insert(2);
|
||||
if (list_os.contains("macos")) os.insert(3);
|
||||
|
||||
AxMenuItem item = {menu, list_agents, list_listeners, os};
|
||||
|
||||
if ( type == "SessionMain") context.menuSessionMain.append(item);
|
||||
else if (type == "SessionAgent") context.menuSessionAgent.append(item);
|
||||
else if (type == "SessionBrowser") context.menuSessionBrowser.append(item);
|
||||
else if (type == "SessionAccess") context.menuSessionAccess.append(item);
|
||||
else if (type == "FileBrowser") context.menuFileBrowser.append(item);
|
||||
else if (type == "ProcessBrowser") context.menuProcessBrowser.append(item);
|
||||
else if (type == "DownloadRunning") context.menuDownloadRunning.append(item);
|
||||
else if (type == "DownloadFinished") context.menuDownloadFinished.append(item);
|
||||
else if (type == "Tasks") context.menuTasks.append(item);
|
||||
else if (type == "TasksJob") context.menuTasksJob.append(item);
|
||||
}
|
||||
|
||||
QList<AxMenuItem> AxScriptEngine::getMenuItems(const QString &type)
|
||||
{
|
||||
if ( type == "SessionMain") return context.menuSessionMain;
|
||||
else if (type == "SessionAgent") return context.menuSessionAgent;
|
||||
else if (type == "SessionBrowser") return context.menuSessionBrowser;
|
||||
else if (type == "SessionAccess") return context.menuSessionAccess;
|
||||
else if (type == "FileBrowser") return context.menuFileBrowser;
|
||||
else if (type == "ProcessBrowser") return context.menuProcessBrowser;
|
||||
else if (type == "DownloadRunning") return context.menuDownloadRunning;
|
||||
else if (type == "DownloadFinished") return context.menuDownloadFinished;
|
||||
else if (type == "Tasks") return context.menuTasks;
|
||||
else if (type == "TasksJob") return context.menuTasksJob;
|
||||
|
||||
return QList<AxMenuItem>();
|
||||
}
|
||||
|
||||
void AxScriptEngine::engineError(const QString &message) { engine()->throwError(QJSValue::TypeError, message); }
|
||||
|
||||
bool AxScriptEngine::execute(const QString &code)
|
||||
{
|
||||
QJSValue result = jsEngine->evaluate(code, context.name);
|
||||
context.scriptObject = result;
|
||||
if (result.isError()) {
|
||||
QString error = QStringLiteral("%1\n at line %2 in %3\n stack: %4\n").arg(result.toString()).arg(result.property("lineNumber").toInt()).arg(context.name).arg(result.property("stack").toString());
|
||||
scriptManager->consolePrintError(error);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,522 @@
|
||||
#include <Agent/Agent.h>
|
||||
#include <Agent/Task.h>
|
||||
#include <Client/Requestor.h>
|
||||
#include <Client/AuthProfile.h>
|
||||
#include <Client/AxScript/AxScriptManager.h>
|
||||
#include <Client/AxScript/AxElementWrappers.h>
|
||||
#include <Client/AxScript/AxScriptEngine.h>
|
||||
#include <Client/AxScript/BridgeEvent.h>
|
||||
#include <UI/Widgets/AdaptixWidget.h>
|
||||
#include <UI/Widgets/AxConsoleWidget.h>
|
||||
|
||||
|
||||
|
||||
AxScriptManager::AxScriptManager(AdaptixWidget* main_widget, QObject *parent): QObject(parent), adaptixWidget(main_widget) {
|
||||
mainScript = new AxScriptEngine(this, "main", this);
|
||||
}
|
||||
|
||||
AxScriptManager::~AxScriptManager() = default;
|
||||
|
||||
QJSEngine* AxScriptManager::MainScriptEngine() { return mainScript->engine(); }
|
||||
|
||||
void AxScriptManager::Clear()
|
||||
{
|
||||
ResetMain();
|
||||
|
||||
qDeleteAll(agents_scripts);
|
||||
agents_scripts.clear();
|
||||
qDeleteAll(listeners_scripts);
|
||||
listeners_scripts.clear();
|
||||
qDeleteAll(scripts);
|
||||
scripts.clear();
|
||||
}
|
||||
|
||||
void AxScriptManager::ResetMain()
|
||||
{
|
||||
auto commanderList = adaptixWidget->GetCommandersAll();
|
||||
for (auto commander : commanderList)
|
||||
commander->RemoveAxCommands(mainScript->context.name);
|
||||
|
||||
if (mainScript)
|
||||
delete mainScript;
|
||||
|
||||
mainScript = new AxScriptEngine(this, "main", this);
|
||||
}
|
||||
|
||||
QJSEngine* AxScriptManager::GetEngine(const QString &name)
|
||||
{
|
||||
if (agents_scripts.contains(name) && agents_scripts[name])
|
||||
return agents_scripts[name]->engine();
|
||||
|
||||
if (scripts.contains(name) && scripts[name])
|
||||
return scripts[name]->engine();
|
||||
|
||||
if (name == "main" && mainScript)
|
||||
return mainScript->engine();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AdaptixWidget* AxScriptManager::GetAdaptix() const { return adaptixWidget; }
|
||||
|
||||
QMap<QString, Agent*> AxScriptManager::GetAgents() const { return adaptixWidget->AgentsMap; }
|
||||
|
||||
QVector<CredentialData> AxScriptManager::GetCredentials() const { return adaptixWidget->Credentials; }
|
||||
|
||||
QStringList AxScriptManager::GetInterfaces() const { return adaptixWidget->addresses; }
|
||||
|
||||
/// MAIN
|
||||
|
||||
QStringList AxScriptManager::ListenerScriptList() { return listeners_scripts.keys(); }
|
||||
|
||||
void AxScriptManager::ListenerScriptAdd(const QString &name, const QString &ax_script)
|
||||
{
|
||||
if (listeners_scripts.contains(name))
|
||||
return;
|
||||
|
||||
AxScriptEngine* script = new AxScriptEngine(this, name, this);
|
||||
script->execute(ax_script);
|
||||
|
||||
listeners_scripts[name] = script;
|
||||
}
|
||||
|
||||
QJSEngine* AxScriptManager::ListenerScriptEngine(const QString &name)
|
||||
{
|
||||
if (!listeners_scripts.contains(name)) return nullptr;
|
||||
return listeners_scripts[name]->engine();
|
||||
}
|
||||
|
||||
|
||||
|
||||
QStringList AxScriptManager::AgentScriptList() { return agents_scripts.keys(); }
|
||||
|
||||
void AxScriptManager::AgentScriptAdd(const QString &name, const QString &ax_script)
|
||||
{
|
||||
if (agents_scripts.contains(name)) return;
|
||||
|
||||
AxScriptEngine* script = new AxScriptEngine(this, name, this);
|
||||
script->execute(ax_script);
|
||||
|
||||
agents_scripts[name] = script;
|
||||
}
|
||||
|
||||
QJSEngine* AxScriptManager::AgentScriptEngine(const QString &name)
|
||||
{
|
||||
if (!agents_scripts.contains(name)) return nullptr;
|
||||
return agents_scripts[name]->engine();
|
||||
}
|
||||
|
||||
QJSValue AxScriptManager::AgentScriptExecute(const QString &name, const QString &code)
|
||||
{
|
||||
QJSValue result;
|
||||
if (agents_scripts.contains(name)) {
|
||||
QJSValue func = agents_scripts[name]->engine()->globalObject().property(code);
|
||||
if (func.isCallable()) {
|
||||
QJSValueList args;
|
||||
args << QJSValue("BeaconHTTP");
|
||||
result = func.call(args);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QStringList AxScriptManager::ScriptList() { return scripts.keys(); }
|
||||
|
||||
bool AxScriptManager::ScriptAdd(ExtensionFile* ext)
|
||||
{
|
||||
AxScriptEngine* script = new AxScriptEngine(this, ext->FilePath, this);
|
||||
scripts[ext->FilePath] = script;
|
||||
bool result = script->execute(ext->Code);
|
||||
if (result) {
|
||||
QJSValue metadata = script->engine()->globalObject().property("metadata");
|
||||
if (metadata.isObject()) {
|
||||
ext->Name = metadata.property("name").toString();
|
||||
ext->Description = metadata.property("description").toString();
|
||||
ext->NoSave = metadata.property("nosave").toBool();
|
||||
}
|
||||
}
|
||||
else {
|
||||
ext->Enabled = false;
|
||||
ext->Message = QString("%1\n at line %2 in %3").arg(script->context.scriptObject.toString()).arg(script->context.scriptObject.property("lineNumber").toInt()).arg(ext->FilePath);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void AxScriptManager::ScriptRemove(const ExtensionFile &ext)
|
||||
{
|
||||
auto scriptEngine = scripts.take(ext.FilePath);
|
||||
|
||||
auto commanderList = adaptixWidget->GetCommandersAll();
|
||||
for (auto commander : commanderList)
|
||||
commander->RemoveAxCommands(ext.FilePath);
|
||||
|
||||
delete scriptEngine;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AxScriptManager::GlobalScriptLoad(const QString &path) { emit adaptixWidget->LoadGlobalScriptSignal(path); }
|
||||
|
||||
void AxScriptManager::GlobalScriptUnload(const QString &path) { emit adaptixWidget->UnloadGlobalScriptSignal(path); }
|
||||
|
||||
void AxScriptManager::RegisterCommandsGroup(const CommandsGroup &group, const QStringList &listeners, const QStringList &agents, const QList<int> &os)
|
||||
{
|
||||
auto commanderList = adaptixWidget->GetCommanders(listeners, agents, os);
|
||||
for (auto commander : commanderList)
|
||||
commander->AddAxCommands(group);
|
||||
}
|
||||
|
||||
void AxScriptManager::RemoveEvent(const QString &event_id)
|
||||
{
|
||||
QList<AxScriptEngine*> list = this->agents_scripts.values() + this->scripts.values();
|
||||
list.append(this->mainScript);
|
||||
|
||||
for (const auto script : list)
|
||||
script->removeEvent(event_id);
|
||||
}
|
||||
|
||||
QList<AxMenuItem> AxScriptManager::FilterMenuItems(const QStringList &agentIds, const QString &menuType)
|
||||
{
|
||||
QSet<QString> agentTypes;
|
||||
QSet<QString> listenerTypes;
|
||||
QSet<int> osTypes;
|
||||
for (auto agent_id: agentIds) {
|
||||
if (adaptixWidget->AgentsMap.contains(agent_id)) {
|
||||
agentTypes.insert(adaptixWidget->AgentsMap[agent_id]->data.Name);
|
||||
osTypes.insert(adaptixWidget->AgentsMap[agent_id]->data.Os);
|
||||
listenerTypes.insert(adaptixWidget->AgentsMap[agent_id]->listenerType);
|
||||
}
|
||||
}
|
||||
|
||||
QList<AxScriptEngine*> list = this->agents_scripts.values() + this->scripts.values();
|
||||
list.append(this->mainScript);
|
||||
|
||||
QList<AxMenuItem> items;
|
||||
for (const auto script : list)
|
||||
items += script->getMenuItems(menuType);
|
||||
|
||||
QList<AxMenuItem> ret;
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
AxMenuItem item = items[i];
|
||||
|
||||
if ( !item.agents.contains(agentTypes) )
|
||||
continue;
|
||||
if (item.os.size() > 0 && !item.os.contains(osTypes))
|
||||
continue;
|
||||
if (item.listenerts.size() > 0 && !item.listenerts.contains(listenerTypes))
|
||||
continue;
|
||||
|
||||
ret.append(item);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QList<AxEvent> AxScriptManager::FilterEvents(const QString &agentId, const QString &eventType)
|
||||
{
|
||||
QList<AxEvent> ret;
|
||||
|
||||
if( !adaptixWidget->AgentsMap.contains(agentId) )
|
||||
return ret;
|
||||
|
||||
QString agentType = adaptixWidget->AgentsMap[agentId]->data.Name;
|
||||
QString listenerType = adaptixWidget->AgentsMap[agentId]->listenerType;
|
||||
int osType = adaptixWidget->AgentsMap[agentId]->data.Os;
|
||||
|
||||
QList<AxScriptEngine*> list = this->agents_scripts.values() + this->scripts.values();
|
||||
list.append(this->mainScript);
|
||||
|
||||
QList<AxEvent> items;
|
||||
for (const auto script : list) {
|
||||
items += script->getEvents(eventType);
|
||||
}
|
||||
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
AxEvent event = items[i];
|
||||
|
||||
if ( !event.agents.contains(agentType) )
|
||||
continue;
|
||||
if (event.os.size() > 0 && !event.os.contains(osType))
|
||||
continue;
|
||||
if (event.listenerts.size() > 0 && !event.listenerts.contains(listenerType))
|
||||
continue;
|
||||
|
||||
ret.append(event);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// APP
|
||||
|
||||
void AxScriptManager::AppAgentSetColor(const QStringList &agents, const QString &background, const QString &foreground, const bool reset)
|
||||
{
|
||||
QString message = "";
|
||||
bool ok = false;
|
||||
HttpReqAgentSetColor(agents, background, foreground, reset, *(adaptixWidget->GetProfile()), &message, &ok);
|
||||
}
|
||||
|
||||
void AxScriptManager::AppAgentSetImpersonate(const QString &id, const QString &impersonate, const bool elevated)
|
||||
{
|
||||
QString message = "";
|
||||
bool ok = false;
|
||||
HttpReqAgentSetImpersonate(id, impersonate, elevated, *(adaptixWidget->GetProfile()), &message, &ok);
|
||||
}
|
||||
|
||||
void AxScriptManager::AppAgentSetMark(const QStringList &agents, const QString &mark)
|
||||
{
|
||||
QString message = "";
|
||||
bool ok = false;
|
||||
HttpReqAgentSetMark(agents, mark, *(adaptixWidget->GetProfile()), &message, &ok);
|
||||
}
|
||||
|
||||
void AxScriptManager::AppAgentSetTag(const QStringList &agents, const QString &tag)
|
||||
{
|
||||
QString message = "";
|
||||
bool ok = false;
|
||||
HttpReqAgentSetTag(agents, tag, *(adaptixWidget->GetProfile()), &message, &ok);
|
||||
}
|
||||
|
||||
/// MENU
|
||||
|
||||
int AxScriptManager::AddMenuSession(QMenu *menu, const QString &menuType, QStringList agentIds)
|
||||
{
|
||||
QVariantList context;
|
||||
for (auto agent_id: agentIds) {
|
||||
if (adaptixWidget->AgentsMap.contains(agent_id)) {
|
||||
context << agent_id;
|
||||
}
|
||||
}
|
||||
int count = 0;
|
||||
QList<AxMenuItem> items = this->FilterMenuItems(agentIds, menuType);
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
AxMenuItem item = items[i];
|
||||
|
||||
item.menu->setContext(context);
|
||||
if (auto* item1 = dynamic_cast<AxSeparatorWrapper*>(item.menu))
|
||||
menu->addAction(item1->action());
|
||||
else if (auto* item2 = dynamic_cast<AxActionWrapper*>(item.menu))
|
||||
menu->addAction(item2->action());
|
||||
else if (auto* item3 = dynamic_cast<AxMenuWrapper*>(item.menu))
|
||||
menu->addMenu(item3->menu());
|
||||
else
|
||||
continue;
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int AxScriptManager::AddMenuFileBrowser(QMenu *menu, QVector<DataMenuFileBrowser> files)
|
||||
{
|
||||
if (files.empty()) return 0;
|
||||
|
||||
QVariantList context;
|
||||
for (auto file : files) {
|
||||
if (adaptixWidget->AgentsMap.contains(file.agentId)) {
|
||||
QVariantMap map;
|
||||
map["agent_id"] = file.agentId;
|
||||
map["path"] = file.path;
|
||||
map["name"] = file.name;
|
||||
map["type"] = file.type;
|
||||
context << map;
|
||||
}
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
QList<AxMenuItem> items = this->FilterMenuItems(QStringList() << files[0].agentId, "FileBrowser");
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
AxMenuItem item = items[i];
|
||||
|
||||
item.menu->setContext(context);
|
||||
if (auto* item1 = dynamic_cast<AxSeparatorWrapper*>(item.menu))
|
||||
menu->addAction(item1->action());
|
||||
else if (auto* item2 = dynamic_cast<AxActionWrapper*>(item.menu))
|
||||
menu->addAction(item2->action());
|
||||
else if (auto* item3 = dynamic_cast<AxMenuWrapper*>(item.menu))
|
||||
menu->addMenu(item3->menu());
|
||||
else
|
||||
continue;
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int AxScriptManager::AddMenuProcessBrowser(QMenu *menu, QVector<DataMenuProcessBrowser> processes)
|
||||
{
|
||||
if (processes.empty()) return 0;
|
||||
|
||||
QVariantList context;
|
||||
for (auto proc : processes) {
|
||||
if (adaptixWidget->AgentsMap.contains(proc.agentId)) {
|
||||
QVariantMap map;
|
||||
map["agent_id"] = proc.agentId;
|
||||
map["pid"] = proc.pid;
|
||||
map["ppid"] = proc.ppid;
|
||||
map["arch"] = proc.arch;
|
||||
map["session_id"] = proc.session_id;
|
||||
map["context"] = proc.context;
|
||||
map["process"] = proc.process;
|
||||
context << map;
|
||||
}
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
QList<AxMenuItem> items = this->FilterMenuItems(QStringList() << processes[0].agentId, "ProcessBrowser");
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
AxMenuItem item = items[i];
|
||||
|
||||
item.menu->setContext(context);
|
||||
if (auto* item1 = dynamic_cast<AxSeparatorWrapper*>(item.menu))
|
||||
menu->addAction(item1->action());
|
||||
else if (auto* item2 = dynamic_cast<AxActionWrapper*>(item.menu))
|
||||
menu->addAction(item2->action());
|
||||
else if (auto* item3 = dynamic_cast<AxMenuWrapper*>(item.menu))
|
||||
menu->addMenu(item3->menu());
|
||||
else
|
||||
continue;
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int AxScriptManager::AddMenuDownload(QMenu *menu, const QString &menuType, QVector<DataMenuDownload> files)
|
||||
{
|
||||
if (files.empty()) return 0;
|
||||
|
||||
QVariantList context;
|
||||
for (auto file : files) {
|
||||
if (adaptixWidget->AgentsMap.contains(file.agentId)) {
|
||||
QVariantMap map;
|
||||
map["agent_id"] = file.agentId;
|
||||
map["file_id"] = file.fileId;
|
||||
map["path"] = file.path;
|
||||
map["state"] = file.state;
|
||||
context << map;
|
||||
}
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
QList<AxMenuItem> items = this->FilterMenuItems(QStringList() << files[0].agentId, menuType);
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
AxMenuItem item = items[i];
|
||||
|
||||
item.menu->setContext(context);
|
||||
if (auto* item1 = dynamic_cast<AxSeparatorWrapper*>(item.menu))
|
||||
menu->addAction(item1->action());
|
||||
else if (auto* item2 = dynamic_cast<AxActionWrapper*>(item.menu))
|
||||
menu->addAction(item2->action());
|
||||
else if (auto* item3 = dynamic_cast<AxMenuWrapper*>(item.menu))
|
||||
menu->addMenu(item3->menu());
|
||||
else
|
||||
continue;
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int AxScriptManager::AddMenuTask(QMenu *menu, const QString &menuType, const QStringList &tasks)
|
||||
{
|
||||
if (tasks.empty()) return 0;
|
||||
|
||||
QSet<QString> agents;
|
||||
|
||||
QVariantList context;
|
||||
for (auto taskId : tasks) {
|
||||
if (adaptixWidget->TasksMap.contains(taskId) && adaptixWidget->TasksMap[taskId]) {
|
||||
TaskData taskData = adaptixWidget->TasksMap[taskId]->data;
|
||||
QVariantMap map;
|
||||
map["agent_id"] = taskData.AgentId;
|
||||
map["task_id"] = taskData.TaskId;
|
||||
map["state"] = taskData.Status;
|
||||
if ( taskData.TaskType == 1 )
|
||||
map["type"] = "TASK";
|
||||
else if ( taskData.TaskType == 3 )
|
||||
map["type"] = "JOB";
|
||||
else if ( taskData.TaskType == 4 )
|
||||
map["type"] = "TUNNEL";
|
||||
else
|
||||
map["type"] = "unknown";
|
||||
|
||||
context << map;
|
||||
agents.insert(taskData.AgentId);
|
||||
}
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
QList<AxMenuItem> items = this->FilterMenuItems(QList<QString>(agents.begin(), agents.end()), menuType);
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
AxMenuItem item = items[i];
|
||||
|
||||
item.menu->setContext(context);
|
||||
if (auto* item1 = dynamic_cast<AxSeparatorWrapper*>(item.menu))
|
||||
menu->addAction(item1->action());
|
||||
else if (auto* item2 = dynamic_cast<AxActionWrapper*>(item.menu))
|
||||
menu->addAction(item2->action());
|
||||
else if (auto* item3 = dynamic_cast<AxMenuWrapper*>(item.menu))
|
||||
menu->addMenu(item3->menu());
|
||||
else
|
||||
continue;
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/// EVENT
|
||||
|
||||
void AxScriptManager::emitFileBrowserDisks(const QString &agentId)
|
||||
{
|
||||
QList<AxEvent> items = this->FilterEvents(agentId, "FileBroserDisks");
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
AxEvent event = items[i];
|
||||
if (event.jsEngine) {
|
||||
QJSValue argId = event.jsEngine->toScriptValue(agentId);
|
||||
event.handler.call(QJSValueList() << argId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AxScriptManager::emitFileBrowserList(const QString &agentId, const QString &path)
|
||||
{
|
||||
QList<AxEvent> items = this->FilterEvents(agentId, "FileBroserList");
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
AxEvent event = items[i];
|
||||
if (event.jsEngine) {
|
||||
QJSValue argId = event.jsEngine->toScriptValue(agentId);
|
||||
QJSValue argPath = event.jsEngine->toScriptValue(path);
|
||||
event.handler.call(QJSValueList() << argId << argPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AxScriptManager::emitFileBrowserUpload(const QString &agentId, const QString &path, const QString &localFilename)
|
||||
{
|
||||
QList<AxEvent> items = this->FilterEvents(agentId, "FileBroserUpload");
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
AxEvent event = items[i];
|
||||
if (event.jsEngine) {
|
||||
QJSValue argId = event.jsEngine->toScriptValue(agentId);
|
||||
QJSValue argPath = event.jsEngine->toScriptValue(path);
|
||||
QJSValue argFile = event.jsEngine->toScriptValue(localFilename);
|
||||
event.handler.call(QJSValueList() << argId << argPath << argFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AxScriptManager::emitProcessBrowserList(const QString &agentId)
|
||||
{
|
||||
QList<AxEvent> items = this->FilterEvents(agentId, "ProcessBrowserList");
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
AxEvent event = items[i];
|
||||
if (event.jsEngine) {
|
||||
QJSValue argId = event.jsEngine->toScriptValue(agentId);
|
||||
event.handler.call(QJSValueList() << argId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// SLOTS
|
||||
|
||||
void AxScriptManager::consolePrintMessage(const QString &message) { this->adaptixWidget->AxConsoleTab->PrintMessage(message); }
|
||||
|
||||
void AxScriptManager::consolePrintError(const QString &message) { this->adaptixWidget->AxConsoleTab->PrintError(message); }
|
||||
@@ -0,0 +1,564 @@
|
||||
#include <main.h>
|
||||
#include <QTimeZone>
|
||||
#include <Agent/Agent.h>
|
||||
#include <Client/AxScript/BridgeApp.h>
|
||||
#include <Client/AxScript/AxScriptEngine.h>
|
||||
#include <Client/AxScript/AxCommandWrappers.h>
|
||||
#include <Client/AxScript/AxScriptManager.h>
|
||||
#include <UI/Widgets/AdaptixWidget.h>
|
||||
#include <UI/Widgets/ConsoleWidget.h>
|
||||
#include <UI/Widgets/CredentialsWidget.h>
|
||||
|
||||
BridgeApp::BridgeApp(AxScriptEngine* scriptEngine, QObject* parent) : QObject(parent), scriptEngine(scriptEngine), widget(new QWidget()){}
|
||||
|
||||
BridgeApp::~BridgeApp() { delete widget; }
|
||||
|
||||
AxScriptEngine* BridgeApp::GetScriptEngine() const { return this->scriptEngine; }
|
||||
|
||||
|
||||
|
||||
QJSValue BridgeApp::agents() const
|
||||
{
|
||||
QVariantMap list;
|
||||
auto mapAgents = scriptEngine->manager()->GetAgents();
|
||||
|
||||
for (auto agent : mapAgents) {
|
||||
QVariantMap map;
|
||||
map["id"] = agent->data.Id;
|
||||
map["type"] = agent->data.Name;
|
||||
map["listener"] = agent->data.Listener;
|
||||
map["external_ip"] = agent->data.ExternalIP;
|
||||
map["internal_ip"] = agent->data.InternalIP;
|
||||
map["domain"] = agent->data.Domain;
|
||||
map["computer"] = agent->data.Computer;
|
||||
map["username"] = agent->data.Username;
|
||||
map["impersonated"] = agent->data.Impersonated;
|
||||
map["process"] = agent->data.Process;
|
||||
map["arch"] = agent->data.Arch;
|
||||
map["pid"] = agent->data.Pid.toInt();
|
||||
map["tid"] = agent->data.Tid.toInt();
|
||||
map["gmt"] = agent->data.GmtOffset;
|
||||
map["elevated"] = agent->data.Elevated;
|
||||
map["tags"] = agent->data.Tags;
|
||||
map["async"] = agent->data.Async;
|
||||
map["sleep"] = agent->data.Sleep;
|
||||
map["os_full"] = agent->data.OsDesc;
|
||||
|
||||
if (agent->data.Os == OS_WINDOWS) map["os"] = "windows";
|
||||
else if (agent->data.Os == OS_LINUX) map["os"] = "linux";
|
||||
else if (agent->data.Os == OS_MAC) map["os"] = "macos";
|
||||
else map["os"] = "unknown";
|
||||
|
||||
list[agent->data.Id] = map;
|
||||
}
|
||||
|
||||
return this->scriptEngine->engine()->toScriptValue(list);
|
||||
}
|
||||
|
||||
QJSValue BridgeApp::agent_info(const QString &id, const QString &property) const
|
||||
{
|
||||
auto mapAgents = scriptEngine->manager()->GetAgents();
|
||||
if (!mapAgents.contains(id))
|
||||
return false;
|
||||
|
||||
QJSValue ret;
|
||||
auto info = mapAgents[id]->data;
|
||||
|
||||
if (property == "id")
|
||||
return QJSValue(info.Id);
|
||||
if (property == "type")
|
||||
return QJSValue(info.Name);
|
||||
if (property == "listener")
|
||||
return QJSValue(info.Listener);
|
||||
if (property == "externalIP")
|
||||
return QJSValue(info.ExternalIP);
|
||||
if (property == "internalIP")
|
||||
return QJSValue(info.InternalIP);
|
||||
if (property == "domain")
|
||||
return QJSValue(info.Domain);
|
||||
if (property == "computer")
|
||||
return QJSValue(info.Computer);
|
||||
if (property == "username")
|
||||
return QJSValue(info.Username);
|
||||
if (property == "impersonated")
|
||||
return QJSValue(info.Impersonated);
|
||||
if (property == "process")
|
||||
return QJSValue(info.Process);
|
||||
if (property == "arch")
|
||||
return QJSValue(info.Arch);
|
||||
if (property == "pid")
|
||||
return QJSValue(info.Pid.toInt());
|
||||
if (property == "tid")
|
||||
return QJSValue(info.Tid.toInt());
|
||||
if (property == "gmt")
|
||||
return QJSValue(info.GmtOffset);
|
||||
if (property == "elevated")
|
||||
return QJSValue(info.Elevated);
|
||||
if (property == "tags")
|
||||
return QJSValue(info.Tags);
|
||||
if (property == "async")
|
||||
return QJSValue(info.Async);
|
||||
if (property == "sleep")
|
||||
return QJSValue(info.Sleep);
|
||||
if (property == "os_full")
|
||||
return QJSValue(info.OsDesc);
|
||||
if (property == "os") {
|
||||
if (info.Os == OS_WINDOWS) return "windows";
|
||||
else if (info.Os == OS_LINUX) return "linux";
|
||||
else if (info.Os == OS_MAC) return "macos";
|
||||
else return "unknown";
|
||||
}
|
||||
|
||||
return QJSValue::UndefinedValue;
|
||||
}
|
||||
|
||||
void BridgeApp::agent_set_color(const QJSValue &agents, const QString &background, const QString &foreground, const bool reset)
|
||||
{
|
||||
if (agents.isUndefined() || agents.isNull() || !agents.isArray()) {
|
||||
emit engineError("agent_set_color expected array of strings in agents parameter!");
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList list_agents;
|
||||
for (int i = 0; i < agents.property("length").toInt(); ++i) {
|
||||
QJSValue val = agents.property(i);
|
||||
list_agents << val.toString();
|
||||
}
|
||||
|
||||
scriptEngine->manager()->AppAgentSetColor(list_agents, background, foreground, reset);
|
||||
}
|
||||
|
||||
void BridgeApp::agent_set_impersonate(const QString &id, const QString &impersonate, const bool elevated) { scriptEngine->manager()->AppAgentSetImpersonate(id, impersonate, elevated); }
|
||||
|
||||
void BridgeApp::agent_set_mark(const QJSValue &agents, const QString &mark)
|
||||
{
|
||||
if (agents.isUndefined() || agents.isNull() || !agents.isArray()) {
|
||||
emit engineError("agent_set_color expected array of strings in agents parameter!");
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList list_agents;
|
||||
for (int i = 0; i < agents.property("length").toInt(); ++i) {
|
||||
QJSValue val = agents.property(i);
|
||||
list_agents << val.toString();
|
||||
}
|
||||
|
||||
scriptEngine->manager()->AppAgentSetMark(list_agents, mark);
|
||||
}
|
||||
|
||||
void BridgeApp::agent_set_tag(const QJSValue &agents, const QString &tag)
|
||||
{
|
||||
if (agents.isUndefined() || agents.isNull() || !agents.isArray()) {
|
||||
emit engineError("agent_set_color expected array of strings in agents parameter!");
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList list_agents;
|
||||
for (int i = 0; i < agents.property("length").toInt(); ++i) {
|
||||
QJSValue val = agents.property(i);
|
||||
list_agents << val.toString();
|
||||
}
|
||||
|
||||
scriptEngine->manager()->AppAgentSetTag(list_agents, tag);
|
||||
}
|
||||
|
||||
QString BridgeApp::arch(const QString &id) const
|
||||
{
|
||||
auto mapAgents = scriptEngine->manager()->GetAgents();
|
||||
if (!mapAgents.contains(id))
|
||||
return "x86";
|
||||
|
||||
return mapAgents[id]->data.Arch;
|
||||
}
|
||||
|
||||
QString BridgeApp::bof_pack(const QString &types, const QJSValue &args)
|
||||
{
|
||||
if (!args.isArray()) {
|
||||
emit engineError("bof_pack expected array of arguments!");
|
||||
return "";
|
||||
}
|
||||
|
||||
QStringList items = types.split(",", Qt::SkipEmptyParts);
|
||||
int length = args.property("length").toInt();
|
||||
|
||||
if (items.size() != length) {
|
||||
emit engineError("bof_pack expects the same number of types and arguments!");
|
||||
return "";
|
||||
}
|
||||
|
||||
QByteArray data;
|
||||
|
||||
for (int i = 0; i < length; ++i) {
|
||||
QVariant value = args.property(i).toVariant();
|
||||
|
||||
if (items[i] == "cstr") {
|
||||
if (!value.canConvert<QString>()) {
|
||||
emit engineError(QString("bof_pack cannot convert argument at index %1 to string").arg(i));
|
||||
return "";
|
||||
}
|
||||
|
||||
QByteArray valueData = value.toString().toUtf8();
|
||||
int strLength = valueData.size() + 1;
|
||||
|
||||
QByteArray valueLengthData;
|
||||
valueLengthData.append(reinterpret_cast<const char*>(&strLength), 4);
|
||||
data.append(valueLengthData);
|
||||
|
||||
valueData.append('\0');
|
||||
data.append(valueData);
|
||||
}
|
||||
else if (items[i] == "wstr") {
|
||||
if (!value.canConvert<QString>()) {
|
||||
emit engineError(QString("bof_pack cannot convert argument at index %1 to string").arg(i));
|
||||
return "";
|
||||
}
|
||||
|
||||
QString str = value.toString();
|
||||
const char16_t* utf16Data = reinterpret_cast<const char16_t*>(str.utf16());
|
||||
int utf16Length = str.size() + 1;
|
||||
|
||||
QByteArray strData;
|
||||
strData.append(reinterpret_cast<const char*>(utf16Data), utf16Length * sizeof(char16_t));
|
||||
|
||||
QByteArray strLengthData;
|
||||
int strLength = utf16Length * sizeof(char16_t);
|
||||
strLengthData.append(reinterpret_cast<const char*>(&strLength), 4);
|
||||
|
||||
data.append(strLengthData);
|
||||
data.append(strData);
|
||||
}
|
||||
else if (items[i] == "bytes") {
|
||||
if (!value.canConvert<QString>()) {
|
||||
emit engineError(QString("bof_pack cannot convert argument at index %1 to string").arg(i));
|
||||
return "";
|
||||
}
|
||||
|
||||
QByteArray valueData = QByteArray::fromBase64(value.toString().toUtf8());
|
||||
int strLength = valueData.size();
|
||||
|
||||
QByteArray valueLengthData;
|
||||
valueLengthData.append(reinterpret_cast<const char*>(&strLength), 4);
|
||||
data.append(valueLengthData);
|
||||
data.append(valueData);
|
||||
}
|
||||
else if (items[i] == "int") {
|
||||
if (!value.canConvert<int>()) {
|
||||
emit engineError(QString("bof_pack cannot convert argument at index %1 to int").arg(i));
|
||||
return "";
|
||||
}
|
||||
|
||||
int num = value.toInt();
|
||||
QByteArray numData;
|
||||
numData.append(reinterpret_cast<const char*>(&num), sizeof(num));
|
||||
data.append(numData);
|
||||
}
|
||||
else if (items[i] == "short") {
|
||||
if (!value.canConvert<int>()) {
|
||||
emit engineError(QString("bof_pack cannot convert argument at index %1 to short").arg(i));
|
||||
return "";
|
||||
}
|
||||
|
||||
short num = static_cast<short>(value.toInt());
|
||||
QByteArray numData;
|
||||
numData.append(reinterpret_cast<const char*>(&num), sizeof(num));
|
||||
data.append(numData);
|
||||
}
|
||||
else {
|
||||
emit engineError(QString("bof_pack does not expect type '%1' (index %2)").arg(items[i]).arg(i));
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray strLengthData;
|
||||
int strLength = data.size();
|
||||
strLengthData.append(reinterpret_cast<const char*>(&strLength), sizeof(strLength));
|
||||
|
||||
strLengthData.append(data);
|
||||
return strLengthData.toBase64();
|
||||
}
|
||||
|
||||
void BridgeApp::copy_to_clipboard(const QString &text) { QApplication::clipboard()->setText(text); }
|
||||
|
||||
void BridgeApp::console_message(const QString &id, const QString &message, const QString &type, const QString &text)
|
||||
{
|
||||
auto mapAgents = scriptEngine->manager()->GetAgents();
|
||||
if (!mapAgents.contains(id))
|
||||
return;
|
||||
|
||||
auto agent = mapAgents[id];
|
||||
if (!agent)
|
||||
return;
|
||||
|
||||
int msgType = CONSOLE_OUT;
|
||||
if (type == "info")
|
||||
msgType = CONSOLE_OUT_LOCAL_INFO;
|
||||
else if (type == "success")
|
||||
msgType = CONSOLE_OUT_LOCAL_SUCCESS;
|
||||
else if (type == "error")
|
||||
msgType = CONSOLE_OUT_LOCAL_ERROR;
|
||||
|
||||
agent->Console->ConsoleOutputMessage(QDateTime::currentSecsSinceEpoch(), "", msgType, message, text, false);
|
||||
}
|
||||
|
||||
QJSValue BridgeApp::credentials() const
|
||||
{
|
||||
QVariantMap list;
|
||||
auto vecCreds = scriptEngine->manager()->GetCredentials();
|
||||
|
||||
for (auto cred : vecCreds) {
|
||||
QVariantMap map;
|
||||
map["id"] = cred.CredId;
|
||||
map["username"] = cred.Username;
|
||||
map["password"] = cred.Password;
|
||||
map["realm"] = cred.Realm;
|
||||
map["type"] = cred.Type;
|
||||
map["tag"] = cred.Tag;
|
||||
map["date"] = cred.Date;
|
||||
map["storage"] = cred.Storage;
|
||||
map["agent_id"] = cred.AgentId;
|
||||
map["host"] = cred.Host;
|
||||
|
||||
list[cred.CredId] = map;
|
||||
}
|
||||
|
||||
return this->scriptEngine->engine()->toScriptValue(list);
|
||||
}
|
||||
|
||||
void BridgeApp::credentials_add(const QString &username, const QString &password, const QString &realm, const QString &type, const QString &tag, const QString &storage, const QString &host) { scriptEngine->manager()->GetAdaptix()->CredentialsTab->CredentialsAdd(username, password, realm, type, tag, storage, host); }
|
||||
|
||||
QObject* BridgeApp::create_command(const QString &name, const QString &description, const QString &example, const QString &message)
|
||||
{
|
||||
auto* wrapper = new AxCommandWrappers(name, description, example, message, this);
|
||||
connect(wrapper, &AxCommandWrappers::scriptError, this, &BridgeApp::engineError);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeApp::create_commands_group(const QString &name, const QJSValue &array)
|
||||
{
|
||||
auto* wrapper = new AxCommandGroupWrapper(scriptEngine->engine(), this);
|
||||
connect(wrapper, &AxCommandGroupWrapper::scriptError, this, &BridgeApp::engineError);
|
||||
wrapper->SetParams(name, array);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
void BridgeApp::execute_alias(const QString &id, const QString &cmdline, const QString &command, const QString &message, const QJSValue &hook) const
|
||||
{
|
||||
auto mapAgents = scriptEngine->manager()->GetAgents();
|
||||
if (!mapAgents.contains(id))
|
||||
return;
|
||||
|
||||
auto agent = mapAgents[id];
|
||||
if (!agent)
|
||||
return;
|
||||
|
||||
auto cmdResult = agent->commander->ProcessInput(id, command);
|
||||
if (!cmdResult.is_pre_hook) {
|
||||
if (!message.isEmpty()) {
|
||||
cmdResult.data["message"] = message;
|
||||
}
|
||||
|
||||
if (!hook.isUndefined() && !hook.isNull() && hook.isCallable())
|
||||
cmdResult.post_hook = {true, scriptEngine->context.name, hook};
|
||||
|
||||
agent->Console->ProcessCmdResult(cmdline, cmdResult, false);
|
||||
}
|
||||
}
|
||||
|
||||
void BridgeApp::execute_browser(const QString &id, const QString &command) const
|
||||
{
|
||||
auto mapAgents = scriptEngine->manager()->GetAgents();
|
||||
if (!mapAgents.contains(id))
|
||||
return;
|
||||
|
||||
auto agent = mapAgents[id];
|
||||
if (!agent)
|
||||
return;
|
||||
|
||||
auto cmdResult = agent->commander->ProcessInput(id, command);
|
||||
agent->Console->ProcessCmdResult(command, cmdResult, true);
|
||||
}
|
||||
|
||||
void BridgeApp::execute_command(const QString &id, const QString &command, const QJSValue &hook) const
|
||||
{
|
||||
auto mapAgents = scriptEngine->manager()->GetAgents();
|
||||
if (!mapAgents.contains(id))
|
||||
return;
|
||||
|
||||
auto agent = mapAgents[id];
|
||||
if (!agent)
|
||||
return;
|
||||
|
||||
auto cmdResult = agent->commander->ProcessInput(id, command);
|
||||
if (!cmdResult.is_pre_hook) {
|
||||
|
||||
if (!hook.isUndefined() && !hook.isNull() && hook.isCallable())
|
||||
cmdResult.post_hook = {true, scriptEngine->context.name, hook};
|
||||
|
||||
agent->Console->ProcessCmdResult(command, cmdResult, false);
|
||||
}
|
||||
}
|
||||
|
||||
QString BridgeApp::file_basename(const QString &path) const
|
||||
{
|
||||
int slash = qMax(path.lastIndexOf('/'), path.lastIndexOf('\\'));
|
||||
return path.mid(slash + 1);
|
||||
}
|
||||
|
||||
bool BridgeApp::file_exists(const QString &path) const { return QFile::exists(path); }
|
||||
|
||||
QString BridgeApp::file_read(QString path) const
|
||||
{
|
||||
if (path.startsWith("~/"))
|
||||
path = QDir::home().filePath(path.mid(2));
|
||||
|
||||
QFile file(path);
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
QByteArray fileData = file.readAll();
|
||||
file.close();
|
||||
return QString::fromLatin1(fileData.toBase64());
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
QString BridgeApp::format_time(const QString &format, const int &time) const
|
||||
{
|
||||
QDateTime epochDateTime = QDateTime::fromSecsSinceEpoch(time, QTimeZone("UTC"));
|
||||
QDateTime localDateTime = epochDateTime.toTimeZone(QTimeZone::systemTimeZone());
|
||||
return localDateTime.toString(format);
|
||||
}
|
||||
|
||||
QJSValue BridgeApp::interfaces() const
|
||||
{
|
||||
QVariantList list;
|
||||
auto interfaces = scriptEngine->manager()->GetInterfaces();
|
||||
|
||||
for (auto addr : interfaces)
|
||||
list.append(addr);
|
||||
|
||||
return this->scriptEngine->engine()->toScriptValue(list);
|
||||
}
|
||||
|
||||
bool BridgeApp::is64(const QString &id) const
|
||||
{
|
||||
auto mapAgents = scriptEngine->manager()->GetAgents();
|
||||
if (!mapAgents.contains(id))
|
||||
return false;
|
||||
|
||||
return mapAgents[id]->data.Arch == "x64";
|
||||
}
|
||||
|
||||
bool BridgeApp::isadmin(const QString &id) const
|
||||
{
|
||||
auto mapAgents = scriptEngine->manager()->GetAgents();
|
||||
if (!mapAgents.contains(id))
|
||||
return false;
|
||||
|
||||
return mapAgents[id]->data.Elevated;
|
||||
}
|
||||
|
||||
void BridgeApp::log(const QString &text) { emit consoleMessage(text); }
|
||||
|
||||
void BridgeApp::log_error(const QString &text) { emit consoleError(text); }
|
||||
|
||||
void BridgeApp::open_agent_console(const QString &id) { scriptEngine->manager()->GetAdaptix()->LoadConsoleUI(id); }
|
||||
|
||||
void BridgeApp::open_access_tunnel(const QString &id, const bool socks4, const bool socks5, const bool lportfwd, const bool rportfwd) { scriptEngine->manager()->GetAdaptix()->ShowTunnelCreator(id, socks4, socks5, lportfwd, rportfwd); }
|
||||
|
||||
void BridgeApp::open_browser_files(const QString &id) { scriptEngine->manager()->GetAdaptix()->LoadFileBrowserUI(id); }
|
||||
|
||||
void BridgeApp::open_browser_process(const QString &id) { scriptEngine->manager()->GetAdaptix()->LoadProcessBrowserUI(id); }
|
||||
|
||||
void BridgeApp::open_remote_terminal(const QString &id) { scriptEngine->manager()->GetAdaptix()->LoadTerminalUI(id); }
|
||||
|
||||
QString BridgeApp::prompt_open_file(const QString &caption, const QString &filter) { return QFileDialog::getOpenFileName(nullptr, caption, QDir::homePath(), filter); }
|
||||
|
||||
QString BridgeApp::prompt_open_dir(const QString &caption) { return QFileDialog::getExistingDirectory(nullptr, caption, QDir::homePath()); }
|
||||
|
||||
QString BridgeApp::prompt_save_file(const QString &filename, const QString &caption, const QString &filter) { return QFileDialog::getSaveFileName(nullptr, caption, filename, filter); }
|
||||
|
||||
void BridgeApp::register_commands_group(QObject *obj, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners)
|
||||
{
|
||||
QList<int> list_os;
|
||||
QStringList list_agents;
|
||||
QStringList list_listeners;
|
||||
|
||||
if (agents.isUndefined() || agents.isNull() || !agents.isArray()) {
|
||||
emit engineError("register_commands_group expected array of strings in agents parameter!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (os.isUndefined() && (os.isNull() || !os.isArray()) ) {
|
||||
emit engineError("register_commands_group expected array of strings in os parameter!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (listeners.isUndefined() && (listeners.isNull() || !listeners.isArray())) {
|
||||
emit engineError("register_commands_group expected array of strings in listeners parameter!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < os.property("length").toInt(); ++i) {
|
||||
QJSValue val = os.property(i);
|
||||
if (val.toString() == "windows") list_os.append(1);
|
||||
else if (val.toString() == "linux") list_os.append(2);
|
||||
else if (val.toString() == "macos") list_os.append(3);
|
||||
}
|
||||
|
||||
for (int i = 0; i < agents.property("length").toInt(); ++i) {
|
||||
QJSValue val = agents.property(i);
|
||||
list_agents << val.toString();
|
||||
}
|
||||
|
||||
for (int i = 0; i < listeners.property("length").toInt(); ++i) {
|
||||
QJSValue val = listeners.property(i);
|
||||
list_listeners << val.toString();
|
||||
}
|
||||
|
||||
auto wrapper = qobject_cast<AxCommandGroupWrapper*>(obj);
|
||||
if (!wrapper) {
|
||||
emit engineError("register_commands_group no support object type!");
|
||||
return;
|
||||
}
|
||||
|
||||
CommandsGroup commandsGroup = {};
|
||||
commandsGroup.groupName = wrapper->getName();
|
||||
commandsGroup.commands = wrapper->getCommands();
|
||||
commandsGroup.engine = wrapper->getEngine();
|
||||
commandsGroup.filepath = scriptEngine->context.name;
|
||||
|
||||
scriptEngine->manager()->RegisterCommandsGroup(commandsGroup, list_listeners, list_agents, list_os);
|
||||
}
|
||||
|
||||
void BridgeApp::script_import(const QString &path)
|
||||
{
|
||||
QFile file(path);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
return scriptEngine->engine()->throwError("Could not open script: " + path);
|
||||
}
|
||||
QTextStream in(&file);
|
||||
QString code = in.readAll();
|
||||
file.close();
|
||||
|
||||
scriptEngine->engine()->evaluate(code, path);
|
||||
}
|
||||
|
||||
void BridgeApp::script_load(const QString &path) { scriptEngine->manager()->GlobalScriptLoad(path); }
|
||||
|
||||
void BridgeApp::script_unload(const QString &path) { scriptEngine->manager()->GlobalScriptUnload(path); }
|
||||
|
||||
QString BridgeApp::script_dir()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
return GetParentPathWindows(scriptEngine->context.name) + "\\";
|
||||
#else
|
||||
return GetParentPathUnix(scriptEngine->context.name) + "/";
|
||||
#endif
|
||||
}
|
||||
|
||||
void BridgeApp::show_message(const QString &title, const QString &text) { QMessageBox::information(nullptr, title, text); }
|
||||
|
||||
int BridgeApp::ticks() { return QDateTime::currentSecsSinceEpoch(); }
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
#include <Client/AxScript/BridgeEvent.h>
|
||||
#include <Client/AxScript/AxScriptEngine.h>
|
||||
#include <Client/AxScript/AxScriptManager.h>
|
||||
|
||||
BridgeEvent::BridgeEvent(AxScriptEngine* scriptEngine, QObject* parent) : QObject(parent), scriptEngine(scriptEngine) {}
|
||||
|
||||
BridgeEvent::~BridgeEvent() {}
|
||||
|
||||
void BridgeEvent::reg(const QString &event, const QString &type, const QJSValue &handler, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners, const QString &event_id)
|
||||
{
|
||||
if (!handler.isCallable()) {
|
||||
emit scriptError( type + " -> handler in not Callable");
|
||||
return;
|
||||
}
|
||||
|
||||
QSet<QString> list_agents;
|
||||
QSet<QString> list_os;
|
||||
QSet<QString> list_listeners;
|
||||
|
||||
if (agents.isUndefined() || agents.isNull() || !agents.isArray() || agents.property("length").toInt() == 0) {
|
||||
emit scriptError(type + " -> agents in undefined");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < agents.property("length").toInt(); ++i) {
|
||||
QJSValue val = agents.property(i);
|
||||
list_agents.insert(val.toString());
|
||||
}
|
||||
|
||||
if (!os.isUndefined() && !os.isNull() && os.isArray()) {
|
||||
for (int i = 0; i < os.property("length").toInt(); ++i) {
|
||||
QJSValue val = os.property(i);
|
||||
list_os << val.toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (!listeners.isUndefined() && !listeners.isNull() && listeners.isArray()) {
|
||||
for (int i = 0; i < listeners.property("length").toInt(); ++i) {
|
||||
QJSValue val = listeners.property(i);
|
||||
list_listeners << val.toString();
|
||||
}
|
||||
}
|
||||
|
||||
this->scriptEngine->registerEvent(event, handler, list_agents, list_os, list_listeners, event_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BridgeEvent::on_filebrowser_disks(const QJSValue &handler, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners, const QString &event_id) {
|
||||
this->reg("FileBroserDisks", "on_filebrowser_disks", handler, agents, os, listeners, event_id);
|
||||
}
|
||||
|
||||
void BridgeEvent::on_filebrowser_list(const QJSValue &handler, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners, const QString &event_id) {
|
||||
this->reg("FileBroserList", "on_filebrowser_list", handler, agents, os, listeners, event_id);
|
||||
}
|
||||
|
||||
void BridgeEvent::on_filebrowser_upload(const QJSValue &handler, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners, const QString &event_id) {
|
||||
this->reg("FileBroserUpload", "on_filebrowser_upload", handler, agents, os, listeners, event_id);
|
||||
}
|
||||
|
||||
void BridgeEvent::on_processbrowser_list(const QJSValue &handler, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners, const QString &event_id) {
|
||||
this->reg("ProcessBrowserList", "on_processbrowser_list", handler, agents, os, listeners, event_id);
|
||||
}
|
||||
|
||||
void BridgeEvent::remove(const QString &event_id) { this->scriptEngine->manager()->RemoveEvent(event_id); }
|
||||
@@ -0,0 +1,290 @@
|
||||
#include <Client/AxScript/BridgeForm.h>
|
||||
#include <Client/AxScript/AxElementWrappers.h>
|
||||
#include <Client/AxScript/AxScriptEngine.h>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaMethod>
|
||||
#include <QJsonDocument>
|
||||
|
||||
BridgeForm::BridgeForm(AxScriptEngine* scriptEngine, QObject* parent) : QObject(parent), scriptEngine(scriptEngine), widget(new QWidget()) {}
|
||||
|
||||
BridgeForm::~BridgeForm() { delete widget; }
|
||||
|
||||
void BridgeForm::connect(QObject* sender, const QString& signalName, const QJSValue& handler)
|
||||
{
|
||||
if (!sender || !handler.isCallable()) {
|
||||
emit scriptError("connect -> Invalid sender or handler");
|
||||
return;
|
||||
}
|
||||
|
||||
const QMetaObject* meta = sender->metaObject();
|
||||
for (int i = 0; i < meta->methodCount(); ++i) {
|
||||
QMetaMethod method = meta->method(i);
|
||||
if (method.methodType() != QMetaMethod::Signal)
|
||||
continue;
|
||||
|
||||
QString name = QString::fromLatin1(method.methodSignature());
|
||||
if (!name.startsWith(signalName))
|
||||
continue;
|
||||
|
||||
int paramCount = method.parameterCount();
|
||||
auto* proxy = new SignalProxy(scriptEngine->engine(), handler, sender);
|
||||
|
||||
bool connected = false;
|
||||
|
||||
if (paramCount == 0) {
|
||||
connected = QObject::connect(sender, method, proxy, proxy->metaObject()->method(proxy->metaObject()->indexOfSlot("call()")));
|
||||
}
|
||||
else if (paramCount == 1) {
|
||||
QByteArray typeName = method.parameterTypes().value(0);
|
||||
if (typeName == "QString")
|
||||
connected = QObject::connect(sender, method, proxy, proxy->metaObject()->method(proxy->metaObject()->indexOfSlot("callWithArg(QString)")));
|
||||
else if (typeName == "int")
|
||||
connected = QObject::connect(sender, method, proxy, proxy->metaObject()->method(proxy->metaObject()->indexOfSlot("callWithArg(int)")));
|
||||
else if (typeName == "bool")
|
||||
connected = QObject::connect(sender, method, proxy, proxy->metaObject()->method(proxy->metaObject()->indexOfSlot("callWithArg(bool)")));
|
||||
}
|
||||
else if (paramCount == 2) {
|
||||
QByteArray typeName1 = method.parameterTypes().value(0);
|
||||
QByteArray typeName2 = method.parameterTypes().value(1);
|
||||
if (typeName1 == "int" && typeName2 == "int")
|
||||
connected = QObject::connect(sender, method, proxy, proxy->metaObject()->method(proxy->metaObject()->indexOfSlot("callWithArgs(int,int)")));
|
||||
}
|
||||
else {
|
||||
emit scriptError("connect -> Signal " + signalName + " has too many parameters (not supported)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!connected)
|
||||
emit scriptError("connect -> Failed to connect signal " + method.methodSignature());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
emit scriptError("connect -> Signal " + signalName + " not found");
|
||||
}
|
||||
|
||||
/// Elements
|
||||
|
||||
QObject* BridgeForm::create_vlayout()
|
||||
{
|
||||
auto* wrapper = new AxBoxLayoutWrapper(QBoxLayout::TopToBottom, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_hlayout()
|
||||
{
|
||||
auto* wrapper = new AxBoxLayoutWrapper(QBoxLayout::LeftToRight, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_gridlayout()
|
||||
{
|
||||
auto* wrapper = new AxGridLayoutWrapper(this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_vline()
|
||||
{
|
||||
auto* wrapper = new AxLineWrapper(QFrame::VLine, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_hline()
|
||||
{
|
||||
auto* wrapper = new AxLineWrapper(QFrame::HLine, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_vspacer()
|
||||
{
|
||||
auto* wrapper = new AxSpacerWrapper(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_hspacer()
|
||||
{
|
||||
auto* wrapper = new AxSpacerWrapper(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_label(const QString& text)
|
||||
{
|
||||
auto* label = new QLabel(text, widget);
|
||||
auto* wrapper = new AxLabelWrapper(label, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_textline(const QString &text)
|
||||
{
|
||||
auto* edit = new QLineEdit(text, widget);
|
||||
auto* wrapper = new AxTextLineWrapper(edit, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_combo()
|
||||
{
|
||||
auto* combo = new QComboBox(widget);
|
||||
auto* wrapper = new AxComboBoxWrapper(combo, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_check(const QString& label)
|
||||
{
|
||||
auto* check = new QCheckBox(label, widget);
|
||||
auto* wrapper = new AxCheckBoxWrapper(check, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_spin()
|
||||
{
|
||||
auto* spin = new QSpinBox(widget);
|
||||
auto* wrapper = new AxSpinBoxWrapper(spin, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_dateline(const QString& format)
|
||||
{
|
||||
auto* date_widget = new QDateEdit(widget);
|
||||
auto* wrapper = new AxDateEditWrapper(date_widget, format, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_timeline(const QString& format)
|
||||
{
|
||||
auto* time_widget = new QTimeEdit(widget);
|
||||
auto* wrapper = new AxTimeEditWrapper(time_widget, format, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_button(const QString& text)
|
||||
{
|
||||
auto* btn = new QPushButton(text, widget);
|
||||
auto* wrapper = new AxButtonWrapper(btn, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_textmulti(const QString& text)
|
||||
{
|
||||
auto* textEdit = new QPlainTextEdit(text, widget);
|
||||
auto* wrapper = new AxTextMultiWrapper(textEdit, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_list()
|
||||
{
|
||||
auto* list = new QListWidget(widget);
|
||||
auto* wrapper = new AxListWidgetWrapper(list, scriptEngine->engine(), this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_table(const QJSValue &headers)
|
||||
{
|
||||
auto* table = new QTableWidget(widget);
|
||||
auto* wrapper = new AxTableWidgetWrapper(headers, table, scriptEngine->engine(), this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_selector_file()
|
||||
{
|
||||
auto fileSelector = new FileSelector(widget);
|
||||
auto* wrapper = new AxSelectorFile(fileSelector, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_tabs()
|
||||
{
|
||||
auto* tabWidget = new QTabWidget(widget);
|
||||
auto* wrapper = new AxTabWrapper(tabWidget, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_groupbox(const QString &title, const bool checkable)
|
||||
{
|
||||
auto* box = new QGroupBox(title, widget);
|
||||
auto* wrapper = new AxGroupBoxWrapper(checkable, box, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_hsplitter()
|
||||
{
|
||||
auto* splitter = new QSplitter(Qt::Horizontal, widget);
|
||||
auto* wrapper = new AxSplitterWrapper(splitter, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_vsplitter()
|
||||
{
|
||||
auto* splitter = new QSplitter(Qt::Vertical, widget);
|
||||
auto* wrapper = new AxSplitterWrapper(splitter, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_scrollarea()
|
||||
{
|
||||
auto* area = new QScrollArea(widget);
|
||||
auto* wrapper = new AxScrollAreaWrapper(area, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_panel()
|
||||
{
|
||||
auto* panel = new QWidget(widget);
|
||||
auto* wrapper = new AxPanelWrapper(panel, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_stack()
|
||||
{
|
||||
auto* stack = new QStackedWidget(widget);
|
||||
auto* wrapper = new AxStackedWidgetWrapper(stack, this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_container()
|
||||
{
|
||||
auto* wrapper = new AxContainerWrapper(scriptEngine->engine(), this);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_dialog(const QString& title) const
|
||||
{
|
||||
auto* wrapper = new AxDialogWrapper(title, widget);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
QObject* BridgeForm::create_selector_credentials(const QJSValue &headers) const
|
||||
{
|
||||
auto* table = new QTableWidget(widget);
|
||||
auto* button = new QPushButton(widget);
|
||||
auto* wrapper = new AxSelectorCreds(headers, table, button, scriptEngine, widget);
|
||||
scriptEngine->registerObject(wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
#include <Client/AxScript/BridgeMenu.h>
|
||||
#include <Client/AxScript/AxScriptEngine.h>
|
||||
#include <Client/AxScript/AxElementWrappers.h>
|
||||
|
||||
BridgeMenu::BridgeMenu(AxScriptEngine* scriptEngine, QObject* parent) : QObject(parent), scriptEngine(scriptEngine), widget(new QWidget()) {}
|
||||
|
||||
BridgeMenu::~BridgeMenu() { delete widget; }
|
||||
|
||||
void BridgeMenu::reg(const QString &type, AbstractAxMenuItem *item, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners)
|
||||
{
|
||||
QSet<QString> list_agents;
|
||||
QSet<QString> list_os;
|
||||
QSet<QString> list_listeners;
|
||||
|
||||
if (agents.isUndefined() || agents.isNull() || !agents.isArray() || agents.property("length").toInt() == 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < agents.property("length").toInt(); ++i) {
|
||||
QJSValue val = agents.property(i);
|
||||
list_agents.insert(val.toString());
|
||||
}
|
||||
|
||||
if (!os.isUndefined() && !os.isNull() && os.isArray()) {
|
||||
for (int i = 0; i < os.property("length").toInt(); ++i) {
|
||||
QJSValue val = os.property(i);
|
||||
list_os << val.toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (!listeners.isUndefined() && !listeners.isNull() && listeners.isArray()) {
|
||||
for (int i = 0; i < listeners.property("length").toInt(); ++i) {
|
||||
QJSValue val = listeners.property(i);
|
||||
list_listeners << val.toString();
|
||||
}
|
||||
}
|
||||
|
||||
this->scriptEngine->registerMenu(type, item, list_agents, list_os, list_listeners);
|
||||
}
|
||||
|
||||
QList<AbstractAxMenuItem*> BridgeMenu::items() const { return menuItems; }
|
||||
|
||||
void BridgeMenu::clear()
|
||||
{
|
||||
qDeleteAll(menuItems);
|
||||
menuItems.clear();
|
||||
}
|
||||
|
||||
AxActionWrapper* BridgeMenu::create_action(const QString& text, const QJSValue& handler)
|
||||
{
|
||||
auto* action = new AxActionWrapper(text, handler, scriptEngine->engine(), this);
|
||||
menuItems.append(action);
|
||||
return action;
|
||||
}
|
||||
|
||||
AxSeparatorWrapper* BridgeMenu::create_separator()
|
||||
{
|
||||
auto* sep = new AxSeparatorWrapper(this);
|
||||
menuItems.append(sep);
|
||||
return sep;
|
||||
}
|
||||
|
||||
AxMenuWrapper* BridgeMenu::create_menu(const QString& title)
|
||||
{
|
||||
auto* menu = new AxMenuWrapper(title, this);
|
||||
menuItems.append(menu);
|
||||
return menu;
|
||||
}
|
||||
|
||||
void BridgeMenu::add_session_main(AbstractAxMenuItem *item, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners) {
|
||||
this->reg("SessionMain", item, agents, os, listeners);
|
||||
}
|
||||
|
||||
void BridgeMenu::add_session_agent(AbstractAxMenuItem *item, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners) {
|
||||
this->reg("SessionAgent", item, agents, os, listeners);
|
||||
}
|
||||
|
||||
void BridgeMenu::add_session_browser(AbstractAxMenuItem* item, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners){
|
||||
this->reg("SessionBrowser", item, agents, os, listeners);
|
||||
}
|
||||
|
||||
void BridgeMenu::add_session_access(AbstractAxMenuItem* item, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners){
|
||||
this->reg("SessionAccess", item, agents, os, listeners);
|
||||
}
|
||||
|
||||
void BridgeMenu::add_filebrowser(AbstractAxMenuItem *item, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners){
|
||||
this->reg("FileBrowser", item, agents, os, listeners);
|
||||
}
|
||||
|
||||
void BridgeMenu::add_processbrowser(AbstractAxMenuItem *item, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners) {
|
||||
this->reg("ProcessBrowser", item, agents, os, listeners);
|
||||
}
|
||||
|
||||
void BridgeMenu::add_downloads_running(AbstractAxMenuItem *item, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners){
|
||||
this->reg("DownloadRunning", item, agents, os, listeners);
|
||||
}
|
||||
|
||||
void BridgeMenu::add_downloads_finished(AbstractAxMenuItem *item, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners){
|
||||
this->reg("DownloadFinished", item, agents, os, listeners);
|
||||
}
|
||||
|
||||
void BridgeMenu::add_tasks(AbstractAxMenuItem *item, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners){
|
||||
this->reg("Tasks", item, agents, os, listeners);
|
||||
}
|
||||
|
||||
void BridgeMenu::add_tasks_job(AbstractAxMenuItem *item, const QJSValue &agents, const QJSValue &os, const QJSValue &listeners) {
|
||||
this->reg("TasksJob", item, agents, os, listeners);
|
||||
}
|
||||
@@ -8,7 +8,6 @@ Extender::Extender(MainAdaptix* m)
|
||||
{
|
||||
mainAdaptix = m;
|
||||
dialogExtender = new DialogExtender(this);
|
||||
|
||||
this->LoadFromDB();
|
||||
}
|
||||
|
||||
@@ -17,147 +16,67 @@ Extender::~Extender() = default;
|
||||
void Extender::LoadFromDB()
|
||||
{
|
||||
auto list = mainAdaptix->storage->ListExtensions();
|
||||
for(int i=0; i < list.size(); i++)
|
||||
this->LoadFromFile( list[i].FilePath, list[i].Enabled );
|
||||
for(auto ext : list) {
|
||||
|
||||
QFile file(ext.FilePath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
ext.Enabled = false;
|
||||
ext.Message = "Cannot open file.";
|
||||
}
|
||||
ext.Code = QTextStream(&file).readAll();
|
||||
file.close();
|
||||
|
||||
extenderFiles[ext.FilePath] = ext;
|
||||
dialogExtender->AddExtenderItem(extenderFiles[ext.FilePath]);
|
||||
}
|
||||
}
|
||||
|
||||
void Extender::LoadFromFile(QString path, bool enabled)
|
||||
void Extender::LoadFromFile(const QString &path, const bool enabled)
|
||||
{
|
||||
QString fileContent;
|
||||
QJsonObject rootObj;
|
||||
QJsonDocument jsonDocument;
|
||||
QJsonArray extensionsArray;
|
||||
QJsonArray agentsArray;
|
||||
QVector<QJsonObject> exConstants;
|
||||
QMap<QString, QVector<QJsonObject> > exCommands;
|
||||
|
||||
ExtensionFile extensionFile = {0};
|
||||
ExtensionFile extensionFile = {};
|
||||
extensionFile.FilePath = path;
|
||||
extensionFile.Enabled = enabled;
|
||||
|
||||
QFile file(path);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
extensionFile.Comment = "File not readed";
|
||||
extensionFile.Enabled = false;
|
||||
extensionFile.Valid = false;
|
||||
extensionFile.Message = "Cannot open file.";
|
||||
goto END;
|
||||
}
|
||||
fileContent = QString(file.readAll());
|
||||
extensionFile.Code = QTextStream(&file).readAll();
|
||||
file.close();
|
||||
|
||||
jsonDocument = QJsonDocument::fromJson(fileContent.toUtf8());
|
||||
if ( jsonDocument.isNull() || !jsonDocument.isObject()) {
|
||||
extensionFile.Comment = "Invalid JSON document!";
|
||||
extensionFile.Enabled = false;
|
||||
extensionFile.Valid = false;
|
||||
goto END;
|
||||
}
|
||||
|
||||
rootObj = jsonDocument.object();
|
||||
if( !rootObj.contains("name") && rootObj["name"].isString() ) {
|
||||
extensionFile.Comment = "JSON document must include a required 'name' parameter";
|
||||
extensionFile.Enabled = false;
|
||||
extensionFile.Valid = false;
|
||||
goto END;
|
||||
}
|
||||
|
||||
if( !rootObj.contains("extensions") && rootObj["extensions"].isArray() ) {
|
||||
extensionFile.Comment = "JSON document must include a required 'extensions' parameter";
|
||||
extensionFile.Enabled = false;
|
||||
extensionFile.Valid = false;
|
||||
goto END;
|
||||
}
|
||||
|
||||
extensionFile.Name = rootObj.value("name").toString();
|
||||
extensionFile.Description = rootObj.value("description").toString();
|
||||
|
||||
extensionsArray = rootObj.value("extensions").toArray();
|
||||
for (QJsonValue extensionValue : extensionsArray) {
|
||||
QJsonObject extJsonObject = extensionValue.toObject();
|
||||
|
||||
if( !extJsonObject.contains("type") && extJsonObject["type"].isString() ) {
|
||||
extensionFile.Comment = "Extension must include a required 'type' parameter";
|
||||
extensionFile.Enabled = false;
|
||||
extensionFile.Valid = false;
|
||||
goto END;
|
||||
}
|
||||
|
||||
QString type = extJsonObject.value("type").toString();
|
||||
if(type == "command") {
|
||||
QStringList agentsList;
|
||||
|
||||
if( !extJsonObject.contains("agents") && extJsonObject["agents"].isArray() ) {
|
||||
extensionFile.Comment = "Extension must include a required 'agents' parameter";
|
||||
extensionFile.Enabled = false;
|
||||
extensionFile.Valid = false;
|
||||
goto END;
|
||||
}
|
||||
|
||||
agentsArray = extJsonObject.value("agents").toArray();
|
||||
for (QJsonValue agentStr : agentsArray) {
|
||||
agentsList.push_back(agentStr.toString());
|
||||
}
|
||||
|
||||
bool result = true;
|
||||
QString msg = ValidExtCommand(extJsonObject, &result);
|
||||
if (!result) {
|
||||
extensionFile.Comment = msg;
|
||||
extensionFile.Enabled = false;
|
||||
extensionFile.Valid = false;
|
||||
goto END;
|
||||
}
|
||||
|
||||
for(QString key : agentsList) {
|
||||
exCommands[key].push_back(extJsonObject);
|
||||
}
|
||||
|
||||
} else if(type == "constant") {
|
||||
bool result = true;
|
||||
QString msg = ValidExtConstant(extJsonObject, &result);
|
||||
if (!result) {
|
||||
extensionFile.Comment = msg;
|
||||
extensionFile.Enabled = false;
|
||||
extensionFile.Valid = false;
|
||||
goto END;
|
||||
}
|
||||
|
||||
exConstants.push_back(extJsonObject);
|
||||
|
||||
} else {
|
||||
extensionFile.Comment = "Unknown extension type";
|
||||
extensionFile.Enabled = false;
|
||||
extensionFile.Valid = false;
|
||||
goto END;
|
||||
}
|
||||
}
|
||||
|
||||
extensionFile.Comment = fileContent;
|
||||
extensionFile.ExConstants = exConstants;
|
||||
extensionFile.ExCommands = exCommands;
|
||||
extensionFile.Enabled = enabled;
|
||||
extensionFile.Valid = true;
|
||||
|
||||
END:
|
||||
this->SetExtension(extensionFile);
|
||||
}
|
||||
|
||||
void Extender::SetExtension(const ExtensionFile &extFile)
|
||||
void Extender::SetExtension(ExtensionFile extFile)
|
||||
{
|
||||
if(extenderFiles.contains(extFile.FilePath)) {
|
||||
if( extFile.Valid && extFile.Enabled ) {
|
||||
if(extFile.Enabled) {
|
||||
mainAdaptix->mainUI->RemoveExtension(extFile);
|
||||
mainAdaptix->mainUI->AddNewExtension(extFile);
|
||||
bool success = mainAdaptix->mainUI->AddNewExtension(&extFile);
|
||||
if (!success) {
|
||||
mainAdaptix->mainUI->RemoveExtension(extFile);
|
||||
}
|
||||
}
|
||||
dialogExtender->UpdateExtenderItem(extFile);
|
||||
mainAdaptix->storage->UpdateExtension(extFile);
|
||||
}
|
||||
else {
|
||||
extenderFiles[extFile.FilePath] = extFile;
|
||||
if( extFile.Valid && extFile.Enabled )
|
||||
mainAdaptix->mainUI->AddNewExtension(extFile);
|
||||
if( extFile.Enabled ) {
|
||||
bool success = mainAdaptix->mainUI->AddNewExtension(&extFile);
|
||||
if (!success) {
|
||||
mainAdaptix->mainUI->RemoveExtension(extFile);
|
||||
}
|
||||
}
|
||||
|
||||
dialogExtender->AddExtenderItem(extFile);
|
||||
if( !mainAdaptix->storage->ExistsExtension(extFile.FilePath))
|
||||
mainAdaptix->storage->AddExtension(extFile);
|
||||
if (!extFile.NoSave) {
|
||||
extenderFiles[extFile.FilePath] = extFile;
|
||||
dialogExtender->AddExtenderItem(extFile);
|
||||
if( !mainAdaptix->storage->ExistsExtension(extFile.FilePath))
|
||||
mainAdaptix->storage->AddExtension(extFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,9 +85,13 @@ void Extender::EnableExtension(const QString &path)
|
||||
if( !extenderFiles.contains(path) )
|
||||
return;
|
||||
|
||||
if( extenderFiles[path].Valid && !extenderFiles[path].Enabled ) {
|
||||
if( !extenderFiles[path].Enabled && extenderFiles[path].Message.isEmpty()) {
|
||||
extenderFiles[path].Enabled = true;
|
||||
mainAdaptix->mainUI->AddNewExtension(extenderFiles[path]);
|
||||
bool success = mainAdaptix->mainUI->AddNewExtension(&(extenderFiles[path]));
|
||||
if (!success) {
|
||||
mainAdaptix->mainUI->RemoveExtension(extenderFiles[path]);
|
||||
}
|
||||
|
||||
dialogExtender->UpdateExtenderItem(extenderFiles[path]);
|
||||
mainAdaptix->storage->UpdateExtension(extenderFiles[path]);
|
||||
}
|
||||
@@ -179,7 +102,7 @@ void Extender::DisableExtension(const QString &path)
|
||||
if( !extenderFiles.contains(path) )
|
||||
return;
|
||||
|
||||
if( extenderFiles[path].Valid && extenderFiles[path].Enabled ) {
|
||||
if( extenderFiles[path].Enabled ) {
|
||||
extenderFiles[path].Enabled = false;
|
||||
mainAdaptix->mainUI->RemoveExtension(extenderFiles[path]);
|
||||
dialogExtender->UpdateExtenderItem(extenderFiles[path]);
|
||||
@@ -197,4 +120,22 @@ void Extender::RemoveExtension(const QString &path)
|
||||
mainAdaptix->storage->RemoveExtension(path);
|
||||
|
||||
extenderFiles.remove(path);
|
||||
}
|
||||
}
|
||||
|
||||
void Extender::syncedOnReload(const QString &project)
|
||||
{
|
||||
for (auto path : extenderFiles.keys()) {
|
||||
if(extenderFiles[path].Enabled) {
|
||||
bool success = mainAdaptix->mainUI->SyncExtension(project, &(extenderFiles[path]));
|
||||
if (!success) {
|
||||
mainAdaptix->mainUI->RemoveExtension(extenderFiles[path]);
|
||||
}
|
||||
}
|
||||
dialogExtender->UpdateExtenderItem(extenderFiles[path]);
|
||||
mainAdaptix->storage->UpdateExtension(extenderFiles[path]);
|
||||
}
|
||||
}
|
||||
|
||||
void Extender::loadGlobalScript(const QString &path) { this->LoadFromFile(path, true); }
|
||||
|
||||
void Extender::unloadGlobalScript(const QString &path) { this->RemoveExtension(path); }
|
||||
|
||||
@@ -13,9 +13,11 @@
|
||||
#include <UI/Widgets/DownloadsWidget.h>
|
||||
#include <UI/Widgets/ScreenshotsWidget.h>
|
||||
#include <UI/Widgets/TunnelsWidget.h>
|
||||
#include <UI/Widgets/CredentialsWidget.h>
|
||||
#include <UI/Graph/SessionsGraph.h>
|
||||
#include <UI/Dialogs/DialogSyncPacket.h>
|
||||
|
||||
|
||||
bool AdaptixWidget::isValidSyncPacket(QJsonObject jsonObj)
|
||||
{
|
||||
if ( !jsonObj.contains("type") || !jsonObj["type"].isDouble() )
|
||||
@@ -24,7 +26,8 @@ bool AdaptixWidget::isValidSyncPacket(QJsonObject jsonObj)
|
||||
int spType = jsonObj["type"].toDouble();
|
||||
|
||||
if( spType == TYPE_SYNC_START ) {
|
||||
if ( !jsonObj.contains("count") || !jsonObj["count"].isDouble() ) return false;
|
||||
if ( !jsonObj.contains("count") || !jsonObj["count"].isDouble() ) return false;
|
||||
if ( !jsonObj.contains("interfaces") || !jsonObj["interfaces"].isArray() ) return false;
|
||||
return true;
|
||||
}
|
||||
if( spType == TYPE_SYNC_FINISH ) {
|
||||
@@ -40,7 +43,7 @@ bool AdaptixWidget::isValidSyncPacket(QJsonObject jsonObj)
|
||||
|
||||
if( spType == TYPE_LISTENER_REG ) {
|
||||
if ( !jsonObj.contains("fn") || !jsonObj["fn"].isString() ) return false;
|
||||
if ( !jsonObj.contains("ui") || !jsonObj["ui"].isString() ) return false;
|
||||
if ( !jsonObj.contains("ax") || !jsonObj["ax"].isString() ) return false;
|
||||
return true;
|
||||
}
|
||||
if( spType == TYPE_LISTENER_START || spType == TYPE_LISTENER_EDIT ) {
|
||||
@@ -59,10 +62,9 @@ bool AdaptixWidget::isValidSyncPacket(QJsonObject jsonObj)
|
||||
}
|
||||
|
||||
if( spType == TYPE_AGENT_REG ) {
|
||||
if ( !jsonObj.contains("agent") || !jsonObj["agent"].isString() ) return false;
|
||||
if ( !jsonObj.contains("watermark") || !jsonObj["watermark"].isString() ) return false;
|
||||
if ( !jsonObj.contains("listeners_json") || !jsonObj["listeners_json"].isString() ) return false;
|
||||
if ( !jsonObj.contains("handlers_json") || !jsonObj["handlers_json"].isString() ) return false;
|
||||
if ( !jsonObj.contains("agent") || !jsonObj["agent"].isString() ) return false;
|
||||
if ( !jsonObj.contains("ax") || !jsonObj["ax"].isString() ) return false;
|
||||
if ( !jsonObj.contains("listeners") || !jsonObj["listeners"].isArray() ) return false;
|
||||
return true;
|
||||
}
|
||||
if( spType == TYPE_AGENT_NEW ) {
|
||||
@@ -142,10 +144,21 @@ bool AdaptixWidget::isValidSyncPacket(QJsonObject jsonObj)
|
||||
if (!jsonObj.contains("a_task_id") || !jsonObj["a_task_id"].isArray()) return false;
|
||||
return true;
|
||||
}
|
||||
if( spType == TYPE_AGENT_TASK_REMOVE ) {
|
||||
if ( spType == TYPE_AGENT_TASK_REMOVE ) {
|
||||
if (!jsonObj.contains("a_task_id") || !jsonObj["a_task_id"].isString()) return false;
|
||||
return true;
|
||||
}
|
||||
if ( spType == TYPE_AGENT_TASK_HOOK ) {
|
||||
if (!jsonObj.contains("a_id") || !jsonObj["a_id"].isString()) return false;
|
||||
if (!jsonObj.contains("a_task_id") || !jsonObj["a_task_id"].isString()) return false;
|
||||
if (!jsonObj.contains("a_hook_id") || !jsonObj["a_hook_id"].isString()) return false;
|
||||
if (!jsonObj.contains("a_job_index") || !jsonObj["a_job_index"].isDouble()) return false;
|
||||
if (!jsonObj.contains("a_msg_type") || !jsonObj["a_msg_type"].isDouble()) return false;
|
||||
if (!jsonObj.contains("a_message") || !jsonObj["a_message"].isString()) return false;
|
||||
if (!jsonObj.contains("a_text") || !jsonObj["a_text"].isString()) return false;
|
||||
if (!jsonObj.contains("a_completed") || !jsonObj["a_completed"].isBool()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if( spType == TYPE_AGENT_CONSOLE_OUT) {
|
||||
if (!jsonObj.contains("time") || !jsonObj["time"].isDouble()) return false;
|
||||
@@ -245,6 +258,35 @@ bool AdaptixWidget::isValidSyncPacket(QJsonObject jsonObj)
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( spType == TYPE_CREDS_CREATE ) {
|
||||
if (!jsonObj.contains("c_creds_id") || !jsonObj["c_creds_id"].isString()) return false;
|
||||
if (!jsonObj.contains("c_username") || !jsonObj["c_username"].isString()) return false;
|
||||
if (!jsonObj.contains("c_password") || !jsonObj["c_password"].isString()) return false;
|
||||
if (!jsonObj.contains("c_realm") || !jsonObj["c_realm"].isString()) return false;
|
||||
if (!jsonObj.contains("c_type") || !jsonObj["c_type"].isString()) return false;
|
||||
if (!jsonObj.contains("c_tag") || !jsonObj["c_tag"].isString()) return false;
|
||||
if (!jsonObj.contains("c_date") || !jsonObj["c_date"].isDouble()) return false;
|
||||
if (!jsonObj.contains("c_storage") || !jsonObj["c_storage"].isString()) return false;
|
||||
if (!jsonObj.contains("c_agent_id") || !jsonObj["c_agent_id"].isString()) return false;
|
||||
if (!jsonObj.contains("c_host") || !jsonObj["c_host"].isString()) return false;
|
||||
return true;
|
||||
}
|
||||
if ( spType == TYPE_CREDS_EDIT ) {
|
||||
if (!jsonObj.contains("c_creds_id") || !jsonObj["c_creds_id"].isString()) return false;
|
||||
if (!jsonObj.contains("c_username") || !jsonObj["c_username"].isString()) return false;
|
||||
if (!jsonObj.contains("c_password") || !jsonObj["c_password"].isString()) return false;
|
||||
if (!jsonObj.contains("c_realm") || !jsonObj["c_realm"].isString()) return false;
|
||||
if (!jsonObj.contains("c_type") || !jsonObj["c_type"].isString()) return false;
|
||||
if (!jsonObj.contains("c_tag") || !jsonObj["c_tag"].isString()) return false;
|
||||
if (!jsonObj.contains("c_storage") || !jsonObj["c_storage"].isString()) return false;
|
||||
if (!jsonObj.contains("c_host") || !jsonObj["c_host"].isString()) return false;
|
||||
return true;
|
||||
}
|
||||
if ( spType == TYPE_CREDS_DELETE ) {
|
||||
if (!jsonObj.contains("c_creds_id") || !jsonObj["c_creds_id"].isString()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if( spType == TYPE_BROWSER_DISKS ) {
|
||||
if (!jsonObj.contains("b_agent_id") || !jsonObj["b_agent_id"].isString()) return false;
|
||||
if (!jsonObj.contains("b_time") || !jsonObj["b_time"].isDouble()) return false;
|
||||
@@ -304,6 +346,13 @@ void AdaptixWidget::processSyncPacket(QJsonObject jsonObj)
|
||||
if( spType == TYPE_SYNC_START )
|
||||
{
|
||||
int count = jsonObj["count"].toDouble();
|
||||
QJsonArray interfaces = jsonObj["interfaces"].toArray();
|
||||
|
||||
for (QJsonValue addrValue : interfaces) {
|
||||
QString addr = addrValue.toString();
|
||||
this->addresses.append(addr);
|
||||
}
|
||||
|
||||
dialogSyncPacket->init(count);
|
||||
this->sync = true;
|
||||
this->setEnabled(false);
|
||||
@@ -325,13 +374,13 @@ void AdaptixWidget::processSyncPacket(QJsonObject jsonObj)
|
||||
if( spType == TYPE_LISTENER_START )
|
||||
{
|
||||
ListenerData newListener = {};
|
||||
newListener.ListenerName = jsonObj["l_name"].toString();
|
||||
newListener.ListenerType = jsonObj["l_type"].toString();
|
||||
newListener.BindHost = jsonObj["l_bind_host"].toString();
|
||||
newListener.BindPort = jsonObj["l_bind_port"].toString();
|
||||
newListener.AgentAddresses = jsonObj["l_agent_addr"].toString();
|
||||
newListener.Status = jsonObj["l_status"].toString();
|
||||
newListener.Data = jsonObj["l_data"].toString();
|
||||
newListener.ListenerName = jsonObj["l_name"].toString();
|
||||
newListener.ListenerFullName = jsonObj["l_type"].toString();
|
||||
newListener.BindHost = jsonObj["l_bind_host"].toString();
|
||||
newListener.BindPort = jsonObj["l_bind_port"].toString();
|
||||
newListener.AgentAddresses = jsonObj["l_agent_addr"].toString();
|
||||
newListener.Status = jsonObj["l_status"].toString();
|
||||
newListener.Data = jsonObj["l_data"].toString();
|
||||
|
||||
ListenersTab->AddListenerItem(newListener);
|
||||
return;
|
||||
@@ -339,13 +388,13 @@ void AdaptixWidget::processSyncPacket(QJsonObject jsonObj)
|
||||
if( spType == TYPE_LISTENER_EDIT )
|
||||
{
|
||||
ListenerData newListener = {};
|
||||
newListener.ListenerName = jsonObj["l_name"].toString();
|
||||
newListener.ListenerType = jsonObj["l_type"].toString();
|
||||
newListener.BindHost = jsonObj["l_bind_host"].toString();
|
||||
newListener.BindPort = jsonObj["l_bind_port"].toString();
|
||||
newListener.AgentAddresses = jsonObj["l_agent_addr"].toString();
|
||||
newListener.Status = jsonObj["l_status"].toString();
|
||||
newListener.Data = jsonObj["l_data"].toString();
|
||||
newListener.ListenerName = jsonObj["l_name"].toString();
|
||||
newListener.ListenerFullName = jsonObj["l_type"].toString();
|
||||
newListener.BindHost = jsonObj["l_bind_host"].toString();
|
||||
newListener.BindPort = jsonObj["l_bind_port"].toString();
|
||||
newListener.AgentAddresses = jsonObj["l_agent_addr"].toString();
|
||||
newListener.Status = jsonObj["l_status"].toString();
|
||||
newListener.Data = jsonObj["l_data"].toString();
|
||||
|
||||
ListenersTab->EditListenerItem(newListener);
|
||||
return;
|
||||
@@ -433,6 +482,7 @@ void AdaptixWidget::processSyncPacket(QJsonObject jsonObj)
|
||||
QString id = idValue.toString();
|
||||
if (TasksMap.contains(id)) {
|
||||
Task* task = TasksMap[id];
|
||||
task->data.Status = "Running";
|
||||
task->item_Result->setText("Running");
|
||||
}
|
||||
}
|
||||
@@ -444,6 +494,10 @@ void AdaptixWidget::processSyncPacket(QJsonObject jsonObj)
|
||||
TasksTab->RemoveTaskItem(TaskId);
|
||||
return;
|
||||
}
|
||||
if ( spType == TYPE_AGENT_TASK_HOOK )
|
||||
{
|
||||
this->PostHookProcess(jsonObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -569,6 +623,46 @@ void AdaptixWidget::processSyncPacket(QJsonObject jsonObj)
|
||||
|
||||
|
||||
|
||||
if ( spType == TYPE_CREDS_CREATE )
|
||||
{
|
||||
CredentialData newCredential = {};
|
||||
newCredential.CredId = jsonObj["c_creds_id"].toString();
|
||||
newCredential.Username = jsonObj["c_username"].toString();
|
||||
newCredential.Password = jsonObj["c_password"].toString();
|
||||
newCredential.Realm = jsonObj["c_realm"].toString();
|
||||
newCredential.Type = jsonObj["c_type"].toString();
|
||||
newCredential.Tag = jsonObj["c_tag"].toString();
|
||||
newCredential.Storage = jsonObj["c_storage"].toString();
|
||||
newCredential.AgentId = jsonObj["c_agent_id"].toString();
|
||||
newCredential.Host = jsonObj["c_host"].toString();
|
||||
newCredential.Date = UnixTimestampGlobalToStringLocal(static_cast<qint64>(jsonObj["c_date"].toDouble()));
|
||||
|
||||
CredentialsTab->AddCredentialsItem(newCredential);
|
||||
return;
|
||||
}
|
||||
if ( spType == TYPE_CREDS_EDIT ) {
|
||||
CredentialData newCredential = {};
|
||||
newCredential.CredId = jsonObj["c_creds_id"].toString();
|
||||
newCredential.Username = jsonObj["c_username"].toString();
|
||||
newCredential.Password = jsonObj["c_password"].toString();
|
||||
newCredential.Realm = jsonObj["c_realm"].toString();
|
||||
newCredential.Type = jsonObj["c_type"].toString();
|
||||
newCredential.Tag = jsonObj["c_tag"].toString();
|
||||
newCredential.Storage = jsonObj["c_storage"].toString();
|
||||
newCredential.Host = jsonObj["c_host"].toString();
|
||||
|
||||
CredentialsTab->EditCredentialsItem(newCredential);
|
||||
return;
|
||||
}
|
||||
if ( spType == TYPE_CREDS_DELETE ) {
|
||||
QString credId = jsonObj["c_creds_id"].toString();
|
||||
|
||||
CredentialsTab->RemoveCredentialsItem(credId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( spType == TYPE_TUNNEL_CREATE )
|
||||
{
|
||||
TunnelData newTunnel = {0};
|
||||
@@ -616,7 +710,7 @@ void AdaptixWidget::processSyncPacket(QJsonObject jsonObj)
|
||||
|
||||
if (AgentsMap.contains(agentId) ) {
|
||||
auto agent = AgentsMap[agentId];
|
||||
if (agent && agent->browsers.FileBrowser && agent->FileBrowser)
|
||||
if (agent && agent->FileBrowser)
|
||||
agent->FileBrowser->SetDisksWin(time, msgType, message, data);
|
||||
}
|
||||
return;
|
||||
@@ -632,7 +726,7 @@ void AdaptixWidget::processSyncPacket(QJsonObject jsonObj)
|
||||
|
||||
if (AgentsMap.contains(agentId) ) {
|
||||
auto agent = AgentsMap[agentId];
|
||||
if (agent && agent->browsers.FileBrowser && agent->FileBrowser)
|
||||
if (agent && agent->FileBrowser)
|
||||
agent->FileBrowser->AddFiles(time, msgType, message, path, data);
|
||||
}
|
||||
return;
|
||||
@@ -647,7 +741,7 @@ void AdaptixWidget::processSyncPacket(QJsonObject jsonObj)
|
||||
|
||||
if (AgentsMap.contains(agentId)) {
|
||||
auto agent = AgentsMap[agentId];
|
||||
if (agent && agent->browsers.ProcessBrowser && agent->ProcessBrowser) {
|
||||
if (agent && agent->ProcessBrowser) {
|
||||
agent->ProcessBrowser->SetStatus(time, msgType, message);
|
||||
agent->ProcessBrowser->SetProcess(msgType, data);
|
||||
}
|
||||
@@ -663,7 +757,7 @@ void AdaptixWidget::processSyncPacket(QJsonObject jsonObj)
|
||||
|
||||
if (AgentsMap.contains(agentId) ) {
|
||||
auto agent = AgentsMap[agentId];
|
||||
if (agent && agent->browsers.FileBrowser && agent->FileBrowser)
|
||||
if (agent && agent->FileBrowser)
|
||||
agent->FileBrowser->SetStatus(time, msgType, message);
|
||||
}
|
||||
return;
|
||||
@@ -730,19 +824,22 @@ void AdaptixWidget::processSyncPacket(QJsonObject jsonObj)
|
||||
if( spType == TYPE_LISTENER_REG )
|
||||
{
|
||||
QString fn = jsonObj["fn"].toString();
|
||||
QString ui = jsonObj["ui"].toString();
|
||||
QString ax = jsonObj["ax"].toString();
|
||||
|
||||
this->RegisterListenerConfig(fn, ui);
|
||||
this->RegisterListenerConfig(fn, ax);
|
||||
return;
|
||||
}
|
||||
if( spType == TYPE_AGENT_REG )
|
||||
{
|
||||
QString agentName = jsonObj["agent"].toString();
|
||||
QString agentwatermark = jsonObj["watermark"].toString();
|
||||
QString listenersJson = jsonObj["listeners_json"].toString();
|
||||
QString handlersJson = jsonObj["handlers_json"].toString();
|
||||
QString agentName = jsonObj["agent"].toString();
|
||||
QString ax_script = jsonObj["ax"].toString();
|
||||
QJsonArray listenersArray = jsonObj["listeners"].toArray();
|
||||
|
||||
this->RegisterAgentConfig(agentName, agentwatermark, handlersJson, listenersJson);
|
||||
QStringList listeners;
|
||||
for (QJsonValue listener : listenersArray)
|
||||
listeners.append(listener.toString());
|
||||
|
||||
this->RegisterAgentConfig(agentName, ax_script, listeners);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ bool HttpReqGetOTP(const QString &type, const QString &objectId, AuthProfile pro
|
||||
return false;
|
||||
}
|
||||
|
||||
/// LISTENER
|
||||
///LISTENER
|
||||
|
||||
bool HttpReqListenerStart(const QString &listenerName, const QString &configType, const QString &configData, AuthProfile profile, QString* message, bool* ok )
|
||||
{
|
||||
@@ -155,7 +155,7 @@ bool HttpReqListenerStop(const QString &listenerName, const QString &listenerTyp
|
||||
return false;
|
||||
}
|
||||
|
||||
/// AGENT
|
||||
///AGENT
|
||||
|
||||
QJsonObject HttpReqTimeout( int timeout, const QString &sUrl, const QByteArray &jsonData, const QString &token )
|
||||
{
|
||||
@@ -199,14 +199,13 @@ QJsonObject HttpReqTimeout( int timeout, const QString &sUrl, const QByteArray &
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
bool HttpReqAgentGenerate(const QString &listenerName, const QString &listenerType, const QString &agentName, const QString &os, const QString &configData, AuthProfile profile, QString* message, bool* ok )
|
||||
bool HttpReqAgentGenerate(const QString &listenerName, const QString &listenerType, const QString &agentName, const QString &configData, AuthProfile profile, QString* message, bool* ok )
|
||||
{
|
||||
QJsonObject dataJson;
|
||||
dataJson["listener_name"] = listenerName;
|
||||
dataJson["listener_type"] = listenerType;
|
||||
dataJson["agent"] = agentName;
|
||||
dataJson["operating_system"] = os;
|
||||
dataJson["config"] = configData;
|
||||
dataJson["listener_name"] = listenerName;
|
||||
dataJson["listener_type"] = listenerType;
|
||||
dataJson["agent"] = agentName;
|
||||
dataJson["config"] = configData;
|
||||
QByteArray jsonData = QJsonDocument(dataJson).toJson();
|
||||
|
||||
QString sUrl = profile.GetURL() + "/agent/generate";
|
||||
@@ -219,15 +218,8 @@ bool HttpReqAgentGenerate(const QString &listenerName, const QString &listenerTy
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HttpReqAgentCommand(const QString &agentName, const QString &agentId, const QString &cmdLine, const QString &data, AuthProfile profile, QString* message, bool* ok )
|
||||
bool HttpReqAgentCommand(const QByteArray &jsonData, AuthProfile profile, QString* message, bool* ok )
|
||||
{
|
||||
QJsonObject dataJson;
|
||||
dataJson["name"] = agentName;
|
||||
dataJson["id"] = agentId;
|
||||
dataJson["cmdline"] = cmdLine;
|
||||
dataJson["data"] = data;
|
||||
QByteArray jsonData = QJsonDocument(dataJson).toJson();
|
||||
|
||||
QString sUrl = profile.GetURL() + "/agent/command/execute";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
@@ -238,26 +230,6 @@ bool HttpReqAgentCommand(const QString &agentName, const QString &agentId, const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HttpReqAgentExit( QStringList agentsId, AuthProfile profile, QString* message, bool* ok )
|
||||
{
|
||||
QJsonArray arrayId;
|
||||
for (QString item : agentsId)
|
||||
arrayId.append(item);
|
||||
|
||||
QJsonObject dataJson;
|
||||
dataJson["agent_id_array"] = arrayId;
|
||||
QByteArray jsonData = QJsonDocument(dataJson).toJson();
|
||||
|
||||
QString sUrl = profile.GetURL() + "/agent/exit";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
*message = jsonObject["message"].toString();
|
||||
*ok = jsonObject["ok"].toBool();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HttpReqConsoleRemove( QStringList agentsId, AuthProfile profile, QString* message, bool* ok )
|
||||
{
|
||||
QJsonArray arrayId;
|
||||
@@ -309,7 +281,7 @@ bool HttpReqAgentSetTag( QStringList agentsId, const QString &tag, AuthProfile p
|
||||
dataJson["tag"] = tag;
|
||||
QByteArray jsonData = QJsonDocument(dataJson).toJson();
|
||||
|
||||
QString sUrl = profile.GetURL() + "/agent/settag";
|
||||
QString sUrl = profile.GetURL() + "/agent/set/tag";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
*message = jsonObject["message"].toString();
|
||||
@@ -330,7 +302,7 @@ bool HttpReqAgentSetMark( QStringList agentsId, const QString &mark, AuthProfile
|
||||
dataJson["mark"] = mark;
|
||||
QByteArray jsonData = QJsonDocument(dataJson).toJson();
|
||||
|
||||
QString sUrl = profile.GetURL() + "/agent/setmark";
|
||||
QString sUrl = profile.GetURL() + "/agent/set/mark";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
*message = jsonObject["message"].toString();
|
||||
@@ -340,7 +312,7 @@ bool HttpReqAgentSetMark( QStringList agentsId, const QString &mark, AuthProfile
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HttpReqAgentSetColor( QStringList agentsId, const QString &background, const QString &foreground, bool reset, AuthProfile profile, QString* message, bool* ok )
|
||||
bool HttpReqAgentSetColor( QStringList agentsId, const QString &background, const QString &foreground, const bool reset, AuthProfile profile, QString* message, bool* ok )
|
||||
{
|
||||
QJsonArray arrayId;
|
||||
for (QString item : agentsId)
|
||||
@@ -353,7 +325,7 @@ bool HttpReqAgentSetColor( QStringList agentsId, const QString &background, cons
|
||||
dataJson["reset"] = reset;
|
||||
QByteArray jsonData = QJsonDocument(dataJson).toJson();
|
||||
|
||||
QString sUrl = profile.GetURL() + "/agent/setcolor";
|
||||
QString sUrl = profile.GetURL() + "/agent/set/color";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
*message = jsonObject["message"].toString();
|
||||
@@ -363,7 +335,27 @@ bool HttpReqAgentSetColor( QStringList agentsId, const QString &background, cons
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HttpReqTaskStop(const QString &agentId, QStringList tasksId, AuthProfile profile, QString* message, bool* ok )
|
||||
bool HttpReqAgentSetImpersonate(const QString &agentId, const QString &impersonate, const bool elevated, AuthProfile profile, QString* message, bool* ok )
|
||||
{
|
||||
QJsonObject dataJson;
|
||||
dataJson["agent_id"] = agentId;
|
||||
dataJson["impersonate"] = impersonate;
|
||||
dataJson["elevated"] = elevated;
|
||||
QByteArray jsonData = QJsonDocument(dataJson).toJson();
|
||||
|
||||
QString sUrl = profile.GetURL() + "/agent/set/impersonate";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
*message = jsonObject["message"].toString();
|
||||
*ok = jsonObject["ok"].toBool();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
///TASK
|
||||
|
||||
bool HttpReqTaskCancel(const QString &agentId, QStringList tasksId, AuthProfile profile, QString* message, bool* ok )
|
||||
{
|
||||
QJsonArray arrayId;
|
||||
for (QString item : tasksId)
|
||||
@@ -374,7 +366,7 @@ bool HttpReqTaskStop(const QString &agentId, QStringList tasksId, AuthProfile pr
|
||||
dataJson["tasks_array"] = arrayId;
|
||||
QByteArray jsonData = QJsonDocument(dataJson).toJson();
|
||||
|
||||
QString sUrl = profile.GetURL() + "/agent/task/stop";
|
||||
QString sUrl = profile.GetURL() + "/agent/task/cancel";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
*message = jsonObject["message"].toString();
|
||||
@@ -405,16 +397,9 @@ bool HttpReqTasksDelete(const QString &agentId, QStringList tasksId, AuthProfile
|
||||
return false;
|
||||
}
|
||||
|
||||
/// DOWNLOADS
|
||||
|
||||
bool HttpReqDownloadStart(const QString &agentId, const QString &path, AuthProfile profile, QString* message, bool* ok )
|
||||
bool HttpReqTasksHook(const QByteArray &jsonData, AuthProfile profile, QString* message, bool* ok)
|
||||
{
|
||||
QJsonObject dataJson;
|
||||
dataJson["agent_id"] = agentId;
|
||||
dataJson["path"] = path;
|
||||
QByteArray jsonData = QJsonDocument(dataJson).toJson();
|
||||
|
||||
QString sUrl = profile.GetURL() + "/download/start";
|
||||
QString sUrl = profile.GetURL() + "/agent/task/hook";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
*message = jsonObject["message"].toString();
|
||||
@@ -424,6 +409,8 @@ bool HttpReqDownloadStart(const QString &agentId, const QString &path, AuthProfi
|
||||
return false;
|
||||
}
|
||||
|
||||
/// DOWNLOADS
|
||||
|
||||
bool HttpReqDownloadAction(const QString &action, const QString &fileId, AuthProfile profile, QString* message, bool* ok )
|
||||
{
|
||||
QJsonObject dataJson;
|
||||
@@ -440,75 +427,6 @@ bool HttpReqDownloadAction(const QString &action, const QString &fileId, AuthPro
|
||||
return false;
|
||||
}
|
||||
|
||||
/// BROWSER
|
||||
|
||||
bool HttpReqBrowserDisks(const QString &agentId, AuthProfile profile, QString* message, bool* ok )
|
||||
{
|
||||
QJsonObject dataJson;
|
||||
dataJson["agent_id"] = agentId;
|
||||
QByteArray jsonData = QJsonDocument(dataJson).toJson();
|
||||
|
||||
QString sUrl = profile.GetURL() + "/browser/disks";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
*message = jsonObject["message"].toString();
|
||||
*ok = jsonObject["ok"].toBool();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HttpReqBrowserProcess(const QString &agentId, AuthProfile profile, QString* message, bool* ok )
|
||||
{
|
||||
QJsonObject dataJson;
|
||||
dataJson["agent_id"] = agentId;
|
||||
QByteArray jsonData = QJsonDocument(dataJson).toJson();
|
||||
|
||||
QString sUrl = profile.GetURL() + "/browser/process";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
*message = jsonObject["message"].toString();
|
||||
*ok = jsonObject["ok"].toBool();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HttpReqBrowserList(const QString &agentId, const QString &path, AuthProfile profile, QString* message, bool* ok )
|
||||
{
|
||||
QJsonObject dataJson;
|
||||
dataJson["agent_id"] = agentId;
|
||||
dataJson["path"] = path;
|
||||
QByteArray jsonData = QJsonDocument(dataJson).toJson();
|
||||
|
||||
QString sUrl = profile.GetURL() + "/browser/files";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
*message = jsonObject["message"].toString();
|
||||
*ok = jsonObject["ok"].toBool();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HttpReqBrowserUpload(const QString &agentId, const QString &path, const QString &content, AuthProfile profile, QString* message, bool* ok )
|
||||
{
|
||||
QJsonObject dataJson;
|
||||
dataJson["agent_id"] = agentId;
|
||||
dataJson["remote_path"] = path;
|
||||
dataJson["content"] = content;
|
||||
QByteArray jsonData = QJsonDocument(dataJson).toJson();
|
||||
|
||||
QString sUrl = profile.GetURL() + "/browser/upload";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
*message = jsonObject["message"].toString();
|
||||
*ok = jsonObject["ok"].toBool();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
///TUNNEL
|
||||
|
||||
bool HttpReqTunnelStartServer(const QString &tunnelType, const QByteArray &jsonData, AuthProfile profile, QString* message, bool* ok)
|
||||
@@ -556,7 +474,7 @@ bool HttpReqTunnelSetInfo(const QString &tunnelId, const QString &info, AuthProf
|
||||
return false;
|
||||
}
|
||||
|
||||
/// SCREEN
|
||||
///SCREEN
|
||||
|
||||
bool HttpReqScreenSetNote( QStringList scrensId, const QString ¬e, AuthProfile profile, QString* message, bool* ok )
|
||||
{
|
||||
@@ -597,4 +515,46 @@ bool HttpReqScreenRemove( QStringList scrensId, AuthProfile profile, QString* me
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
///CREDS
|
||||
|
||||
bool HttpReqCredentialsCreate(const QByteArray &jsonData, AuthProfile profile, QString *message, bool *ok)
|
||||
{
|
||||
QString sUrl = profile.GetURL() + "/creds/add";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
*message = jsonObject["message"].toString();
|
||||
*ok = jsonObject["ok"].toBool();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HttpReqCredentialsEdit(const QByteArray &jsonData, AuthProfile profile, QString *message, bool *ok)
|
||||
{
|
||||
QString sUrl = profile.GetURL() + "/creds/edit";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
*message = jsonObject["message"].toString();
|
||||
*ok = jsonObject["ok"].toBool();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HttpReqCredentialsRemove(const QString &credsId, AuthProfile profile, QString* message, bool* ok)
|
||||
{
|
||||
QJsonObject dataJson;
|
||||
dataJson["cred_id"] = credsId;
|
||||
QByteArray jsonData = QJsonDocument(dataJson).toJson();
|
||||
|
||||
QString sUrl = profile.GetURL() + "/creds/remove";
|
||||
QJsonObject jsonObject = HttpReq(sUrl, jsonData, profile.GetAccessToken());
|
||||
if ( jsonObject.contains("message") && jsonObject.contains("ok") ) {
|
||||
*message = jsonObject["message"].toString();
|
||||
*ok = jsonObject["ok"].toBool();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user