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-10-03 12:22:37 +00:00
|
|
|
page = utils.http.get_url(URL_HAVEIBEENPWNEDAPI % event["args"],
|
|
|
|
json=True, code=True)
|
2016-03-29 15:20:50 +00:00
|
|
|
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")
|