Development Guide

Module Factory

Module factories are used to create both proxy modules (class ProxyModuleFactory) and interceptor modules (class InterceptorModuleFactory). These factories are used to create modules based on users' configuration.

Module factories are also used to create graphical configuration components (by implementing Configurator) and in proxy factories, they are used to create metadata PDU components.

Both ProxyModuleFactory and InterceptorModuleFactory are registered using ExtensionHelper inside Extension.init() method.

Attributes

Code
Module code has to be unique, because it is used internally to, for example, serialize and deserialize modules from project configuration.
Name
Name of the module displayed to the user.

Module Factory class

com.warxim.petep.module.ModuleFactory
/*
 * 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/>.
 */
/** Module factory base class. */
@PetepAPI
public abstract class ModuleFactory<M extends Module<?>> {
  protected final Extension extension;

  public ModuleFactory(Extension extension) {
    this.extension = extension;
  }

  public final Extension getExtension() {
    return extension;
  }

  /** Returns name of the factory. */
  public abstract String getName();

  /** Returns unique code of the factory. */
  public abstract String getCode();

  /** Creates module with specified parameters. */
  public abstract M createModule(String code, String name, String description, boolean enabled);
}

Proxy Module Factory class

Proxy module factories create proxy modules and you can use them to create support for new protocols in PETEP.

Besides the abstract methods of ModuleFactory class you have to implement method "createPduMetadataPane" which creates editor for PDU metadata for you protocol (if you do not want to create your own editor, you can just return null in this method) and you have to implements methods that return serializer and deserializer.

You can specify the serializer/deserializer that will be used to serialize/deserialize metadata of PDUs into maps.

com.warxim.petep.proxy.factory.ProxyModuleFactory
/*
 * 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/>.
 */
/** Proxy module factory. */
@PetepAPI
public abstract class ProxyModuleFactory extends ModuleFactory<ProxyModule> {
  public ProxyModuleFactory(Extension extension) {
    super(extension);
  }

  /** Creates PDU metadata component for modules of this factory. */
  public abstract PduMetadataPane createPduMetadataPane() throws IOException;

  /** Returns proxy serializer. */
  public abstract ProxySerializer getSerializer();

  /** Returns proxy deserializer. */
  public abstract ProxyDeserializer getDeserializer();
}

Interceptor Module Factory class

Interceptor module factories create interceptor modules and you can use them to create various PDU modifications and processing like logging, replacing, tagging, encoding/decoding etc.

com.warxim.petep.interceptor.factory.InterceptorModuleFactory
/*
 * 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/>.
 */
/** Interceptor module interface. */
@PetepAPI
public abstract class InterceptorModuleFactory extends ModuleFactory<InterceptorModule> {
  public InterceptorModuleFactory(Extension extension) {
    super(extension);
  }
}
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