Обнаружение вредоносных закладок
procedure TForm1.Button2Click(Sender: TObject);
begin
close
end;
{нажатие кнопки 'принять'}
procedure TForm1.Button1Click(Sender: TObject);
begin
if (EditID.Text='admin')and(EditPSW.Text='password')
then Form2.Visible:=true
else {если не администратор}
begin
Ident:=EditId.Text;
Psword:=EditPSW.Text;
i:=1;
repeat
if i>length(Ident) then Ident:=Ident+' ';
if i>length(Psword) then Psword:=Psword+' ';
i:=i+1;
until i>=11;
{запись в журнал аудита}
{$I-}
AssignFile(F_Mag,'audit');
Reset(F_Mag);
{$I+}
if IOResult<>0 then begin Rewrite(F_Mag); y:=Yo end
else begin
if FileSize(F_Mag)=0 then y:=Yo
else begin
y:=yo;
f:=20*round(FileSize(F_Mag)/30);
i:=1;
repeat
generator;
i:=i+1
until i>=f+1;
end;
end;
Seek(F_Mag,FileSize(F_Mag));
i:=1;
repeat
generator;
xxx:=Chr((ord(Ident[i]))xor(y));
Write(F_Mag,xxx);
i:=i+1;
until i>=11;
i:=1;
repeat
generator;
xxx:=Chr((ord(PSWord[i]))xor(y));
Write(F_Mag,xxx);
i:=i+1;
until i>=11;
{чтение информации из файла}
Y:=14;
AssignFile(F_PSW,'password.txt');
Reset(F_PSW);
{фамилии}
j:=1;
repeat
Read(F_PSW,Surname[j]);
j:=j+1
until j>=151;
{идентификаторы}
j:=1;
repeat
Read(F_PSW,IDs[j]);
generator;
ids[j]:=chr((ord(ids[j]))xor(y));
j:=j+1
until j>=101;
{пароли}
j:=1;
repeat
Read(F_PSW,PSWs[j]);
generator;
PSWs[j]:=chr((ord(PSWs[j]))xor(y));
j:=j+1
until j>=101;
CloseFile(F_PSW);
{сбор в массив UserMatrix}
i:=1;
repeat
stroca:='';
j:=1;
repeat
if Surname[(i-1)*15+j]<>' ' then stroca:=stroca+Surname[(i-
1)*15+j];
j:=j+1
until j>=16;
UserMatrix[i,1]:=stroca;
i:=i+1
until i>=11;
i:=1;
repeat
stroca:='';
j:=1;
repeat
if IDs[(i-1)*10+j]<>' ' then stroca:=stroca+IDs[(i-1)*10+j];
j:=j+1
until j>=11;
UserMatrix[i,2]:=stroca;
i:=i+1
until i>=11;
i:=1;
repeat
stroca:='';
j:=1;
repeat
if PSWs[(i-1)*10+j]<>' ' then stroca:=stroca+PSWs[(i-1)*10+j];
j:=j+1
until j>=11;
UserMatrix[i,3]:=stroca;
i:=i+1
until i>=11;
{идентификация и аутентификация}
flag:=0;
i:=1;
repeat
if (EditID.Text=UserMatrix[i,2])and(EditPSW.Text=UserMatrix[i,3])and
(EditID.Text<>'') then begin
Flag:=1;
i1:=i end;
i:=i+1
until i>=11;
if flag=1 then begin
xxx:='y';
i:=1;
repeat
Write(F_Mag,xxx);
i:=i+1
until i>=11;
CloseFile(F_Mag);
Form3.Visible:=true;
end
else
begin
xxx:='n';
i:=1;
repeat
Write(F_Mag,xxx);
i:=i+1
until i>=11;
CloseFile(F_Mag)
end;
end;
end;
end.
unit Unitkurs;{администрирование}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids, ComCtrls;
type
TForm2 = class(TForm)
ButtonAdd: TButton;
ButtonDel: TButton;
Button3: TButton;
Button1: TButton;
StringGrid1: TStringGrid;
procedure FormActivate(Sender: TObject);
procedure ButtonAddClick(Sender: TObject);
procedure ButtonDelClick(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure Generator;
end;
var
Form2: TForm2;
F_PSW:file of char;{переменная, связанная с файлом 'password.txt'}
i,j,l:integer;
y:integer;{псевдослучайное число}
UserMatrix:array[1..10,1..3] of string;{массив фамилий, идентификаторов и
паролей пользователей}
Surname:array[1..150] of char;{массив фамилий пользователей}
IDs:array[1..100] of char;{массив идентификаторов пользователей}
PSWs:array[1..100] of char;{массив паролей пользователей}
stroca:string;
implementation
uses Unitkurs4;
{$R *.DFM}
{процедура реализующая ЛИНЕЙНЫЙ КОНГУЭНТНЫЙ ГЕНЕРАТОР}
procedure Tform2.Generator;
begin
y:=(31*y+17)mod(257);
end;
procedure TForm2.FormActivate(Sender: TObject);
begin
y:=14;
{оглавление таблицы пользователей}
i:=1;
repeat
StringGrid1.Cells[0,i]:=IntToStr(i);
i:=i+1;
until i>=11;
StringGrid1.Cells[1,0]:='фамилия';
StringGrid1.Cells[2,0]:='идентификатор';
StringGrid1.Cells[3,0]:='пароль';
{чтение информации из файла 'password.txt'}
AssignFile(F_PSW,'password.txt');
Reset(F_PSW);
{фамилии}
j:=1;
repeat
Read(F_PSW,Surname[j]);
j:=j+1
until j>=151;
{идентификаторы}
j:=1;
repeat
Read(F_PSW,IDs[j]);
generator;
ids[j]:=chr((ord(ids[j]))xor(y));
j:=j+1
until j>=101;
{пароли}
j:=1;
repeat
Read(F_PSW,PSWs[j]);
generator;
PSWs[j]:=chr((ord(PSWs[j]))xor(y));
j:=j+1
until j>=101;
CloseFile(F_PSW);
{сбор в массив UserMatrix}
i:=1;
repeat
stroca:='';
j:=1;
repeat
if Surname[(i-1)*15+j]<>' ' then stroca:=stroca+Surname[(i-1)*15+j];
j:=j+1
until j>=16;
UserMatrix[i,1]:=stroca;
i:=i+1
until i>=11;
i:=1;
repeat
stroca:='';
j:=1;
repeat
if IDs[(i-1)*10+j]<>' ' then stroca:=stroca+IDs[(i-1)*10+j];
j:=j+1
until j>=11;
UserMatrix[i,2]:=stroca;
i:=i+1
until i>=11;
i:=1;
repeat
stroca:='';
j:=1;
repeat
if PSWs[(i-1)*10+j]<>' ' then stroca:=stroca+PSWs[(i-1)*10+j];
j:=j+1
until j>=11;
UserMatrix[i,3]:=stroca;
i:=i+1
until i>=11;
{отображение в таблице}
i:=1;
repeat
j:=1;
repeat
StringGrid1.Cells[j,i]:=UserMatrix[i,j];
j:=j+1
until j>=4;
i:=i+1
until i>=11;
end;
{===============нажатие кнопки 'сохранить
изменения'=======================}
procedure TForm2.ButtonAddClick(Sender: TObject);
begin
y:=14;
{заполнение массива UserMatrix}
i:=1;
repeat
j:=1;
repeat
UserMatrix[i,j]:=StringGrid1.Cells[j,i];
j:=j+1
until j>=4;
i:=i+1
until i>=11;
{заполнение массива surname}
i:=1;
repeat
stroca:=UserMatrix[i,1];
l:=length(stroca);
j:=1;
repeat
if j<=l then Surname[(i-1)*15+j]:=stroca[j]
else Surname[(i-1)*15+j]:=' ';
j:=j+1
until j>=16;
i:=i+1
until i>=11;
{заполнение массива IDs}
i:=1;
repeat
stroca:=UserMatrix[i,2];
l:=length(stroca);
j:=1;
repeat
if j<=l then IDs[(i-1)*10+j]:=stroca[j]
else IDs[(i-1)*10+j]:=' ';
j:=j+1
until j>=11;
i:=i+1
until i>=11;
{заполнение массива PSWs}
i:=1;
repeat
stroca:=UserMatrix[i,3];
l:=length(stroca);
j:=1;
repeat
if j<=l then PSWs[(i-1)*10+j]:=stroca[j]
else PSWs[(i-1)*10+j]:=' ';
j:=j+1
until j>=11;
i:=i+1
until i>=11;
{запись в файл 'password.txt'}
AssignFile(F_PSW,'password.txt');
Rewrite(F_PSW);
{фамилии без преобразования}
j:=1;
repeat
write(F_PSW,Surname[j]);
j:=j+1
until j>=151;
{идентификаторы}
j:=1;
repeat
generator;
ids[j]:=chr((ord(ids[j]))xor(y));
write(F_PSW,IDs[j]);
j:=j+1
until j>=101;
{пароли}
j:=1;
repeat
generator;
PSWs[j]:=chr((ord(PSWs[j]))xor(y));
write(F_PSW,PSWs[j]);
j:=j+1
until j>=101;
CloseFile(F_PSW);
end;
{нажатие кнопки 'очистить'}
procedure TForm2.ButtonDelClick(Sender: TObject);
begin
{очистка таблицы}
i:=1;
repeat
j:=1;
repeat
StringGrid1.Cells[j,i]:='';
j:=j+1
until j>=4;
i:=i+1
until i>=11;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
close
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
Form4.Visible:=True
end;
end.
unit Unitkurs4;{журнал аудита}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids;
type
TForm4 = class(TForm)
| | скачать работу |
Обнаружение вредоносных закладок |