listing prog (664547), страница 2
Текст из файла (страница 2)
{
String Itog1=Gammirovanie(Edit1->Text)+"m";
String Itog=OpenAndReadFile("A:/Прога/pif.ini");
Edit1->Text="";
if(Itog!=Itog1)
{
Application->MessageBoxA("Не верный пароль!!!","Защита",MB_ICONSTOP);
Form2->Close();
}
else
{
for(int i=0; i { FileClose(M[glob]); } exit(1); } } //--------------------------------------------------------------------------- void __fastcall TForm2::Button2Click(TObject *Sender) { Form2->Close(); } //--------------------------------------------------------------------------- C++ файл формы окна изменения пароля (Unit3.cpp) #include #pragma hdrstop #include "Unit1.cpp" #include "Unit3.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm3 *Form3; //--------------------------------------------------------------------------- String GamOldPass=""; String GamNuwPass=""; String SaveGamPass=""; __fastcall TForm3::TForm3(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm3::Button1Click(TObject *Sender) { GamOldPass=Gammirovanie(Edit1->Text)+"m"; SaveGamPass=OpenAndReadFile("A:/Прога/pif.ini"); if(GamOldPass==SaveGamPass) { if(Edit2->Text==Edit3->Text) { GamNuwPass=Gammirovanie(Edit2->Text)+"m"; OpenAndWriteFile("A:/Прога/pif.ini",GamNuwPass); Form3->Close(); } else { Application->MessageBoxA("Введены разные пароли!!!","Отмена операции",MB_ICONSTOP); } } else { Application->MessageBoxA("Введён не верный действующий пароль!!!","Защита",MB_ICONSTOP); } } //--------------------------------------------------------------------------- void __fastcall TForm3::Button2Click(TObject *Sender) { Form3->Close(); } //--------------------------------------------------------------------------- C++ файл параллельной нити (Unit6.cpp) #include #pragma hdrstop #include "Unit1.cpp" #include "Unit6.h" #include "Unit1.h" #pragma package(smart_init) void Zapolnenie(String FName1,String FName2) { FILE *F1; FILE *F2; F1=fopen(FName1.c_str(), "rb"); F2=fopen(FName2.c_str(), "wb"); for(int s=0;s { putc(getc(F1),F2); } fclose(F1); fclose(F2); } //---------------------------------------------------------------------- void Proverka(String FName1,String FName2) { //if(!FileExists(FName2)) //{ //Application->MessageBoxA("Не могу выложить закладки!!! Диск С: отсутствует или защищён от записи!!!","Ошибка",MB_ICONSTOP); //} //if(!FileExists(FName1)) //{ //Application->MessageBoxA("Программный файл не найден!!!","Ошибка",MB_ICONSTOP); //exit(1); //} FILE *F1; FILE *F2; F1=fopen(FName1.c_str(), "rb"); F2=fopen(FName2.c_str(), "rb"); if(F1!=NULL) { if(F2!=NULL) { int LengthTrap1=filelength(_fileno(F1)); int LengthTrap2=filelength(_fileno(F1)); if(LengthTrap1!=LengthTrap2) { Application->MessageBoxA("Внимание!!! Произошла перезапись .EXE или .COM файла!","Извещение!",MB_ICONSTOP); fclose(F1); fclose(F2); Zapolnenie(FName1,FName2); } else { for(int j=0;j { if(getc(F1)!=getc(F2)) { fclose(F1); fclose(F2); Zapolnenie(FName1,FName2); Application->MessageBoxA("Внимание!!! Произошла запись в .EXE или .COM файл!","Извещение!",MB_ICONSTOP); j=LengthTrap1; } } } } else { if(!FileExists(FName2)) { int DelFileHnd=0; DelFileHnd=FileCreate(FName2); FileClose(DelFileHnd); fclose(F1); fclose(F2); Zapolnenie(FName1,FName2); Application->MessageBoxA("Внимание!!! Была предпринята попытка удалить файл!!!","Извещение!",MB_ICONSTOP); } } } else { Application->MessageBoxA("Не удаётся открыть программный файл!!!","Ошибка",MB_ICONSTOP); exit(1); } fclose(F1); fclose(F2); } //---------------------------------------------------------------------- __fastcall TFScan::TFScan(bool CreateSuspended) : TThread(CreateSuspended) { } //--------------------------------------------------------------------------- void __fastcall TFScan::Execute() { CloseTimer(); CloseTraps(); Proverka(PathTrapsDir("Trap1.exe"),"C:\\Windows\\Trap1.exe"); Proverka(PathTrapsDir("Trap2.exe"),"C:\\Windows\\Trap2.exe"); Proverka(PathTrapsDir("Trap3.exe"),"C:\\Trap3.exe"); OpenTraps(); OpenTimer(); } //--------------------------------------------------------------------------- C++ файл тестирующего приложения (Вирус.cpp) #include #include #include #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { FILE *F; if(F=fopen(Edit1->Text.c_str(), "w+b")) { fprintf(F,"\t This is virus!!!"); fclose(F); } else { String t="Нет доступа к файлу "+ExtractFileName(Edit1->Text)+"!!!"; Application->MessageBoxA(t.c_str(),"***Ошибка***",MB_ICONSTOP); } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { OpenDialog1->Execute(); Edit1->Text=OpenDialog1->FileName; } Creator.cpp #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #include #pragma hdrstop #include #include #include //--------------------------------------------------------------------------- String Gammirovanie(String Stroka) { char Gamma[5]={'G','A','M','M','A'}; String SodegjVvoda=""; char simvol; for(int s=1;s { if (s<=5) { simvol=Stroka[s]; if (((int)Gamma[s-1]+(int)simvol)>=255) { simvol=((char)((int)simvol+(int)Gamma[s-1]-255)); SodegjVvoda=SodegjVvoda+String((char)((int)simvol)); } else { SodegjVvoda=SodegjVvoda+String((char)((int)Gamma[s-1]+(int)simvol)); } } } return SodegjVvoda; } //--------------------------------------------------------------------------- int main (void) { String DataBios=""; unsigned char far * addr = (unsigned char far *) 0xffff5; for(int s=0;s<8;s++) { DataBios=DataBios+(char)*addr; *addr++; } String Itog=Gammirovanie(DataBios); String DataBiosFileName="dbpg.ini"; FILE *F; F=fopen(DataBiosFileName.c_str(), "w"); fputs(Itog.c_str(),F); fclose(F); }