Skip to content

Instantly share code, notes, and snippets.

@Ellyll
Created February 15, 2014 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ellyll/9021333 to your computer and use it in GitHub Desktop.
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
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