HTTP SSL Certificate Impersonation - Metasploit
This page contains detailed information about how to use the auxiliary/gather/impersonate_ssl metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: HTTP SSL Certificate Impersonation
Module: auxiliary/gather/impersonate_ssl
Source code: modules/auxiliary/gather/impersonate_ssl.rb
Disclosure date: -
Last modification time: 2022-06-08 11:53:42 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): 443
List of CVEs: -
This module request a copy of the remote SSL certificate and creates a local (self.signed) version using the information from the remote version. The module then Outputs (PEM|DER) format private key / certificate and a combined version for use in Apache or other Metasploit modules requiring SSLCert Inputs for private key / CA cert have been provided for those with DigiNotar certs hanging about!
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
msf > use auxiliary/gather/impersonate_ssl
msf auxiliary(impersonate_ssl) > show targets
... a list of targets ...
msf auxiliary(impersonate_ssl) > set TARGET target-id
msf auxiliary(impersonate_ssl) > show options
... show and set options ...
msf auxiliary(impersonate_ssl) > exploit
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Go back to menu.
Msfconsole Usage
Here is how the gather/impersonate_ssl auxiliary module looks in the msfconsole:
msf6 > use auxiliary/gather/impersonate_ssl
msf6 auxiliary(gather/impersonate_ssl) > show info
Name: HTTP SSL Certificate Impersonation
Module: auxiliary/gather/impersonate_ssl
License: Metasploit Framework License (BSD)
Rank: Normal
Provided by:
Chris John Riley
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
ADD_CN no Add CN to match spoofed site name (e.g. *.example.com)
CA_CERT no CA Public certificate
EXPIRATION no Date the new cert should expire (e.g. 06 May 2012, YESTERDAY or NOW)
OUT_FORMAT PEM yes Output format (Accepted: DER, PEM)
PRIVKEY no Sign the cert with your own CA private key
PRIVKEY_PASSWORD no Password for private key specified in PRIV_KEY (if applicable)
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 443 yes The target port (TCP)
SNI no Server Name Indicator
Description:
This module request a copy of the remote SSL certificate and creates
a local (self.signed) version using the information from the remote
version. The module then Outputs (PEM|DER) format private key /
certificate and a combined version for use in Apache or other
Metasploit modules requiring SSLCert Inputs for private key / CA
cert have been provided for those with DigiNotar certs hanging
about!
References:
http://www.slideshare.net/ChrisJohnRiley/ssl-certificate-impersonation-for-shits-andgiggles
Module Options
This is a complete list of options available in the gather/impersonate_ssl auxiliary module:
msf6 auxiliary(gather/impersonate_ssl) > show options
Module options (auxiliary/gather/impersonate_ssl):
Name Current Setting Required Description
---- --------------- -------- -----------
ADD_CN no Add CN to match spoofed site name (e.g. *.example.com)
CA_CERT no CA Public certificate
EXPIRATION no Date the new cert should expire (e.g. 06 May 2012, YESTERDAY or NOW)
OUT_FORMAT PEM yes Output format (Accepted: DER, PEM)
PRIVKEY no Sign the cert with your own CA private key
PRIVKEY_PASSWORD no Password for private key specified in PRIV_KEY (if applicable)
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 443 yes The target port (TCP)
SNI no Server Name Indicator
Advanced Options
Here is a complete list of advanced options supported by the gather/impersonate_ssl auxiliary module:
msf6 auxiliary(gather/impersonate_ssl) > show advanced
Module advanced options (auxiliary/gather/impersonate_ssl):
Name Current Setting Required Description
---- --------------- -------- -----------
AlterSerial true no Alter the serial number slightly to avoid FireFox serial matching
CHOST no The local client address
CPORT no The local client port
ConnectTimeout 10 yes Maximum number of seconds to establish a TCP connection
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
SSL false no Negotiate SSL/TLS for outgoing connections
SSLCipher no String for SSL cipher - "DHE-RSA-AES256-SHA" or "ADH"
SSLVerifyMode PEER no SSL verification method (Accepted: CLIENT_ONCE, FAIL_IF_NO_PEER_CERT, NONE, PEER)
SSLVersion Auto yes Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Auxiliary Actions
This is a list of all auxiliary actions that the gather/impersonate_ssl module can do:
msf6 auxiliary(gather/impersonate_ssl) > show actions
Auxiliary actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the gather/impersonate_ssl auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 auxiliary(gather/impersonate_ssl) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
TCP::max_send_size 0 no Maxiumum tcp segment size. (0 = disable)
TCP::send_delay 0 no Delays inserted before every send. (0 = disable)
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
CA Certificate AND Private Key must be provided!
Here is a relevant code snippet related to the "CA Certificate AND Private Key must be provided!" error message:
74: ca_key = OpenSSL::PKey::RSA.new(File.read(datastore['PRIVKEY']))
75: end
76: ca = OpenSSL::X509::Certificate.new(File.read(datastore['CA_CERT']))
77: elsif !datastore['PRIVKEY'].nil? || !datastore['CA_CERT'].nil?
78: # error if both PRIVKEY and CA_CERT are not BOTH provided
79: print_error('CA Certificate AND Private Key must be provided!')
80: return
81: end
82:
83: begin
84: cert = get_cert(rhost, rport, sni)
<RHOST>:<RPORT> No certificate subject or CN found
Here is a relevant code snippet related to the "<RHOST>:<RPORT> No certificate subject or CN found" error message:
87: rescue ::Timeout::Error, ::Errno::EPIPE => e
88: print_error(e.message)
89: end
90:
91: if !cert
92: print_error("#{rhost}:#{rport} No certificate subject or CN found")
93: return
94: end
95:
96: print_status("Copying certificate from #{rhost}:#{rport}\n#{cert.subject} ")
97: vprint_status("Original Certifcate Details\n\n#{cert.to_text}")
The serial number of the original cert is too short. Creating new random serial
Here is a relevant code snippet related to the "The serial number of the original cert is too short. Creating new random serial" error message:
147: if (cert.serial.to_s.length > 1)
148: # alter last digits of the serial number
149: new_cert.serial = (cert.serial.to_s[0..-2] + rand(0xFF).to_s).to_i
150: else
151: # serial is too small, create random serial
152: vprint_error('The serial number of the original cert is too short. Creating new random serial')
153: new_cert.serial = rand(0xFFFF)
154: end
155: else
156: # match serial number
157: new_cert.serial = cert.serial.to_s
Go back to menu.
Related Pull Requests
- #14911 Merged Pull Request: impersonate_ssl: added an SNI option for the ssl certificate request
- #8888 Merged Pull Request: spelling/grammar fixes part 1
- #8716 Merged Pull Request: Print_Status -> Print_Good (And OCD bits 'n bobs)
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #5668 Merged Pull Request: Fix a small typo in impersonate_ssl
- #2525 Merged Pull Request: Change module boilerplate
- #1294 Merged Pull Request: [FixRM: #7482] Move impersonate_ssl
References
- CVE: Not available
- http://www.slideshare.net/ChrisJohnRiley/ssl-certificate-impersonation-for-shits-andgiggles
See Also
Check also the following modules related to this module:
- auxiliary/scanner/http/ssl
- auxiliary/dos/ssl/dtls_changecipherspec
- auxiliary/dos/ssl/dtls_fragment_overflow
- auxiliary/dos/ssl/openssl_aesni
- auxiliary/scanner/ssl/bleichenbacher_oracle
- auxiliary/scanner/ssl/openssl_ccs
- auxiliary/scanner/ssl/openssl_heartbleed
- auxiliary/scanner/ssl/ssl_version
- exploit/windows/ssl/ms04_011_pct
- auxiliary/gather/fortios_vpnssl_traversal_creds_leak
- auxiliary/gather/ssllabs_scan
- auxiliary/dos/http/sonicwall_ssl_format
- auxiliary/scanner/http/cisco_ssl_vpn
- auxiliary/scanner/http/cisco_ssl_vpn_priv_esc
- auxiliary/scanner/http/fortinet_ssl_vpn
- auxiliary/scanner/http/ssl_version
- auxiliary/scanner/sap/sap_mgmt_con_getprocesslist
- auxiliary/server/openssl_altchainsforgery_mitm_proxy
- auxiliary/server/openssl_heartbeat_client_memory
Authors
Chris John Riley
Version
This page has been produced using Metasploit Framework version 6.2.29-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.