我正在尝试构建一个动态密码恢复工具。您可以指定密码和与未知密码索引相对应的未知字符列表。所以,如果你记住了90%的密码,却记不住几个字母,这对你来说将是一种轻量的暴力。我能够将用户提供的密码与未知字符列表相结合;然而,我一直在努力打印每一个潜在的密码。
我被困在这里:
password = 'Dude123'
charList = ['d8','vV','','D8','','','']
finalString = [''.join(set((a, b))) for a, b in zip(password, charList)]
print(finalString) #This statement yields the following
['Dd8', 'uv^', 'd', 'eD8', '1', '2', '3']
现在我需要打印:Dudd123哑弹1238ude123Dvde123dvde1238vde123…
或者类似的东西(它没有按任何特定顺序循环字符,我只需要一个所有可能组合的列表
谢谢你的帮助!
Dave
你的意思是这样的吗?
>>> import itertools
>>>
>>> password = 'Dude123'
>>> charList = ['d8','vV','','D8','','','']
>>>
>>> finalString = [''.join(set((a, b))) for a, b in zip(password, charList)]
>>>
>>> possibles = list(''.join(poss) for poss in itertools.product(*finalString))
>>> possibles
['Dude123', 'DudD123', 'Dud8123', 'Dvde123', 'DvdD123', 'Dvd8123', 'DVde123', 'DVdD123', 'DVd8123', 'dude123', 'dudD123', 'dud8123', 'dvde123', 'dvdD123', 'dvd8123', 'dVde123', 'dVdD123', 'dVd8123', '8ude123', '8udD123', '8ud8123', '8vde123', '8vdD123', '8vd8123', '8Vde123', '8VdD123', '8Vd8123']