我是python的新手,但我刚刚创建了一个基本的wordlist生成器,它包含存储在文件中的未知和已知字母数字字符的组合:
textfile = file('passwords.txt', 'wt')
import itertools
numbers = itertools.product('0123456789', repeat=8)
alphanum = itertools.product('0123456789ABCDEF', repeat=4)
for i in numbers:
for c in alphanum:
textfile.write(''.join(i)+'XXXX'+''.join(c)+'\n')
textfile.close()
我得到了这种输出:
"00000000XXXX@@@@"
其中X是数字(已知数字),@是字符和数字的混合。 没关系。但我希望前8个数值改变,它们保持0,而不是0-9。我尝试过一些东西,但没有任何效果......
如何解决这个问题?我做错了什么? 我知道有像crunch和cewl等程序。但我更喜欢开始做我自己的简单脚本并继续学习。
谢谢,对不起,如果这样的事情得到了解答,我找不到我想要的确切内容。
答案 0 :(得分:0)
你的问题是,在第一次循环之后,alphanum会用完/ exhausted。试试这个:
textfile = file('passwords.txt', 'wt')
numbers = itertools.product('0123456789', repeat=8)
for i in numbers:
print ''.join(i)+'XXXX' # notice that this works
alphanum = itertools.product('0123456789ABCDEF', repeat=4)
for c in alphanum:
textfile.write(''.join(i)+'XXXX'+''.join(c)+'\n')
textfile.close()
请注意,这需要很长时间才能完成