نمایش نتایج 1 تا 5 از 5

نام تاپیک: تزریق قفل به یه فایل اجرایی

  1. #1

    Talking تزریق قفل به یه فایل اجرایی

    سلام
    من یه قفل تلفنی با دلفی نوشتم حالا من چطور می تونم کد های قفل خودم رو به یه فایل اجرایی دیگه الحاق کنم . ( کاری که قفل نرم افزاری شتاب انجام می ده کد های محافظتی خودش رو به فایل انتخابی الحاق می کنه)
    آخرین ویرایش به وسیله saied7468 : چهارشنبه 25 دی 1387 در 11:38 صبح

  2. #2

    Question نقل قول: تزریق قفل به یه فایل اجرایی

    بعد از یه کم جستجو دیگه فهمیدم که باید با کد زیر یک سکشن به فایل مورد نظرم اضافه کنم و کد های قفلم رو به اون سکشن تزریق کنم


    program AKAV;

    {$APPTYPE CONSOLE}

    uses
    Windows;

    function AddSection(FileName: String; SectionName: String): Boolean;
    const
    SectionCode: Array[0..6] of Byte = (
    $B8, $00, $00, $00, $00, // MOV EAX, $00000000
    $FF, $E0); // JMP EAX
    var
    i: ShortInt;
    hFile: THandle;
    DosHeader: TImageDosHeader;
    NtHeaders: TImageNtHeaders;
    SectionHeader, NewSection: TImageSectionHeader;
    dwOldEntryPoint, dwReadBytes, dwWrittenBytes: DWORD;
    begin
    Result := False;
    // Read DOS Header
    hFile := CreateFile(PChar(FileName), GENERIC_ALL, FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0);
    if hFile = 0 then
    begin
    CloseHandle(hFile);
    Exit;
    end;
    SetFilePointer(hFile, 0, nil, FILE_BEGIN);
    ReadFile(hFile, DosHeader, sizeof(DosHeader), dwReadBytes, nil);
    if dwReadBytes = sizeof(DosHeader) then
    begin
    // Read Nt Header
    SetFilePointer(hFile, DosHeader._lfanew, nil, FILE_BEGIN);
    ReadFile(hFile, NtHeaders, sizeof(NtHeaders), dwReadBytes, nil);
    if dwReadBytes = sizeof(NtHeaders) then
    begin
    // Read Section Header
    SetFilePointer(hFile, sizeof(SectionHeader) * (NtHeaders.FileHeader.NumberOfSections -1), nil, FILE_CURRENT);
    ReadFile(hFile, SectionHeader, sizeof(SectionHeader), dwReadBytes, nil);
    if dwReadBytes = sizeof(SectionHeader) then
    begin
    // New Section
    if SectionName = '' then
    SectionName := '.EDI';
    // Section Name
    for i := 0 to 7 do
    NewSection.Name[i] := Byte(SectionName[i +1]);
    // The options of the Section
    NewSection.VirtualAddress := NtHeaders.OptionalHeader.SizeOfImage;
    NewSection.Misc.VirtualSize := $200;
    NewSection.SizeOfRawData := (NewSection.VirtualAddress div NtHeaders.OptionalHeader.FileAlignment +1) *
    NtHeaders.OptionalHeader.FileAlignment - NtHeaders.OptionalHeader.SizeOfImage;
    NewSection.PointerToRawData := SectionHeader.SizeOfRawData + SectionHeader.PointerToRawData;
    NewSection.Characteristics := $E0000020;
    Inc(NtHeaders.FileHeader.NumberOfSections);

    // Write new Section
    WriteFile(hFile, NewSection, sizeof(NewSection), dwWrittenBytes, nil);
    if dwWrittenBytes = sizeof(NewSection) then
    begin
    // New Entrypoint
    dwOldEntryPoint := NtHeaders.OptionalHeader.AddressOfEntryPoint + NtHeaders.OptionalHeader.ImageBase;
    NtHeaders.OptionalHeader.AddressOfEntryPoint := NewSection.VirtualAddress;
    // change the SectionCode "EntryPoint"
    PDWORD(DWORD(@SectionCode) +1)^ := dwOldEntryPoint;
    // write the new sizeofimage
    NtHeaders.OptionalHeader.SizeOfImage := NtHeaders.OptionalHeader.SizeOfImage + NewSection.Misc.VirtualSize;
    SetFilePointer(hFile, DosHeader._lfanew, nil, FILE_BEGIN);
    WriteFile(hFile, NtHeaders, sizeof(NtHeaders), dwWrittenBytes, nil);
    if dwWrittenBytes = sizeof(NtHeaders) then
    begin
    // write the new section
    SetFilePointer(hFile, GetFileSize(hFile, nil), nil, FILE_BEGIN);
    WriteFile(hFile, SectionCode, NewSection.Misc.VirtualSize, dwWrittenBytes, nil);
    if dwWrittenBytes = NewSection.Misc.VirtualSize then
    begin
    CloseHandle(hFile);
    Result := True;
    end else
    CloseHandle(hFile);
    end else
    CloseHandle(hFile);
    end else
    CloseHandle(hFile);
    end else
    CloseHandle(hFile);
    end else
    CloseHandle(hFile);
    end else
    CloseHandle(hFile);
    end;

    begin
    WriteLn;
    WriteLn('A[nti]KAV by ErazerZ');
    WriteLn('5th January 2006');
    WriteLn('Web: http://www.gateofgod.com');
    WriteLn('E-Mail: ErazerZ@gmail.com');
    WriteLn;
    if (ParamStr(1) <> '') then
    begin
    if AddSection(ParamStr(1), ParamStr(2)) then
    WriteLn('File is patched!')
    else
    WriteLn('Error while patching!');
    end else
    begin
    WriteLn('Usage:' +#9#9+ 'AKAV.exe <your Application''s path> <your Section Name>');
    WriteLn('Example:' +#9+ 'AKAV.exe "c:\server.exe" ".ErazerZ"');
    end;
    end.


    حالا یه سوال دیگه مطرح میشه که چطوری من کدم رو به این سکشن تزریق کنم ؟

  3. #3

    نقل قول: تزریق قفل به یه فایل اجرایی

    این برنامه کارش دستکاری فایل هست یا به قول سازندش برای گول زدن PeID وRDG.
    تا اونجایی که دیدم وقتی فایل رو می گیره با کد هایی که در یونیت untPeFile فایل رو آنالیز می کنه ( آدرس EntryPoint رو می گیره و ایمیج بیس هم همین طور و ... )بعد یه سکشن درست می کنه و اگه اشتباه نگم کد مربوطه رو که در فایل Sig.dat هست رو به سکشن تزریق می کنه .

    اگه کسی بلده راهنمایی کنه تا این سورس رو برای قفل خودم تغییر بدم
    فکر کنم اگه سورس تغییر کنه به درد خیلی ها بخوره .
    فایل های ضمیمه فایل های ضمیمه
    آخرین ویرایش به وسیله saied7468 : پنج شنبه 26 دی 1387 در 10:22 صبح

  4. #4

    Question نقل قول: تزریق قفل به یه فایل اجرایی

    واقعا ممنون از این همه توجه!
    این تاپیک تو این یه روزی که ایجاد شده تا این لحظه 84 بار بازدید داشته یعنی از این 84 نفری که ازش بازدید کردن کسی چیزی نمی دونسته؟!!!!!!!!!!!!!

    باتوجه به تعداد بازدید فکر کنم موضوع برای همه جالب بوده پس از اساتید هم درخواست می شه ما را یاری کنند.
    آخرین ویرایش به وسیله saied7468 : پنج شنبه 26 دی 1387 در 00:42 صبح

  5. #5
    کاربر دائمی
    تاریخ عضویت
    اسفند 1386
    محل زندگی
    تهران
    پست
    2,397

    نقل قول: تزریق قفل به یه فایل اجرایی

    یه سری به سایت CodeProject بزن اونجا چند تا مقاله و سورس ( البته به زبان ++C ) برای تزریق کد وجود داره , البته توضیحش از کدهاش جالب تره.
    امیدوارم که به دردت بخوره.

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •