Exemplo n.º 1
0
    def set_kwargs(self, task):
        """Creates widgets for each task keyword argument."""
        if not task or task is self.current_task:
            return
        else:
            for widget_dict in self.widgets:
                key_widget = widget_dict.get("key")
                value_widget = widget_dict.get("value")

                if key_widget:
                    key_widget.setParent(None)
                    self.widget_layout.removeWidget(key_widget)

                value_widget.setParent(None)
                self.widget_layout.removeWidget(value_widget)
            self.widgets.clear()
            self.current_task = task

        kwargs_dict = task.get("kwargs")
        for key, value in kwargs_dict.items():
            key_label = QLabel(str(key).replace("_", " ").capitalize(), self)
            val_type = value.get("type")
            default = value.get("default")

            if val_type is int:
                value_widget = QSpinBox(self)
                value_widget.setRange(-1, 100000)
                value_widget.setValue(int(default))
            elif val_type is list:
                value_widget = QListWidget(self)
                value_widget.addItems([str(item) for item in default])
                for i in range(value_widget.count()):
                    value_widget.item(i).setFlags(
                        value_widget.item(i).flags() | Qt.ItemIsEditable)
            elif val_type is str:
                value_widget = QLineEdit(self)
                value_widget.setText(str(default))
            elif val_type is bool:
                key_label = None
                value_widget = QCheckBox(
                    str(key).replace("_", " ").capitalize(), self)
                value_widget.setChecked(bool(default))
            elif val_type == "text":
                value_widget = QTextEdit(self)
                value_widget.setText(str(default))
            else:
                continue

            value_widget.setObjectName(key)
            value_widget.setToolTip(value.get("description"))
            self.widgets.append({"key": key_label, "value": value_widget})
            if type(value_widget) is QCheckBox:
                self.widget_layout.addWidget(value_widget)
            else:
                self.widget_layout.addRow(key_label, value_widget)
 def createSpinBox(
     self,
     variable_name,
     variable_value,
     analysis_module_variables_model,
 ):
     spinner = QSpinBox()
     spinner.setMinimumWidth(75)
     spinner.setMaximum(
         analysis_module_variables_model.getVariableMaximumValue(
             variable_name))
     spinner.setMinimum(
         analysis_module_variables_model.getVariableMinimumValue(
             variable_name))
     spinner.setSingleStep(
         analysis_module_variables_model.getVariableStepValue(
             variable_name))
     spinner.setObjectName(variable_name)
     if variable_value is not None:
         spinner.setValue(variable_value)
     return spinner
Exemplo n.º 3
0
class GUIConfigFrame(ConfigBaseFrame):
    def __init__(self, parent):
        super(GUIConfigFrame, self).__init__(parent)
        self.widget_layout = QVBoxLayout(self)
        self.setLayout(self.widget_layout)

        self.gui_conf_label = QLabel(self)
        self.gui_conf_label.setText("GUI server configuration")
        self.widget_layout.addWidget(self.gui_conf_label)

        self.desc_label = QLabel(self)
        self.desc_label.setWordWrap(True)
        self.desc_label.setText(
            "QtPyBotnet GUI if fully remote. This means that you can connect to C2 server and "
            "manage bots wherever you are. To authenticate when connecting to GUI server use the "
            "key below.")
        self.widget_layout.addWidget(self.desc_label)

        self.gui_config = QWidget(self)
        self.gui_config_layout = QFormLayout(self.gui_config)
        self.widget_layout.addWidget(self.gui_config)

        self.gui_ip_label = QLabel(self.gui_config)
        self.gui_ip_label.setObjectName("gui_ip_label")
        self.gui_ip_label.setText("GUI IP Address")

        self.gui_ip_combo = QComboBox(self.gui_config)
        self.gui_config_layout.addRow(self.gui_ip_label, self.gui_ip_combo)

        self.gui_port_label = QLabel(self.gui_config)
        self.gui_port_label.setObjectName("gui_port_label")
        self.gui_port_label.setText("GUI Port")

        self.gui_port_edit = QSpinBox(self.gui_config)
        self.gui_port_edit.setObjectName("gui_port_spin")
        self.gui_port_edit.setRange(1024, 65535)
        self.gui_port_edit.setValue(15692)
        self.gui_config_layout.addRow(self.gui_port_label, self.gui_port_edit)

        self.gui_key_label = QLabel(self.gui_config)
        self.gui_key_label.setObjectName("gui_key_label")
        self.gui_key_label.setText("GUI encryption key")

        self.gui_key_edit = QLineEdit(self.gui_config)
        self.gui_key_edit.setObjectName("gui_key_edit")
        self.gui_key_edit.setReadOnly(True)
        self.gui_config_layout.addRow(self.gui_key_label, self.gui_key_edit)

        self.gmaps_key_label = QLabel(self.gui_config)
        self.gmaps_key_label.setObjectName("gmaps_key_label")
        self.gmaps_key_label.setText("Google Maps API key")

        self.gmap_key_edit = QLineEdit(self.gui_config)
        self.gmap_key_edit.setObjectName("gmap_key_edit")
        self.gui_config_layout.addRow(self.gmaps_key_label, self.gmap_key_edit)

        spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                 QSizePolicy.Expanding)
        self.widget_layout.addItem(spacerItem)

    @Slot(dict)
    def set_options(self, options):
        self.gui_ip_combo.addItems(
            [iface.get("ip") for iface in options.get("interfaces")])
        self.gui_key_edit.setText(options.get("gui_key"))

    @Slot()
    def collect_info(self):
        return {
            "gui_ip": self.gui_ip_combo.currentText(),
            "gui_port": int(self.gui_port_edit.text()),
            "gmaps_key": self.gmap_key_edit.text(),
            "gui_key": self.gui_key_edit.text()
        }