-
Notifications
You must be signed in to change notification settings - Fork 1
/
IDSModule.cs
59 lines (47 loc) · 1.67 KB
/
IDSModule.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
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Configuration;
using System.Text.RegularExpressions;
namespace DOTNETIDS
{
class IDSModule : IHttpModule
{
#region IHttpModule Members
public void Dispose()
{
}
public void Init(HttpApplication context)
{
//Hook the BeginRequest event
//context.BeginRequest += new EventHandler(ids_BeginRequest);
context.PreRequestHandlerExecute += new EventHandler(ids_BeginRequest);
}
void ids_BeginRequest(object sender, EventArgs e)
{
//Attempt to read the app's config
IDSGlobalSettings ims = (IDSGlobalSettings)ConfigurationSettings.GetConfig("dotnetids/idsconfig");
string filename = System.IO.Path.GetFileName(HttpContext.Current.Request.Url.AbsolutePath).ToLowerInvariant();
//Look for regex options to exclude
foreach (RegexSettings rs in ims.ExcludedRegexen)
{
RegexOptions ro = new RegexOptions();
if (rs.IgnoreCase)
{
ro = ro | RegexOptions.IgnoreCase;
}
if (Regex.IsMatch(HttpContext.Current.Request.Url.AbsolutePath, rs.Pattern, ro)) return;
}
//Look for pages to exclude
foreach (string s in ims.ExcludedPages)
{
if (s.ToLowerInvariant() == filename) return;
}
//Run the scanner
WebScanRunner sr = new WebScanRunner(ims);
sr.Run();
}
#endregion
}
}