Skip to content

Commit 0f7fc54

Browse files
committed
[ADDED]: GoNot Tool
1 parent 5471f33 commit 0f7fc54

3 files changed

Lines changed: 161 additions & 0 deletions

File tree

GoNot/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# GoNot - Enhanced "Have I Been Pwned" Checker
2+
GoNot is a Python script that interacts with the "Have I Been Pwned" API to check if email addresses or domains have been involved in data breaches. This enhanced version of the script includes optimized code, improved features, and enhanced efficiency.
3+
4+
## Features
5+
- Check breach status for a specific email address.
6+
- Check breach status for a specific domain.
7+
- Get detailed information about a specific breach.
8+
- Fetch and display dump data for breached email addresses.
9+
## Requirements
10+
- Python 3.x
11+
- requests library (pip install requests)
12+
- html2text library (pip install html2text)
13+
## Usage
14+
Run the script with appropriate command-line arguments to utilize its features.
15+
16+
```
17+
python3 gonot.py -e <email_address>
18+
python3 gonot.py -e <email_address> -d <domain>
19+
python3 gonot.py -b <breach_name>
20+
```
21+
- -e or --email: Check breach status for a specific email address.
22+
- -d or --domain: Check breach status for a specific domain.
23+
- -b or --breach: Get detailed information about a specific breach.
24+
25+
# API Key
26+
To use the script, replace the API_KEY variable in the script with your actual Have I Been Pwned API key. If you don't have an API key, you can obtain one by visiting Have I Been Pwned API Key
27+
28+
# Output
29+
The script provides clear and formatted output regarding the breach status and relevant information for email addresses and domains. It also displays dump data for breached email addresses, if available.
30+

GoNot/gonot.py

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/usr/bin/env python3
2+
3+
import requests
4+
import argparse
5+
from time import time, sleep
6+
from json import loads
7+
from html2text import html2text
8+
9+
API_BASE_URL = "https://haveibeenpwned.com/api/v3"
10+
API_KEY = "" # Your API Key
11+
12+
R = '\033[31m' # red
13+
G = '\033[32m' # green
14+
C = '\033[36m' # cyan
15+
W = '\033[0m' # white
16+
Y = '\033[33m' # yellow
17+
18+
version = '1.3.0.1'
19+
20+
response_codes = {
21+
200: "OK",
22+
400: "Bad request",
23+
401: "Unauthorised",
24+
403: "Forbidden",
25+
404: "Not Pwned",
26+
429: "Too many requests",
27+
503: "Service unavailable",
28+
}
29+
30+
def banner():
31+
banner_text = r'''
32+
______ _ __ __
33+
/ ____/___ / | / /___ / /_
34+
/ / __/ __ \ / |/ / __ \/ __/
35+
/ /_/ / /_/ // /| / /_/ / /_
36+
\____/\____//_/ |_/\____/\__/
37+
'''
38+
print(G + banner_text + W)
39+
print(f'{G}[>]{C} Created by : {W}thewhiteh4t')
40+
print(f'{G}[>]{C} Version : {W}{version}\n')
41+
42+
def get_api_headers():
43+
headers = {'User-Agent': 'pwnedOrNot', 'hibp-api-key': API_KEY}
44+
return headers
45+
46+
def check_breach(email):
47+
url = f"{API_BASE_URL}/breachedaccount/{email}"
48+
headers = get_api_headers()
49+
50+
response = requests.get(url, headers=headers, params={'truncateResponse': 'false'})
51+
return response
52+
53+
def check_domain_breach(email, domain):
54+
url = f"{API_BASE_URL}/breachedaccount/{email}?domain={domain}"
55+
headers = get_api_headers()
56+
57+
response = requests.get(url, headers=headers, params={'truncateResponse': 'false'})
58+
return response
59+
60+
def get_breach_info(breach_name):
61+
url = f"{API_BASE_URL}/breach/{breach_name}"
62+
headers = get_api_headers()
63+
64+
response = requests.get(url, headers=headers)
65+
return response
66+
67+
def get_paste_account(email):
68+
url = f"{API_BASE_URL}/pasteaccount/{email}"
69+
headers = get_api_headers()
70+
71+
response = requests.get(url, headers=headers)
72+
return response
73+
74+
def print_breach_info(breach_data):
75+
print(f'{G}[+] {C}Breach : {W}{breach_data["Title"]}')
76+
print(f'{G}[+] {C}Domain : {W}{breach_data["Domain"]}')
77+
print(f'{G}[+] {C}Date : {W}{breach_data["BreachDate"]}')
78+
print(f'{G}[+] {C}Pwn Count : {W}{breach_data["PwnCount"]}')
79+
print(f'{G}[+] {C}Fabricated : {W}{breach_data["IsFabricated"]}')
80+
print(f'{G}[+] {C}Verified : {W}{breach_data["IsVerified"]}')
81+
print(f'{G}[+] {C}Retired : {W}{breach_data["IsRetired"]}')
82+
print(f'{G}[+] {C}Spam : {W}{breach_data["IsSpamList"]}')
83+
print(f'{G}[+] {C}Data Types : {W}{", ".join(breach_data["DataClasses"])}')
84+
print(f'{G}[+] {C}Description : {W}{html2text(breach_data["Description"])}')
85+
86+
def main():
87+
banner()
88+
89+
parser = argparse.ArgumentParser(description="Check email or domain against Have I Been Pwned database.")
90+
parser.add_argument("-e", "--email", help="Email address to check")
91+
parser.add_argument("-d", "--domain", help="Domain name to filter breaches")
92+
parser.add_argument("-b", "--breach", help="Get information about a breach")
93+
args = parser.parse_args()
94+
95+
if args.breach:
96+
response = get_breach_info(args.breach)
97+
if response.status_code == 200:
98+
breach_data = response.json()
99+
print_breach_info(breach_data)
100+
else:
101+
print(f'{R}[-] {C}Error: {W}{response_codes.get(response.status_code, "Unknown error")}')
102+
103+
elif args.email:
104+
if args.domain:
105+
response = check_domain_breach(args.email, args.domain)
106+
else:
107+
response = check_breach(args.email)
108+
109+
if response.status_code == 200:
110+
breach_data = response.json()
111+
print_breach_info(breach_data)
112+
if args.email:
113+
paste_response = get_paste_account(args.email)
114+
if paste_response.status_code == 200:
115+
paste_data = paste_response.json()
116+
print(f'\n{G}[+] {C}Dumps Found:{W}')
117+
for paste in paste_data:
118+
print(f'{G}[+] {W}{paste["Id"]}')
119+
elif paste_response.status_code == 404:
120+
print(f'{G}[+] {C}No dumps found for {W}{args.email}')
121+
else:
122+
print(f'{R}[-] {C}Error fetching paste data: {W}{paste_response.status_code}')
123+
elif response.status_code == 404:
124+
print(f'{G}[+] {C}No breaches found for {W}{args.email}')
125+
else:
126+
print(f'{R}[-] {C}Error: {W}{response_codes.get(response.status_code, "Unknown error")}')
127+
128+
if __name__ == "__main__":
129+
main()

GoNot/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
requests
2+
html2text

0 commit comments

Comments
 (0)