2018-09-24 14:13:27 +00:00
|
|
|
from src import 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(object):
|
2018-09-02 18:54:45 +00:00
|
|
|
def __init__(self, bot, events, exports):
|
2018-09-19 12:25:12 +00:00
|
|
|
events.on("received.command.beenpwned").hook(self.beenpwned,
|
2016-03-29 15:20:50 +00:00
|
|
|
help="Find out if a username, email or similar has appeared "
|
2018-09-19 12:25:12 +00:00
|
|
|
"in any hacked databases", usage="<username/email>", min_args=1)
|
2016-03-29 15:20:50 +00:00
|
|
|
|
|
|
|
def beenpwned(self, event):
|
|
|
|
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")
|