• <legend id='ZLrxe'><style id='ZLrxe'><dir id='ZLrxe'><q id='ZLrxe'></q></dir></style></legend>
    <tfoot id='ZLrxe'></tfoot>
    <i id='ZLrxe'><tr id='ZLrxe'><dt id='ZLrxe'><q id='ZLrxe'><span id='ZLrxe'><b id='ZLrxe'><form id='ZLrxe'><ins id='ZLrxe'></ins><ul id='ZLrxe'></ul><sub id='ZLrxe'></sub></form><legend id='ZLrxe'></legend><bdo id='ZLrxe'><pre id='ZLrxe'><center id='ZLrxe'></center></pre></bdo></b><th id='ZLrxe'></th></span></q></dt></tr></i><div id='ZLrxe'><tfoot id='ZLrxe'></tfoot><dl id='ZLrxe'><fieldset id='ZLrxe'></fieldset></dl></div>

      1. <small id='ZLrxe'></small><noframes id='ZLrxe'>

          <bdo id='ZLrxe'></bdo><ul id='ZLrxe'></ul>

        Python 3.2 中的蛮力脚本

        Brute force script in Python 3.2(Python 3.2 中的蛮力脚本)
        • <bdo id='mfH61'></bdo><ul id='mfH61'></ul>

            <legend id='mfH61'><style id='mfH61'><dir id='mfH61'><q id='mfH61'></q></dir></style></legend>
          1. <tfoot id='mfH61'></tfoot>
              <tbody id='mfH61'></tbody>
            • <i id='mfH61'><tr id='mfH61'><dt id='mfH61'><q id='mfH61'><span id='mfH61'><b id='mfH61'><form id='mfH61'><ins id='mfH61'></ins><ul id='mfH61'></ul><sub id='mfH61'></sub></form><legend id='mfH61'></legend><bdo id='mfH61'><pre id='mfH61'><center id='mfH61'></center></pre></bdo></b><th id='mfH61'></th></span></q></dt></tr></i><div id='mfH61'><tfoot id='mfH61'></tfoot><dl id='mfH61'><fieldset id='mfH61'></fieldset></dl></div>

                  <small id='mfH61'></small><noframes id='mfH61'>

                  本文介绍了Python 3.2 中的蛮力脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是编写代码的初学者,我从 Python 开始,因为它似乎是最简洁和最容易开始的(我目前有 Python 3.2).现在我已经阅读了一些关于 python 编码的在线书籍等,我已经制作了一些小程序,仅此而已.

                  I'm a beginner in writing code and I've started with Python because it seemed the neatest and the easiest to start with (I currently have Python 3.2). Now I've read some online books and so on about coding in python, I've made some small programs and that's it.

                  但后来我想制作一个可以暴力破解随机密码的程序,例如:

                  But then I wanted to make a program that could brute-force a random password like:

                  PassWord = random.randint(0,9999)
                  

                  我做了一些可以尝试随机密码的东西:

                  I made something that could try random passwords:

                  import random
                  PassWord = str(random.randint(0,9999))
                  Trial = ' '
                  while Trial != PassWord:
                      Trial = str(random.randint(0,9999))
                      print(Trial)
                      if Trial == PassWord:
                          print('The password is: '+PassWord)
                          input()
                  

                  但这并不是真正的暴力攻击,它更多的是尝试随机猜测密码.我认为蛮力攻击是首先用 1 位数字尝试所有可能性,然后是 2、3 等等.但我不知道如何做到这一点.

                  But that's not really a brute-force attack, it's more trying to randomly guess a password. I think a Brute-Force attack is first tries all possibility's with 1 digit then 2, 3 and so on. But I have no clue and knowledge how to do this.

                  如果有人能说出如何创建一个程序,该程序首先检查 1 位数字的所有可能性,如果可能,以正确的顺序(0、1、2、3 等),然后是 2、3 和4 位数.

                  I would really appreciate if someone would say how to create a program that first checks all possibilities with 1 digit and if possible, in the right order (0,1,2,3 and so on), then 2,3 and 4 digits.

                  然后我可以解决它,并了解有关 Python 的更多信息.

                  Then I could work around on it, and learn more about Python.

                  推荐答案

                  代码优先:

                  from itertools import product
                  
                  chars = '0123456789' # chars to look for
                  
                  for length in range(1, 3): # only do lengths of 1 + 2
                      to_attempt = product(chars, repeat=length)
                      for attempt in to_attempt:
                          print(''.join(attempt))
                  

                  itertools.product 生成其输入的笛卡尔连接 - 在这种情况下,它被连接"到自身.所以在第一次迭代中,每一个字符都会被打印出来.然后在下一次迭代中,因为repeat=length(而length现在==2),生成了'00'、'01'等……值得尝试并查看输出以更好地理解它.

                  itertools.product produces a Cartesian join of its input(s) - in this case, it's being 'joined' to itself. So in the first iteration, each single character is printed. Then in the next iteration, because of repeat=length (and length is now == 2), generates '00', '01', etc... It's worth trying it and seeing the output to understand it better.

                  这也意味着您可以输入字母(大写/小写),并在 range 函数中更改上限.

                  This also means you can throw in letters (uppercase/lowercase), and change the upperbound in the range function.

                  它肯定不会打破代码破解的世界,但应该让您了解 Python 的灵活性和可用的工具.

                  It's certainly not going to break the world of code-breaking, but should give you an idea of the flexibility of Python and the tools available to you.

                  我会让你检查密码是否匹配并打破循环.

                  I'll leave you to check the passwords match and break out the loop.

                  这篇关于Python 3.2 中的蛮力脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                1. <legend id='8gTXH'><style id='8gTXH'><dir id='8gTXH'><q id='8gTXH'></q></dir></style></legend>
                  <tfoot id='8gTXH'></tfoot>

                      <tbody id='8gTXH'></tbody>
                        • <bdo id='8gTXH'></bdo><ul id='8gTXH'></ul>

                          <small id='8gTXH'></small><noframes id='8gTXH'>

                          • <i id='8gTXH'><tr id='8gTXH'><dt id='8gTXH'><q id='8gTXH'><span id='8gTXH'><b id='8gTXH'><form id='8gTXH'><ins id='8gTXH'></ins><ul id='8gTXH'></ul><sub id='8gTXH'></sub></form><legend id='8gTXH'></legend><bdo id='8gTXH'><pre id='8gTXH'><center id='8gTXH'></center></pre></bdo></b><th id='8gTXH'></th></span></q></dt></tr></i><div id='8gTXH'><tfoot id='8gTXH'></tfoot><dl id='8gTXH'><fieldset id='8gTXH'></fieldset></dl></div>