-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathps_invoke
More file actions
executable file
·64 lines (54 loc) · 1.15 KB
/
ps_invoke
File metadata and controls
executable file
·64 lines (54 loc) · 1.15 KB
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
#!/bin/bash
shopt -s lastpipe
read -r CMD
SCRIPT="$0"
# Check if powershell is 32 or 64 bit
# [Environment]::Is64BitProcess
# If current powershell is running in 32 bit:
# 64 Version: C:\Windows\SysNative
# 32 Version: C:\Windows\SystemWOW64
# If current powershell is running in 64 bit:
# 64 Version: C:\Windows\System32
# 32 Version: C:\Windows\SystemWOW64
PS_32="C:\\Windows\\SystemWOW\\WindowsPowerShell\\v1.0\\powershell.exe"
PS_64="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
OPTS="-NoP -NonI -W Hidden -Exec Bypass"
usage() {
echo $1
echo "$SCRIPT [-e] [-a 32|64]"
exit 1
}
while getopts "hea:" o; do
case "${o}" in
e)
ENCODED=true
;;
a)
if [[ ${OPTARG} == "32" ]]; then
ARCH=32
elif [[ ${OPTARG} == "64" ]]; then
ARCH=64
else
usage "wrong arch ${OPTARG}"
fi
;;
h | *)
usage
;;
esac
done
function encode() {
echo "$CMD" | iconv -t UNICODELITTLE | base64 | tr -d "\n"
}
if [ $ENCODED ]; then
CMD=$(encode $CMD)
OPTS="$OPTS -Encode"
else
OPTS="$OPTS -Command"
fi
if [[ $ARCH -eq 32 ]];then
PS=$PS_32
else
PS=$PS_64
fi
echo "$PS $OPTS $CMD"