コード例 #1
0
  @Override
  public void fromBytes(final ByteBuf stream) {
    // Read the id
    short id = stream.readShort();
    if (id == -1) {
      // Invalid packet
      ThELog.warning("Unknown packet detected");
      return;
    }

    // Get the class for that id
    Class epClass = NetworkHandler.getPacketClassFromID(id);
    if (epClass == null) {
      return;
    }

    // Construct the class
    try {
      this.embeddedPacket = (ThEBasePacket) epClass.newInstance();

      // Pass to packet
      this.embeddedPacket.fromBytes(stream);
    } catch (Exception e) {
      // Packet did not have default constructor
      ThELog.warning("Unable to construct packet %s", epClass.getCanonicalName());
    }
  }
コード例 #2
0
  @Override
  public byte[] receive() {
    data = nic.receiveFrame();
    id = (int) data[19]; // Get ID

    LOGGER.debug("receive() TLS-FLAG: {}", Byte.toString(data[23]));

    if (data[23] == (byte) 0xc0) {
      eapolMachine.setState(new FragStartState(eapolMachine, id));
    } else if (data[23] == (byte) 0x80) {
      eapolMachine.setState(new NoFragState(eapolMachine, id)); // Nur zum
      // Testen!
      // Muss
      // durch
      // seperaten
      // State
      // ersetzt
      // werden
    } else if (data[18] == 0x04) {
      eapolMachine.setState(new FailureState(eapolMachine, id));
    } else {
      eapolMachine.setState(new FragState(eapolMachine, id));
    }

    LOGGER.debug("change State to: {}", eapolMachine.getState());
    return data;
  }
コード例 #3
0
  @Override
  public void sendTLS(byte[] tlspacket) {

    EAPFrame eapstart = eaptlsfactory.createFrame("EAPTLSCH", id, tlspacket);

    LOGGER.debug("sendTLS(): {}", eapolMachine.getState());

    nic.sendFrame(eapstart.getFrame());
  }
コード例 #4
0
ファイル: FinishedState.java プロジェクト: C1tas/TLS-Attacker
  @Override
  public void send() {

    EAPFrame eapstart = eaptlsfactory.createFrame("EAPTLSFRAGACK", id);

    LOGGER.debug("send(): {}", eapolMachine.getState());

    nic.sendFrame(eapstart.getFrame());
  }
コード例 #5
0
 @Override
 public void handleServerSide(PacketHackingEntityStart message, EntityPlayer player) {
   Entity entity = player.worldObj.getEntityByID(message.entityId);
   if (entity != null) {
     CommonHUDHandler.getHandlerForPlayer(player).setHackedEntity(entity);
     NetworkHandler.sendToAllAround(
         message,
         new NetworkRegistry.TargetPoint(
             entity.worldObj.provider.dimensionId, entity.posX, entity.posY, entity.posZ, 64));
   }
 }
コード例 #6
0
ファイル: EapStartState.java プロジェクト: C1tas/TLS-Attacker
/**
 * Set EAP-TLS Statemachine in Start-State and send EAP-Start out. Change the State if a Identity
 * Frame was received.
 *
 * @author Felix Lange <*****@*****.**>
 */
public class EapStartState implements EapState {

  EapolMachine eapolMachine;

  EapFactory eaptlsfactory = new EapTlsFactory();

  NetworkHandler nic = NetworkHandler.getInstance();

  byte[] data = {};

  public EapStartState(EapolMachine eapolMachine) {

    this.eapolMachine = eapolMachine;
  }

  @Override
  public void send() {

    EAPFrame eapstart = eaptlsfactory.createFrame("STARTEAP", 0);
    nic.sendFrame(eapstart.getFrame());
  }

  @Override
  public void sendTLS(byte[] tlspacket) {}

  @Override
  public byte[] receive() {

    data = nic.receiveFrame();
    int id = (int) data[19]; // Get ID

    // Identity Frame?
    if (data[22] == 0x01) {
      eapolMachine.setState(new IdentityState(eapolMachine, id));
    } else {
      eapolMachine.setState(new EapStartState(eapolMachine));
    }

    return data;
  }

  @Override
  public String getState() {
    return "EapStartState";
  }

  @Override
  public int getID() {

    return (int) data[19];
  }
}
コード例 #7
0
  @Override
  public void toBytes(final ByteBuf stream) {
    if (this.embeddedPacket != null) {
      // Write the id
      short id = NetworkHandler.getPacketID(this.embeddedPacket);
      stream.writeShort(id);

      // Call embedded
      this.embeddedPacket.toBytes(stream);
    } else {
      // Write -1
      stream.writeShort(-1);
    }
  }
コード例 #8
0
ファイル: FinishedState.java プロジェクト: C1tas/TLS-Attacker
  @Override
  public byte[] receive() {

    data = nic.receiveFrame();
    id = (int) data[19]; // Get ID

    if (data[18] == (byte) 0x03) {
      eapolMachine.setState(new SuccessState(eapolMachine, id));
    } else if (data[18] == (byte) 0x04) {
      eapolMachine.setState(new FailureState(eapolMachine, id));
    }

    return data;
  }
