-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhhtp_req.py
35 lines (27 loc) · 977 Bytes
/
hhtp_req.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import requests
import argparse
import sys
import time
from datetime import datetime
def check_mails(parameter):
# The Have I Been Pawned API Key and URL
hibp_api_key = "ab62cea28a114653909fa9ef1547d590"
base_url = "https://haveibeenpwned.com/api/v3"
# Building the header used to call the API
headers = {
"hibp-api-key": hibp_api_key,
"user-agent": "PythonApp" # Custom user-agent
}
# Check the DataBase for each email provided as a command line argument
response = requests.get(f"{base_url}/breachedaccount/{parameter}", headers=headers)
# Handle the response
if response.status_code == 200:
print("Breaches found:")
print(response.json())
return 1 # Parse the JSON response
elif response.status_code == 404:
print("No breaches found for this account.")
return 0
else:
print(f"Error: {response.status_code} - {response.text}")
return -1