-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExploit.cs
70 lines (60 loc) · 2.3 KB
/
Exploit.cs
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
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
namespace DirbWin
{
internal class Exploit
{
private List<string> riskDirs = null;
private string url = string.Empty;
public delegate void CallBack(object obj);
public delegate void AddRiskCallBack(string dir, int resCode);
public Exploit(List<string> risksDirs, string url)
{
this.riskDirs = risksDirs;
this.url = url;
}
public void StartExploit(AddRiskCallBack addRiskCallBack, CallBack endCallBack)
{
Task task = new Task(new Action(() =>
{
foreach (string item in riskDirs)
{
try
{
using (var client = new HttpClient())
{
var res = client.GetAsync(url + item).Result;
if ((int)res.StatusCode != 404)
{
var responseContent = res.Content;
var code = (int)res.StatusCode;
Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
{
addRiskCallBack(item, (int)res.StatusCode);
}));
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error", "DirbWin", MessageBoxButton.OK, MessageBoxImage.Error);
Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
{
endCallBack(new object());
}));
return;
}
}
Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
{
endCallBack(new object());
}));
}));
task.Start();
}
}
}