Development Guide

Modifier

Internal Modifier extension allows developers to create their own modifiers.

Modifier Data

Modifier Data has no restrictions on what it has to implement. It is up to you what you will store inside it.

com.warxim.petep.extension.internal.modifier.factory.ModifierData
/*
 * PEnetration TEsting Proxy (PETEP)
 * 
 * Copyright (C) 2020 Michal Válka
 *
 * This program is free software: you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program. If
 * not, see <https://www.gnu.org/licenses/>.
 */
/** Processor data. */
@PetepAPI
public class ModifierData {
}

Modifier

Modifier contains the main logic (method process() returns false if PDU should be dropped).

com.warxim.petep.extension.internal.modifier.factory.Modifier
/*
 * PEnetration TEsting Proxy (PETEP)
 * 
 * Copyright (C) 2020 Michal Válka
 *
 * This program is free software: you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program. If
 * not, see <https://www.gnu.org/licenses/>.
 */
@PetepAPI
public abstract class Modifier {
  protected final ModifierFactory factory;

  protected ModifierData data;

  public Modifier(ModifierFactory factory, ModifierData data) {
    this.factory = factory;
    this.data = data;
  }

  public ModifierFactory getFactory() {
    return factory;
  }

  public ModifierData getData() {
    return data;
  }

  /**
   * Processes PDU in the modifier.
   *
   * @return FALSE if PDU should be dropped.
   */
  public abstract boolean process(PDU pdu);

  @Override
  public String toString() {
    return factory.getName();
  }
}

Modifier Configurator

Configurator is graphical element used for configuration of the modifier.

com.warxim.petep.extension.internal.modifier.factory.ModifierConfigurator
/*
 * PEnetration TEsting Proxy (PETEP)
 * 
 * Copyright (C) 2020 Michal Válka
 *
 * This program is free software: you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program. If
 * not, see <https://www.gnu.org/licenses/>.
 */
@PetepAPI
public abstract class ModifierConfigurator extends ConfigPane<ModifierData> {
  public ModifierConfigurator(String template) throws IOException {
    super(template);
  }
}

Modifier Factory

Modifier Factory creates the modifier and also provides configuration pane (if it exists).

com.warxim.petep.extension.internal.modifier.factory.ModifierFactory
/*
 * PEnetration TEsting Proxy (PETEP)
 * 
 * Copyright (C) 2020 Michal Válka
 *
 * This program is free software: you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program. If
 * not, see <https://www.gnu.org/licenses/>.
 */
/** Modifier factory. */
@PetepAPI
public abstract class ModifierFactory {
  /** Returns factory code (for configuration purposes). */
  public abstract String getCode();

  /** Returns factory name (visible for user). */
  public abstract String getName();

  /** Creates modifier using given data. */
  public abstract Modifier createModifier(ModifierData data);

  /** Creates config pane for modifier data. */
  public abstract ModifierConfigurator createConfigPane() throws IOException;

  /** Returns type of configuration, so it can be deserialized from JSON configuration. */
  public abstract Type getConfigType();

  @Override
  public String toString() {
    return getName();
  }
}

Registration

In order to register ModifierFactory, you have to implement ExtensionInitListener in your extension and the following lines to beforeInit method:

petep.PetepExtension: public void beforeInit(ExtensionHelper helper)
Extension modifier = helper.getExtension("modifier");

if (modifier == null) {
  return;
}

if (((ModifierApi) modifier).registerModifierFactory(new ExampleModifierFactory())) {
  Logger.getGlobal().info("Example modifier registered!");
}
Získejte registraci domén s tld .online, .space, .store, .tech zdarma!
Stačí si k jedné z těchto domén vybrat hosting Plus nebo Mega a registraci domény od nás dostanete za 0 Kč!
Objednat