-
Notifications
You must be signed in to change notification settings - Fork 3
/
file_ext_blacklist.go
231 lines (202 loc) · 5.28 KB
/
file_ext_blacklist.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
package dash
import (
"regexp"
)
// I know what you're thinking.
//
// You're thinking: I love amos and all, but he's being kinda dumb right now -
// why not just use a whitelist? You'd put ".exe", ".sh", and a handful of
// others and - voilà! You'd only sniff files that could potentially be
// launchable.
//
// And the terrible truth is: that's what this code was, until a blessed unit
// test reminded me that Linux/macOS binaries can be named *darn well anything*.
// Not just "diceydungeons" but also "Game.x86_64".
//
// And if your whitelist doesn't have ".x86_64", well then you're out of luck,
// aren't you?
//
// So, now, it's a blacklist with the file extensions we're *pretty damn sure*
// aren't executables.
//
// TL;DR - an incomplete whitelist means we miss the thing we need to launch and NOTHING works.
// An incomplete blacklist just slows us down a little, and can always be completed later.
var fileExtBlacklist map[string]struct{} = map[string]struct{}{
// images
".atf": struct{}{}, // adobe texture format
".xcf": struct{}{}, // gimp
".psd": struct{}{}, // photoshop
".ico": struct{}{}, // windows icons
".icns": struct{}{}, // macOS icons
".bmp": struct{}{}, // bitmaps
".tga": struct{}{}, // targa
".png": struct{}{},
".gif": struct{}{},
".jpg": struct{}{},
".jpeg": struct{}{},
// electron
".asar": struct{}{},
// adobe air
".vch": struct{}{},
// audio
".ogg": struct{}{},
".wav": struct{}{},
".mp3": struct{}{},
".vox": struct{}{}, // voice something?
".bnk": struct{}{}, // sound banks?
".snd": struct{}{},
".bfxrsound": struct{}{},
// video
".mp4": struct{}{},
".mpg": struct{}{},
".avi": struct{}{},
".aspx": struct{}{},
// levels
".lvl": struct{}{},
".tmx": struct{}{},
// source files
".tsx": struct{}{},
".ts": struct{}{},
".jsx": struct{}{},
".js": struct{}{},
".is": struct{}{},
".rb": struct{}{},
".go": struct{}{},
".c": struct{}{},
".h": struct{}{},
".c++": struct{}{},
".cxx": struct{}{},
".cpp": struct{}{},
".moon": struct{}{},
".hx": struct{}{},
".vbs": struct{}{},
".pxi": struct{}{},
// java stuff?
".pf": struct{}{},
".jfc": struct{}{},
".template": struct{}{},
".policy": struct{}{},
".access": struct{}{},
".libraries": struct{}{},
".jsa": struct{}{},
".bfc": struct{}{},
".src": struct{}{},
".certs": struct{}{},
".security": struct{}{},
".cpl": struct{}{},
".ja": struct{}{},
".properties": struct{}{},
// python stuff
".py": struct{}{},
".pyo": struct{}{},
".pyd": struct{}{},
".pyx": struct{}{},
".rpy": struct{}{},
".rpyc": struct{}{},
".rpym": struct{}{},
".rpymc": struct{}{},
".egg": struct{}{},
// structured data
".json": struct{}{},
".xml": struct{}{},
".csv": struct{}{},
".manifest": struct{}{},
".data": struct{}{},
// unknown
".pck": struct{}{},
".assets": struct{}{},
".asset": struct{}{},
".sav": struct{}{},
".wem": struct{}{},
".browser": struct{}{},
".resource": struct{}{},
".ress": struct{}{},
".chr": struct{}{},
".rpa": struct{}{},
".pxd": struct{}{},
".exr": struct{}{},
".unityweb": struct{}{},
// debug symbols
".pdb": struct{}{},
".mdb": struct{}{},
// UE4 stuff
".pak": struct{}{},
".uasset": struct{}{},
".uplugin": struct{}{},
".uproject": struct{}{},
".umap": struct{}{},
".res": struct{}{},
".brk": struct{}{},
".nrm": struct{}{},
".tps": struct{}{},
".icu": struct{}{},
".cnv": struct{}{},
".cfu": struct{}{},
".locres": struct{}{},
".sse": struct{}{},
".rnt": struct{}{},
".vis": struct{}{},
".ecm": struct{}{},
".rgb": struct{}{},
".taw": struct{}{},
".caw": struct{}{},
// source engine
".vdf": struct{}{},
".bsp": struct{}{}, // maps
".vmt": struct{}{}, // valve material type
".vmf": struct{}{}, // valve map file
".vtf": struct{}{}, // valve texture format
".nav": struct{}{}, // nav meshes
// libraries
".dll": struct{}{},
".ndll": struct{}{}, // Haxe/Neko stuff
".so": struct{}{},
".dylib": struct{}{},
// fonts
".fnt": struct{}{},
".otf": struct{}{},
".ttf": struct{}{},
".packedfont": struct{}{},
// ?? found in opus magnum
".cso": struct{}{},
// shaders
".glsl": struct{}{},
// ffs @queenjazz
".roobos": struct{}{},
// macOS crap
".ds_store": struct{}{},
".plist": struct{}{},
// databases
".db": struct{}{},
".sql": struct{}{},
".sqlite": struct{}{},
// various
".txt": struct{}{},
".rtf": struct{}{},
".ini": struct{}{},
".conf": struct{}{},
".config": struct{}{},
".cfg": struct{}{},
".dat": struct{}{},
".map": struct{}{},
".out": struct{}{},
".solution": struct{}{},
".info": struct{}{},
// html
".css": struct{}{},
// flash
".swf": struct{}{},
}
var soRegexp = regexp.MustCompile(`(?i)\.so(\.[0-9]+)*$`)
// Note: ext must be lower-case, and include the dot,
// so it could be ".swf", or "" - see the blacklist map definition
func isBlacklistedExt(name string) bool {
if _, ok := fileExtBlacklist[getExt(name)]; ok {
return true
}
if soRegexp.MatchString(name) {
return true
}
// not blacklisted
return false
}