[python]Sample code to check if your email is pwned

Background
https://haveibeenpwned.com/API/Consumers
This is a free website where you can check if your email address is exposed from some hacked website which you are registered to.

import requests
import sys


check_account_api = "https://haveibeenpwned.com/api/v2/pasteaccount/"
email = sys.argv[1]


try:
    response = requests.get(check_account_api + email)
    result = response.json()[0]
    print(result["Id"] + "\n" +
          result["Source"] + "\n" +
          result["Title"] + "\n" +
          result["Date"] + "\n")

except BaseException as e:
    print("Page not found, http:" + str(response.status_code) + " " +
          "probably your email is not breached")
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s