-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
379 lines (351 loc) · 12 KB
/
Makefile
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# NOTE: Reusing the TEMP_FILE after removing it is insecure (multiple
# foo.tar.bz2 targets, i.e. ``make all''). The ``-u'' option is even worse. --
# But do we really care?
TEMP_FILE := $(shell mktemp -u ./XXXXXXXXX)
TARCAT = ./util/tarcat
SUBDIRS = gzip_vim filetype.vim filetype.vim.updated tarplugin tarplugin.updated tarplugin.v2 zipplugin zipplugin.v2 netrw netrw.v2 netrw.v3 netrw.v4 netrw.v5 xpm.vim shellescape
# Lame name!
BACKUPDIR = backups
VIM_VERSION = $(shell vim --version | sed -n '1s/[^0-9]*\([^ ]*\).*/Vim version \1/p;2s/Included/, included/p' | tr -d '\n'; echo )
ZIPVIM_VERSION = $(shell make -sC zipplugin zipvim_version_print )
FILETYPEVIM_VERSION = $(shell make -sC filetype.vim.updated filetypevim_version_print )
NETRW_VERSION = $(shell make -sC netrw.v5 plugin_version_print )
# Author's email address
MY_EMAIL = [email protected]
.PHONY: dist
dist: vulnerablevim.tar.bz2
# test_vim_version -- Print vim version
.PHONY: test_vim_version
test_vim_version:
printf '%s\n' "$(VIM_VERSION)"
# Send a hash of the distributed files to be signed by the stamper service -- thereby proving we are indeed the authors of said
.PHONY: stamper
stamper: dist
mkdir -p $(BACKUPDIR)
timestamped="vulnerablevim-`date -Iseconds|tr -d :`.tar.bz2"; \
: XXX We should really create the file in a safe manner; \
test -e $(BACKUPDIR)/"$$timestamped" && exit 1; \
cp vulnerablevim.tar.bz2 $(BACKUPDIR)/"$$timestamped"; \
( cd $(BACKUPDIR); openssl sha1 "$$timestamped" ) \
| mail -r $(MY_EMAIL) -s "$$timestamped hash" -c $(MY_EMAIL) \
.PHONY: test
test:
# TODO: Should be split amongst the individual Makefiles in the individual
# subdirectories
: Magic numbers in the inline comments are corresponding advisory
: sections.
\
results=-------------------------------------------; \
results="`printf '%s\n%s' "$$results" "-------- Test results below ---------------"`"; \
results="`printf '%s\n%s' "$$results" "-------------------------------------------"`"; \
: Version info; \
results="`printf '%s\n%s' "$$results" "$(VIM_VERSION)"`"; \
results="`printf '%s\n%s' "$$results" "filetype.vim revision date: $(FILETYPEVIM_VERSION)"`"; \
results="`printf '%s\n%s' "$$results" "zip.vim version: $(ZIPVIM_VERSION)"`"; \
results="`printf '%s\n%s' "$$results" "netrw.vim version: $(NETRW_VERSION)"`"; \
\
results="`printf '%s\n%s' "$$results" "-------------------------------------------"`"; \
\
: 3.4.2.2. filetype.vim; \
dir=filetype.vim; \
results="`printf '%s\n%s' "$$results" "$$dir"`"; \
for EXPLOIT_FLAVOUR in strong weak; do \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n %-8s: %s' "$$results" "$$EXPLOIT_FLAVOUR" "$$status"`"; \
done; \
\
: 3.4.2.2. filetype.vim "updated"; \
dir=filetype.vim.updated; \
results="`printf '%s\n%s' "$$results" "$$dir"`"; \
for EXPLOIT_FLAVOUR in strong weak; do \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n %-8s: %s' "$$results" "$$EXPLOIT_FLAVOUR" "$$status"`"; \
done; \
: Note: the remote exploit does not test reliably -- disabling; \
: make -sC $$dir test-remote; \
: test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
: make -sC $$dir clean; \
: results="`printf '%s\n %-8s: %s' "$$results" "remote" "$$status"`"; \
\
: 3.4.2.3. tar.vim; \
dir=tarplugin; \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n%-10s: %s' "$$results" "$$dir" "$$status"`"; \
\
: NOT IN ORIGINAL ADVISORY tar.vim "updated"; \
dir=tarplugin.updated; \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n%-10s: %s' "$$results" "$$dir" "$$status"`"; \
\
: NOT IN ORIGINAL ADVISORY tar.vim version 2; \
dir=tarplugin.v2; \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n%-10s: %s' "$$results" "$$dir" "$$status"`"; \
\
: 3.4.2.4. zip.vim; \
dir=zipplugin; \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n%-10s: %s' "$$results" "$$dir" "$$status"`"; \
\
: NOT IN ORIGINAL ADVISORY zip.vim version 2; \
dir=zipplugin.v2; \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n%-10s: %s' "$$results" "$$dir" "$$status"`"; \
\
: 3.4.2.5. xpm.vim and xpm2.vim; \
dir=xpm.vim; \
results="`printf '%s\n%s' "$$results" "$$dir"`"; \
for EXPLOIT_FLAVOUR in xpm xpm2; do \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n %-8s: %s' "$$results" "$$EXPLOIT_FLAVOUR" "$$status"`"; \
done; \
\
: 3.4.2.5.3. Remote exploit; \
make -sC $$dir test-remote; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n %-8s: %s' "$$results" "remote" "$$status"`"; \
\
: 3.4.2.6. gzip.vim; \
dir=gzip_vim; \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n%-10s: %s' "$$results" "$$dir" "$$status"`"; \
\
: 3.4.2.7. Netrw; \
dir=netrw; \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n%-10s: %s' "$$results" "$$dir" "$$status"`"; \
\
: NOT IN ORIGINAL ADVISORY Netrw version 2; \
dir=netrw.v2; \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n%-10s: %s' "$$results" "$$dir" "$$status"`"; \
\
: NOT IN ORIGINAL ADVISORY Netrw version 3; \
dir=netrw.v3; \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n%-10s: %s' "$$results" "$$dir" "$$status"`"; \
\
: NOT IN ORIGINAL ADVISORY Netrw version 4; \
dir=netrw.v4; \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n%-10s: %s' "$$results" "$$dir" "$$status"`"; \
\
: NOT IN ORIGINAL ADVISORY Netrw version 5; \
dir=netrw.v5; \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n%-10s: %s' "$$results" "$$dir" "$$status"`"; \
\
: NOT IN ORIGINAL ADVISORY shellescape; \
dir=shellescape; \
make -sC $$dir test; \
test -e $$dir/pwned && status=VULNERABLE || status='EXPLOIT FAILED'; \
make -sC $$dir clean; \
results="`printf '%s\n%-10s: %s' "$$results" "$$dir" "$$status"`"; \
\
echo "$$results"
.PHONY: all
all:
for target in $(SUBDIRS); do \
make $$target; \
done
.PHONY: cleanlocal
cleanlocal:
for a in $(SUBDIRS); do \
for timestamped in $$a-*.tar.bz2; do \
if test -e $$timestamped; then \
mv -f $$timestamped old; \
fi; \
done; \
if test -e $$a.tar.bz2 || test -L $$a.tar.bz2; then \
rm -f $$a.tar.bz2; \
fi; \
done
.PHONY: clean
clean:
for a in $(SUBDIRS); do \
make -C $$a clean; \
done
vulnerablevim.tar.bz2: all advisory
# bits_and_pieces are not a separate target, because we'll unlink it
# before this target is finished
tar cjf bits_and_pieces.tar.bz2 Makefile advisory README licenses \
util Changelog patch
$(TARCAT) bits_and_pieces.tar.bz2 \
`for a in $(SUBDIRS); do echo $$a.tar.bz2; done`\
> vulnerablevim.tar.bz2
rm -f bits_and_pieces.tar.bz2
.PHONY: filetype.vim.updated.tar.bz2
.PHONY: filetype.vim.updated
filetype.vim.updated: filetype.vim.updated.tar.bz2
filetype.vim.updated.tar.bz2:
make -C filetype.vim.updated clean
ln -sf "filetype.vim.updated-`date -Iseconds|tr -d :`.tar.bz2" $(TEMP_FILE)
tar cjf $(TEMP_FILE) filetype.vim.updated
if diff filetype.vim.updated.tar.bz2 $(TEMP_FILE) >/dev/null 2>&1; then \
rm -f "`readlink $(TEMP_FILE)`" $(TEMP_FILE) ;\
else \
mv $(TEMP_FILE) filetype.vim.updated.tar.bz2 ;\
fi
.PHONY: filetype.vim.tar.bz2
.PHONY: filetype.vim
filetype.vim: filetype.vim.tar.bz2
filetype.vim.tar.bz2:
make -C filetype.vim clean
ln -sf "filetype.vim-`date -Iseconds|tr -d :`.tar.bz2" $(TEMP_FILE)
tar cjf $(TEMP_FILE) filetype.vim
if diff filetype.vim.tar.bz2 $(TEMP_FILE) >/dev/null 2>&1; then \
rm -f "`readlink $(TEMP_FILE)`" $(TEMP_FILE) ;\
else \
mv $(TEMP_FILE) filetype.vim.tar.bz2 ;\
fi
.PHONY: tarplugin.updated.tar.bz2
.PHONY: tarplugin.updated
tarplugin.updated: tarplugin.updated.tar.bz2
tarplugin.updated.tar.bz2:
make -C tarplugin.updated clean
ln -sf "tarplugin.updated-`date -Iseconds|tr -d :`.tar.bz2" $(TEMP_FILE)
tar cjf $(TEMP_FILE) tarplugin.updated
if diff tarplugin.updated.tar.bz2 $(TEMP_FILE) >/dev/null 2>&1; then \
rm -f "`readlink $(TEMP_FILE)`" $(TEMP_FILE) ;\
else \
mv $(TEMP_FILE) tarplugin.updated.tar.bz2 ;\
fi
.PHONY: tarplugin.tar.bz2
.PHONY: tarplugin
tarplugin: tarplugin.tar.bz2
tarplugin.tar.bz2:
make -C tarplugin clean
ln -sf "tarplugin-`date -Iseconds|tr -d :`.tar.bz2" $(TEMP_FILE)
tar cjf $(TEMP_FILE) tarplugin
if diff tarplugin.tar.bz2 $(TEMP_FILE) >/dev/null 2>&1; then \
rm -f "`readlink $(TEMP_FILE)`" $(TEMP_FILE) ;\
else \
mv $(TEMP_FILE) tarplugin.tar.bz2 ;\
fi
.PHONY: tarplugin.v2.tar.bz2
.PHONY: tarplugin.v2
tarplugin.v2: tarplugin.v2.tar.bz2
tarplugin.v2.tar.bz2:
make -C tarplugin.v2 clean
ln -sf "tarplugin.v2-`date -Iseconds|tr -d :`.tar.bz2" $(TEMP_FILE)
tar cjf $(TEMP_FILE) tarplugin.v2
if diff tarplugin.v2.tar.bz2 $(TEMP_FILE) >/dev/null 2>&1; then \
rm -f "`readlink $(TEMP_FILE)`" $(TEMP_FILE) ;\
else \
mv $(TEMP_FILE) tarplugin.v2.tar.bz2 ;\
fi
.PHONY: zipplugin.tar.bz2
.PHONY: zipplugin
zipplugin: zipplugin.tar.bz2
zipplugin.tar.bz2:
make -C zipplugin clean
ln -sf "zipplugin-`date -Iseconds|tr -d :`.tar.bz2" $(TEMP_FILE)
tar cjf $(TEMP_FILE) zipplugin
if diff zipplugin.tar.bz2 $(TEMP_FILE) >/dev/null 2>&1; then \
rm -f "`readlink $(TEMP_FILE)`" $(TEMP_FILE) ;\
else \
mv $(TEMP_FILE) zipplugin.tar.bz2 ;\
fi
.PHONY: zipplugin.v2.tar.bz2
.PHONY: zipplugin.v2
zipplugin.v2: zipplugin.v2.tar.bz2
zipplugin.v2.tar.bz2:
make -C zipplugin.v2 clean
ln -sf "zipplugin.v2-`date -Iseconds|tr -d :`.tar.bz2" $(TEMP_FILE)
tar cjf $(TEMP_FILE) zipplugin.v2
if diff zipplugin.v2.tar.bz2 $(TEMP_FILE) >/dev/null 2>&1; then \
rm -f "`readlink $(TEMP_FILE)`" $(TEMP_FILE) ;\
else \
mv $(TEMP_FILE) zipplugin.v2.tar.bz2 ;\
fi
.PHONY: doit
doit:
make -C $(BASE) clean
ln -sf $(BASE)"-`date -Iseconds|tr -d :`.tar.bz2" $(TEMP_FILE)
tar cjf $(TEMP_FILE) $(BASE)
if diff $(BASE).tar.bz2 $(TEMP_FILE) >/dev/null 2>&1; then \
rm -f "`readlink $(TEMP_FILE)`" $(TEMP_FILE) ;\
else \
mv $(TEMP_FILE) $(BASE).tar.bz2 ;\
fi
.PHONY: xpm.vim.tar.bz2
.PHONY: xpm.vim
xpm.vim.tar.bz2: xpm.vim
xpm.vim: BASE = xpm.vim
xpm.vim:
env BASE=$(BASE) make doit
.PHONY: gzip_vim.tar.bz2
.PHONY: gzip_vim
gzip_vim.tar.bz2: gzip_vim
gzip_vim: BASE = gzip_vim
gzip_vim:
env BASE=$(BASE) make doit
.PHONY: netrw.tar.bz2
.PHONY: netrw
netrw.tar.bz2: netrw
netrw: BASE = netrw
netrw:
env BASE=$(BASE) make doit
.PHONY: netrw.v2.tar.bz2
.PHONY: netrw.v2
netrw.v2.tar.bz2: netrw.v2
netrw.v2: BASE = netrw.v2
netrw.v2:
env BASE=$(BASE) make doit
.PHONY: netrw.v3.tar.bz2
.PHONY: netrw.v3
netrw.v3.tar.bz2: netrw.v3
netrw.v3: BASE = netrw.v3
netrw.v3:
env BASE=$(BASE) make doit
.PHONY: netrw.v4.tar.bz2
.PHONY: netrw.v4
netrw.v4.tar.bz2: netrw.v4
netrw.v4: BASE = netrw.v4
netrw.v4:
env BASE=$(BASE) make doit
.PHONY: netrw.v5.tar.bz2
.PHONY: netrw.v5
netrw.v5.tar.bz2: netrw.v5
netrw.v5: BASE = netrw.v5
netrw.v5:
env BASE=$(BASE) make doit
.PHONY: shellescape.tar.bz2
.PHONY: shellescape
shellescape.tar.bz2: shellescape
shellescape: BASE = shellescape
shellescape:
env BASE=$(BASE) make doit
.PHONY: advisory
advisory:
make -C advisory