-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod_Common.go
162 lines (150 loc) · 5.49 KB
/
mod_Common.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package main
import (
"bytes"
"crypto/sha256"
"encoding/hex"
"io"
"io/ioutil"
"log"
"os"
"strings"
"golang.org/x/text/encoding/charmap"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
)
func isError(err error) bool {
if err != nil {
log.Println(err.Error())
}
return (err != nil)
}
func containsIpas(ipaArr []Ipa, ipa Ipa) bool {
for _, a := range ipaArr {
if a.SHA256 == ipa.SHA256 {
return true
}
}
return false
}
// MakeNetworkPath make network path from local path
func MakeNetworkPath(server string, directory string) string {
path := strings.Replace("\\\\"+server+"\\"+directory, ":", "$", -1)
return path
}
// Convert - convert executable output
func Convert(i int, s []byte) string {
var reader *transform.Reader
switch i {
case 1:
reader = transform.NewReader(bytes.NewReader(s), charmap.ISO8859_1.NewDecoder())
case 2:
reader = transform.NewReader(bytes.NewReader(s), charmap.ISO8859_2.NewDecoder())
case 3:
reader = transform.NewReader(bytes.NewReader(s), charmap.ISO8859_3.NewDecoder())
case 4:
reader = transform.NewReader(bytes.NewReader(s), charmap.ISO8859_4.NewDecoder())
case 5:
reader = transform.NewReader(bytes.NewReader(s), charmap.ISO8859_5.NewDecoder())
case 6:
reader = transform.NewReader(bytes.NewReader(s), charmap.ISO8859_6.NewDecoder())
case 7:
reader = transform.NewReader(bytes.NewReader(s), charmap.ISO8859_7.NewDecoder())
case 8:
reader = transform.NewReader(bytes.NewReader(s), charmap.ISO8859_8.NewDecoder())
case 9:
reader = transform.NewReader(bytes.NewReader(s), charmap.ISO8859_9.NewDecoder())
case 10:
reader = transform.NewReader(bytes.NewReader(s), charmap.ISO8859_10.NewDecoder())
case 11:
reader = transform.NewReader(bytes.NewReader(s), charmap.ISO8859_13.NewDecoder())
case 12:
reader = transform.NewReader(bytes.NewReader(s), charmap.ISO8859_14.NewDecoder())
case 13:
reader = transform.NewReader(bytes.NewReader(s), charmap.ISO8859_15.NewDecoder())
case 14:
reader = transform.NewReader(bytes.NewReader(s), charmap.ISO8859_16.NewDecoder())
case 15:
reader = transform.NewReader(bytes.NewReader(s), charmap.KOI8R.NewDecoder())
case 16:
reader = transform.NewReader(bytes.NewReader(s), charmap.KOI8U.NewDecoder())
case 17:
reader = transform.NewReader(bytes.NewReader(s), charmap.Macintosh.NewDecoder())
case 18:
reader = transform.NewReader(bytes.NewReader(s), charmap.MacintoshCyrillic.NewDecoder())
case 19:
reader = transform.NewReader(bytes.NewReader(s), charmap.Windows874.NewDecoder())
case 20:
reader = transform.NewReader(bytes.NewReader(s), charmap.Windows1250.NewDecoder())
case 21:
reader = transform.NewReader(bytes.NewReader(s), charmap.Windows1251.NewDecoder())
case 22:
reader = transform.NewReader(bytes.NewReader(s), charmap.Windows1252.NewDecoder())
case 23:
reader = transform.NewReader(bytes.NewReader(s), charmap.Windows1253.NewDecoder())
case 24:
reader = transform.NewReader(bytes.NewReader(s), charmap.Windows1254.NewDecoder())
case 25:
reader = transform.NewReader(bytes.NewReader(s), charmap.Windows1255.NewDecoder())
case 26:
reader = transform.NewReader(bytes.NewReader(s), charmap.Windows1256.NewDecoder())
case 27:
reader = transform.NewReader(bytes.NewReader(s), charmap.Windows1257.NewDecoder())
case 28:
reader = transform.NewReader(bytes.NewReader(s), charmap.Windows1258.NewDecoder())
case 29:
reader = transform.NewReader(bytes.NewReader(s), charmap.XUserDefined.NewDecoder())
case 30:
reader = transform.NewReader(bytes.NewReader(s), charmap.CodePage037.NewDecoder())
case 31:
reader = transform.NewReader(bytes.NewReader(s), charmap.CodePage437.NewDecoder())
case 32:
reader = transform.NewReader(bytes.NewReader(s), charmap.CodePage850.NewDecoder())
case 33:
reader = transform.NewReader(bytes.NewReader(s), charmap.CodePage852.NewDecoder())
case 34:
reader = transform.NewReader(bytes.NewReader(s), charmap.CodePage855.NewDecoder())
case 35:
reader = transform.NewReader(bytes.NewReader(s), charmap.CodePage858.NewDecoder())
case 36:
reader = transform.NewReader(bytes.NewReader(s), charmap.CodePage860.NewDecoder())
case 37:
reader = transform.NewReader(bytes.NewReader(s), charmap.CodePage862.NewDecoder())
case 38:
reader = transform.NewReader(bytes.NewReader(s), charmap.CodePage863.NewDecoder())
case 39:
reader = transform.NewReader(bytes.NewReader(s), charmap.CodePage865.NewDecoder())
case 40:
reader = transform.NewReader(bytes.NewReader(s), charmap.CodePage865.NewDecoder())
case 41:
reader = transform.NewReader(bytes.NewReader(s), charmap.CodePage866.NewDecoder())
case 42:
reader = transform.NewReader(bytes.NewReader(s), charmap.CodePage1047.NewDecoder())
case 43:
reader = transform.NewReader(bytes.NewReader(s), charmap.CodePage1140.NewDecoder())
case 44:
reader = transform.NewReader(bytes.NewReader(s), simplifiedchinese.GBK.NewEncoder())
case 45:
reader = transform.NewReader(bytes.NewReader(s), simplifiedchinese.HZGB2312.NewEncoder())
case 46:
reader = transform.NewReader(bytes.NewReader(s), simplifiedchinese.GB18030.NewEncoder())
}
d, _ := ioutil.ReadAll(reader)
return string(d)
}
func getSHA256(filePath string) string {
f, err := os.Open(filePath)
if err != nil {
log.Fatal(err)
}
defer f.Close()
h := sha256.New()
if _, err := io.Copy(h, f); err != nil {
log.Fatal(err)
}
return hex.EncodeToString(h.Sum(nil))
}
/*
func getIpasRoot() string {
return fmt.Sprintf("%s/ipa/", cfg.Service.Url, ipa.CFBundleName, ipa.CFBundleShortVersionString, ipa.CFBundleVersion, "fileName")
}
*/