Skip to content

Latest commit

 

History

History
268 lines (242 loc) · 7.5 KB

mabs.pas

File metadata and controls

268 lines (242 loc) · 7.5 KB
 
Nov 18, 2000
Nov 18, 2000
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
uses dos,
mdek,timejunk;
(*
Execution method:
MABS [site type] [[site info file] [serial number]]
*)
type infoheaderrec=array[1..6] of byte;
const infoheader:infoheaderrec=($FA,$CD,$20,$EF,$02,$AA);
var siteinfof:text;
f:file;
pdt:packdatetime;
pstr:array[1..20] of string;
s,siteinfofile,siteinfos,oversiteinfo:string;
r:array[1..144] of byte;
lng,serialnumber:longint;
chk,chk1,chk2:word;
res,i,pcount,wanttype:integer;
c:char;
vertypes:byte;
b,notcoded:boolean;
function stripcolor(o:string):string;
var s:string;
i:integer;
lc:boolean;
begin
s:=''; lc:=FALSE;
for i:=1 to length(o) do
if (lc) then lc:=FALSE
else if ((o[i]=#3) or (o[i]='^')) then lc:=TRUE else s:=s+o[i];
stripcolor:=s;
end;
procedure decryptinfo;
var s:string;
i:integer;
begin
for i:=13 to 142 do s[i-12]:=chr(r[i]); s[0]:=chr(132);
s:=decrypt(s,r[7],r[8],r[9],r[10],r[11],r[12]);
for i:=13 to 142 do r[i]:=ord(s[i-12]);
end;
procedure encryptinfo;
var s:string;
i:integer;
begin
for i:=13 to 142 do s[i-12]:=chr(r[i]); s[0]:=chr(132);
s:=encrypt(s,r[7],r[8],r[9],r[10],r[11],r[12]);
for i:=13 to 142 do r[i]:=ord(s[i-12]);
end;
procedure maketruerandom;
var dt:ldatetimerec;
ll,ll2:longint;
begin
getdatetime(dt);
with dt do
ll:=(year-1980)+month+day*hour*min*sec*sec100;
randseed:=ll;
end;
function aonoff(b:boolean; s1,s2:string):string;
begin
if (b) then aonoff:=s1 else aonoff:=s2;
end;
begin
maketruerandom;
siteinfofile:=''; oversiteinfo:='';
wanttype:=-1; serialnumber:=0;
pcount:=paramcount;
for i:=1 to pcount do pstr[i]:=paramstr(i);
{$IFDEF AS1}
pstr[1]:='9'; pstr[2]:='***'; pstr[3]:='1'; pcount:=3;
oversiteinfo:='Eric Oman'+^J+#3#7+'Grosse '+#3#0+'Pointe '+#3#4+'Centrale'+
^J+#3#7+'313-'+#3#0+'885-'+#3#4+'1779'+^J;
{$ELSE}
{$IFDEF AS2}
pstr[1]:='1'; pstr[2]:='***'; pstr[3]:='2'; pcount:=3;
oversiteinfo:='Todd Bolitho'+^J+'Warp Speed BBS'+^J+'313-544-0405'+^J;
{$ELSE}
{$IFDEF AS3}
pstr[1]:='1'; pstr[2]:='***'; pstr[3]:='3'; pcount:=3;
oversiteinfo:='Martin Pollard'+^J+'The I/O Bus'+^J+'313-755-7786'+^J;
{$ELSE}
{$IFDEF AS4}
pstr[1]:='1'; pstr[2]:='***'; pstr[3]:='4'; pcount:=3;
oversiteinfo:='John Dixon (Nikademus)'+^J+'The Ozone BBS'+^J+
'313-689-2876'+^J;
{ELSE}
{$IFDEF AS5}
pstr[1]:='1'; pstr[2]:='***'; pstr[3]:='5'; pcount:=3;
oversiteinfo:='Bill Schwartz'+^J+'Electric Eye II BBS'+^J+
'313-776-8928'+^J;
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}
if (pcount>=1) then begin
val(pstr[1],wanttype,i);
if (pcount>=2) then
if (pstr[2]='***') then
siteinfofile:='***'
else begin
siteinfofile:=pstr[2];
assign(f,siteinfofile);
{$I-} reset(f); {$I+}
if (ioresult<>0) then begin
writeln;
writeln(siteinfofile+': File not found.');
halt(1);
end else
close(f);
end;
if (pcount>=3) then val(pstr[3],serialnumber,i);
end;
assign(f,'bbs.ovr');
{$I-} reset(f,1); {$I+}
if (ioresult<>0) then begin
writeln;
writeln('BBS files not found.');
halt(1);
end;
seek(f,filesize(f)-144);
blockread(f,r,144,res);
close(f);
if (res<>144) then writeln('Errors reading in current data');
notcoded:=FALSE;
for i:=1 to 6 do
if (r[i]<>infoheader[i]) then notcoded:=TRUE;
if (not notcoded) then decryptinfo;
if (wanttype=-1) then begin
serialnumber:=r[20]+r[21] shl 8+r[22] shl 16+r[23] shl 24;
vertypes:=r[19];
c:=#0;
repeat
if (c<>'?') then begin
writeln;
write('Version type = ');
case (vertypes and $07) of
$00:writeln('Standard');
$01:writeln('Alpha'); $02:writeln('Beta');
$03:writeln('Gamma'); $04:writeln('Special');
else writeln('Unknown! (',vertypes,')');
end;
writeln('Serial number = ',serialnumber);
writeln('Registration = '+aonoff((vertypes and $08=$08),'Yes','No'));
writeln('Node membership = '+aonoff((vertypes and $10=$10),'Yes','No'));
writeln;
end;
write('[>'); readln(s); c:=upcase(s[1]);
if (s<>'') then
case c of
'0'..'4':
begin
vertypes:=vertypes and ($FF-$07);
case c of
'1':vertypes:=vertypes or $01;
'2':vertypes:=vertypes or $02;
'3':vertypes:=vertypes or $03;
'4':vertypes:=vertypes or $04;
'5':vertypes:=vertypes or $05;
end;
end;
'#':if (length(s)<>1) then begin
s:=copy(s,2,length(s)-1); val(s,lng,i);
serialnumber:=lng;
end;
'$':begin
b:=vertypes and $08=$08;
if (b) then vertypes:=vertypes and ($FF-$08)
else vertypes:=vertypes or $08;
end;
'@':begin
b:=vertypes and $10=$10;
if (b) then vertypes:=vertypes and ($FF-$10)
else vertypes:=vertypes or $10;
end;
'?':begin
writeln;
writeln('0:Standard');
writeln('1:Alpha - "à"');
writeln('2:Beta - "á"');
writeln('3:Gamma - "â"');
writeln('4:Special - "ä"');
writeln('#xxxxx:Change serial number');
writeln('$:Toggle registration');
writeln('@:Toggle node membership');
writeln;
writeln('R:elist');
writeln;
end;
end;
until ((s='') or (c='Q'));
end else
vertypes:=wanttype;
for i:=1 to 6 do r[i]:=infoheader[i];
r[19]:=vertypes;
reset(f,1);
if (notcoded) then seek(f,filesize(f))
else seek(f,filesize(f)-144);
getpackdatetime(@pdt);
r[13]:=pdt[1]; r[14]:=pdt[2]; r[15]:=pdt[3];
r[16]:=pdt[4]; r[17]:=pdt[5]; r[18]:=pdt[6];
r[20]:=(serialnumber and $FF);
r[21]:=((serialnumber and $FF00) shr 8);
r[22]:=((serialnumber and $FF0000) shr 16);
r[23]:=((serialnumber and $FF000000) shr 24);
siteinfos:='';
if (siteinfofile<>'') then
if (oversiteinfo<>'') then begin
siteinfos:=oversiteinfo;
s:='';
for i:=1 to length(oversiteinfo) do
if (oversiteinfo[i]=^J) then s:=s+^M^J
else s:=s+oversiteinfo[i];
writeln;
writeln('This Alpha version is licensed to:');
write(stripcolor(s));
writeln;
writeln('WARNING: Giving out this EXE file, or your BBS.EXE or BBS.OVR');
writeln('files automatically terminates your status as an Alpha site.');
end else begin
assign(siteinfof,siteinfofile);
reset(siteinfof);
repeat
readln(siteinfof,s);
siteinfos:=siteinfos+s+^J;
until ((eof(siteinfof)) or (length(siteinfos)>118));
close(siteinfof);
end;
if (length(siteinfos)>118) then siteinfos:=copy(siteinfos,1,118);
r[24]:=length(siteinfos);
for i:=1 to 118 do r[i+24]:=random(256);
for i:=1 to length(siteinfos) do r[i+24]:=ord(siteinfos[i]);
for i:=1 to 6 do r[i+6]:=random(256); { new encryption indices }
chk:=0;
for i:=13 to 142 do inc(chk,r[i]);
chk1:=(chk div 6)*5;
chk2:=(chk div 19)*25;
r[143]:=chk1 mod 256;
r[144]:=chk2 mod 256;
encryptinfo;
blockwrite(f,r,144,res);
if (res<>144) then writeln('Error writing data.');
close(f);
end.