add argparser, add template for checking email adress against leak database
This commit is contained in:
parent
8ef0bd785c
commit
c500bdfe9e
1
Pipfile
1
Pipfile
@ -8,6 +8,7 @@ verify_ssl = true
|
||||
[packages]
|
||||
requests = "*"
|
||||
pyinstaller = "*"
|
||||
argparse = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.7"
|
||||
|
11
Pipfile.lock
generated
11
Pipfile.lock
generated
@ -1,7 +1,7 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "38e2af2d59158d85bb4d55eb3140a0745c9eb21635643df4b2192cdd0abc2074"
|
||||
"sha256": "72f7b87a032a3c10cfa8b0914121403db30a4f3582386cce2f516a1b7f897b42"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
@ -23,6 +23,14 @@
|
||||
],
|
||||
"version": "==0.16.1"
|
||||
},
|
||||
"argparse": {
|
||||
"hashes": [
|
||||
"sha256:62b089a55be1d8949cd2bc7e0df0bddb9e028faefc8c32038cc84862aefdd6e4",
|
||||
"sha256:c31647edb69fd3d465a847ea3157d37bed1f95f19760b11a47aa91c04b666314"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.4.0"
|
||||
},
|
||||
"certifi": {
|
||||
"hashes": [
|
||||
"sha256:59b7658e26ca9c7339e00f8f4636cdfe59d34fa37b9b04f6f9e9926b3cece1a5",
|
||||
@ -39,7 +47,6 @@
|
||||
},
|
||||
"future": {
|
||||
"hashes": [
|
||||
"sha256:1d73b8a1aab19cb8c2c961ba82bf93860e1fb7d361be21e7288691c068cd3cfc",
|
||||
"sha256:67045236dcfd6816dc439556d009594abf643e5eb48992e36beac09c2ca659b8"
|
||||
],
|
||||
"version": "==0.17.1"
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
|
||||
from sys import argv, stdout, exit
|
||||
from argparse import ArgumentParser
|
||||
from hashlib import sha1
|
||||
from getpass import getpass
|
||||
from requests import get
|
||||
@ -40,22 +41,57 @@ ROW = '{:<30}{:<10}{:<45}'
|
||||
HIDDEN = False
|
||||
|
||||
|
||||
parser = ArgumentParser(description='Check if your email or password appears in a data leak.')
|
||||
parser.add_argument('-m', '-mail', '--mail',
|
||||
metavar='foo@adress.bar',
|
||||
nargs='+',
|
||||
help='Email address which should be checked against the leak database.'
|
||||
)
|
||||
parser.add_argument('-p', '-password', '--password',
|
||||
metavar='password',
|
||||
nargs='+',
|
||||
help='Password which should be checked against the leak database.'
|
||||
)
|
||||
args = parser.parse_args()
|
||||
print(args)
|
||||
|
||||
|
||||
|
||||
def header():
|
||||
print()
|
||||
print(ROW.format('password', 'leaked', 'sha1'))
|
||||
print('-' * 80)
|
||||
|
||||
|
||||
def prompt_password_or_mail():
|
||||
print()
|
||||
while True:
|
||||
choice = input('Do you wannt to check a password [p] or an email adress [e]: ')
|
||||
if choice == 'p':
|
||||
prompt_password()
|
||||
elif choice == 'e':
|
||||
prompt_mail()
|
||||
|
||||
|
||||
def prompt_password():
|
||||
print()
|
||||
password = getpass('Tell me your password: ')
|
||||
global HIDDEN
|
||||
HIDDEN = True
|
||||
header()
|
||||
query(password)
|
||||
query_password(password)
|
||||
|
||||
|
||||
def query(password):
|
||||
def prompt_mail():
|
||||
print()
|
||||
mail = input('Tell me your mail adress: ')
|
||||
global HIDDEN
|
||||
HIDDEN = True
|
||||
header()
|
||||
query_mail(mail)
|
||||
|
||||
|
||||
def query_password(password):
|
||||
password_hash = sha1(password.encode('UTF-8')).hexdigest().upper()
|
||||
request = password_hash[:5]
|
||||
response = get(API + request).text
|
||||
@ -79,15 +115,22 @@ def query(password):
|
||||
stdout.write(RESET)
|
||||
|
||||
if HIDDEN:
|
||||
prompt_password()
|
||||
prompt_password_or_mail()
|
||||
|
||||
|
||||
def query_mail(mail):
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(argv) < 2:
|
||||
prompt_password()
|
||||
else:
|
||||
if args.password:
|
||||
header()
|
||||
for password in argv[1:]:
|
||||
query(password)
|
||||
for password in args.password:
|
||||
query_password(password)
|
||||
elif args.mail:
|
||||
for mail in args.mail:
|
||||
query_mail(mail)
|
||||
else:
|
||||
prompt_password_or_mail()
|
||||
print()
|
||||
exit(0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user