-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
111 lines (96 loc) · 1.89 KB
/
main.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
package core
import (
"sync"
"time"
"github.com/The-Cracker-Technology/fiesta/pkg/httpipe"
"github.com/The-Cracker-Technology/fiesta/pkg/tlsrelay"
)
const (
wildcard = "§1§"
)
// Core type is ...
type Core struct {
// Servers
pipe httpipe.Server
relay tlsrelay.TLSRelay
// Heuristic Parameters
minSize int
connN int
timeout time.Duration
timeoutConn time.Duration
// Status parameters
attack uint8
option map[string]string
running bool
mtx sync.Mutex
charset []string
// Output channels
out chan string
error chan error
status chan string
result chan string
}
// Exploit function...
func (c *Core) Exploit() (chan string, chan string, chan string, chan error) {
// Set default parameters
c.minSize = 0
c.connN = 0
c.timeout = time.Second * 4
c.timeoutConn = time.Millisecond * 100
// Prepare output
c.mtx.Lock()
if c.out == nil {
c.out = make(chan string, 100)
}
if c.error == nil {
c.error = make(chan error, 10)
}
if c.status == nil {
c.status = make(chan string, 100)
}
if c.result == nil {
c.result = make(chan string, 100)
}
c.running = true
c.mtx.Unlock()
go c.exploit()
return c.status, c.out, c.result, c.error
}
// Break function stop the execution of Exploit function
func (c *Core) Break() {
// exit if already stoped
if !c.running {
return
}
// set state to not running
c.mtx.Lock()
c.running = false
c.mtx.Unlock()
// clean status and error channels
for len(c.status) > 0 {
<-c.status
}
for len(c.error) > 0 {
<-c.error
}
// stop services
c.status <- "Shutdown Control HTTP server"
c.pipe.StopBackground()
c.status <- "Shutdown TLS Relay server"
c.relay.Stop()
// close output channel, force to continue
c.mtx.Lock()
if c.out != nil {
close(c.out)
c.out = nil
}
if c.status != nil {
close(c.status)
c.status = nil
}
if c.error != nil {
close(c.error)
c.error = nil
}
c.mtx.Unlock()
}