我正在尝试在 python 中解析一个 pwdump 文件。pwdump 文件的内容如下所示:
...[snip]
Domain\TESTIN$::aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
Guest(current):501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
Guest(hist_01):501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
Guest(hist_02):501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
...[snip]
我想从中得到两件事:
Domain\USER (So first string before the ":")
和实际的哈希:
"aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0"
我在想这样的事情:
import sys
infile, outfile = sys.argv[1], sys.argv[2]
with open(infile) as inf, open(outfile,"w") as outf:
line_words = (line.split('::') for line in inf)
outf.writelines(words[1].strip() + '\n' for words in line_words if len(words)>1)
但不知何故,我只解析了第一个哈希。
任何帮助将不胜感激 !
谢谢