-
Notifications
You must be signed in to change notification settings - Fork 1
/
decrypt.sh
173 lines (161 loc) · 3.99 KB
/
decrypt.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
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
#Function: Decrypt script binary obtain source code.
#Author: ChenZhongChao
#Birthdate: 2024-12-05
#Github: https://github.com/chenzhch/decrypt.git
total=3 #Decryption result count
new=""
old=""
count=0
style=$1
program=$2
#Using stdin
stdin()
{
while [ : ]; do
>decrypt.txt
$program "$@" </dev/null & child=$!
timeout 5 cat /proc/${child}/fd/3 2>/dev/null >decrypt.txt
kill -9 $(pgrep -P $child)
kill -9 $child
len=`wc -l decrypt.txt |awk '{print $1}'`
if [ $len -gt 0 ]; then
new=$(cat decrypt.txt)
if [ ${#new} -gt 3 ];then
count=`expr $count + 1`
fi
fi
if [ ${#new} -gt ${#old} ]; then
old="$new"
new=""
fi
if [ $count -gt $total ]; then
clear
echo "$old"
exit
fi
done
}
#Using pipe: shc shellc ssc
pipe()
{
while [ : ]; do
$program "$@" </dev/null & child=$!
timeout 5 strace -p $child -e read -o decrypt.txt 2>&1 >/dev/null
kill -9 $(pgrep -P $child)
kill -9 $child
len=`wc -l decrypt.txt |awk '{print $1}'`
if [ $len -gt 0 ]; then
new=$(cat decrypt.txt)
if [ ${#new} -gt 3 ];then
count=`expr $count + 1`
fi
fi
if [ ${#new} -gt ${#old} ]; then
old="$new"
new=""
fi
hs='read(255, "'
ts='", 1)'
content=""
if [ $count -gt $total ]; then
clear
while IFS= read -r line; do
if [[ $line == read\(255* ]]; then
line=${line#*${hs}}
line=${line%${ts}*}
if [[ -n $line ]] && [[ $line = '\n' ]]; then
echo "$content"
content=""
elif [[ -n $line ]] && [[ $line = '\t' ]]; then
content="$content "
elif [[ -n $line ]] && [[ $line = '\"' ]]; then
content="$content\""
else
content="$content$line"
fi
fi
done <<< "$old"
echo $content
exit
fi
done
}
#Using shc
shc()
{
while [ : ]; do
> decrypt.txt
$program "$@" & child=$!
#ps -aux | grep $child | grep $program | grep -v grep >decrypt.txt
cat /proc/$child/cmdline >decrypt.txt
kill -9 $(pgrep -P $child)
kill -9 $child
len=`wc -l decrypt.txt |awk '{print $1}'`
if [ $len -gt 0 ]; then
new="$(cat decrypt.txt)"
if [ ${#new} -gt 3 ];then
count=`expr $count + 1`
fi
fi
if [ ${#new} -gt ${#old} ]; then
old="$new"
new=""
fi
if [ $count -gt $total ]; then
clear
old=${old#*#}
old=${old%./*}
echo "${old}"
exit
fi
done
}
#Using shc -H
shch()
{
trap 'sleep 1; clear; cat decrypt.txt' INT TERM EXIT
while [ : ]; do
>decrypt.txt
nice -n 19 $program "$@" </dev/null & child=$!
cp hook.so /tmp/shc_x.so
kill -9 $(pgrep -P $child)
kill -9 $child
len=`wc -l decrypt.txt |awk '{print $1}'`
if [ $len -gt 0 ]; then
exit
fi
done
}
#Using source temporary file
temp()
{
prlimit --cpu=1
while [ : ]; do
nice -n 19 $program "$@" </dev/null
done
}
if [ $# -lt 2 ]; then
echo "Usage: $0 style program [args...]"
exit
fi
shift 2
case $style in
1) shc "$@" #Using shc
;;
2) cc -fpic -shared -o hook.so hook.c -ldl
shch "$@" #Using shc -H
;;
3) stdin "$@" #Using stdin: shellc v.03 shellc -s
;;
4) pipe "$@" #Using pipe: shellc ssh shc -P
;;
5) #Using source temporary file
sh daemon.sh $total &
sleep 1
temp "$@"
;;
*)
echo "error style"
exit
;;
esac