├── .ob
├── README.md
├── capture-20211103-160212.png
├── capture-20211103-160509.png
├── main.go
└── monmind.png
/.ob:
--------------------------------------------------------------------------------
1 | this is secret
2 | this is super secret
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Monmind - obfuscate multiple strings & hide text from binary searching
2 | Obfuscation strings in golang code
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | ## INSTALL
11 |
12 | You can install monmind by running:
13 |
14 | ```
15 | go get github.com/CRYBOII/monmind
16 | ```
17 |
18 |
19 |
20 | ## USAGE
21 |
22 | Once [monmind](https://github.com/CRYBOII/monmind) is installed
23 | go to workspace folder and create .ob file,
24 |
25 | and slap your strings in there on different lines.
26 |
27 | now you can run this command
28 |
29 | ```
30 | monmind
31 | ```
32 |
33 | this should be generate the file `obfuscated.go`
34 | all encoded strings will be contians in that file
35 |
36 | ### Example
37 |
38 | in .ob file
39 | ```
40 | this is secret
41 | this is super secret
42 | ```
43 | when we run `monmind` obfuscated file is generated
44 | ```
45 | package main
46 |
47 | import (
48 | "unsafe"
49 | )
50 |
51 | func eax() uint8 {
52 | return uint8(unsafe.Sizeof(true))
53 | }
54 |
55 | // [ YLM01E5A6 ] ====> this is secret
56 |
57 | func YLM01E5A6() string {
58 | return string(
59 | []byte{
60 | (((eax()< this is super secret
79 |
80 | func YLMEECE42() string {
81 | return string(
82 | []byte{
83 | (((eax()<
125 |
126 |
127 |
128 | #### with obfuscated
129 |
130 |
131 |
132 |
133 |
134 | ## Acknowledgments
135 |
136 | * Thanks [jeromer](https://github.com/jeromer)
137 |
--------------------------------------------------------------------------------
/capture-20211103-160212.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRYBOII/monmind/c3151b398842a23e31516afee8447d12e3591f50/capture-20211103-160212.png
--------------------------------------------------------------------------------
/capture-20211103-160509.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRYBOII/monmind/c3151b398842a23e31516afee8447d12e3591f50/capture-20211103-160509.png
--------------------------------------------------------------------------------
/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "bufio"
5 | "bytes"
6 | ctr "crypto/rand"
7 | "fmt"
8 | "io/ioutil"
9 | "log"
10 | "math/rand"
11 | "os"
12 | "path/filepath"
13 | "strings"
14 | "text/template"
15 | "time"
16 | "unsafe"
17 | )
18 |
19 | var (
20 | Tmp = `
21 | package main
22 | import (
23 | "unsafe"
24 | )
25 | func eax() uint8{
26 | return uint8(unsafe.Sizeof(true))
27 | }
28 |
29 | {{range .Obfuscated}}
30 |
31 | // [ {{index . 2}} ] ====> {{index . 0}}
32 |
33 |
34 | func {{index . 2}}() string {
35 | {{index . 1}}
36 | }
37 |
38 |
39 |
40 |
41 | {{end}}
42 |
43 | `
44 | )
45 |
46 | type TplData struct {
47 | Obfuscated [][]string
48 | }
49 |
50 | const (
51 | EAX = uint8(unsafe.Sizeof(true))
52 | ONE = "eax()"
53 | )
54 |
55 | var letterRunes = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
56 |
57 | func RandStringRunes(n int) string {
58 | b := make([]rune, n)
59 | for i := range b {
60 | b[i] = letterRunes[rand.Intn(len(letterRunes))]
61 | }
62 | return string(b)
63 | }
64 |
65 | func getObTexts() ([]string, error) {
66 |
67 | files, err := ioutil.ReadDir("./")
68 | if err != nil {
69 | log.Fatal(err)
70 | }
71 |
72 | for _, f := range files {
73 |
74 | if f.Name() == ".ob" {
75 | file, err := os.Open("./.ob")
76 | if err != nil {
77 | log.Fatal(err)
78 | }
79 | defer file.Close()
80 |
81 | scanner := bufio.NewScanner(file)
82 | texts := []string{}
83 | for scanner.Scan() {
84 | texts = append(texts, scanner.Text())
85 | }
86 |
87 | if err := scanner.Err(); err != nil {
88 | return nil, fmt.Errorf("cound not read the .ob file")
89 | }
90 | if len(texts) <= 0 {
91 | return nil, fmt.Errorf("make sure .ob file contains atleast 1 line of string ")
92 | }
93 | return texts, nil
94 | }
95 | }
96 |
97 | return nil, fmt.Errorf(".ob file cound not be found in the current directory")
98 |
99 | }
100 |
101 | func Obfuscation(txt string) []string {
102 | rand.Seed(time.Now().UnixNano())
103 | lines := []string{}
104 |
105 | for _, item := range []byte(txt) {
106 | lines = append(
107 | lines, GetNumber(item),
108 | )
109 | }
110 | n := 3
111 | b := make([]byte, n)
112 | if _, err := ctr.Read(b); err != nil {
113 | panic(err)
114 | }
115 | s := fmt.Sprintf("%X", b)
116 | return []string{txt, fmt.Sprintf(
117 | "return string(\n[]byte{\n%s,\n},\n)",
118 | strings.Join(lines, ",\n"),
119 | ), RandStringRunes(3) + s}
120 | }
121 |
122 | func GetNumber(n byte) (buf string) {
123 | var arr []byte
124 | var x uint8
125 |
126 | for n > EAX {
127 | x = 0
128 |
129 | if n%2 == EAX {
130 | x = EAX
131 | }
132 |
133 | arr = append(arr, x)
134 |
135 | n = n >> EAX
136 | }
137 |
138 | buf = ONE
139 |
140 | rand.Seed(
141 | time.Now().Unix(),
142 | )
143 |
144 | for i := len(arr) - 1; i >= 0; i-- {
145 | buf = fmt.Sprintf(
146 | "%s<<%s", buf, ONE,
147 | )
148 |
149 | if arr[i] == EAX {
150 | op := "(%s|%s)"
151 |
152 | if rand.Intn(2) == 0 {
153 | op = "(%s^%s)"
154 | }
155 |
156 | buf = fmt.Sprintf(
157 | op, buf, ONE,
158 | )
159 | }
160 | }
161 |
162 | return buf
163 | }
164 |
165 | func GenerateGoCode(data TplData) string {
166 | tmpl := template.Must(
167 | template.New("x").Parse(Tmp),
168 | )
169 |
170 | w := new(bytes.Buffer)
171 | err := tmpl.Execute(w, data)
172 |
173 | if err != nil {
174 | panic(err)
175 | }
176 |
177 | return w.String()
178 | }
179 |
180 | func main() {
181 | startObfuscation()
182 | }
183 |
184 | func startObfuscation() {
185 |
186 | texts, err := getObTexts()
187 |
188 | if err != nil {
189 | log.Fatal(err)
190 | }
191 | obTexts := [][]string{}
192 |
193 | for _, v := range texts {
194 |
195 | en := Obfuscation(v)
196 | obTexts = append(obTexts, en)
197 |
198 | }
199 | s := GenerateGoCode(
200 | TplData{
201 |
202 | Obfuscated: obTexts,
203 | },
204 | )
205 |
206 | wd, err := os.Getwd()
207 | if err != nil {
208 | panic(err)
209 | }
210 |
211 | err = ioutil.WriteFile(filepath.Join(wd, filepath.Base(fmt.Sprintf("%s.go", "obfuscated"))), []byte(s), 0755)
212 | if err != nil {
213 | fmt.Printf("Unable to write file: %v", err)
214 | }
215 |
216 | }
217 |
--------------------------------------------------------------------------------
/monmind.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRYBOII/monmind/c3151b398842a23e31516afee8447d12e3591f50/monmind.png
--------------------------------------------------------------------------------