Защита данных от несанкционированного доступа
GetPalette := @P[AppPalette];
end;
{Изменить палитру окна выбора файлов}
function TMyFDialog.GetPalette: PPalette;
const
{Синяя палитра}
CMyCluster =
#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;
P: string [32] = CMyCluster;
begin
GetPalette := @P;
end;
{Инициализировать окно выбора файлов}
constructor TMyFileDialog.Init(AWildCard: tWildStr;
const ATitle, InputName: string;
AOptions: Word; HistoryId: Byte);
var
ScrollBar: PScrollBar;
R : TRect;
begin
{ Создание окна диалога }
R.Assign(15, 1, 64, 20);
TDialog.Init(R, ATitle);
Options:= Options or ofCentered;
WildCard:= AWildCard;
{ Строка ввода имени файла }
R.Assign(3, 3, 31, 4);
FileName:= New(PFileInputLine, Init(R, 79));
FileName^.Data^:= WildCard;
Insert(FileName);
R.Assign(2, 2, 6, 3);
Insert(New(PLabel, Init(R, InputName, FileName)));
R.Assign(31, 3, 34, 4);
Insert(New(PHistory, Init(R, FileName, HistoryId)));
{ Линейка скроллинга и список файлов }
R.Assign(3, 14, 34, 15);
ScrollBar:= New(PScrollBar, Init(R));
Insert(ScrollBar);
R.Assign(3, 6, 34, 14);
FileList:= New(PFileList, Init(R, ScrollBar));
Insert(FileList);
R.Assign(2, 5, 8, 6);
Insert(New(PLabel, Init(R, 'Файлы', FileList)));
{ Задание кнопок }
R.Assign(35, 3, 46, 5);
if AOptions and fdOpenButton <> 0 then
begin
Insert(New(PButton, Init(
R, 'Открыть', cmFileOpen, bfDefault)));
Inc(R.A.Y,3); Inc(R.B.Y,3);
end;
if AOptions and fdOkButton <> 0 then
begin
Insert(New(PButton, Init(
R, 'Ага', cmFileOpen, bfNormal)));
Inc(R.A.Y,3); Inc(R.B.Y,3);
end;
if AOptions and fdReplaceButton <> 0 then
begin
Insert(New(PButton, Init(
R, 'Замена',cmFileReplace, bfNormal)));
Inc(R.A.Y,3); Inc(R.B.Y,3);
end;
if AOptions and fdClearButton <> 0 then
begin
Insert(New(PButton, Init(
R, 'Удал.',cmFileClear, bfNormal)));
Inc(R.A.Y,3); Inc(R.B.Y,3);
end;
Insert(New(PButton, Init(
R, 'Нека', cmCancel, bfNormal)));
{ Информационная панель с параметрами файла }
R.Assign(1, 16, 48, 18);
Insert(New(PFileInfoPane, Init(R)));
SelectNext(False);
{ Загрузка каталога }
if AOptions and fdNoLoadDir = 0 then
begin
FileList^.ReadDirectory(WildCard);
Directory:= NewStr(GetCurDir);
end;
end;
Var
MyApp: TMyApp; {Переменная основного объекта}
Begin
WriteLn('Система защиты данных от НСД. Версия 1.0 beta.'+
+' 1996 МГВРК Еганов М. Ю., Юзефович А. Г.');
GetIntVec($09,Int09_Save);
MyApp.Init;
MyApp.Run;
MyApp.Done;
SetIntVec($09, Int09_Save);
End.
Приложение 2
Листинг библиотек
{**************************************************************************
*}
{**************************************************************************
*}
{**
**}
{** КП "ЗАЩИТА ДАННЫХ ОТ НСД"
**}
{** Выполнил учащийся гр.46491 ЕГАНОВ МАКСИМ
**}
{** 1996
**}
{**
**}
{** Программа инсталляции
**}
{**************************************************************************
*}
{**************************************************************************
*}
Program Install;
Uses
App, Dialogs, Drivers, Menus, MsgBox, Objects,
Views, Memory, StdDlg, CRT, DOS, SetConf;
Const {константы кодов команд}
cmAboutBox = 700;
cmCode = 1001;
cmDeCode = 1002;
cmSetPass = 1005;
cmLockDisk = 1006;
cmOptions = 1007;
cmKeyDisk = 1008;
cmPasswords = 1009;
RMenuBar: TStreamRec = ( {Запись для работы с потоком, TV}
ObjType: 2000;
VmtLink: Ofs(TypeOf(TMenuBar)^);
Load: @TMenuBar.Load;
Store: @TMenuBar.Store);
Var
Save23hInt : Pointer; {Переменные сохранения векторов прерываний}
Save1bhInt : Pointer;
MyApp : TApplication;
MyRes : TResourceFile;
MyStream : PBufStream;
{Формирование подменю "Файлы"}
function MyStdFileMenuItems(Next: pMenuItem): pMenuItem;
begin
MyStdFileMenuItems:=
NewItem('Выбрать...', 'F3', kbF3, cmOpen, hcOpen,
NewItem('Сменить каталог...', '',
kbNoKey, cmChangeDir, hcChangeDir,
NewLine(
NewItem('Выход в ДОС', '', kbNoKey, cmDosShell, hcDosShell,
NewItem('Завершение', 'Alt+X', kbAltX, cmQuit, hcExit,
Next)))));
end;
{Формирование основного меню}
procedure CreateMenuBar;
var
MenuBar: PMenuBar;
R : TRect;
begin
R.Assign(0, 0, 80, 1);
MenuBar:= New(pMenuBar, Init(R, NewMenu(
NewSubMenu('~Ф~айлы', hcNoContext, NewMenu(
MyStdFileMenuItems(nil)),
NewSubMenu('~З~ащита', hcNoContext, NewMenu(
NewItem('~У~становить пароль', 'F5', kbF5, cmSetPass, 1005,
NewItem('~Б~локировать винчестер', '', kbNoKey, cmLockDisk, 1006,
nil))),
NewSubMenu('~К~лючевая дискета', hcNoContext, NewMenu(
NewItem('~Д~обавить проверку по ключу', '', kbNoKey, cmKeyDisk,
1008, nil)),
NewSubMenu('~К~риптография', hcNoContext, NewMenu(
NewItem('Зашифровать файл данных','', kbNoKey, cmCode, 1001,
NewItem('Расшифровать файл данных','', kbNoKey, cmDeCode, 1002,
nil))),
NewSubMenu('~Н~астройки', hcNoContext, NewMenu(
NewItem('Криптография...','F9', kbF9, cmOptions, 1007,
NewItem('Пароли...','F8', kbF8, cmPasswords, 1008, nil))),
NewItem('~О~ программе', '', kbAltJ, cmAboutBox, 700, nil)))))))));
MyRes.Put(MenuBar, Config);
Dispose(MenuBar, Done);
end;
{Процедура управления формой курсора}
procedure SetCursorSize(c_start,c_end:byte);
var
regs: registers;
begin
with regs do
begin
ah:=$01;
ch:=c_start;
cl:=c_end;
end;
intr($10,regs);
end;
{Процедура замены вектора преываний}
{$F+}
procedure My23hInt;Interrupt;
begin
end;
{$F-}
{Процедура копирования файлов}
procedure CopyFyle(FromCopy: string);
const
TempLength = 1125.28;
var
ToCopy : string;
Source, Target : file;
NumRead, NumWrite: word;
buf : string;
TempPos, Temp : real;
begin
{Открыть файлы}
ToCopy := 'c:';
ToCopy := ToCopy + copy(FromCopy, 3, length(FromCopy) - 2);
assign(Source, FromCopy);
assign(Target, ToCopy);
reset(Source, 1);
rewrite(Target, 1);
Temp := 0;
{Копировать}
repeat
BlockRead(Source, Buf, Sizeof(Buf)-1, NumRead);
if FromCopy = 'a:\sub_rosa\sub_rosa.exe' then
begin
TempPos := 100*Temp/TempLength;
Temp := Temp + 2.5;
GotoXY(17, 25);
if (TempPos > 98) and (TempPos < 100) then write('100.0 %')
else write(TempPos: 4: 1, ' %');
end;
{Обработчик ошибок}
if (NumRead<>Sizeof(Buf)-1) and (not EOF(Source)) then
begin
WriteLn;
WriteLn('Ошибка чтения с диска');
SetIntVec($23, Save23hInt);
SetIntVec($1b, Save1bhInt);
halt;
end;
BlockWrite(Target,Buf,NumRead,NumWrite);
If NumRead<>NumWrite then
begin
WriteLn;
WriteLn('На диске не хватает места для записи');
SetIntVec($23, Save23hInt);
SetIntVec($1b, Save1bhInt);
halt;
end;
until NumRead=0;
close(Source);
close(Target);
end;
Var
Directory: string; {Куда копировать}
Begin {Основная часть программы}
GetIntVec($23, Save23hInt); {Подменить вектора прерываний 23h, 1bh}
GetIntVec($1b, Save1bhInt); {Отключение Ctrl-C или Ctrl-Break}
SetIntVec($23, @My23hInt);
SetIntVec($1b, @My23hInt);
SetCursorSize(32, 0);
{$I-}
Directory:='c:\sub_rosa'; {Создать каталог для установки}
MkDir(Directory);
if IOResult <> 0 then {Обработчик ошибок}
begin
WriteLn('Система уже была инсталлирована');
SetIntVec($23, Save23hInt);
SetIntVec($1b, Save1bhInt);
halt;
end;
{$I+}
{Создать файл ресурсов с привязкой к уникальным параметрам BIOS}
MyStream := New(PBufStream, Init('c:\sub_rosa\Setup.res', stCreate,
2048));
MyRes.Init(MyStream);
RegisterType(RMenuBar);
CreateMenuBar;
MyRes.Done;
{Копировать файлы}
CopyFyle('a:\sub_rosa\block.');
CopyFyle('a:\sub_rosa\keydisk.');
CopyFyle('a:\sub_rosa\plus.');
CopyFyle('a:\sub_rosa\passw.');
CopyFyle('a:\sub_rosa\system.res');
GotoXY(1, 25);
Write('Инсталлировано');
CopyFyle('a:\sub_rosa\sub_rosa.exe');
WriteLn;
WriteLn('Система готова к работе');
ChDir('c:\sub_rosa');
Mem[$40:$1a]:=Mem[$40:$1c];
{Восстановить вектора прерываний}
SetIntVec($23, Save23hInt);
SetIntVec($1b, Save1bhInt);
End.
{**************************************************************************
*}
{**************************************************************************
*}
{**
**}
{** КП "ЗАЩИТА ДАННЫХ ОТ НСД"
**}
{** Выполнил учащийся гр.46491 ЕГАНОВ МАКСИМ
**}
{** 1996
**}
{** **}
{** Модуль привязки к BIOS
**}
{**************************************************************************
*}
{**************************************************************************
*}
Unit SetConf;
Interface
function config: string; {Дата BIOS}
Implementation
{Получить дату BIOS}
function config: string;
var
conf, s: String;
Control: char absolute $F000:$FFF5;
i :byte;
begin
Move(Control, s[1], 8);
s[0] := #8;
for i := 1 to length(s) do conf[i] := chr(ord(s[i]) + 5*i);
conf[0] := #8;
config := conf;
end;
End.
{**************************************************************************
**}
{**************************************************************************
**}
{**
**}
{** КП "ЗАЩИТА ДАННЫХ ОТ НСД"
**}
{** Выполнил учащийся гр.46491 ЮЗЕФОВИЧ АРТЕМ
**}
{** 1996
**}
{**
**}
{** Дописывание к файлу
**}
{**************************************************************************
**}
{**************************************************************************
**}
code segment public
assume cs: code, ds: code, es: code, ss: code
org 80h ;Хвост команды
dta label byte
com_siz db ?
probel db ?
com_par db ?
org 100h
start:
jmp test_par
type_t db ? ;Тип расширения target
len_s dw ? ;Длина source_file
len_t_1 dw ? ;Длина target_file
len_t_2 dw ? ;Длина target_file
hand_1 dw ? ;Обработка source_file
hand_2 dw ? ;Обработка target_file
NameTarOff dw ? ;Смещение имени target_file
NameSouOff dw ? ;Смещение имени source_file
ext_a db 'com', 'exe' ;Допустимые расширения
mbad_use db 10, 13
syn db 10, 13
TEST_PAR:
lea si, dta+1 ;Далее идет проверка
l_0: ;параметров в командной
cmp byte ptr [si], 0Dh ;строке
je c_syn
cmp byte ptr [si], '?'
je c_h
cmp byte ptr [si], ' '
jne not_prob
inc si
jmp short l_0
c_syn:
int 20h
c_h:
int 20h
use:
int 20h
not_prob:
mov NameTarOff, si ;1-ый параметр правильный ?
l_1:
cmp byte ptr [si], 0Dh
je c_b_1_m_2
cmp byte ptr [si], ' '
je c_b_1
cmp byte ptr [si], '.'
je d_t_1
inc si
jmp short l_1
c_b_1_m_2:
jmp use ;Недопустимое расширение
c_b_1: ;у target_file
jmp use
D_T_1: ;Анализ расширения
inc si
call det_type
pop ax
mov type_t, al
cmp ax, 2
je C_B_1
add si, 3
lea cx, dta
add cl, byte ptr dta
adc ch, 0
cmp cx, si
jbe C_M_2
mov byte ptr [si], 0
l_2: ;2-ой параметр
правильный ?
inc si
cmp cx, si
jb c_m_2
cmp byte ptr [si], ' '
je l_2
mov NameSouOff, si
l_3:
cmp byte ptr [si], '.'
je d_t_2
inc si
cmp cx, si
jb c_b_2
jmp l_3 ;Отсутствует source_file
c_m_2:
jmp use
d_t_2:
inc si
call det_type
pop ax
cmp ax, 0
je test_end
c_b_2:
jmp use
test_end:
add si, 2
cmp cx, si
jb c_b_2
mov byte ptr [si+1], 0
OPEN_F: ;Открыть, определить
длину
mov ah, 3dh ;и прочитать в буфер файл
mov al, 2 ;source_file
mov dx, NameSouOff
int 21h
jnc yes_open
int 20h
yes_open: ;Определить длину
mov bx, ax
mov hand_2, ax
mov ah, 42h
xor cx, cx
xor dx, dx
mov al, 2
int 21h
jnc yes_p_1
cn_mov_2:
int 20h
yes_p_1:
mov word ptr len_s, ax
mov ah, 42h
xor cx, cx
xor dx, dx
mov al, 0
int 21h
jc cn_mov_2
mov ah, 3Fh
lea dx, buff
mov cx, word ptr len_s
int 21h
jnc open_targ
int 20h
OPEN_TARG ;Открыть target_file
mov ah, 3Dh
mov al, 2
mov dx, NameTarOff
int 21h
jnc det_len_1
int 20h
det_len_1:
mov hand_1, ax
mov bx, hand_1
mov ah, 42h
xor cx, cx
xor dx, dx
mov al, 2
int 21h
jnc rest_len
jmp cn_mov_1
rest_len:
mov len_t_1, dx
mov len_t_2, ax
TO_PROC: ;Если target_file - COM,
cmp type_t, 0 ;то CALL WR2COM.
Страницы: 1, 2, 3, 4, 5, 6, 7
|