From cbd26551fcf9a4558b507f0acc46c30c63faf596 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 29 Oct 2015 03:23:51 +0100 Subject: blacklist a words in /usr/share/dict and /usr/local/share/dict MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- info/passcheck.texinfo | 4 ++++ passcheck.py | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/info/passcheck.texinfo b/info/passcheck.texinfo index ad1c879..90da502 100644 --- a/info/passcheck.texinfo +++ b/info/passcheck.texinfo @@ -98,6 +98,10 @@ the strength of a passphrase: The passphrase is not a commonly use passphrase. Currently a top-1000 list is used. @item +The passphrase is not a word listed in a file +inside either ofthe directory @file{/usr/share/dict/} +abd @file{/usr/local/share/dict/}. +@item The degree to which characters are mixed. @item The classes of used characters. For example non-ASCII diff --git a/passcheck.py b/passcheck.py index 0cfdd32..e8776c8 100755 --- a/passcheck.py +++ b/passcheck.py @@ -19,6 +19,7 @@ # import sys +import os def _class(char): @@ -114,6 +115,17 @@ def evaluate(data): blacklist = None with open('blacklist', 'rb') as file: blacklist = set(file.read().decode('utf-8', 'replace').split('\n')) +for directory in ['/usr/share/dict/', '/usr/local/share/dict/']: + dictionaries = None + try: + dictionaries = os.listdir(directory) + except FileNotFoundError: + pass + if dictionaries is not None: + for dictionary in dictionaries: + if not os.path.isdir(directory + dictionary): + with open(directory + dictionary, 'rb') as file: + blacklist.update(set(file.read().decode('utf-8', 'replace').split('\n'))) raw = ('--raw' in sys.argv[1:]) or ('-r' in sys.argv[1:]) -- cgit v1.2.3-70-g09d2