-
Notifications
You must be signed in to change notification settings - Fork 9
/
modDatabaseHandling.bas
187 lines (163 loc) · 9.91 KB
/
modDatabaseHandling.bas
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
Attribute VB_Name = "modDatabaseHandling"
Option Explicit
Public Const APP_TESTNAME_ATTACKREQUEST As String = "attack_request"
Public Const APP_TESTNAME_DELETEEXISTING As String = "delete_existing"
Public Const APP_TESTNAME_GETEXISTING As String = "get_existing"
Public Const APP_TESTNAME_GETLONG As String = "get_long"
Public Const APP_TESTNAME_GETNONEXISTING As String = "get_nonexisting"
Public Const APP_TESTNAME_HEADEXISTING As String = "head_existing"
Public Const APP_TESTNAME_OPTIONS As String = "options"
Public Const APP_TESTNAME_WRONGMETHOD As String = "wrong_method"
Public Const APP_TESTNAME_WRONGVERSION As String = "wrong_version"
Public app_dir_databases As String
Public app_dir_attackrequest As String
Public app_dir_deleteexisting As String
Public app_dir_getexisting As String
Public app_dir_getlong As String
Public app_dir_getnonexisting As String
Public app_dir_headexisting As String
Public app_dir_options As String
Public app_dir_wrongmethod As String
Public app_dir_wrongversion As String
Public app_file_banner As String
Public app_file_xpoweredby As String
Public app_file_protocolname As String
Public app_file_protocolversion As String
Public app_file_statuscode As String
Public app_file_statustext As String
Public app_file_headerspace As String
Public app_file_headercapitalafterdash As String
Public app_file_headerorder As String
Public app_file_optionsallowed As String
Public app_file_optionspublic As String
Public app_file_optionsdelimiter As String
Public app_file_etaglength As String
Public app_file_etagquotes As String
Public app_file_contenttype As String
Public app_file_acceptrange As String
Public app_file_connection As String
Public app_file_cachecontrol As String
Public app_file_pragma As String
Public app_file_varyorder As String
Public app_file_varycapitalize As String
Public app_file_varydelimiter As String
Public app_file_htaccessrealm As String
Public Sub InitializeDirectories()
Call ChangeStatusBar("Initialize Directories...")
app_dir_databases = App.Path & "\database\"
app_dir_attackrequest = app_dir_databases & APP_TESTNAME_ATTACKREQUEST & "\"
app_dir_deleteexisting = app_dir_databases & APP_TESTNAME_DELETEEXISTING & "\"
app_dir_getexisting = app_dir_databases & APP_TESTNAME_GETEXISTING & "\"
app_dir_getlong = app_dir_databases & APP_TESTNAME_GETLONG & "\"
app_dir_getnonexisting = app_dir_databases & APP_TESTNAME_GETNONEXISTING & "\"
app_dir_headexisting = app_dir_databases & APP_TESTNAME_HEADEXISTING & "\"
app_dir_options = app_dir_databases & APP_TESTNAME_OPTIONS & "\"
app_dir_wrongmethod = app_dir_databases & APP_TESTNAME_WRONGMETHOD & "\"
app_dir_wrongversion = app_dir_databases & APP_TESTNAME_WRONGVERSION & "\"
Call ChangeStatusBarDone
End Sub
Public Sub InitializeFiles()
Call ChangeStatusBar("Initialize Files...")
Const sExtension As String = ".fdb"
app_file_banner = "banner" & sExtension
app_file_protocolname = "protocol-name" & sExtension
app_file_protocolversion = "protocol-version" & sExtension
app_file_statuscode = "statuscode" & sExtension
app_file_statustext = "statustext" & sExtension
app_file_headerspace = "header-space" & sExtension
app_file_headercapitalafterdash = "header-capitalafterdash" & sExtension
app_file_headerorder = "header-order" & sExtension
app_file_optionsallowed = "options-allowed" & sExtension
app_file_optionspublic = "options-public" & sExtension
app_file_optionsdelimiter = "options-delimited" & sExtension
app_file_etaglength = "etag-length" & sExtension
app_file_etagquotes = "etag-quotes" & sExtension
app_file_contenttype = "content-type" & sExtension
app_file_acceptrange = "accept-range" & sExtension
app_file_connection = "connection" & sExtension
app_file_cachecontrol = "cache-control" & sExtension
app_file_pragma = "pragma" & sExtension
app_file_varyorder = "vary-order" & sExtension
app_file_varycapitalize = "vary-capitalize" & sExtension
app_file_varydelimiter = "vary-delimiter" & sExtension
app_file_xpoweredby = "x-powered-by" & sExtension
app_file_htaccessrealm = "htaccess-realm" & sExtension
Call ChangeStatusBarDone
End Sub
Public Sub SaveAllFingerprintsToDatabase(ByRef sImplementationName As String, ByRef sDatabasePath As String, ByRef sOriginalResponse As String)
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_banner, sImplementationName, GetBanner(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_xpoweredby, sImplementationName, GetXPoweredBy(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_protocolname, sImplementationName, GetProtocolName(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_protocolversion, sImplementationName, GetProtocolVersion(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_statuscode, sImplementationName, GetStatusCode(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_statustext, sImplementationName, GetStatusText(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_headerspace, sImplementationName, GetHeaderSpace(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_headercapitalafterdash, sImplementationName, GetHeaderCapitalAfterDash(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_headerorder, sImplementationName, GetHeaderOrder(sOriginalResponse, vbNullString))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_optionsallowed, sImplementationName, GetOptionsAllowed(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_optionspublic, sImplementationName, GetOptionsPublic(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_optionsdelimiter, sImplementationName, GetOptionsDelimiter(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_etaglength, sImplementationName, GetEtagLength(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_etagquotes, sImplementationName, GetEtagQuotes(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_contenttype, sImplementationName, GetContentType(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_acceptrange, sImplementationName, GetAcceptRange(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_connection, sImplementationName, GetConnection(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_cachecontrol, sImplementationName, GetCacheControl(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_pragma, sImplementationName, GetPragma(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_varyorder, sImplementationName, GetVaryOrder(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_varycapitalize, sImplementationName, GetVaryCapitalized(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_varydelimiter, sImplementationName, GetVaryDelimiter(sOriginalResponse))
Call SaveNewFingerprintToDatabase(sDatabasePath & app_file_htaccessrealm, sImplementationName, GetHtaccessRealm(sOriginalResponse))
End Sub
Public Sub SaveAllFingerprintsToAllDatabases(ByRef sImplementationName As String)
Call ChangeStatusBar("Save All Fingerprints to Database...")
Call SaveAllFingerprintsToDatabase(sImplementationName, app_dir_attackrequest, response_attackrequest)
Call SaveAllFingerprintsToDatabase(sImplementationName, app_dir_deleteexisting, response_delete)
Call SaveAllFingerprintsToDatabase(sImplementationName, app_dir_getexisting, response_getexist)
Call SaveAllFingerprintsToDatabase(sImplementationName, app_dir_getlong, response_getlongrequest)
Call SaveAllFingerprintsToDatabase(sImplementationName, app_dir_getnonexisting, response_get_nonexistent)
Call SaveAllFingerprintsToDatabase(sImplementationName, app_dir_headexisting, response_head)
Call SaveAllFingerprintsToDatabase(sImplementationName, app_dir_options, response_options)
Call SaveAllFingerprintsToDatabase(sImplementationName, app_dir_wrongmethod, response_testmethod)
Call SaveAllFingerprintsToDatabase(sImplementationName, app_dir_wrongversion, response_protocolversion)
Call ChangeStatusBarDone
End Sub
Public Sub SaveNewFingerprintToDatabase(ByRef sFileName As String, ByRef sImplementationName As String, ByRef sFingerprintValue As String)
Dim sNewEntry As String
If (Dir$(sFileName, 16) <> "") Then
If (LenB(sFingerprintValue)) Then
If (LenB(sImplementationName)) Then
sNewEntry = sImplementationName & ";" & sFingerprintValue
If (IsAlreadyInDatabase(sFileName, sNewEntry) = False) Then
Open sFileName For Append As #1
Print #1, sNewEntry
Close
End If
End If
End If
End If
End Sub
Public Function IsAlreadyInDatabase(ByRef sDatabase As String, ByRef sNewEntry As String) As Boolean
Dim sDatabaseContent As String
sDatabaseContent = ReadFile(sDatabase)
If (InStrB(1, sDatabaseContent, sNewEntry, vbBinaryCompare)) Then
IsAlreadyInDatabase = True
Else
IsAlreadyInDatabase = False
End If
End Function
Public Function ReadFile(ByRef sFileName As String) As String
Dim sFileContent As String
If (Dir$(sFileName, 16) <> "") Then
Open sFileName For Input As #1
sFileContent = Input(LOF(1), #1)
Close
End If
ReadFile = sFileContent
End Function
Public Sub SaveFingerprints(ByRef sImplementationName As String)
If (LenB(sImplementationName)) Then
Call SaveAllFingerprintsToAllDatabases(sImplementationName)
Call AnalyzeFingerprintsAndShowResult
End If
End Sub