开发者

How to print password combination (but with custom constraints for each index)

开发者 https://www.devze.com 2023-03-11 11:53 出处:网络
I am trying to build a dynamic password recovery tool. You can specify a password, and an unknown character list which correspond to unknown password indexes. So, if you remember 90% of your password,

I am trying to build a dynamic password recovery tool. You can specify a password, and an unknown character list which correspond to unknown password indexes. So, if you remember 90% of your password, and can't remember a few letters, this will do a light weight brute force for you. I am able to combine the user supplied password with an unknown character list; however, I am stuck trying to print every potential password.

I am stuck here:

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']

Now I need 开发者_JS百科to print: Dude123 dude123 8ude123 Dvde123 dvde123 8vde123 ...

or something to that effect (it doesn't have loop through the characters in any particular order, I just need a list of all the possible combinations.

Thank you for any help!

Dave


Do you mean something like this?

>>> 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']
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号