bitbot-3.11-fork/modules/haveibeenpwned.py

27 lines
996 B
Python
Raw Normal View History

from src import ModuleManager, Utils
2016-03-29 15:20:50 +00:00
URL_HAVEIBEENPWNEDAPI = "https://haveibeenpwned.com/api/v2/breachedaccount/%s"
URL_HAVEIBEENPWNED = "https://haveibeenpwned.com/"
class Module(ModuleManager.BaseModule):
@Utils.hook("received.command.beenpwned", usage="<username/email>",
min_args=1)
2016-03-29 15:20:50 +00:00
def beenpwned(self, event):
"""
Find out if a username, email or similar has appeared in any
hacked databases
"""
2016-03-29 15:20:50 +00:00
page = Utils.get_url(URL_HAVEIBEENPWNEDAPI % event["args"], json=True,
code=True)
if page:
code, page = page
if code == 200:
event["stdout"].write(
"It seems '%s' has been pwned. check on %s." % (event["args"],
URL_HAVEIBEENPWNED))
else:
event["stdout"].write("It seems '%s' has not been pwned" % (
event["args"]))
else:
event["stderr"].write("Failed to load results")