Development Guide

Module Worker

Module workers are started when PETEP core starts and stopped when PETEP core stops.

Module Worker class

com.warxim.petep.module.ModuleWorker
/*
 * 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/>.
 */
/** Instance base class. */
@PetepAPI
public abstract class ModuleWorker<M extends Module<?>> {
  /** PETEP helper for current running PETEP core instance. */
  protected final PetepHelper helper;

  /** Parent module. */
  protected final M module;

  public ModuleWorker(M module, PetepHelper helper) {
    this.helper = helper;
    this.module = module;
  }

  /** Returns parent module. */
  public final M getModule() {
    return module;
  }

  /** Returns PetepHelper of current PETEP core instance. */
  public final PetepHelper getHelper() {
    return helper;
  }

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

Proxy class

Proxy listens for incomming connections, provides connection manager.

Methods prepare and start can return "false" and by that abort start of PETEP core.

Method stop should be used to free resources - stop threads, close connections and connection manager etc.

Start and stop methods should be used to start(stop) new threads inside proxy and they have to be nonblocking!

com.warxim.petep.proxy.worker.Proxy
/*
 * 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 base class. */
@PetepAPI
public abstract class Proxy extends ModuleWorker<ProxyModule> {
  public Proxy(ProxyModule module, PetepHelper helper) {
    super(module, helper);
  }

  /** Prepares proxy to start. */
  public abstract boolean prepare();

  /** Starts proxy. */
  public abstract boolean start();

  /** Stops proxy. */
  public abstract void stop();

  /** Returns proxy connection manager. */
  public abstract ConnectionManager getConnectionManager();
}

Interceptor class

Method prepare can return "false" and by that abort start of PETEP core.

Method stop should be used to free resources.

Interceptors are wrapped inside threads automatically and you do not have to create any threads. Intercept method is called automatically for each PDU that goes through the interceptor.

com.warxim.petep.interceptor.worker.Interceptor
/*
 * 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 base class. */
@PetepAPI
public abstract class Interceptor extends ModuleWorker<InterceptorModule> {
  /** ID of interceptor (interceptor index in interceptors list). */
  protected final int id;

  public Interceptor(int id, InterceptorModule module, PetepHelper helper) {
    super(module, helper);
    this.id = id;
  }

  /** Prepares instance for intercepting. */
  public abstract boolean prepare();

  /** Intercepts PDUs. */
  public abstract boolean intercept(PDU pdu);

  /** Stops intercepting. */
  public abstract void stop();

  /** Returns interceptor ID. */
  public final int getId() {
    return id;
  }
}
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