forked from safe6Sec/GolangBypassAV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.go
49 lines (41 loc) · 926 Bytes
/
util.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
package encry
import (
"encoding/hex"
"fmt"
"io/ioutil"
"strconv"
"strings"
)
func Convert(data string) []byte {
shellcodeHex, _ := hex.DecodeString(strings.ReplaceAll(strings.ReplaceAll(data, "\n", ""), "\\x", ""))
return shellcodeHex
}
func Parse(data string) string {
var result string
isArr := strings.Contains(data, ",")
if isArr {
context := strings.Split(data, ",")
size := len(context)
dataArr := make([]byte, size)
for i, v := range context {
val, _ := strconv.Atoi(v)
dataArr[i] = byte(val)
}
result = hex.EncodeToString([]byte(dataArr))
fmt.Println(result)
} else {
val, _ := strconv.Atoi(data)
data := make([]byte, 1)
data[0] = byte(val)
result = hex.EncodeToString([]byte(data))
fmt.Println(result)
}
return result
}
func ReadFile(data string) []byte {
b, err := ioutil.ReadFile(data) // just pass the file name
if err != nil {
fmt.Print(err)
}
return b
}