Support reading passwords from standard input

This commit is contained in:
Michal Nazarewicz 2019-03-13 01:31:23 +00:00
parent 366b730905
commit 068f0832f7
2 changed files with 10 additions and 2 deletions

View File

@ -3,6 +3,13 @@ Pwned Password API lookup
Usage: Usage:
python pwned.py [password] * `python pwned.py` reads passwords from standard input;
* `pytohn pwned.py <[file-with-passwords]` reads passwords from
a file;
* `another-command | pytohn pwned.py <[file-with-passwords]` reads
passwords written to standard output by another command;
* `python pwned.py [password]` checks passwords given as command line
arguments (beware the password may be saved in shell history and that
other users on the system ma be able to observe the command line).
Have fun! Oh, and if you find one of your own passwords, change it asap! Have fun! Oh, and if you find one of your own passwords, change it asap!

View File

@ -18,7 +18,8 @@ def lookup_pwned_api(pwd):
def main(args): def main(args):
for pwd in args: for pwd in args or sys.stdin:
pwd = pwd.strip()
api_return = lookup_pwned_api(pwd) api_return = lookup_pwned_api(pwd)
if (api_return): if (api_return):
print(pwd, "was found") print(pwd, "was found")