2018-10-03 12:22:37 +00:00
|
|
|
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/"
|
|
|
|
|
2018-09-26 17:27:17 +00:00
|
|
|
class Module(ModuleManager.BaseModule):
|
2018-10-03 12:22:37 +00:00
|
|
|
@utils.hook("received.command.beenpwned", min_args=1)
|
2016-03-29 15:20:50 +00:00
|
|
|
def beenpwned(self, event):
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 16:29:09 +00:00
|
|
|
:help: Find out if a username, email or similar has appeared in any
|
|
|
|
hacked databases
|
|
|
|
:usage: <username/email>
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-12-11 22:26:38 +00:00
|
|
|
page = utils.http.request(URL_HAVEIBEENPWNEDAPI % event["args"],
|
2018-10-03 12:22:37 +00:00
|
|
|
json=True, code=True)
|
2016-03-29 15:20:50 +00:00
|
|
|
if page:
|
2018-12-11 22:26:38 +00:00
|
|
|
if page.code == 200:
|
2016-03-29 15:20:50 +00:00
|
|
|
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:
|
2018-10-20 19:51:29 +00:00
|
|
|
raise utils.EventsResultsError()
|