This project demonstrates a secure key exchange using the Diffie-Hellman protocol while simulating a Man-in-the-Middle (MITM) attack using Java socket programming.
- To implement a multi-party Diffie-Hellman key exchange protocol.
- To simulate a Man-in-the-Middle attack on the key exchange.
The Diffie-Hellman protocol allows two parties to securely share a secret key over an insecure channel. A MITM attack compromises the exchange by intercepting and modifying public keys, establishing separate shared secrets with both parties without their knowledge.
ClientAlice.java
: Simulates Alice, who initiates the key exchange.ClientBob.java
: Simulates Bob, the receiver of Alice's key.MitmEve.java
: Simulates Eve, the attacker performing a MITM attack.
Compile all Java files:
javac ClientAlice.java ClientBob.java MitmEve.java
Open 3 terminals and run the programs in the following order:
Terminal 1 (Start Eve / MITM Server):
java MitmEve
Terminal 2 (Start Alice):
java ClientAlice
Terminal 3 (Start Bob):
java ClientBob
Observe the shared secret and public key exchange on each terminal. You will see that Eve successfully establishes shared secrets with both Alice and Bob separately.