蛮力攻击项目

Bruteforce Attack Project

本文关键字:项目 攻击      更新时间:2023-10-16

我正在为一个项目(与学校无关)创建一个简单的"暴力攻击"。谁能告诉我代码的哪一部分是错误的,得到这些错误。

代码:

#include <string>
using namespace std;
//Password array
std::string passwordArray;
//Lowercare character array
std::string lower = { "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" };
//Uppercase character array
std::string upper = { "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" };
//Digits array
std::string digits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
private void setupCharArray()
{
   if (ckhLower.Checked)
{
   characterArray.AddRange(lower);
}
if (chkUpper.Checked)
{
  characterArray.AddRange(upper);
}
if (chkDigits.Checked)
{
  characterArray.AddRange(digits);
}
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
  brute();
}

所以我尝试使用MinGW

编译这段代码

g++ bruteforce.cpp -o bruteforce.exe

我得到了这些错误信息
c:UsersLotty PlayleDocuments>g++ bruteforce.cpp -o bruteforce.exe
bruteforce.cpp:7:66: error: in C++98 'lower' must be initialized by constructor,
not by '{...}'
bruteforce.cpp:7:66: error: could not convert '{"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"}' from '<brace-enclosed initializer list>' to 'std::string {aka
std::basic_string<char>}'
bruteforce.cpp:10:66: error: in C++98 'upper' must be initialized by constructor
, not by '{...}'
bruteforce.cpp:10:66: error: could not convert '{"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"}' from '<brace-enclosed initializer list>' to 'std::string {ak
a std::basic_string<char>}'
bruteforce.cpp:12:73: error: in C++98 'digits' must be initialized by constructo
r, not by '{...}'
bruteforce.cpp:12:73: error: could not convert '{"0", "1", "2", "3", "4", "5", "
6", "7", "8", "9"}' from '<brace-enclosed initializer list>' to 'std::string {ak
a std::basic_string<char>}'
 bruteforce.cpp:14:1: error: expected unqualified-id before 'private'

如果有人知道我做错了什么,请告诉我。

L x

字符串数组应该是这样的:(与[])

std::string lower[] = { "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" };

字符的std::string看起来像这样:

std::string lower = "abcdefghijklmnopqrstuvwxyz";

请注意,使用一堆std::string s来表示字符是非常低效的。您应该使用字符数组,或者只使用ascii算术。