C# 在c语言中强行将字符放入文本框#
我想做一个“测试密码”的程序,看看用基本的暴力攻击破解密码需要多长时间。所以我做了两个文本框。 (C# 在c语言中强行将字符放入文本框#,c#,algorithm,textbox,passwords,brute-force,C#,Algorithm,Textbox,Passwords,Brute Force,我想做一个“测试密码”的程序,看看用基本的暴力攻击破解密码需要多长时间。所以我做了两个文本框。 (textbox1和textbox2)并编写了程序,因此如果文本框有输入,将出现“正确密码”标签,但我想编写程序,以便textbox2将在其中运行暴力算法,当遇到正确密码时,它将停止。我真的需要帮助,若你们能在我的附加代码中加入正确的添加剂,那个就太好了。到目前为止,这个程序非常简单,但是我对这个非常陌生,所以 private void textBox2_TextChanged(object send
textbox1
和textbox2
)并编写了程序,因此如果文本框有输入,将出现“正确密码”标签,但我想编写程序,以便textbox2
将在其中运行暴力算法,当遇到正确密码时,它将停止。我真的需要帮助,若你们能在我的附加代码中加入正确的添加剂,那个就太好了。到目前为止,这个程序非常简单,但是我对这个非常陌生,所以
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox2.Text == textBox1.Text)
{
label1.Text = "Password Correct";
}
else
{
label1.Text = "Password Wrong";
}
}
private void label1_Click(object sender, EventArgs e)
{
}
需要更多的信息;你是在随机猜测密码吗?字典攻击?你是在按顺序猜密码吗?密码中使用的长度/字符集还有哪些其他限制 我将假设您的程序在UI中自动调用这些尝试,而不是您作为用户。如果是这样的话,我会放弃UI策略,转而使用控制台实现
“随机”猜测问题之所以重要,是因为如果您按顺序猜测,所需的时间长度与您选择的密码直接相关。我不确定你想要什么结果。需要更多信息;你是在随机猜测密码吗?字典攻击?你是在按顺序猜密码吗?密码中使用的长度/字符集还有哪些其他限制 我将假设您的程序在UI中自动调用这些尝试,而不是您作为用户。如果是这样的话,我会放弃UI策略,转而使用控制台实现
“随机”猜测问题之所以重要,是因为如果您按顺序猜测,所需的时间长度与您选择的密码直接相关。我不确定你想要什么结果。使用这个简单的暴力类来“破解”你的密码。我已将此处的最大大小设置为3,因此我不必等待太久。如果你有一整天的时间,增加这个
private class BrutePasswordGuesser
{
private const int MaxAscii = 126;
private const int MaxSize = 3;
private const int MinAscii = 33;
private int _currentLength;
public BrutePasswordGuesser()
{
//Init the length, and current guess array.
_currentLength = 0;
CurrentGuess = new char[MaxSize];
CurrentGuess[0] = (char) MinAscii;
}
public char[] CurrentGuess { get; private set; }
public bool NextGuess()
{
if (_currentLength >= MaxSize)
{
return false;
}
//Increment the previous digit (Uses recursion!)
IncrementDigit(_currentLength);
return true;
}
/// <summary>
/// Increment the character at the index by one. If the character is at the maximum
/// ASCII value, set it back to the minimum, and increment the previous character.
/// Use recursion to do this, so that the proggy will step all the way back as needed.
/// If the very bottom of the string is reached, add another character to the guess.
/// </summary>
/// <param name="digitIndex"></param>
private void IncrementDigit(int digitIndex)
{
//Don't fall out the bottom of the array.
//If we're at the bottom of the array, add another character
if (digitIndex < 0)
{
AddCharacter();
}
else
{
//If the current character is max ASCII, set to min ASCII, and increment the previous char.
if (CurrentGuess[digitIndex] == (char) MaxAscii)
{
CurrentGuess[digitIndex] = (char) MinAscii;
IncrementDigit(digitIndex - 1);
}
else
{
CurrentGuess[digitIndex]++;
}
}
}
private void AddCharacter()
{
_currentLength++;
//If we've reached our maximum guess size, leave now and don't come back.
if (_currentLength >= MaxSize)
{
return;
}
//Initialis as min ASCII.
CurrentGuess[_currentLength] = (char) (MinAscii);
}
}
使用这个简单的暴力类来“破解”你的密码。我已将此处的最大大小设置为3,因此我不必等待太久。如果你有一整天的时间,增加这个
private class BrutePasswordGuesser
{
private const int MaxAscii = 126;
private const int MaxSize = 3;
private const int MinAscii = 33;
private int _currentLength;
public BrutePasswordGuesser()
{
//Init the length, and current guess array.
_currentLength = 0;
CurrentGuess = new char[MaxSize];
CurrentGuess[0] = (char) MinAscii;
}
public char[] CurrentGuess { get; private set; }
public bool NextGuess()
{
if (_currentLength >= MaxSize)
{
return false;
}
//Increment the previous digit (Uses recursion!)
IncrementDigit(_currentLength);
return true;
}
/// <summary>
/// Increment the character at the index by one. If the character is at the maximum
/// ASCII value, set it back to the minimum, and increment the previous character.
/// Use recursion to do this, so that the proggy will step all the way back as needed.
/// If the very bottom of the string is reached, add another character to the guess.
/// </summary>
/// <param name="digitIndex"></param>
private void IncrementDigit(int digitIndex)
{
//Don't fall out the bottom of the array.
//If we're at the bottom of the array, add another character
if (digitIndex < 0)
{
AddCharacter();
}
else
{
//If the current character is max ASCII, set to min ASCII, and increment the previous char.
if (CurrentGuess[digitIndex] == (char) MaxAscii)
{
CurrentGuess[digitIndex] = (char) MinAscii;
IncrementDigit(digitIndex - 1);
}
else
{
CurrentGuess[digitIndex]++;
}
}
}
private void AddCharacter()
{
_currentLength++;
//If we've reached our maximum guess size, leave now and don't come back.
if (_currentLength >= MaxSize)
{
return;
}
//Initialis as min ASCII.
CurrentGuess[_currentLength] = (char) (MinAscii);
}
}
已有一些工具可以计算密码强度。为什么您要编写自己的密码,而不是使用其中一个?已有一些工具可以计算密码强度。为什么你要写你自己的而不是使用其中的一个呢?我认为UI部分的出现是因为现在有些人直接从表单和所有这些开始,甚至从来没有意识到他们不需要表单。它是
Console.WriteLine(“你好,世界!”)
然后是windows。有时直接到控制台。WriteLine(“Hello World!”)
,然后是windows。或者有时直接使用MessageBox.Show(“Hello World!”)
:(是的,我陷入了陷阱,不仅使用.C++管理了.NET,而且只是跳入了WiFrm的训练中(C++中,没有先验知识)。我想做一个顺序密码攻击,我知道它完全是针对所选择的密码,但它可能比随机猜测密码更容易,我不知道,所以我想这两种方法都可以,就像我说的,我对这很陌生。只适用于maxsize=4,但我必须将其用于maxsize=14,直到maxsize=4为止,但我必须将其用于maxsize=14