Skip to content

Commit

Permalink
Fix encoding in both python2 and python3
Browse files Browse the repository at this point in the history
  • Loading branch information
rbsec committed Mar 15, 2019
1 parent ed4b2d2 commit 87783fa
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pwdumpstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import print_function

import argparse
import io
import platform
import re
import os
Expand Down Expand Up @@ -105,12 +106,12 @@ def mask(s):
enterpriseadmins = []

if args.filter_file:
with open(args.filter_file) as infile:
with io.open(args.filter_file, encoding="utf8", errors='replace') as infile:
for line in infile:
line = line.rstrip()
filterlist.add(line)
try:
with open(pot_path, encoding="utf8", errors='replace') as potfile:
with io.open(pot_path, encoding="utf8", errors='replace') as potfile:
hashregex = re.compile('(^(\$NT\$)?([a-fA-F0-9]{32}):(.*)$)')
for line in potfile:
line = line.rstrip()
Expand All @@ -129,7 +130,7 @@ def mask(s):


for filename in args.files:
with open(filename) as userfile:
with io.open(filename, encoding="utf8", errors='replace') as userfile:
for line in userfile:
if not args.disabled:
if "Disabled=1" in line or "Disabled=True" in line or ",Expired=True" in line:
Expand Down

0 comments on commit 87783fa

Please sign in to comment.