-
Notifications
You must be signed in to change notification settings - Fork 0
/
IISRFBaseline-allowHighBitCharacters-IIS.psm1
102 lines (86 loc) · 2.87 KB
/
IISRFBaseline-allowHighBitCharacters-IIS.psm1
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
function Get-RFLpQueryAllowHighBitCharactersIIS
{
<#
.SYNOPSIS
Creates Logparser query for RF allowHighBitCharacters baseline using IIS logs.
.EXAMPLE
Get-RFLpQueryAllowHighBitCharactersIIS -Sitename W3SVC1 -LogDir D:\inetpub\Logs\ex*.log -OutputDir D:\WorkingFolder\
#>
[CmdletBinding()]
param(
[parameter(Mandatory=$true)]
[System.String]
# IIS Sitename of target website.
$Sitename
,
[parameter(Mandatory=$true)]
[System.String]
# IIS log directory.
$LogDir
,
[parameter(Mandatory=$true)]
[System.String]
# Outut directory for writing files.
$OutputDir
)
$ResultFile = Join-Path -Path $OutputDir -ChildPath 'lp_results_allowHighBitCharacters_IIS.csv'
return @"
--lp_query_allowHighBitCharacters_IIS.sql--
SELECT
date,
time,
c-ip,
cs-host,
sc-status,
sc-substatus,
cs-uri-stem,
URLESCAPE(cs-uri-stem) AS EncodedURL,
cs(User-Agent)
INTO $ResultFile
FROM $LogDir
WHERE
s-sitename LIKE `'$Sitename`'
AND (EncodedURL LIKE '%\%8%' OR
EncodedURL LIKE '%\%9%' OR
EncodedURL LIKE '%\%a%' OR
EncodedURL LIKE '%\%b%' OR
EncodedURL LIKE '%\%c%' OR
EncodedURL LIKE '%\%d%' OR
EncodedURL LIKE '%\%e%' OR
EncodedURL LIKE '%\%f%' OR
(sc-status=404 AND sc-substatus=12))
AND NOT ((sc-status=400 AND sc-substatus=0)
OR (sc-status=404 AND sc-substatus=0))
--lp_query_allowHighBitCharacters_IIS.sql--
"@
} # End function Get-RFLpQueryAllowHighBitCharactersIIS
function New-RFLpFileAllowHighBitCharactersIIS
{
<#
.SYNOPSIS
Creates Logparser file for RF allowHighBitCharacters baseline using IIS logs.
.EXAMPLE
New-RFLpFileAllowHighBitCharactersIIS -Sitename W3SVC1 -LogDir D:\inetpub\Logs\ex*.log -OutputDir D:\WorkingFolder\
#>
[CmdletBinding()]
param(
[parameter(Mandatory=$true)]
[System.String]
# IIS Sitename of target website.
$Sitename
,
[parameter(Mandatory=$true)]
[System.String]
# IIS log directory.
$LogDir
,
[parameter(Mandatory=$true)]
[System.String]
# Outut directory for writing files.
$OutputDir
)
$FileLocation = Join-Path -Path $OutputDir -ChildPath 'lp_query_allowHighBitCharacters_IIS.sql'
Get-RFLpQueryAllowHighBitCharactersIIS -Sitename $Sitename -LogDir $LogDir -OutputDir $OutputDir | Out-File -LiteralPath $FileLocation -Force -Encoding ascii
return $FileLocation
} # End function New-RFLpFileAllowHighBitCharactersIIS
Export-ModuleMember -Function 'Get-RFLpQueryAllowHighBitCharactersIIS','New-RFLpFileAllowHighBitCharactersIIS'