Development Guide

Tagger

Internal Tagger extension allows developers to create their own tagging subrules.

Tag Subrule Data

Tag Subrule 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.tagger.factory.TagSubruleData
/*
 * 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/>.
 */
/** Tag subrule data. */
@PetepAPI
public class TagSubruleData {
}

Tag Subrule

Tag Subrule contains the main logic (method test() that returns true is should be tagger).

com.warxim.petep.extension.internal.tagger.factory.TagSubrule
/*
 * 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/>.
 */
/** Tag subrule. */
@PetepAPI
public abstract class TagSubrule {
  protected final TagSubruleFactory factory;
  protected TagSubruleData data;

  /** Tag subrule constructor. */
  public TagSubrule(TagSubruleFactory factory, TagSubruleData data) {
    this.factory = factory;
    this.data = data;
  }

  public final TagSubruleFactory getFactory() {
    return factory;
  }

  public final TagSubruleData getData() {
    return data;
  }

  public abstract boolean test(PDU pdu);

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

Tag Subrule Configurator

Configurator is graphical element used for configuration of the subrule.

com.warxim.petep.extension.internal.tagger.factory.TagSubruleConfigurator
/*
 * 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 TagSubruleConfigurator extends ConfigPane<TagSubruleData> {
  public TagSubruleConfigurator(String template) throws IOException {
    super(template);
  }
}

Tag Subrule Factory

Tag Subrule Factory creates the subrule and also provides configuration pane (if it exists).

com.warxim.petep.extension.internal.tagger.factory.TagSubruleFactory
/*
 * 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/>.
 */
/** Tag subrule factory. */
@PetepAPI
public abstract class TagSubruleFactory {
  /** Returns factory code (for configuration purposes). */
  public abstract String getCode();

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

  /** Creates subrule using given data. */
  public abstract TagSubrule createSubrule(TagSubruleData data);

  /** Creates config pane for subrule data. */
  public abstract TagSubruleConfigurator 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 TagSubruleFactory, you have to implement ExtensionInitListener in your extension and the following lines to beforeInit method:

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

if (tagger == null) {
  return;
}

if (((TaggerApi) tagger).registerSubruleFactory(new ExampleTagSubruleFactory())) {
  Logger.getGlobal().info("Example tag subrule 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