From 068f0832f795793ec2a4305a226bffaad40893a1 Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Wed, 13 Mar 2019 01:31:23 +0000 Subject: [PATCH] Support reading passwords from standard input --- README.md | 9 ++++++++- pwned.py | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5832155..0cfe926 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,13 @@ Pwned Password API lookup 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! diff --git a/pwned.py b/pwned.py index c63703d..057dfef 100644 --- a/pwned.py +++ b/pwned.py @@ -18,7 +18,8 @@ def lookup_pwned_api(pwd): def main(args): - for pwd in args: + for pwd in args or sys.stdin: + pwd = pwd.strip() api_return = lookup_pwned_api(pwd) if (api_return): print(pwd, "was found")