Created
February 15, 2014 16:03
-
-
Save Ellyll/9021333 to your computer and use it in GitHub Desktop.
Check a list of addresses on https://haveibeenpwned.com to see if they've been compromised
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/http' | |
require 'json' | |
http = Net::HTTP.new('haveibeenpwned.com',443) | |
http.use_ssl = true | |
addresses = %w(foo@bar.com) # Add your addresses here separated by spaces | |
http.start | |
addresses.each do |email_address| | |
res = http.get("/api/v2/breachedaccount/#{email_address}") | |
if res.code == '404' | |
puts "#{email_address} is not pwned" | |
else | |
if res.code == '200' | |
pwns = JSON.parse(res.body) | |
titles = pwns.map { |pwn| pwn['Title'] } | |
puts "#{email_address} IS PWNED! #{titles.join(', ')}" | |
end | |
end | |
end | |
http.finish |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment