diff options
Diffstat (limited to 'crtsh-getcerts')
-rwxr-xr-x | crtsh-getcerts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/crtsh-getcerts b/crtsh-getcerts new file mode 100755 index 0000000..0191e2e --- /dev/null +++ b/crtsh-getcerts @@ -0,0 +1,28 @@ +#!/usr/bin/env ruby +require 'nokogiri' +require 'open-uri' + +certs = {} +ARGV.each do |domain| + [ domain, "%.#{domain}" ].each do |pattern| + Nokogiri::XML(open("https://crt.sh/atom?identity=#{pattern}&exclude=expired")).css('feed > entry').each do |entry| + url = entry.css('id').first.text.split("#").first + + updated = entry.css('updated').first.text + + html = Nokogiri::HTML(entry.css('summary').first.text) + html.css('br').each{|br| br.replace("\n")} + pem = html.css('div').first.text + + lines = pem.split("\n") + lines.insert(1, "X-Crt-Sh-Url: #{url}", "X-Crt-Sh-Updated: #{updated}") + pem = lines.join("\n")+"\n" + + certs[url] = pem + end + end +end + +certs.each do |url, pem| + print pem +end |