/
Tools.go
146 lines (130 loc) · 3.92 KB
/
Tools.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
package module
import (
"crypto/rand"
"encoding/base64"
"encoding/json"
"fmt"
"log"
"os"
"strings"
"github.com/fatih/color"
)
// Colors
var (
blue = color.New(color.FgBlue).SprintFunc()
red = color.New(color.FgRed).SprintFunc()
orange = color.New(color.FgHiRed).SprintFunc()
yellow = color.New(color.FgHiYellow).SprintFunc()
hiblue = color.New(color.FgHiBlue).SprintFunc()
green = color.New(color.FgGreen).SprintFunc()
magenta = color.New(color.FgMagenta).SprintFunc()
)
const (
letterBytes = "abcdPQRSTUVefstuvwxyzABCDEFGHghijklmnopqrIJKLMNOWXYZ"
letterIdxBits = 6 // 6 bits to represent a letter index
letterIdxMask = 1<<letterIdxBits - 1 // All 1-bits, as many as letterIdxBits
replacement = ""
)
// vers
var (
DeveloperModeSet bool
ShowWarnsSet bool
ShowLogsSet bool
apiKey string
replacer = strings.NewReplacer("\n", replacement)
sreplacer = strings.NewReplacer("\r", replacement)
)
// Revnewline removes /r and /n
func Revnewline(s string) string {
s = replacer.Replace(s)
return sreplacer.Replace(s)
}
// Password generator base64
func Password(n int) string {
b := make([]byte, n)
_, err := rand.Read(b)
// Note that err == nil only if we read len(b) bytes.
if err != nil {
log.Fatal(err)
}
v := base64.URLEncoding.EncodeToString(b)
if err != nil {
log.Fatal(err)
}
return v
}
// Save hits function
func Save(message string, filePath string) {
file, err := os.OpenFile(filePath, os.O_APPEND|os.O_WRONLY, 0600)
if err != nil {
log.Fatal("We got error ", err)
}
defer file.Close()
file.WriteString(message + "\n")
file.Close()
}
// Configuration : ProxyFile string, Combolist string, TwoCaptcha string, Invite string, Speed:Threads int
type Configuration struct {
ProxyFile string `json:"ProxiesFile"`
Combolist string `json:"CombolistFile"`
TwoCaptcha string `json:"TwoCaptchaKey"`
Invite string `json:"InviteCode"`
Speed int `json:"Threads"`
ShowWarns bool `json:"ShowWarns"`
DeveloperMode bool `json:"DeveloperMode"`
ShowLogs bool `json:"ShowLogs"`
}
// LoadConfiguration E.g: config.ProxyFile => path/name.txt
func LoadConfiguration(filename string) (Configuration, error) {
var config Configuration
configFile, err := os.Open(filename)
defer configFile.Close()
if err != nil {
return config, err
}
jsonParser := json.NewDecoder(configFile)
err = jsonParser.Decode(&config)
ShowWarnsSet = config.DeveloperMode
DeveloperModeSet = config.DeveloperMode
ShowLogsSet = config.ShowLogs
apiKey = config.TwoCaptcha
return config, err
}
// Log print colorful chars in console
func Log(message string, box string, colorsidkthis string) {
switch colorsidkthis {
case "log":
if ShowLogsSet == true {
fmt.Fprintf(color.Output, "[%s] %s\n", blue("Log"), message)
}
case "warn":
if ShowWarnsSet == true {
fmt.Fprintf(color.Output, "[%s] %s\n", yellow("Warn"), message)
}
case "fatal":
if DeveloperModeSet == true {
fmt.Fprintf(color.Output, "[%s] %s\n", red(box), message)
}
case "bad":
if DeveloperModeSet == true {
fmt.Fprintf(color.Output, "[%s] %s\n", orange(box), message)
}
case "success":
fmt.Fprintf(color.Output, "[%s] %s\n", green(box), message)
case "error":
if DeveloperModeSet == true {
fmt.Fprintf(color.Output, "[%s] %s\n", magenta(box), message)
}
}
}
// Logo func prints acsii art
func Logo() {
art := `
____ _ _ _____ _
| _ \(_)___ ___ ___ _ __ __| | |_ _|__ ___ | |
| | | | / __|/ __/ _ \| '__/ _' | | |/ _ \ / _ \| |
| |_| | \__ \ (_| (_) | | | (_| | | | (_) | (_) | |
|____/|_|___/\___\___/|_| \__,_| |_|\___/ \___/|_|
`
fmt.Fprintf(color.Output, "%s\n\t\t %s %s%s\n\n\n", blue(art), hiblue("Developed by"), blue("@"), orange("Strxngy"))
}