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
|
package store
import "fmt"
type IntruderConfig struct {
DelayMs int
StopOnStatus int
MaxRedirects int
FollowRedirects string // "never", "always", "in-scope"
TimeoutMs int
RawRequest string
Payloads string
}
func DefaultIntruderConfig() IntruderConfig {
return IntruderConfig{
DelayMs: 0,
StopOnStatus: 0,
MaxRedirects: 10,
FollowRedirects: "never",
TimeoutMs: 30000,
RawRequest: "",
Payloads: "",
}
}
func (s *Store) LoadIntruderConfig() IntruderConfig {
config := DefaultIntruderConfig()
err := s.db.QueryRow(`
SELECT delay_ms, stop_on_status, max_redirects, follow_redirects, timeout_ms, raw_request, payloads
FROM intruder_config WHERE id = 1`).Scan(
&config.DelayMs,
&config.StopOnStatus,
&config.MaxRedirects,
&config.FollowRedirects,
&config.TimeoutMs,
&config.RawRequest,
&config.Payloads,
)
if err != nil {
return config
}
return config
}
func (s *Store) SaveIntruderConfig(config IntruderConfig) error {
return s.write(func() error {
_, err := s.db.Exec(`
INSERT INTO intruder_config (id, delay_ms, stop_on_status, max_redirects, follow_redirects, timeout_ms, raw_request, payloads)
VALUES (1, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT(id) DO UPDATE SET
delay_ms = excluded.delay_ms,
stop_on_status = excluded.stop_on_status,
max_redirects = excluded.max_redirects,
follow_redirects = excluded.follow_redirects,
timeout_ms = excluded.timeout_ms,
raw_request = excluded.raw_request,
payloads = excluded.payloads`,
config.DelayMs,
config.StopOnStatus,
config.MaxRedirects,
config.FollowRedirects,
config.TimeoutMs,
config.RawRequest,
config.Payloads,
)
if err != nil {
return fmt.Errorf("store: save intruder config: %w", err)
}
return nil
})
}
|