-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
100 lines (80 loc) · 2.39 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
package main
import (
"fmt"
"os"
"strconv"
"time"
"github.com/aztecrabbit/brainfuck-tunnel-go/src/libsshclient"
"github.com/aztecrabbit/libinject"
"github.com/aztecrabbit/liblog"
"github.com/aztecrabbit/libproxyrotator"
"github.com/aztecrabbit/libredsocks"
"github.com/aztecrabbit/libutils"
)
const (
appName = "Brainfuck Tunnel"
appVersionName = "Go"
appVersionCode = "1.3.200911"
copyrightYear = "2020"
copyrightAuthor = "Aztec Rabbit"
)
var (
InterruptHandler = new(libutils.InterruptHandler)
Redsocks = new(libredsocks.Redsocks)
)
type Config struct {
ProxyRotator *libproxyrotator.Config
Inject *libinject.Config
SshClientThreads int
SshClient *libsshclient.Config
}
func init() {
InterruptHandler.Handle = func() {
libsshclient.Stop()
libredsocks.Stop(Redsocks)
liblog.LogKeyboardInterrupt()
}
InterruptHandler.Start()
}
func main() {
liblog.Header(
[]string{
fmt.Sprintf("%s [%s Version. %s]", appName, appVersionName, appVersionCode),
fmt.Sprintf("(c) %s %s.", copyrightYear, copyrightAuthor),
},
liblog.Colors["G1"],
)
config := new(Config)
defaultConfig := new(Config)
defaultConfig.ProxyRotator = libproxyrotator.DefaultConfig
defaultConfig.Inject = libinject.DefaultConfig
defaultConfig.SshClientThreads = 4
defaultConfig.SshClient = libsshclient.DefaultConfig
libutils.JsonReadWrite(libutils.RealPath("config.json"), config, defaultConfig)
ProxyRotator := new(libproxyrotator.ProxyRotator)
ProxyRotator.Config = config.ProxyRotator
Inject := new(libinject.Inject)
Inject.Redsocks = Redsocks
Inject.Config = config.Inject
if len(os.Args) > 1 {
Inject.Config.Port = os.Args[1]
}
go ProxyRotator.Start()
go Inject.Start()
time.Sleep(200 * time.Millisecond)
liblog.LogInfo("Proxy Rotator running on port "+ProxyRotator.Config.Port, "INFO", liblog.Colors["G1"])
liblog.LogInfo("Inject running on port "+Inject.Config.Port, "INFO", liblog.Colors["G1"])
Redsocks.Config = libredsocks.DefaultConfig
Redsocks.Start()
for i := 1; i <= config.SshClientThreads; i++ {
SshClient := new(libsshclient.SshClient)
SshClient.ProxyRotator = ProxyRotator
SshClient.Config = config.SshClient
SshClient.InjectPort = Inject.Config.Port
SshClient.ListenPort = strconv.Itoa(libutils.Atoi(ProxyRotator.Config.Port) + i)
SshClient.Verbose = false
SshClient.Loop = true
go SshClient.Start()
}
InterruptHandler.Wait()
}