Category : Network Files
Archive   : PWDCHK.ZIP
Filename : PW_DAYS.PAS

 
Output of file : PW_DAYS.PAS contained in archive : PWDCHK.ZIP
{****************************************************************************}
{ program PW_Days.PAS. Turbo Pascal Version 5.0 Version }
{ CopyRight 1989 by Donald C. Williams. All rights reserved. }
{****************************************************************************}
program DaysUntilPasswordExpires;
Uses Dos;
type
ch7 = array[1..7] of char;
ch48 = array[1..48] of char;
ch70 = array[1..70] of char;
ch128 = array[1..128] of char;
st15 = string[15];
st47 = string[47];
GetConnectionInfoReqRec = record
RequestLength : word;
ReqFunction : byte;
Connection : byte;
end;
GetConnectionInfoRepRec = record
ReturnLength : word;
ObjectID : longint;
ObjectType : word;
ObjectName : ch48;
LoginTime : ch7
end;
ReadPropertyValueReqRec = record
case integer of
0 ๐Ÿ™ RequestLength : word;
ReqFunction : byte;
ObjectType : word;
ObjectName : st47;
SegNumber : byte;
PropertyName : st15;);
1 ๐Ÿ™ entire : ch70);
end;
ReadPropertyValueRepRec = record
ReturnLength : word;
PropertyValue : ch128;
MoreSegments : byte;
PropertyFlags : byte;
end;
var
ConnectionRec : GetConnectionInfoRepRec;
Days : real;
bell : boolean;
{****************************************************************************}
{ general functions / procedures }
{****************************************************************************}
function int_lohi(original:integer):integer;
begin
int_lohi:=(lo(original) * 256) + hi(original);
end; { function int_lohi }
{****************************************************************************}
function word_lohi(original:word):word;
begin
word_lohi:=(lo(original) * 256) + hi(original);
end; { function word_lohi }
{****************************************************************************}
function SwapLong( InInt : longint) : longint;
var char4 : array[1..4] of char;
i : integer;
begin
for i := 1 to 4 do
begin
char4[i] := #0;
char4[i] := chr(mem[seg(InInt) : ofs(InInt) + (i - 1)]);
end; { FOR }
SwapLong := ord(char4[4]) +
( 256 * ord(char4[3])) +
( 256 * 256 * ord(char4[1])) +
( 256 * 256 * 256 * ord(char4[2]));
end; { function SwapLong }
{****************************************************************************}
procedure KillNull( var InStr : st47 );
var i : integer;
begin
i := pos(#0,InStr);
while i > 0 do
begin
delete(InStr,i,1);
i := pos(#0,InStr);
end; { while }
end; { procedure KillNull }
{****************************************************************************}
function Julian( year : integer; mon, day : byte): real;
var
temp : real;
begin { function Julian }
if (year < 0) OR (mon < 1) OR (day < 1) OR (day > 31) then
begin
Julian := -1;
exit;
end; { IF }
if year < 100 then
year := year + 1900;
temp := int((mon - 14.0) / 12.0);
Julian := day - 32075.0 +
int(1461.0 * (year + 4800.0 + temp) / 4.0) +
int(367.0 * (mon - 2.0 - temp * 12.0) / 12.0) -
int(3.0 * int((year + 4900.0 + temp) / 100.0) / 4.0)
end; { function Julian }
{****************************************************************************}
procedure JulToYMD( JulianDay : real;
var year : integer;
var mon, day : byte);
var
TempA ,
TempB : real;
begin
TempA := JulianDay + 68569.0;
TempB := int(4.0 * TempA / 146097.0);
TempA := TempA - int((146097.0 * TempB + 3.0) / 4.0);
year := trunc(4000.0 * (TempA + 1.0) / 1461001.0);
TempA := TempA - int(1461.0 * year / 4.0) + 31.0;
mon := trunc(80.0 * TempA / 2447.0);
day := trunc(TempA - int(2447.0 * mon / 80.0));
TempA := int(mon / 11.0);
mon := trunc(mon + 2.0 - 12.0 * TempA);
year := trunc(100.0 * (TempB - 49.0) + year + TempA);
end;
{****************************************************************************}
function GetConnectionNumber : byte;
var regs : registers;
begin
regs.AH := $DC;
MsDos(regs);
GetConnectionNumber := regs.AL;
end; { function GetConnectionNumber }
{****************************************************************************}
procedure GetConnectionInfo( var reply : GetConnectionInfoRepRec );
var regs : registers;
request : GetConnectionInfoReqRec;
begin
request.RequestLength := 4;
request.ReqFunction := $16;
request.Connection := GetConnectionNumber;
reply.ReturnLength := 63;
regs.AH := $E3;
regs.DS := seg(request);
regs.SI := ofs(request);
regs.ES := seg(reply);
regs.DI := ofs(reply);
MsDos(regs);
end; { procedure GetConnectionInfo }
{****************************************************************************}
function GetDays(InRec : GetConnectionInfoRepRec) : real;
var regs : registers;
temp : array[1..70] of char;
request : ReadPropertyValueReqRec;
reply : ReadPropertyValueRepRec;
i,j : integer;
SysYear : word;
SysMon : word;
SysDay : word;
SysDOW : word;
PWYear : integer;
PWMon : integer;
PWDay : integer;
begin
request.RequestLength := 70; { build request packet }
request.ReqFunction := $3D;
request.ObjectType := word_lohi(1);
request.ObjectName := InRec.ObjectName;
KillNull(request.ObjectName);
request.SegNumber := $01;
request.PropertyName := 'LOGIN_CONTROL';
reply.ReturnLength := 132;
for i := 1 to 70 do temp[i] := #0; { deal with pascal strings }
for i := 1 to 6 do temp[i] := request.entire[i];
for i := 1 to ord(request.ObjectName[0]) do
temp[6+i] := request.ObjectName[i];
j := 6 + ord(request.ObjectName[0]);
for i := 54 to 70 do
begin
j := j + 1;
temp[j] := request.entire[i];
end; { for }
regs.AH := $E3; { make the call }
regs.DS := seg(temp);
regs.SI := ofs(temp);
regs.ES := seg(reply);
regs.DI := ofs(reply);
MsDos(regs);
if regs.AL = 0 then
begin
PWYear := ord(reply.PropertyValue[5]);
PWMon := ord(reply.PropertyValue[6]);
PWDay := ord(reply.PropertyValue[7]);
GetDate(SysYear,SysMon,SysDay,SysDOW);
GetDays := ( Julian(PWYear,PWMon,PWDay) -
Julian(SysYear,SysMon,SysDay));
end { if }
else
begin
write(regs.AL:3);
readln;
end; { else }
end; { function GetDays }
{****************************************************************************}
begin
bell := (paramcount > 0) and ((pos('/B',paramstr(1)) > 0) or
(pos('/b',paramstr(1)) > 0));
GetConnectionInfo(ConnectionRec);
Days := GetDays(ConnectionRec);
if days < 11.0 then
begin
if bell then write(#7);
writeln('Your Password Expires in ',Days:3:0,' days.');
end; { if }
end.


  3 Responses to “Category : Network Files
Archive   : PWDCHK.ZIP
Filename : PW_DAYS.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! ๐Ÿ˜€ I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/