Defending against attacks: To simulate the Secure Socket Layer (SSL) transmission between a user and a server
Procedure
Begin a session by typing the following command on terminal 1 with the server's IP address and port.
- openssl s_client -connect host:port
On a successful connection, the server will send a copy of its assymmetric public key to the client. Try catting the file to see what it looks like.
- cat server_pubkey.pem
The client then creates a static session key by executing the following command.
- openssl rand -hex 16 > sessionkey.txt
The client then encrypts the session key using the server's public key.
- openssl rsautl -encrypt -in sessionkey.txt -out sessionkey.enc-pubin -inkey server_pubkey.pem
The client then sends the encrypted session key to the server.
- cat sessionkey.enc | nc host port
The server then decrypts the session key using its private key.
- openssl rsautl -decrypt -in sessionkey.enc -out sessionkey.txt -inkey server_privkey.pem
The server has decrypted the session key using its private key. Try catting the file to see what it looks like, it should be the same as the session key generated in step 3.
To identify the host IP, the client will send a ping request to the server by executing the following command:
- ping -c 3 IP_ADDRESS
To display the certificate info of the server, the client will execute the following command:
- openssl x509 -in server.crt -text -noout
To quit the session, the client will execute the following command:
- quit