-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.sh
56 lines (51 loc) · 1.25 KB
/
generate.sh
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
#!/usr/bin/env bash
unsafe_methods=(
'html'
'prepend'
'prependTo'
'append'
'appendTo'
'before'
'after'
'insertBefore'
'insertAfter'
'wrap'
'wrapInner'
'wrapAll'
)
batch=1
mkdir -p ./out/tmp/
echo "generate basic samples for each method"
for method in ${unsafe_methods[*]}; do
echo -n "${method}, generate"
method_dir="./out/tmp/${method}"
mkdir "${method_dir}"
for filepath in ./in/*.js; do
filename=$(basename "$filepath")
cp "$filepath" "${method_dir}/${batch}_${filename}"
cp "${filepath%.js}.out" "${method_dir}/${batch}_${filename%.js}.out"
echo -n "."
done
echo ""
sed -i "s/__BATCH__/_${batch}_/g" "${method_dir}/"*.js
sed -i "s/__METHOD__/${method}/g" "${method_dir}/"*.js
echo "${method}, done"
mv "${method_dir}/"*.js ./out/tmp/
mv "${method_dir}/"*.out ./out/
rmdir "${method_dir}"
echo "${method}, moved"
batch=$((batch+1))
done
echo "copy static samples"
cp ./static/*.js ./out/tmp/
cp ./static/*.out ./out/
echo -n "finalize all samples with xss from parameter"
for filepath in ./out/tmp/*.js; do
filename=$(basename "$filepath")
cat ./xss_param.js "$filepath" > "./out/${filename%.js}.gen.js"
rm "$filepath"
echo -n "."
done
echo ""
rmdir ./out/tmp/
echo "all samples finalized"