如何打印密码组合(但每个索引都有自定义约束)

编程入门 行业动态 更新时间:2024-10-25 02:20:45
本文介绍了如何打印密码组合(但每个索引都有自定义约束)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试构建动态密码恢复工具.您可以指定密码以及与未知密码索引相对应的未知字符列表.因此,如果您记住90%的密码,并且不记得几个字母,这将为您带来轻巧的暴力. 我可以将用户提供的密码与未知字符列表结合使用;但是,我一直试图打印每个可能的密码.

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.

我被困在这里:

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

现在我需要打印: 杜德123 dude123 8ude123 Dvde123 dvde123 8vde123 ...

Now I need 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.

谢谢您的帮助!

戴夫

推荐答案

您的意思是这样的吗?

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

更多推荐

如何打印密码组合(但每个索引都有自定义约束)

本文发布于:2023-10-25 21:51:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1528207.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:都有   组合   自定义   索引   密码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!