Python Brute Forcer?

时间:2016-02-02 18:12:42

标签: python python-2.7

我心中想到了一种强制密码的方法,但只是一个蟒蛇新手,我不知道从哪里开始...

到目前为止,我有以下内容:

password = "myPaSs123"

ll = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
ul = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
n = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
s = ["!", "@", "#", "$", "%", "^", "&"]
full = ll+ul+n+s
crackedPass = []

def guesser():
    guess = 0
    for i in full:
        for x in range(len(password)):
            if i == password:
                crackedPass.append(i)
                print "Password found: " + str(crackedPass)

guesser()

我现在不知道该怎么办。如果有人对这个话题有一些了解,我会很乐意帮助你。谢谢!

1 个答案:

答案 0 :(得分:-1)

这就是你想要的我相信,问题是我只是给你解答你的问题,我相信你不明白我发布的代码所以让我详细解释一下! 你的代码还可以,但是在阅读这个代码方面我觉得很讨厌你发布的是你想要实现的东西,但是对你想要做的事情有了更多的了解......

  

(1)我们导入函数:itertools,math和os

它们为我们提供了大量的功能,可以在程序中使用... 然后我们有一个很简单的字母表,它包含字母或字符,因为我喜欢称它们,因为它们毕竟是字符。

剩下的由你来决定这不是一个教程,但阅读我给你的东西应该在快乐的编码兄弟/姐妹的背后给出颜色的线条!

import itertools, math
import os
Alphabet = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890") # Add or     remove whatevs you think will be in the password you're cracking (example, [symbols])
counter = 1
CharLength = 1
range_num = int(raw_input("Enter range: "))
stopper = range_num + 1
filename = "bruteforce_%r.txt" % (range_num)
f = open(filename, 'a')
#n_1 = len(Alphabet)
#n_2 = n_1 - 1 # <-- total useless peice of garbage that could of been great in vurtual life
#n_3 = '0' * n_2
#n = '1' + n_3
x = range_num
y = len(Alphabet)
amount = math.pow(y, x)
total_items = math.pow(y, x)
for CharLength in range(range_num, stopper):
    passwords = (itertools.product(Alphabet, repeat = CharLength))

    for i in passwords:
        counter += 1
        percentage = (counter / total_items) * 100
        amount -= 1
        i = str(i)
        i = i.replace("[", "")
        i = i.replace("]", "")
        i = i.replace("'", "")
        i = i.replace(" ", "")
        i = i.replace(",", "")
        i = i.replace("(", "")
        i = i.replace(")", "")
        f.write(i)
        f.write('\n')
        print "Password: %r\tPercentage: %r/100\tAmount left: %r" % (i, int(percentage), amount)
        if i == '0'* range_num:
            print "*Done"
            f.close()
            exit(0)
        else:
            pass