I am not able to scan a file containing the EICAR (Standard File for Anti-Virus Scanning) characters, because it contains escape characters such as "\", "()", "[]". I need help identifying these characters in my program as being normal inside a string, like other common ones like "a", "b", "1", "2", and so on. Here is the code below:
string[] Lista = new string[] { "X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"};
string dir = @"C:\Program Files (x86)";
private void btnScan_Click(object sender, EventArgs e)
{
List<string> busca= Directory.GetFiles(dir, "*.dll*", SearchOption.AllDirectories).ToList();
foreach (string item in busca)
{
StreamReader stream = new StreamReader(item);
string ler = stream.ReadToEnd();
foreach (string st in Lista)
{
if (Regex.IsMatch(ler, st))
{
btnDelete.Visible = true;
btnQuarentena.Visible = true;
}
}
}
}
I have tried to put EICAR string in this way, but it did not work:
string[] Lista = new string[] { @"X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"};
Visual Studio always returns me the same escape sequence error, affected by the "\", "[]" and "()" characters.