コード例 #9
0
ファイル: EapStartState.java プロジェクト: C1tas/TLS-Attacker
  @Override
  public byte[] receive() {

    data = nic.receiveFrame();
    int id = (int) data[19]; // Get ID

    // Identity Frame?
    if (data[22] == 0x01) {
      eapolMachine.setState(new IdentityState(eapolMachine, id));
    } else {
      eapolMachine.setState(new EapStartState(eapolMachine));
    }

    return data;
  }
コード例 #10
0
ファイル: EapStartState.java プロジェクト: C1tas/TLS-Attacker
  @Override
  public void send() {

    EAPFrame eapstart = eaptlsfactory.createFrame("STARTEAP", 0);
    nic.sendFrame(eapstart.getFrame());
  }
コード例 #11
0
/**
 * State for Client Hello. Sends the Client Hello Frame. Change state if a Failure,Frag, Frag Start,
 * Nofrag or Frag End Frame was received.
 *
 * @author Felix Lange <*****@*****.**>
 */
public class HelloState implements EapState {

  private static final Logger LOGGER = LogManager.getLogger(HelloState.class);

  EapolMachine eapolMachine;

  int id;

  EapFactory eaptlsfactory = new EapTlsFactory();

  NetworkHandler nic = NetworkHandler.getInstance();

  byte[] data = {};

  public HelloState(EapolMachine eapolMachine, int id) {

    this.eapolMachine = eapolMachine;
    this.id = id;
  }

  @Override
  public void send() {
    // TODO Auto-generated method stub

  }

  @Override
  public void sendTLS(byte[] tlspacket) {

    EAPFrame eapstart = eaptlsfactory.createFrame("EAPTLSCH", id, tlspacket);

    LOGGER.debug("sendTLS(): {}", eapolMachine.getState());

    nic.sendFrame(eapstart.getFrame());
  }

  @Override
  public byte[] receive() {
    data = nic.receiveFrame();
    id = (int) data[19]; // Get ID

    LOGGER.debug("receive() TLS-FLAG: {}", Byte.toString(data[23]));

    if (data[23] == (byte) 0xc0) {
      eapolMachine.setState(new FragStartState(eapolMachine, id));
    } else if (data[23] == (byte) 0x80) {
      eapolMachine.setState(new NoFragState(eapolMachine, id)); // Nur zum
      // Testen!
      // Muss
      // durch
      // seperaten
      // State
      // ersetzt
      // werden
    } else if (data[18] == 0x04) {
      eapolMachine.setState(new FailureState(eapolMachine, id));
    } else {
      eapolMachine.setState(new FragState(eapolMachine, id));
    }

    LOGGER.debug("change State to: {}", eapolMachine.getState());
    return data;
  }

  @Override
  public String getState() {
    return "HelloState";
  }

  @Override
  public int getID() {

    return id;
  }
}
コード例 #12
0
ファイル: FinishedState.java プロジェクト: C1tas/TLS-Attacker
/**
 * Last state in the protocolflow, sends the last EAP-ACK and switch to Success or Failure. This
 * depends on the received frame.
 *
 * @author Felix Lange <*****@*****.**>
 */
public class FinishedState implements EapState {

  private static final Logger LOGGER = LogManager.getLogger(FragEndState.class);

  EapolMachine eapolMachine;

  int id;

  EapFactory eaptlsfactory = new EapTlsFactory();

  NetworkHandler nic = NetworkHandler.getInstance();

  byte[] data = {};

  public FinishedState(EapolMachine eapolMachine, int id) {

    this.eapolMachine = eapolMachine;
    this.id = id;
  }

  @Override
  public void send() {

    EAPFrame eapstart = eaptlsfactory.createFrame("EAPTLSFRAGACK", id);

    LOGGER.debug("send(): {}", eapolMachine.getState());

    nic.sendFrame(eapstart.getFrame());
  }

  @Override
  public void sendTLS(byte[] tlspacket) {

    EAPFrame eapstart = eaptlsfactory.createFrame("EAPTLSCH", id, tlspacket);

    LOGGER.debug("sendTLS(): {}", eapolMachine.getState());

    nic.sendFrame(eapstart.getFrame());
  }

  @Override
  public byte[] receive() {

    data = nic.receiveFrame();
    id = (int) data[19]; // Get ID

    if (data[18] == (byte) 0x03) {
      eapolMachine.setState(new SuccessState(eapolMachine, id));
    } else if (data[18] == (byte) 0x04) {
      eapolMachine.setState(new FailureState(eapolMachine, id));
    }

    return data;
  }

  @Override
  public String getState() {
    return "FinishedState";
  }

  @Override
  public int getID() {

    return id;
  }
}