蛮力算法

时间:2012-12-19 21:01:52

标签: algorithm cryptography brute-force

没有特别的原因,除了我在密码学和计算方面很有意思,我想用Java或Visual Basic或C#制作我自己的暴力程序,看看它是否可以破解密码。我对性能不感兴趣,我知道这是一种完全不切实际的方法 - 说实话,这只是一个有趣的项目。但是,我脑子里只有一个粗略的想法,我甚至无法将其放入伪代码中。我最熟悉Java,但即使有人能为我提供一个很棒的伪代码!

我不想为程序提供长度,但我会提供最大长度。我知道该程序将需要做很多工作,但我也认为我过度思考它。

4 个答案:

答案 0 :(得分:0)

你要做的第一件事是找出你想要暴​​力的东西。我会选择一种单向散列方案,例如MD5或SHA-1,可以高速率强制使用。在选择了想要“破解”的单向散列方案后,您将需要找到某种密码列表,例如http://www.whatsmypass.com/the-top-500-worst-passwords-of-all-time。获得列表后,您需要散列值并将其存储在某处。拥有此存储的“真实”数据集后,您将创建强力循环并进行比较。找到匹配项后,输出匹配项。你现在已经通过蛮力“破解”了一个假人密码。祝好运!

答案 1 :(得分:0)

好的,所以我刚刚找到了一个我想用C ++做的例子,并且我已经设法将它转换为以下Visual Basic .NET代码,它完美地运行。然而,输出似乎有点慢,我认为该程序将使用接近100%的处理能力,但事实并非如此。有人可以告诉我为什么会这样,我怎么可以改变它?

Public Class Form1
    Dim chars() As Char = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYX".ToCharArray
    Dim csize As Integer = chars.Length - 1
    Dim upto As String
    Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
        upto = "                                                  "

        Dim max_length As Integer = 50

        For i = 1 To max_length
            bf_recursion(0, i)
            Update()
        Next

    End Sub

    Private Sub bf_recursion(ByVal index As Integer, ByVal depth As Integer)
        Dim current() As Char = upto.ToCharArray()

        For i = 0 To csize
            current(index) = chars(i)
            upto = CStr(current)

            Console.WriteLine(CStr(current))
            '\\lblOutput.Text = CStr(current)

            If index <> (depth - 1) Then
                bf_recursion(index + 1, depth)
            End If
        Next
    End Sub
End Class

答案 2 :(得分:0)

while (true) 
{

 string[] mystring = new string[27];
                    mystring[0] = "";
                    mystring[1] = "a";
                    mystring[2] = "b";
                    mystring[3] = "c";
                    mystring[4] = "d";
                    mystring[5] = "e";
                    mystring[6] = "f";
                    mystring[7] = "g";
                    mystring[8] = "h";
                    mystring[9] = "i";
                    mystring[10] = "j";
                    mystring[11] = "k";
                    mystring[12] = "l";
                    mystring[13] = "m";
                    mystring[14] = "n";
                    mystring[15] = "o";
                    mystring[16] = "p";
                    mystring[17] = "q";
                    mystring[18] = "r";
                    mystring[19] = "s";
                    mystring[20] = "t";
                    mystring[21] = "u";
                    mystring[22] = "v";
                    mystring[23] = "w";
                    mystring[24] = "x";
                    mystring[25] = "y";
                    mystring[26] = "z";



                    if (counter == 27)
                    {
                        counter = 0;
                        counter2++;
                    }

                    if (counter2 == 27)
                    {
                        counter2 = 0;
                        counter3++;
                    }

                    if (counter3 == 27)
                    {
                        counter3 = 0;
                        counter4++;
                    }

                    if (counter4 == 27)
                    {
                        counter4 = 0;
                        counter5++;
                    }

                    if (counter5 == 27)
                    {
                        counter5 = 0;
                        counter6++;
                    }

                    if (counter6 == 27)
                    {
                        throw new Exception();
                    }



                    guessedpassword =  mystring[counter6] + mystring[counter5] + mystring[counter4] + mystring[counter3] + mystring[counter2] + mystring[counter];


                    counter++;
    }

这是我写的一些代码。破解效率非常低,但很简单。

答案 3 :(得分:0)

Hasan-G:是的,我可以

Dim chars() As Char = "1234567890abcdefghijklmnopqrstuvwxyz".ToCharArray
    Dim csize As Integer = chars.Length - 1
    Dim upto As String
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        upto = "                                                  "

        Dim max_length As Integer = 25

        For i = 1 To max_length
            bf_recursion(0, i)
            Update()
        Next

    End Sub

    Private Sub bf_recursion(ByVal index As Integer, ByVal depth As Integer)
        Dim current() As Char = upto.ToCharArray()

        For i = 0 To csize
            current(index) = chars(i)
            upto = CStr(current)

            TextBox1.Text = (CStr(current))
            TextBox1.Refresh()
            Me.Refresh()
            '\\lblOutput.Text = CStr(current)

            If index <> (depth - 1) Then
                bf_recursion(index + 1, depth)
            End If
        Next
    End Sub
相关问题