-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.go
258 lines (222 loc) · 6.1 KB
/
app.go
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
package main
import (
"GoInjection/backend/helper"
"GoInjection/backend/injections"
"GoInjection/backend/injections/blind"
helper2 "GoInjection/backend/injections/helper"
"GoInjection/backend/modules"
"GoInjection/backend/structs"
"context"
"strconv"
"strings"
)
type App struct {
ctx context.Context
}
func NewApp() *App {
return &App{}
}
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
}
// SetTarget Input: (string: Option) (string: Value)
func (a *App) SetTarget(option string, value string) {
switch option {
case "url":
structs.TargetURL = value
break
case "dbms":
structs.TargetDBMS = value
break
case "syntax":
structs.TargetSyntax = value
break
case "columns":
target, _ := strconv.Atoi(value)
structs.TargetColumns = target
break
case "database":
structs.TargetDatabaseName = value
break
}
}
// GetTarget Input: (string: Option)
//
// GetTarget Returns: (string: Value)
func (a *App) GetTarget(option string) string {
switch option {
case "url":
return structs.TargetURL
case "dbms":
return structs.TargetDBMS
case "syntax":
return structs.TargetSyntax
case "columns":
return strconv.Itoa(structs.TargetColumns)
case "database":
return structs.TargetDatabaseName
case "union":
return strconv.FormatBool(structs.TargetUnion)
case "error":
return strconv.FormatBool(structs.TargetError)
case "boolean":
return strconv.FormatBool(structs.TargetBoolean)
case "time":
return strconv.FormatBool(structs.TargetTime)
case "unionLinks":
return strconv.Itoa(structs.UnionLinks)
case "errorLinks":
return strconv.Itoa(structs.ErrorLinks)
case "booleanLinks":
return strconv.Itoa(structs.BooleanLinks)
case "timeLinks":
return strconv.Itoa(structs.TimeLinks)
case "fingerprintLinks":
return strconv.Itoa(structs.FingerprintLinks)
case "wafLinks":
return strconv.Itoa(structs.WAFLinks)
}
return ""
}
func CheckVariables(vars interface{}) bool {
switch v := vars.(type) {
case string:
return v == ""
case int:
return v == 0
default:
return false
}
}
// CheckWAF Needs: -/-
//
// CheckWAF Returns: (string: Url, string: Detection)
func (a *App) CheckWAF() map[string]string {
helper.LogLine("Function called.")
cleanedURLs, err := helper.GetUrls(structs.TargetURL)
helper.LogError(err)
for _, cleanedURL := range cleanedURLs {
isWaf, wafType := modules.DetectWAF(cleanedURL, structs.TargetURL)
cleanedURL = helper.ExtractDomain(cleanedURL)
isWafParsed, _ := strconv.ParseBool(isWaf)
helper.LogLine("URL: " + cleanedURL)
helper.LogLine("WAF: " + strconv.FormatBool(isWafParsed))
helper.LogLine("WAF Type: " + wafType)
return map[string]string{
"isWaf": isWaf,
"wafType": wafType,
"domain": cleanedURL,
}
}
return map[string]string{
"isWaf": "",
"wafType": "",
"domain": "",
}
}
// Fingerprint Needs: structs.TargetColumns
//
// Fingerprint Returns: (string: Url, string: DBMS)
//
// Fingerprint Input: (string: Method)
func (a *App) Fingerprint(method string) map[string]string {
helper.LogLine("Function called.")
cleanedURLs, err := helper.GetUrls(structs.TargetURL)
helper.LogError(err)
for _, cleanedURL := range cleanedURLs {
detectedDB := modules.FingerprintDB(cleanedURL, method)
cleanedURL = helper.ExtractDomain(cleanedURL)
helper.LogLine("URL: " + cleanedURL)
helper.LogLine("DBMS: " + detectedDB)
structs.TargetDBMS = detectedDB
return map[string]string{
"dbms": detectedDB,
"domain": cleanedURL,
}
}
return map[string]string{
"dbms": "",
"domain": "",
}
}
// Interpreter Needs: structs.TargetDBMS
//
// Interpreter Returns: (string: DBMS)
func (a *App) Interpreter() string {
if CheckVariables(structs.TargetDBMS) {
return ""
}
helper.LogLine("Function called.")
structs.TargetSyntax = strings.ReplaceAll(helper2.Interpreter(structs.TargetDBMS), " (default)", "")
helper.LogLine("DBMS: " + structs.TargetDBMS)
helper.LogLine("Syntax: " + structs.TargetSyntax)
return structs.TargetSyntax
}
// Resolver Needs: -/-
//
// Resolver Returns: (string: Columns, string: Database Name)
func (a *App) Resolver() map[string]string {
helper.LogLine("Function called.")
cleanedURLs, err := helper.GetUrls(structs.TargetURL)
helper.LogError(err)
for _, cleanedURL := range cleanedURLs {
_, structs.TargetColumns = helper2.GetColumnCount(cleanedURL)
_, structs.TargetDatabaseName = helper2.GetDatabase(cleanedURL, structs.TargetColumns)
cleanedURL = helper.ExtractDomain(cleanedURL)
helper.LogLine("URL:" + cleanedURL)
helper.LogLine("Columns: " + strconv.Itoa(structs.TargetColumns))
helper.LogLine("Database: " + structs.TargetDatabaseName)
return map[string]string{
"domain": cleanedURL,
"columns": strconv.Itoa(structs.TargetColumns),
"database": structs.TargetDatabaseName,
}
}
return map[string]string{
"domain": "",
"columns": "",
"database": "",
}
}
// Injection Needs: structs.TargetURL, structs.TargetColumns, structs.TargetSyntax
//
// Injection Returns: (string: Domain, string: Bool, string: Result)
//
// Injection Input: (string: Method)
func (a *App) Injection(method string) map[string]string {
if CheckVariables(structs.TargetURL) || CheckVariables(structs.TargetColumns) || CheckVariables(structs.TargetSyntax) {
return map[string]string{
"domain": "",
"bool": "",
"result": "",
}
}
var injectionFunc func(string) (bool, string)
switch method {
case "union":
injectionFunc = injections.UnionInjection
case "error":
injectionFunc = injections.ErrorInjection
case "time":
injectionFunc = blind.TimeBasedInjection
case "boolean":
injectionFunc = blind.BooleanBasedInjection
default:
return map[string]string{
"domain": "",
"bool": "",
"result": "",
}
}
injectionBool, injectionResult := injectionFunc(structs.TargetURL)
cleanedURL := helper.ExtractDomain(structs.TargetURL)
helper.LogLine("URL: " + cleanedURL)
helper.LogLine("Injection:" + injectionResult)
helper.LogLine("Injection Bool: " + strconv.FormatBool(injectionBool))
helper.LogLine("Injection Method: " + method)
return map[string]string{
"domain": cleanedURL,
"bool": strconv.FormatBool(injectionBool),
"result": injectionResult,
}
}