Last active
May 12, 2023 07:34
-
-
Save mgeeky/5e36d6482e73ab85c161c35bfd50c465 to your computer and use it in GitHub Desktop.
Simple SSL/TLS self-signed CA Certificate generator for MITM purposes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo -e "\n\nSimple SSL/TLS self-signed CA Certificate generator\n\n" | |
if [ -z $1 ]; then | |
echo "Usage: $0 [file_name]" | |
echo -e "\nGoing with default name: './rogue_server'\n\n" | |
fi | |
FILENAME=${1:-rogue_server} | |
echo "[+] Generating public and private keys pair (.key)..." | |
openssl genrsa -out $FILENAME.key 1024 | |
echo "[+] Generating a self-signed x509 CA's certificate (.crt)..." | |
openssl req -new -key $FILENAME.key -x509 -sha256 -days 3600 -out $FILENAME.crt | |
echo "[+] Generating the PEM file out of the key and certificate files..." | |
cat $FILENAME.key $FILENAME.crt > $FILENAME.pem | |
echo -e "\n[>] Certificate's dump:" | |
openssl x509 -in $FILENAME.pem -text -noout | |
echo -e "\n[>] Generated files:" | |
echo -e "\tPKI keys (public/private):\t$FILENAME.key" | |
echo -e "\tCA Certficate:\t\t$FILENAME.crt" | |
echo -e "\tResulting PEM:\t\t$FILENAME.pem" | |
echo -e "\n\n[+] Now you can start a TLS-enabled server with:\n" | |
echo -e "\n$ sudo socat -vv openssl-listen:443,reuseaddr,fork,cert=$FILENAME.pem,cafile=$FILENAME.crt,verify=0 openssl-connect::,verify=0 \n" | |
echo "Happy MITM-ing!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lovely Jubbly! Thanks