-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttack.cs
More file actions
76 lines (73 loc) · 2.33 KB
/
Attack.cs
File metadata and controls
76 lines (73 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml;
namespace MicroFocus_Scanner
{
class Attack : IAttack
{
public IGenPayload PayloadGenerator;
public string attack_name = "SQL Injection";
public string attack_str;
public Request Request;
public string Response_attack;
public Regex[] Errors;
public Attack(string atk_name, IGenPayload pGenerator, Request request, IErrorLoader errorLoader)
{
this.PayloadGenerator = pGenerator;
this.attack_name = atk_name;
this.Request = request;
this.attack_str = PayloadGenerator.GeneratePayload();
this.Response_attack = "";
this.Errors = errorLoader.load_errors();
}
public string run_attack()
{
this.Inject();
bool success = this.validate_attack();
if (success)
{
return this.generate_success();
}
else
{
return this.generate_error();
}
}
public void Inject()
{
this.Request.modify_request(this.attack_str);
this.Response_attack = this.Request.send_request();
}
public bool validate_attack()
{
if (this.Response_attack == null)
{
Console.WriteLine("Can't Validate, there was not response!");
return false;
}
foreach (Regex rx in this.Errors)
{
Match m = rx.Match(this.Response_attack);
if (m.Success)
{
return true;
}
}
return false;
}
private string generate_error()
{
string err_msg = "Didn't find "+ this.attack_name+" vulnerablitiy for " + this.Request.parsed.Uri.AbsoluteUri;
return err_msg;
}
private string generate_success()
{
string suc_msg = "The target " + this.Request.parsed.Uri.AbsoluteUri + " is vulnerable to " + this.attack_name;
return suc_msg;
}
}
}