صفحه 1 از 2 12 آخرآخر
نمایش نتایج 1 تا 40 از 67

نام تاپیک: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

  1. #1
    کاربر دائمی آواتار joker
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    اصفهان
    سن
    42
    پست
    1,326

    محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    یه چند وقتی دنبال روشهایی بودم که بتونه کار کرکرها را سخت تر کنه
    یه چندتاییش را با توضیحات و کارایی مربوطه اینجا مینویسم
    امیدوارم دوستان برنامه نویس از این سورس ها استفاده مربوطه را ببرن

    این 3-4تا برای شناسایی وجود دیباگر SoftIce هستن

    function IsDebuggerPresent: BOOL; stdcall; external 'kernel32.dll';

    function BoundsCheckerDetected: Boolean;
    begin
    try
    asm
    push ebp
    mov ebp, 'BCHK'
    mov ax, 4
    int 3
    cmp ax, 4
    jne @@softice_detected
    mov ax, 0
    jmp @@exit
    @@softice_detected:
    mov ax, 1
    @@exit:
    pop ebp
    end;
    except
    on E: EExternalException do
    begin
    result:=False;
    end else begin
    result:=true;
    end;
    end;
    end;


    function SoftIceVXDDetected: Boolean;
    begin
    try
    asm
    push esi
    push edi
    mov ax, $1684
    mov bx, $0202 // VXD ID for SoftIce
    xor di, di
    mov es, di
    int $2F
    mov ax, es
    add di,ax
    cmp di, 0
    jne @@softice_detected
    mov ax, 0
    jmp @@exit
    @@softice_detected:
    mov ax, 1
    @@exit:
    pop edi
    pop esi
    end;
    except
    // Not hooked
    result:=False;
    end;
    end;
    //------------
    function WinIceDetected: Boolean;
    begin
    try
    asm
    mov ah, $43
    int $68
    cmp ax, $F386
    jz @@winice_detected
    mov ax, 0
    jmp @@exit
    @@winice_detected:
    mov ax, 1
    @@exit:
    end;
    except
    // Not hooked
    result:=False;
    end;
    end;



    ///////////
    function MeltIceDetected: Boolean;
    var hIce: THandle;
    dwCount: Integer;
    const
    ICE_FILES: Array [0..3] of PChar = ('\\.\SICE', '\\.\NTICE', '\\.\SIWVID', '\\.\FROGICE');
    begin

    // Description: Detect the presence of SoftIce and many other memory resident
    // tools by attempting to load SoftIce related devices such its display
    // driver, or its access driver. Devices such as SICE, NTICE, SIWVID, FROGICE.
    result:=False;
    for dwCount:=0 to High(ICE_FILES) do
    begin
    hIce:=CreateFile(ICE_FILES[dwCount], GENERIC_READ, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, 0);
    if (hIce <> INVALID_HANDLE_VALUE) then
    begin
    CloseHandle(hIce);
    result:=True;
    break;
    end;
    end;
    end;
    ///////////
    اینطوری هم استفاده میشن :

    if SoftIceVXDDetected then Application.Terminate;
    if WinIceDetected then Application.Terminate;
    if BoundsCheckerDetected then Application.Terminate;
    if MeltIceDetected then Application.Terminate;
    if IsDebuggerPresent then Application.Terminate;
    البته میتونید بعد از تشخیص دیباگر کارهایی بدتری غیر از بستن برنامه هم بکنید....;)

    آنتی دامپ:
    کد زیر کارش تغییر ایمج بیس برنامه هست که از Dump گرفتن برنامه جلوگیری میکنه


    procedure FOLL();
    begin
    asm
    mov eax, fs:[$30]
    mov eax, [eax+$C]
    mov eax, [eax+$C]
    add dword ptr [eax+$20], $2000
    end;
    end;
    البته به این نکته توجه داشته باشین که جهت خنثی کردن این کد با نرم افزار LoredPe در قسمت CorectImageBase قابل انجام هست بنابراین توی یک تایمر در نرم افزار میتونید هر 1 میلی ثانیه یکبار این پروسه را اجرا کنید و شاهد سرویس شدن کرکر محترم در گرفتن دامپ باشید .( این مرحله را از خودم در ورکردم ) یکی از راههای دور زدنش از کار انداختن تایمر با thread هست که توی برنامه داره این کار را انجام میده ! ( تقریبا روش مطمئنیه )

    AntiOlly
    :
    برای مقابله با نرم افزار دیباگرOlyDbg از روشهایی مثل FindWindow استفاده کنید چنانچه یکی از پنجره ها اسم olly توش بود برنامه را خاتمه بدین ( برای این روش توی olly دیباگر یکسری پلاگین هست ، که از تغییر عنوان پنجره تا هوک کردن این تابع استفاده میشه )
    یا از نرم افزار آنتی olly که به همین پست ضمیمه میکنم استفاده کنید که کمی به امنیت برنامه ها در مقابل این دیباگر خوش دست کمک میکنه.
    استفاده از توابع IsDebugerPereset هم توضیح ندم سنگین تر هست.

    در عین حال میتونید از باگی که در Olly در موقع صدا زدن تابع OutputDebugString هست هم برای آورفلو و نهایتن کرش کردن این دیباگر موقع باز کردن برنامه تان استفاده کنید.
    تمامی موارد فوق قابل دور زدن میباشد ، فقط جنبه تقویت قفل میباشد.
    حسش بود یه چندتایی روش دیگه را هم مینویسم....
    نکته : این کدها را در آخر سر به برنامه تان اضافه کنید چون موقع اجرای مستقیم ممکنه خودIde قاط بزنه ...
    بعد از اضافه کردن این توابع برنامه را فقط کامپایل کنید ، و مستقل از ide اون را به راحتی اجرا کنید ( دیباگر داخلی ide فعال میشه )
    فایل های ضمیمه فایل های ضمیمه
    آخرین ویرایش به وسیله joker : یک شنبه 06 آذر 1390 در 20:37 عصر

  2. #2
    کاربر دائمی آواتار joker
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    اصفهان
    سن
    42
    پست
    1,326
    اگه احیانا فایلتون را پک کردین
    با پکر ها یا پروتکتورها فرقی نمیکنه...
    چون همیشه راهی برای آنپک هست بهتره این تکه کد را هم به سورستون اضافه کنید
    ( هرچند که کسی که دنبال کرک باشه نهایتا از این کد ها هم میگزره ولی اصل خسته کردن کرکر فراموش نشه یک قفل هم یک قفله )


    procedure TFORO1.FormCreate(Sender: TObject);
    var
    size:Longint;
    hFile: Thandle;
    begin

    try
    hFile := CreateFileA( pchar(paramstr(0)) , GENERIC_READ ,
    FILE_SHARE_READ , nil, OPEN_EXISTING,
    FILE_ATTRIBUTE_NORMAL, 0);
    if( hFile <> INVALID_HANDLE_VALUE ) then
    begin
    Size :=GetFileSize(hfile,nil);
    end;

    if size <> سایز فایل پک شده then Application.Terminate;
    CloseHandle(hFile);
    if size > سایزفایل پک شده then Application.Terminate;

    except
    end;


    end;

    فایل آنپک شده به طور حتم فایلیه که قصد انجام کرک را براش کردن بنابراین میتونید به جای بسته شدن مستقیم کلا روتین اجرای برنامه را به سمت حالت shareware پیش ببرید که سراغ روتینهایی برن که عملا در فایل اصلی هیچ وقت اجرا نمیشن مثلا روتین قفل الکی و پیغامهای الکی و.......
    با این روش حتی اگه از upx هم استفاده کرده باشین بازم جای امیدواری داره ;)

    لازم به ذکر است یکی از راههای کرکرها برای اینکه نیازی به آنپک نداشته باشن استفاده از تکنیک InLinePatch هست.
    پیوست:
    برای دیدن نمونه برنامه هایی که با این روشها محافظت شدن به تاپیک زیر میتونید سر بزنید
    https://barnamenevis.org/showthread.php?t=53797

  3. #3
    کاربر دائمی آواتار joker
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    اصفهان
    سن
    42
    پست
    1,326

    analyze PE file headers

    حسش نبود کل یک سایتو به خاطر 2تاتابع بگردم ;)
    -------------------

    برای اینکه برنامه خودتون را به صورت دقیق تر ( دقیق تر از گرفتن یک حجم ساده بتونید کنترل کنید که چیزی دستکاری نشده باشه ...
    analyze PE file headers

    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls;

    type
    TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    OpenDialog1: TOpenDialog;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    var
    Form1: TForm1;

    implementation
    procedure DumpDOSHeader(const h: IMAGE_DOS_HEADER; Lines: TStrings);
    begin
    Lines.Add('Dump of DOS file header');
    Lines.Add(Format('Magic number: %d', [h.e_magic]));
    Lines.Add(Format('Bytes on last page of file: %d', [h.e_cblp]));
    Lines.Add(Format('Pages in file: %d', [h.e_cp]));
    Lines.Add(Format('Relocations: %d', [h.e_crlc]));
    Lines.Add(Format('Size of header in paragraphs: %d', [h.e_cparhdr]));
    Lines.Add(Format('Minimum extra paragraphs needed: %d', [h.e_minalloc]));
    Lines.Add(Format('Maximum extra paragraphs needed: %d', [h.e_maxalloc]));
    Lines.Add(Format('Initial (relative) SS value: %d', [h.e_ss]));
    Lines.Add(Format('Initial SP value: %d', [h.e_sp]));
    Lines.Add(Format('Checksum: %d', [h.e_csum]));
    Lines.Add(Format('Initial IP value: %d', [h.e_ip]));
    Lines.Add(Format('Initial (relative) CS value: %d', [h.e_cs]));
    Lines.Add(Format('File address of relocation table: %d', [h.e_lfarlc]));
    Lines.Add(Format('Overlay number: %d', [h.e_ovno]));
    Lines.Add(Format('OEM identifier (for e_oeminfo): %d', [h.e_oemid]));
    Lines.Add(Format('OEM information; e_oemid specific: %d', [h.e_oeminfo]));
    Lines.Add(Format('File address of new exe header: %d', [h._lfanew]));
    Lines.Add('');
    end;

    procedure DumpPEHeader(const h: IMAGE_FILE_HEADER; Lines: TStrings);
    var
    dt: TDateTime;
    begin
    Lines.Add('Dump of PE file header');
    Lines.Add(Format('Machine: %4x', [h.Machine]));
    case h.Machine of
    IMAGE_FILE_MACHINE_UNKNOWN : Lines.Add(' MACHINE_UNKNOWN ');
    IMAGE_FILE_MACHINE_I386: Lines.Add(' Intel 386. ');
    IMAGE_FILE_MACHINE_R3000: Lines.Add(' MIPS little-endian, 0x160 big-endian ');
    IMAGE_FILE_MACHINE_R4000: Lines.Add(' MIPS little-endian ');
    IMAGE_FILE_MACHINE_R10000: Lines.Add(' MIPS little-endian ');
    IMAGE_FILE_MACHINE_ALPHA: Lines.Add(' Alpha_AXP ');
    IMAGE_FILE_MACHINE_POWERPC: Lines.Add(' IBM PowerPC Little-Endian ');
    // some values no longer defined in winnt.h
    $14D: Lines.Add(' Intel i860');
    $268: Lines.Add(' Motorola 68000');
    $290: Lines.Add(' PA RISC');
    else
    Lines.Add(' unknown machine type');
    end; { Case }
    Lines.Add(Format('NumberOfSections: %d', [h.NumberOfSections]));
    Lines.Add(Format('TimeDateStamp: %d', [h.TimeDateStamp]));
    dt := EncodeDate(1970, 1, 1) + h.Timedatestamp / SecsPerDay;
    Lines.Add(FormatDateTime(' c', dt));

    Lines.Add(Format('PointerToSymbolTable: %d', [h.PointerToSymbolTable]));
    Lines.Add(Format('NumberOfSymbols: %d', [h.NumberOfSymbols]));
    Lines.Add(Format('SizeOfOptionalHeader: %d', [h.SizeOfOptionalHeader]));
    Lines.Add(Format('Characteristics: %d', [h.Characteristics]));
    if (IMAGE_FILE_DLL and h.Characteristics) <> 0 then
    Lines.Add(' file is a DLL')
    else if (IMAGE_FILE_EXECUTABLE_IMAGE and h.Characteristics) <> 0 then
    Lines.Add(' file is a program');
    Lines.Add('');
    end;

    procedure DumpOptionalHeader(const h: IMAGE_OPTIONAL_HEADER; Lines: TStrings);
    begin
    Lines.Add('Dump of PE optional file header');
    Lines.Add(Format('Magic: %d', [h.Magic]));
    case h.Magic of
    $107: Lines.Add(' ROM image');
    $10b: Lines.Add(' executable image');
    else
    Lines.Add(' unknown image type');
    end; { If }
    Lines.Add(Format('MajorLinkerVersion: %d', [h.MajorLinkerVersion]));
    Lines.Add(Format('MinorLinkerVersion: %d', [h.MinorLinkerVersion]));
    Lines.Add(Format('SizeOfCode: %d', [h.SizeOfCode]));
    Lines.Add(Format('SizeOfInitializedData: %d', [h.SizeOfInitializedData]));
    Lines.Add(Format('SizeOfUninitializedData: %d', [h.SizeOfUninitializedData]));
    Lines.Add(Format('AddressOfEntryPoint: %d', [h.AddressOfEntryPoint]));
    Lines.Add(Format('BaseOfCode: %d', [h.BaseOfCode]));
    Lines.Add(Format('BaseOfData: %d', [h.BaseOfData]));
    Lines.Add(Format('ImageBase: %d', [h.ImageBase]));
    Lines.Add(Format('SectionAlignment: %d', [h.SectionAlignment]));
    Lines.Add(Format('FileAlignment: %d', [h.FileAlignment]));
    Lines.Add(Format('MajorOperatingSystemVersion: %d', [h.MajorOperatingSystemVersion]));
    Lines.Add(Format('MinorOperatingSystemVersion: %d', [h.MinorOperatingSystemVersion]));
    Lines.Add(Format('MajorImageVersion: %d', [h.MajorImageVersion]));
    Lines.Add(Format('MinorImageVersion: %d', [h.MinorImageVersion]));
    Lines.Add(Format('MajorSubsystemVersion: %d', [h.MajorSubsystemVersion]));
    Lines.Add(Format('MinorSubsystemVersion: %d', [h.MinorSubsystemVersion]));
    Lines.Add(Format('Win32VersionValue: %d', [h.Win32VersionValue]));
    Lines.Add(Format('SizeOfImage: %d', [h.SizeOfImage]));
    Lines.Add(Format('SizeOfHeaders: %d', [h.SizeOfHeaders]));
    Lines.Add(Format('CheckSum: %d', [h.CheckSum]));
    Lines.Add(Format('Subsystem: %d', [h.Subsystem]));
    case h.Subsystem of
    IMAGE_SUBSYSTEM_NATIVE:
    Lines.Add(' Image doesn''t require a subsystem. ');
    IMAGE_SUBSYSTEM_WINDOWS_GUI:
    Lines.Add(' Image runs in the Windows GUI subsystem. ');
    IMAGE_SUBSYSTEM_WINDOWS_CUI:
    Lines.Add(' Image runs in the Windows character subsystem. ');
    IMAGE_SUBSYSTEM_OS2_CUI:
    Lines.Add(' image runs in the OS/2 character subsystem. ');
    IMAGE_SUBSYSTEM_POSIX_CUI:
    Lines.Add(' image run in the Posix character subsystem. ');
    else
    Lines.Add(' unknown subsystem')
    end; { Case }
    Lines.Add(Format('DllCharacteristics: %d', [h.DllCharacteristics]));
    Lines.Add(Format('SizeOfStackReserve: %d', [h.SizeOfStackReserve]));
    Lines.Add(Format('SizeOfStackCommit: %d', [h.SizeOfStackCommit]));
    Lines.Add(Format('SizeOfHeapReserve: %d', [h.SizeOfHeapReserve]));
    Lines.Add(Format('SizeOfHeapCommit: %d', [h.SizeOfHeapCommit]));
    Lines.Add(Format('LoaderFlags: %d', [h.LoaderFlags]));
    Lines.Add(Format('NumberOfRvaAndSizes: %d', [h.NumberOfRvaAndSizes]));
    end;

    {$R *.DFM}

    procedure TForm1.Button1Click(Sender: TObject);
    var
    fs: TFilestream;
    signature: DWORD;
    dos_header: IMAGE_DOS_HEADER;
    pe_header: IMAGE_FILE_HEADER;
    opt_header: IMAGE_OPTIONAL_HEADER;
    begin
    memo1.Clear;
    with Opendialog1 do
    begin
    Filter := 'Executables (*.EXE)|*.EXE';
    if Execute then
    begin
    fs := TFilestream.Create(FileName, fmOpenread or fmShareDenyNone);
    try
    fs.read(dos_header, SizeOf(dos_header));
    if dos_header.e_magic <> IMAGE_DOS_SIGNATURE then
    begin
    memo1.Lines.Add('Invalid DOS file header');
    Exit;
    end;
    DumpDOSHeader(dos_header, memo1.Lines);

    fs.seek(dos_header._lfanew, soFromBeginning);
    fs.read(signature, SizeOf(signature));
    if signature <> IMAGE_NT_SIGNATURE then
    begin
    memo1.Lines.Add('Invalid PE header');
    Exit;
    end;

    fs.read(pe_header, SizeOf(pe_header));
    DumpPEHeader(pe_header, memo1.Lines);

    if pe_header.SizeOfOptionalHeader > 0 then
    begin
    fs.read(opt_header, SizeOf(opt_header));
    DumpOptionalHeader(opt_header, memo1.Lines);
    end;
    finally
    fs.Free;
    end; { finally }
    end;
    end;
    end;
    end.


    دوستانی که احیانا خودشون قصد نوشتن پکر دارن ، این سورس میتونه خیلی براشون مفید باشه
    مرجع سورس
    عکس های ضمیمه عکس های ضمیمه  

  4. #4
    کاربر دائمی آواتار joker
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    اصفهان
    سن
    42
    پست
    1,326
    Anti OllyDebuger
    این مورد تجربه ای از کار با یک CrackMe هست که در اختیار دوستان قرار میدم.
    ( با تشکر از دوست عزیز SubZero)
    خب اگه با دیباگری مثلی olly کار کرده باشین حتما پلاگینهایی را دید که نام OllyDbg را موقع گرفتن لیست عنوان پنجره ها مخفی میکنند ( همانطور که قبلا گفتم موراد مربوط به تابع FindWindow

    خب بیایم یه کم ما هم غیر عادی تر عمل کنیم ، یعنی دنبال نام OllyDbg اصلا نباشیم ( چون تحت هر عنوانی ممکنه این نام عوض شده باشه ( حتی تغییر نام فایل exe این دیباگر روی بعضی از پلاگینها اثر میگذاره :) )
    یکی از راههای مقابله با این روش کرکرها اینه که توی لیست دنبال کلمه
    Module یا thread بگردیم یا جمله کاملش ...
    اگه یک فایل توی olly باز کنید متوجه میشید چی میگم ( عکس ضمیمه )

    خب پس ما کد مون را طوری تغییر میدیم که اگه چنین کلمه ای در یکی از عناوین وجود داشت فرض را بر باز بودن این دیباگر بزاره و ( چگونگی ادامه کار به عهده خودتون )

    سورس مربوطه برای لیست کردن تمام پنجره های قابل نمایش و غیر قابل نمایش در task Manager ویندوز
    توابع جستجو در استرینگها هم که توضیح لازم نداره ...



      
    function enumwindowsproc(wnd:Hwnd ; form:Tform):boolean;export; {$ifdef win32} stdcall ;{$endif}
    var
    buffer : array[0..250] of char ;
    begin

    getwindowtext(wnd,buffer,100);
    if strlen(buffer)<> 0 then
    form1.ListBox1.Items.Add(strpas(buffer));
    result := true ;
    end;

    // 0000000000000000000000000000000000

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    listbox1.Clear;
    enumwindows(@enumwindowsproc,longint(self));
    end;

    البته میتونید مستقیما از GetForegroundWindow هم استفاده کنید... ;) اما سورسی که ضمیمه کردم را داشته باشین برای مطالب بعدی که مینویسم در مورد محافظت برنامه در مقابل سیستمهای مونیتورینگ مثل FileMonitor و RegistryMonitor ها. چون یکی از روشهای اولیه مقابله با این نرم افزارها گرفتن هندل اونها هست ، ( البته روشهایی هم برای مخفی کردنشون بکار میره که بعدا به طور دقیقتر بررسی میکنیم)
    اگه زنده موندم....
    عکس های ضمیمه عکس های ضمیمه   

  5. #5
    کاربر دائمی آواتار joker
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    اصفهان
    سن
    42
    پست
    1,326
    شما را به خواندن مطالب خوشنگارشتر در مورد فرمت فایلهایPE دعوت میکنم
    http://www.ALT.ir/help/ARTeam PE Tutorial.chm

  6. #6
    مقاله خوبی بود و در بیشتر موارد از Iczelion's استفاده کرده بود. در هر حال به تمام دوستانی که در این زمینه نیاز به اطلاعات دارند توصیه می کنم که این مقاله را بخوانند و در ضمن به این http://spiff.tripnet.se/~iczelion/files/pe-tuts.zip هم نظری داشته باشند.

    البته دوستان بهتر هست که مرجع سایت را ارائه نماییند و در اختیار قرار دهند چون سایت http://arteam.accessroot.com سایت بسیار مفیدی بود و به لیست Favoraites من پیوست.
    در اینجا از Joker تشکر می کنم.

  7. #7
    1) این روش رو اولین بار در Cra@ck me دیدم:
    پنجره برنامه خود رو TOP MOST کنید؛ اینطوری برنامه شما Focus رو می گیره و Debugger همیشه پشت پنجره میمونه.

    2) اگه اشتباه نکنم اساس روش زیر از Cr@ck me ایه که با DotFix انگولک شده بود :
    یه Thread با اولویت High بسازید تا دیباگر Hang کنه.

    3) تجربه شخصی میگه:
    -> همه چیز رو در داخل یه کد نریزید, منظورم اینه که علاوه بر برنامه خود از Thread و فایلهای جانبی (مثل DLL) هم برای چک کردن امنیت برنامه استفاده کنید.

    -> فقط به یکبار چک کردن امنیت ؛ اکتفا نکنید. مثلا چندین بار از طریق Procedure های متفاوت وجود دیباگر رو شناسایی کنید. اگه میگم Procedureهای متفاوت واسه اینه که اگه یک Procedure رو 100 جا فراخوانی کنید؛ واضحه که همه فراخوانی ها به یک آدرس مراجعه میکنن لذا در خیلی موارد استفاده از RETN میتونه Procedure شما رو برای همیشه فلج کنه.

    ->بهتره سطر اول و آخر Function ها و Procedure های خود رو به Trick هایی جهت شناسایی BP مجهز کنید؛ چون کرکرها از روی عادت؛ همیشه روی اولین خط یا آخرین خط یه تابع BP میذارن.

    -> غیر فعال کردن یه CRC خوب ؛ معمولا خسته کننده ترین جای یه کد واسه کرکره!

    -> به عنوان یه اصل؛ هیچ گاه بلافاصله بعد از این که چک کردید که آیا شرط امنیتی نقض شده یا نه؛ Jump نکنید و MessageBox رو نشون ندید ...!

    -> Registery ویندوز عمومیترین جاییه که برنامه نویسان واسه نگهداری کدها و جنبه های امنیتی برنامه شون ازش استفاده میکنن...!

    -> با کمی مطالعه و تحقیق میتونین IAT رو دستکاری کنید....این عاقلانه ترین کار واسه مخفی کردن لیست API هایی است که برنامه تون ازش استفاده میکنه.

    تذکر:
    1) تمام روشهایی که من و Joker ذکر کردیم به Ring3 مربوط میشه.
    2) تمام روشهای فوق الذکر قابل دور زدن هستن

    خواهش:
    کما فی السابق از هیچکدام از روشهای من و جوکر استفاده نکنید...!

  8. #8
    کاربر دائمی آواتار joker
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    اصفهان
    سن
    42
    پست
    1,326
    در ادامه تائید حرفهای افشین :

    برای کدTOP توی دیباگری مثلsice جوابگو نیست ، توی oly هم در اکثر موارد ALT+F5 مشکل را حل میکنه :)
    ولی برای کرکرهای تازه کار بد نیست حال گیری کنه .

    Thread ها همیشه مایه دردسر کرکرها هست ، حتما استفاده کنید ( اللخصوص روتینهای مربوط به امنیت ، و همیشه تکه ای از کد اصلی برنامه را هم اجرایش را منوط به در حال استفاده بودن ترد بزارین که در صورتی که ترد را ساسپند کردن برنامه عملا کار نکنه )

    پیرو حرف افشین نه تنها یکبار چک نکنید بلکه با یه case و یه تابع random روتینهای مختلف را چک کنید ( سرویس دهان و دندان )
    بهتره سطر اول و آخر Function ها و Procedure های خود رو به Trick هایی جهت شناسایی BP مجهز کنید؛ چون کرکرها از روی عادت؛ همیشه روی اولین خط یا آخرین خط یه تابع BP میذارن.
    سورس بزار لطفا :)

    -> به عنوان یه اصل؛ هیچ گاه بلافاصله بعد از این که چک کردید که آیا شرط امنیتی نقض شده یا نه؛ Jump نکنید و MessageBox رو نشون ندید ...!
    حتی المکان اصلا نزارید ، به جاش برنامه را طوری بنویسید که بعد از ورود قفل ( مثلا اکتیو کد) برنامه نیاز به ریست داشته باشه و توی بارگذاری مجدد وجود قفل چک بشه ( شایداین روش را توی خیلی از برنامه ها دیده باشین )
    > Registery ویندوز عمومیترین جاییه که برنامه نویسان واسه نگهداری کدها و جنبه های امنیتی برنامه شون ازش استفاده میکنن...!
    اگه احیانا مجبور به استفاده از ثبت اطلاعات در رجیستری یا فایل شدید ( که حتما میشید) سعی کنید اطلاعات کد شده نوشته بشن
    ( روتین دیکود که خودتون دارید)
    یک نمونه در اینجا از روتین های کد گزاری متن میزارم.
    ( میشه گفت غیر از کدینگ معمولی برای دریافت و ارسال اکتیو کد های فایلیKey هم خیلی خوب میتونید ازش استفاده کنید )


    function MY_Encript(const ReaLtext:String;password:string ):string ;
    var
    x,i, // count variables
    sText,sPW: Integer; // size of Text, PW
    Buffer,PW: PChar; // buffer for Text, PW
    begin
    sText:=Length(Realtext)+1;
    sPW:=Length(password)+1;

    GetMem(Buffer,sText);
    GetMem(PW,sPW);

    // GetWindowText( hEdit,Text,sText);
    Buffer := pchar(Realtext) ;
    PW := pchar(password) ;

    x:=0; // initialize count
    for i:=0 to sText-2 do
    begin
    Buffer[i]:=Chr(Ord(Buffer[i])+Ord(PW[x]));
    Inc(x);
    if x=(sPW-1)then x:=0;
    end;
    Result := Buffer ;
    end;// end of proc



    function MY_Descript(inText:String;password:string ):String ;

    var
    x,i, // count variables
    sText,sPW: Integer; // size of Text, PW
    Text,PW: PChar; // buffer for Text, PW
    begin
    sText:=Length(intext)+1;

    sPW:=Length(password)+1;

    GetMem(Text,sText);
    GetMem(PW,sPW);

    text:= pchar(intext);
    PW:= pchar(password);

    x:=0; // initialize count
    for i:=0 to sText-2 do
    begin
    Text[i]:=Chr(Ord(Text[i])-Ord(PW[x]));
    Inc(x);
    if x=(sPW-1)then x:=0;
    end;
    result := text ;
    end;// end of prioc

    تذکر:
    1) تمام روشهایی که من و Joker ذکر کردیم به Ring3 مربوط میشه.
    2) تمام روشهای فوق الذکر قابل دور زدن هستن
    حالا بیا و درستش کن :)
    استفاده کنید اقا ( این افشین طرف خرسه هست )، یه قفلم یه قفله
    رینگ 0 را هم استاد میکنن ، ولی خب آدمهای کمتر.

  9. #9
    یه مورد از خودم بدم حال ببرید.

    .386
    .model flat, stdcall
    option casemap :none ; case sensitive

    include \masm32\include\windows.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc

    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib

    .data
    msgTitle db "Execution status:",0h
    msgText1 db "No debugger detected!",0h
    msgText2 db "Debugger detected!",0h
    .code

    start:

    ; MASM32 antiRing3Debugger example

    ; This code takes advantage of debugger not handleing INT3
    ; instructions correctly. If we set a SEH before INT3 executing
    ; INT3 instruction will fire SEH. If debugger is present it
    ; will just walk over INT3 and go straight forward.
    ; If debugger is not present exception will occure and exection
    ; will be handled by SEH.

    ; Set SEH
    ASSUME FS:NOTHING
    PUSH offset @Check
    PUSH FS:[0]
    MOV FS:[0],ESP

    ; Exception
    INT 3h

    PUSH 30h
    PUSH offset msgTitle
    PUSH offset msgText2
    PUSH 0
    CALL MessageBox

    PUSH 0
    CALL ExitProcess

    ; SEH handleing
    @Check:
    POP FS:[0]
    ADD ESP,4

    PUSH 40h
    PUSH offset msgTitle
    PUSH offset msgText1
    PUSH 0
    CALL MessageBox

    PUSH 0
    CALL ExitProcess

    end start

    و برای SICE :

    ; ################################################## #######################

    .586
    .model flat, stdcall
    option casemap :none ; case sensitive

    ; ################################################## #######################
    include \masm32\include\windows.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\comdlg32.inc

    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib
    includelib \masm32\lib\comdlg32.lib

    ; ################################################## #######################
    .data
    VICETOOLZ_1 db "\\.\SICE",0h
    VICETOOLZ_2 db "\\.\SIWVID",0h
    VICETOOLZ_3 db "\\.\NTICE",0h
    VICETOOLZ_4 db "\\.\REGSYS",0h
    VICETOOLZ_5 db "\\.\REGVXG",0h
    VICETOOLZ_6 db "\\.\FILEVXG",0h
    VICETOOLZ_7 db "\\.\FILEM",0h
    VICETOOLZ_8 db "\\.\TRW",0h
    VICETOOLZ_9 db "\\.\ICEEXT",0h

    DbgNotFoundTitle db "Debugger status:",0h
    DbgFoundTitle db "Debugger status:",0h
    DbgNotFoundText db "Debugger or other vice tool not found!",0h
    DbgFoundText db "Debugger or other vice tool found!",0h
    .code

    start:

    ; This is the oldest way to detect SoftICE. Here we do it by trying to
    ; create a file named as SoftICE driver. Since we can not access it
    ; error will occure and we will detect this by CreateFileA return value.
    ; If EAX is zero, SICE or other "vice" tool is detected.

    ; Start data. There are 9 of vice tools and first string is located at
    ; VICETOOLZ_1 offset.

    MOV ESI,9
    MOV EDI,offset VICETOOLZ_1

    @TryNext:
    PUSH 0h ;hTemplateFile
    PUSH FILE_ATTRIBUTE_NORMAL ;Hidden/Normal
    PUSH OPEN_EXISTING ;OPEN_EXISTING
    PUSH 0h ;pSecurity
    PUSH FILE_SHARE_READ ;ShareMode = File Share Write
    PUSH FILE_FLAG_WRITE_THROUGH ;Access
    PUSH EDI ;Path
    CALL CreateFileA ;CreateFileA

    ; Small fix here!

    CMP EAX,-1
    JNE @ToolFound

    ; Here we search for the next vice tool string [name].

    @find_next:
    INC EDI
    CMP BYTE PTR[EDI],0h
    JNE @find_next
    INC EDI
    DEC ESI
    JNE @TryNext

    PUSH 40h
    PUSH offset DbgNotFoundTitle
    PUSH offset DbgNotFoundText
    PUSH 0
    CALL MessageBox

    @Exit:
    PUSH 0
    CALL ExitProcess

    @ToolFound:
    PUSH 30h
    PUSH offset DbgFoundTitle
    PUSH offset DbgFoundText
    PUSH 0
    CALL MessageBox
    JMP @Exit

    end start

    البته من فکر کنم قبلا بحثی داشتم. http://www.barnamenevis.org/sh...t=17923&page=4

    البته دیگه این چیزا قدیمی شده و بچه کرکر ها هم دیگه می تونند این چیزا رو در بشوند. من خودم به شخصه دیگه از این جور بحثا خوشم نمی آد ولی بهترین روش همون Ring0 نویسی هست .
    اینم یه سایت توپ : http://www.microsoft.com/whdc/devtools/ddk/default.mspx :)
    آخرین ویرایش به وسیله whitehat : دوشنبه 30 اردیبهشت 1387 در 10:56 صبح دلیل: اضافه كردن تگ كد

  10. #10
    کاربر دائمی آواتار joker
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    اصفهان
    سن
    42
    پست
    1,326
    برنامه های محافظت شده رینگ0 در بعضی جاها به مشکل بر میخورند کاربرهایی که میخوان برنامه را در سطح user معمولی ویندوز نصب کنن و کار کنن نه administrator
    البته محاسنش به دردسرهاش می ارزه...
    برای برنامه نویسی درایور ویندوزی هم کتاب The Windows 2000 Device Driver Book, A Guide for Programmers بد نیست


    The Windows 2000 Device Driver Book, A Guide for Programmers, Second Edition

    Foreword

    Preface
    What You Should Already Know
    What's Covered
    What's Not
    About the Sample Code
    History of this Book
    Training and Consulting Services

    Acknowledgments

    1. Introduction to Windows 2000 Drivers
    Overall System Architecture
    Kernel-Mode I/O Components
    Special Driver Architectures
    Summary

    2. The Hardware Environment
    Hardware Basics
    Buses and Windows 2000
    Hints for Working with Hardware
    Summary

    3. Kernel-Mode I/O Processing
    How Kernel-Mode Code Executes
    Use of Interrupt Priorities by Windows 2000
    Deferred Procedure Calls (DPCs)
    Access to User Buffers
    Structure of a Kernel-Mode Driver
    I/O Processing Sequence
    Summary

    4. Drivers and Kernel-Mode Objects
    Data Objects and Windows 2000
    I/O Request Packets (IRPs)
    Driver Objects
    Device Objects and Device Extensions
    Controller Objects and Controller Extensions
    Adapter Objects
    Interrupt Objects
    Summary

    5. General Development Issues
    Driver Design Strategies
    Coding Conventions and Techniques
    Driver Memory Allocation
    Unicode Strings
    Interrupt Synchronization
    Synchronizing Multiple CPUs
    Linked Lists
    Summary

    6. Initialization and Cleanup Routines
    Writing a DriverEntry Routine
    Code Example: Driver Initialization
    Writing Reinitialize Routines
    Writing an Unload Routine
    Code Example: Driver Unload
    Writing Shutdown Routines
    Testing the Driver
    Summary

    7. Driver Dispatch Routines
    Announcing Driver Dispatch Routines
    Writing Driver Dispatch Routines
    Processing Read and Write Requests
    Code Example: A Loopback Device
    Extending the Dispatch Interface
    Testing Driver Dispatch Routines
    Summary

    8. Interrupt-Driven I/O
    How Programmed I/O Works
    Driver Initialization and Cleanup
    Writing a Start I/O Routine
    Writing an Interrupt Service Routine (ISR)
    Writing a DpcForIsr Routine
    Some Hardware: The Parallel Port
    Code Example: Parallel Port Loopback Driver
    Testing the Parallel Port Loopback Driver
    Summary

    9. Hardware Initialization
    The Plug and Play Architecture: A Brief History
    The Role of the Registry for Legacy Drivers
    Detecting Devices with Plug and Play
    The Role of Driver Layers in Plug and Play
    The New WDM IRP Dispatch Functions
    Device Enumeration
    Device Interfaces
    Code Example: A Simple Plug and Play Driver
    Summary

    10. Power Management
    Hot Plug Devices
    OnNow Initiative
    Wake Requests
    Power Management Issues
    Summary

    11. Timers
    Handling Device Timeouts
    Code Example: Catching Device Timeouts
    Managing Devices without Interrupts
    Code Example: A Timer-Based Driver
    Summary

    12. DMA Drivers
    How DMA Works under Windows 2000
    Working with Adapter Objects
    Writing a Packet-Based Slave DMA Driver
    Code Example: A Packet-Based Slave DMA Driver
    Writing a Packet-Based Bus Master DMA Driver
    Writing a Common Buffer Slave DMA Driver
    Writing a Common Buffer Bus Master DMA Driver
    Summary

    13. Windows Management and Instrumentation
    WMI: The Industry Picture
    The WMI Architecture
    WMI Summary
    Conventional Driver Event Logging
    Summary

    14. System Threads
    Definition and Use of System Threads
    Thread Synchronization
    Using Dispatcher Objects
    Code Example: A Thread-Based Driver
    Summary

    15. Layered Drivers
    An Overview of Intermediate Drivers
    Writing Layered Drivers
    Writing I/O Completion Routines
    Allocating Additional IRPs
    Writing Filter Drivers
    Code Example: A Filter Driver
    Writing Tightly Coupled Drivers
    Summary

    16. Driver Installation
    Installation of a Driver
    Auto-Install Using INF Files
    Using a Driver INF File
    Controlling Driver Load Sequence
    Digital Signing of a Driver
    Summary

    17. Testing and Debugging Drivers
    Guidelines for Driver Testing
    Why Drivers Fail
    Reading Crash Screens
    An Overview of WinDbg
    Analyzing a Crash Dump
    Interactive Debugging
    Writing WinDbg Extensions
    Code Example: A WinDbg Extension
    Miscellaneous Debugging Techniques
    Summary

    A. The Driver Debug Environment
    Hardware and Software Requirements
    Debug Symbol Files
    Enabling Crash Dumps on the Target System
    Enabling the Target System's Debug Client

    B. Bugcheck Codes

    C. Building Drivers
    The Build Utility
    Using Visual Studio to Build Drivers

    آخرین ویرایش به وسیله Inprise : شنبه 02 دی 1385 در 03:47 صبح دلیل: Warez Activity

  11. #11
    1) فرض کنید که برنامه تون رو اونقدر قوی ساختید که Patch کردنش وقت و هزینه زیادی میخواد.
    اگه مطالب اینپرایز عزیز رو در مورد Loader به یاد داشته باشید. باید خدمتتون عرض کنم که با استفاده از Loader , بسیار راحت میشه امنیت برنامه تون رو دور زد.
    Loader برنامه تون رو اجرا میکنه و در RAM روی Offset مورد نظر می ایسته و تغییر لازم رو اعمال میکنه. اینطوری بدون اینکه سایز برنامه تون در دیسک تغییر کنه؛ Patch میشه.

    2)تصور کنید برنامه ای نوشتین که به ازای Name های مختلف, Serial Number های متفاوتی تولید میکنه. و کاری کردید که کرکر حتی در RAM هم قادر به دستکاری برنامه نیست.
    اساس کار Serial Fishing از این ضعف استفاده میکنه که برنامه شما یک رشته رو با رشته دیگه مقایسه میکنه. کرکر میتونه با مراجعه به محتوای ثباتها, "کد صحیح" رو استخراج کنه.
    اما از اونجایی که برنامه شما هربار کد جدیدی تولید میکنه (و غیر قابل تغییر هم هست) باید از روش فوق العاده زیبای دیگه استفاده کرد.
    Serial Sniffing روشیه که از ترکیب دو روش بالا استفاده میکنه؛ یعنی همیشه برنامه رو تا آدرس مورد نظر اجرا میکنه و بعد محتوای ثباتها رو نشون میده

    3)با استفاده از تابع VirtualAlloc صفحاتی(Page) از حافظه رو که داده های خود رو بار گذاری کردید, کدگذاری کنید و فقط زمانی انرا کدگشایی کنید که به اطلاعات آن نیاز دارید( بدیهی است که بلافاصله بعد از خواندن باید دوباره کدگذاری کنید)
    این روش رو تقربیا همه پروتکتورهای قوی استفاده میکنن.

    4)از پروتکتورهای آماده(و مشهور) استفاده نکنید. چون روشهای دور زدن اونها خیلی زود کشف میشه.

    5)تجربه شخصی نشون داده که متاسفانه یا خوشبختانه؛ هیچ وقت قادر به تضمین 100% امنیت برنامه تون نخواهید بود.
    فایل های ضمیمه فایل های ضمیمه

  12. #12
    اگه هنوز نمیدونین که یه دیباگر چطور میتونه برنامه رو اجرا کنه و محتوای ثباتها رو نشون بده، کد زیر میتونه خیلی بهتون کمک کنه

    var
    si: TStartupInfo;
    Programm:PChar;
    context:_CONTEXT;
    buf1:array[0..1] of char;
    bp:array[0..1] of char;
    addr:Pointer;
    num:DWORD;
    pi :_PROCESS_INFORMATION
    begin
    // Ziel-EXE
    Programm:='D:\Cr@cking\Cr@ckMe\HDasm\HDasm.exe';
    // Code für BreakPoint
    bp:=chr($EB)+chr($FE);
    // Programm wird im Suspended-Mode gestartet
    FillChar(si, SizeOf(si), 0);
    FillChar(pi, SizeOf(pi), 0);
    CreateProcess(Programm,nil,nil,nil,false,CREATE_SUSPENDED,nil,nil,si,pi);
    // Register werden gelesen
    context.ContextFlags:=CONTEXT_FULL or CONTEXT_FLOATING_POINT or CONTEXT_DEBUG_REGISTERS;
    GetThreadContext(pi.hThread,context);
    // EntryPoint wid ermittelt
    addr:=ptr(context.Eax);
    // Schreib-Lese-Rechte werden geholt
    VirtualProtectEx(pi.hProcess,addr,2,PROCESS_ALL_AC CESS,num);
    // alte werte werden gesichert
    ReadProcessMemory(pi.hProcess,addr,@buf1,sizeof(bu f1),num);
    showmessage(inttostr(num));
    // breakPoint wird gesetzt
    WriteProcessMemory(pi.hProcess,addr,@bp,sizeof(bp) ,num);
    showmessage(inttostr(num));
    // Prozess wird fortgesetzt
    ResumeThread(pi.hThread);
    // es wird gewartet bis Programm am BP h&auml;ngt
    sleep(100);
    // Prozess wird angehalten
    suspendThread(pi.hThread);
    // Register werden gelesen
    GetThreadContext(pi.hThread,context);
    // alte werte werden wiederergestellt
    WriteProcessMemory(pi.hProcess,addr,@buf1,sizeof(b uf1),num);
    // Register werden ausgegeben
    showmessage('EAX: '+inttohex(context.Eax,8)+#13+
    'EBX: '+inttohex(context.Ebx,8)+#13+
    'ECX: '+inttohex(context.Ecx,8)+#13+
    'EDX: '+inttohex(context.Edx,8)+#13+
    'ESP: '+inttohex(context.Esp,8)+#13+
    'EDI: '+inttohex(context.Edi,8)+#13+
    'EIP: '+inttohex(context.Eip,8)+#13
    );
    // Prozess wird fortgesetzt
    ResumeThread(pi.hThread);
    end;

  13. #13
    واقعا تا اینجای کار مطالب مفیدی رد وبدل شد و من خیلی استفاده کردم

    قطعا نمیشه برنامه رو 100 درصد از نظر امنیت تضمین کرد ولی همونطور که دوستان اشاره کردن میشه کرکر رو خسته کرد.


    1)میشه با برنامه نویسی محلهای حساس برنامه رو چک کرد و اگر دستورات پچ شده بودن متوجه شد. فرض کنید دستور JE رو در فلان آفست و سگمنت میان و Nop می کنن.
    باید راهی وجود داشته باشه که با برنامه نویسی اینو فهمید.

    2)حالتی دیگه هم CRC هست. که مجموع چک سام رو با چک سام اصلی مقایسه می کنه اگه برابر نبود که یعنی فایل دستکاری شده.

    3) راه بعدی هدایت کردن برنامه به Exception های مختلفه. به طوری که کرک فکر کنه اشتباهی این نقطه رو پچ کرده

    4) میشه با ترکیبی از پکرها عملیات آنپک و کرک رو برای مدتی به تعویق انداخت.


    از دوستان خواهشمندم در مورد 1 و 2 و 3 اگه سورسی دارن اتچ کنن تا صحبت ها جنبه عملی پیدا کنه


    اینا ایده های من بود امیدوارم به درد بخوره - با تشکر محمد بشیری

  14. #14
    * تصور میکنم اِشکال بزرگی که نویسندگان نرم افزار مرتکب میشن اینه که قفل رو فقط برای صحت اطمینان استفاده میکنن. در نتیحه اگه قفل برداشته بشه هیچ مشکلی پیش نمیاد. اما اگه قسمتی از کد خودشون رو داخل قفل بریزن... حتما باید قفل وجود داشته باشه تا کد به طور کامل اجرا بشه

    * برنامه ای مثل RFA ، بعضی از functionهای خود رو encrypt میکنه. و فقط با شماره سریال صحیح میتونه اون functionها رو decrypt کنه...

  15. #15
    VIP آواتار دنیای دلفی
    تاریخ عضویت
    فروردین 1403
    محل زندگی
    یک جایی توی جنوب ایران
    پست
    1,298

    محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    اين مطالبي را كه مي نويسم شامل تجربيات بنده در مورد نوشتن رويه هاي محافظت از نرم افزارهاي تحت ويندوز مي باشد :
    ‌‍{ممكن است خيلي ساده باشه ولي خيلي روش كار و فكر كردم}
    1- اگر اسمبلي يك مقداري سردر بياريد بسيار مفيد است
    2-برنامه هاي وجود دارد كه به راحتي فانكشنها و پروسيجر هاي شما را غير فعال و حتي مسير اجرا شدن آنها را تغيير مي دهند . حتي بدون يك خط كدنويسي مانند :PE Explorer و Resource Tuner كه توي اين كار بسيار حرفه اي عمل مي كنند . حتي مي تونند برنامه هاي نوشته شده با VB.NET را فرمهايشان را نيز نشان دهند .
    گروهي از كركرهاي ساده (تازه كار)كه از اسمبلي خبر ندارند با استفاده از اين برنامه هاي برنامه هاي شما را حداقل مي توانيد تغيير ليبل دهند . پس براي جلوگيري از شناسايي توابع بايد چه راهي را اتخاذ كرد ؟
    جواب : شما نبايد در زمان طراحي فرم از اشياء استفاده كنيد بايد آنها را در هنگام اجرا بسازيد (Run Time) . شما نبايد در رويداد OnCreate فرم توابع بررسي قفل يا اطلاعات نويسنده را بنويسيد . يك تابع تعريف مي نمائيد .
      public
    { Public declarations }
    procedure FirstTestLock(Sender: TObject);
    end;

    ببينيد چون مي خواهيم در بخش ديگري اين تابع را صدا بزنيم آن را نبايد در بخش Private تعريف نمود و طبق كد پايين اين تابع را صدا مي زنيم .

     
    program Project1;
    uses
    Forms,
    Unit1 in 'Unit1.pas' {Form1};
    {$R *.res}
    begin
    Application.Initialize;
    Application.CreateForm(TForm1, Form1);
    Form1.FirstTestLock(nil);
    Application.Run;
    end.


    حالا بايد اشياء ي را كه مي خواهيم بسازيم درون تابع مربوطه توليد كنيم . به كد زير توجه كنيد براي ساختن يك تايمر است و مقدار دهي به تايمر كه چه كدي را بايد اجرا نمايد :

    اين فرامين را در تابع تعريف شده مي نويسيم :

     
    procedure TForm1.FirstTestLock(Sender: TObject);
    var
    Timer1: TTimer;
    begin
    Try
    Timer1 := TTimer.Create(self);
    Timer1.Interval:=60000;
    Timer1.Enabled:=True;
    Timer1.OnTimer:=OnTimerActive1;
    .
    .
    .


    حالا بايد تابع OnTimerActive1 تعريف كنيم دقيقا در مكاني كه مشخص مي كنم :


     
    private
    { Private declarations }
    procedure OnTimerActive1(Sender: TObject);

    .
    .
    .




    حالا در مكاني دلخواه كدهاي اين تايمر را مي نويسيم :

    procedure TForm1.OnTimerActive1(Sender: TObject);
    begin

    با استفاده از توابع موجود حجم و Crc32 فايل را بدست آوريد

    حجم فايل را درون يك فايل به صورت كد شده يا در رجيستري ذخيره نمائيد
    Crc را نيز همين طور حالا بررسي كنيد كه آيا حجم يا سي آر سي فايل تغيير نموده يا خير كه اگر تغيير نموده بود برنامه را Halt و مي توانيد دهن ويندوز را هم بكنيد در غير اين صورت .

    حالا اگر كركر از Loader استفاده كرده باشد كه دهن ما ... است . براي رفع تا حدودي اين مشكل مي توانيد از يكي از شماره سريالهاي منحصر بفرد سيستم مانند هارد ديسك استفاده كنيد كه به صورت كد شده در فايل بانك اطلاعاتي يا رجيستري ذخيره و با شماره فعلي سيستم مقايسه كنيد . چون اين فرامين در داخل يك تايمر هستند مي توانيد حتي اگر برنامه با لودر اجرا شده باشد (معمولا حجم و CRC تغيير نمي كند) باعث بسته شدن برنامه و ساير كارهاي شويد .

    نكته بسيار مهم رشته ها هستند شما تحت هيچ شرايطي رشته ها را لخت ()رها نكنيد
    يعني آنها را مستقيم در برنامه ننويسيد :
    پيشنهاد : شما مي توانيد در بيرون برنامه رشته را كد كنيد (مثلا :استفاده از خاصيت AESEncrypt مربوط به IceLicense) حالا در برنامه آنها را دي كد كنيد (مثلا : با استفاده از AESDecrypt مربوط به IceLicense ) ولي يك مشكل وجود دارد آن هم استفاده از كليد براي دي كد كردن است كه شما مجبور هستيد آن را در برنامه به صورت يك رشته وارد كنيد .
    راه حل : شما مي توانيد : كليد را به اين صورت بنويسيد

    PChar(Char(72)+Char(104)+Char(125))

    اين كار باعث مي شود كه كليد فقط RunTime ظاهر شود . و در حالت عادي در فايل اجراي شما قابل ديدن نباشد . اين باعث مي شود كه تا حدي وضعيت رشته ها در برنامه مستحكم شود . البته تا حدي

    حالا بهتره توي تايمر يه مقداري حال ديباگر ها را هم بگيريم البته تا حدي :
    با استفاده از :

     
    var
    Task:HWND;

    Task:=FindWindow(Pchar(IceLicense1.AESDecrypt('wdw UZkYwdwZawd',PChar(Char(51)+Char(95)+Char(50)),nil ));
    PostMessage(Task,WM_CLOSE,0,0);



    wdwUZkYwdwZawd : كد كلمه OlyDbg است
    PChar(Char(51)+Char(95)+Char(50))

    كليد تبديل كد به OlyDbg است .

    البته تايمري كه اين كار و كارهاي ديگر را مي كند با همان روش بالا ايجاد و نيم ثانيه به نيم ثانيه اجرا شود .
    اين جوري هم يكم كركرهاي تازه كار را آره ...



    كليه روشهاي فوق قابل دور زدن و روئيت هستند فقط براي بالا بردن امنيت استفاده مي شوند .

    البته يه كاري ديگه هم مي شه كرد كه من انجام دادم هنوز كه هنوزه كسي نتونسته Crack Me من را بيشتر از 50 درصد كرك كنند . البته اون 50 درصد بعدي خيلي مهم تره چون مجوز اجراي برنامه رو در گام اخر ميده اگر نتونستند كرك كنند اون را هم مي گم .

    پايان قسمت اول

  16. #16
    VIP آواتار دنیای دلفی
    تاریخ عضویت
    فروردین 1403
    محل زندگی
    یک جایی توی جنوب ایران
    پست
    1,298
    بخش دوم آموزش محافظت از نرم افزارها در مقابل كركينگ:

    شايد براي شما اين سوال پيش بيايد كه چگونه بايد CRC و حجم يك فايل را بدست آورد :
    روش بدست آوردن CRC16 , CRC32 , Size با استفاده از كامپوننت زير

    با استفاده از تابع زير مي توانيد موارد مورد نياز خود را بدست آوريد

    Error32 : WORD;
    FileBytes: TInteger8;
    CRC32File : LongWord;

    CalcFileCRC32 (Application.ExeName, CRC32File, FileBytes, Error32);


    روش ديگر براي بدست آوردن حجم فايل برنامه :


    function GetFSize(Handle: THandle): Int64;
    var
    i64: record
    LoDWord: LongWord;
    HiDWord: LongWord;
    end;
    begin
    i64.LoDWord := GetFileSize(Handle, @i64.HiDWord);
    if (i64.LoDWord = MAXDWORD) and (GetLastError <> 0) then
    Result := 0
    else
    Result := PInt64(@i64)^;
    end;



    Stream:TFileStream;
    FSize2:int64;


    Stream := nil;
    try
    Stream := TFileStream.Create(Application.ExeName,
    fmOpenRead or fmShareDenyNone);

    Fsize2:=GetFSize(Stream.Handle);
    finally
    Stream.Free;
    end;

    شما مي توانيد براي امنيت بيشتر در صورت عدم شرايط مجاز اقدام به خودزني و حذف فايل اجرايي كنيد فايل براي انجام اين جنايت ضميمه شده است .

    با استفاده از تابع

    Deleteexe;
    پايان قسمت دوم
    فایل های ضمیمه فایل های ضمیمه

  17. #17
    VIP آواتار دنیای دلفی
    تاریخ عضویت
    فروردین 1403
    محل زندگی
    یک جایی توی جنوب ایران
    پست
    1,298
    بخش سوم امنيت نرم افزارهاي (پيشرفته):
    اين روش بسيار كارآمد و تقريبا مي توان گفت تا وقتي كه كد اصلي (Decode) لو نرفته برنامه شما تا 99% ايمن و به راحتي قابل انتشار در بازار حتي بازار جهاني است .
    گوش فرا دهيد :
    در برنامه هاي تجاري مي توان گفت كه 100% وجود بانك اطلاعاتي الزامي است (Sql Sever,Oracle , MySql ,DBISAM) و نكته مهمي كه وجود دارد برقراي ارتباط با بانك اطلاعتي است (Connect To Database) پس يكي از گزينه هاي مهم برنامه اتصال به بانك اطلاعاتي است .
    در صورتي كه شما بخشي از كدهاي مهم برنامه را كه براي اجراي برنامه وجودشان حياتي است را محافظت كنيد مي توانيد گام مؤثري را در مقابله با كركرها برداريد .
    كركرها در حالت طبيعي و نرمال پس از UnPack برنامه مي توانيد شرطها و كيسها و حلقه ها را شناسايي و عملكرد آنها را تغيير يا غيرفعال كنند . يك تايمر يا يك تابع را با يك Nop يا عكس كردن عملش آن را غير فعال و اصطلاحاٌ آن را كرك كنند . اما اگر حلقه For يا Case يا Connect به بانك اطلاعاتي وجود داشته باشد .
    بله مي خوام برم بعد از اين مقدمه كوتاه روي اصل ماجرا .
    خوب اگر ما بتوانيم كدهاي برنامه را بعد از مرحله Design و توليد فايل اجرايي تغيير دهيم ديگر كسي نمي تواند كدهاي ما را تغيير و آنها را Crack كند . البته غيير ممكن نيست ولي بسيار مشكل و به شانس بسيار زيادي بستگي دارد .
    خوب پس براي اجراي كدهاي تغيير پيدا كرده چه كاري مي توان انجام داد . بايد با استفاده از الگوريتم عكس عمل كد در زمان اجرا (Run Time) كدهاي Encrypt شده را در حافظه Decrypt نمود .

    بسياري از پروتكتورهاي معرف اين امكان مهم را ارائه و پشتيباني مي كنند كه ما به راحتي از آن به دليل (شايد بلد نبود نحوه استفاده يا عدم مطالعه Help) ناشناخته استفاده نمي كنيم .

    من براي مثال نحوه انجام اين كار را با Protector & Packer SVKP 1.44 توضيح مي دهم .

    در پكيجهاي ابزارهاي Packer و Protector معمولا دو فايل با نامهاي مشخص وجود دارد كه براي اين مجموعه به نامهاي delphi_svkp_block_begin.inc و delphi_svkp_block_end.inc فايل اول حاوي اطلاعات و كدهاي اسمبلي زير است :

    asm DB $EB,$7F,$EB,$00,$99,$AA,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $EB,$7F,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;


    و فايل دوم حاوي كدهاي زير است :

    asm DB $EB,$7F,$EB,$00,$BB,$CC,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $EB,$7F,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;
    asm DB $90,$90,$90,$90,$90,$90,$90,$90,$90,$90 end;



    اين كدها قرار است قبل و بعد از فرامين كليدي و مهم ما كه در بالا به يكي از مهمترين آنها اشاره شد قرار مي گيرند .

    با فرض اينكه اين دو فايل در پوشه include قرار داشته باشند به اين نحو استفاده مي شوند :

    unit main;

    interface

    procedure Start;

    implementation

    uses
    Registry,
    Classes,
    Windows,
    SysUtils,
    special;

    var
    RegMessage : String;
    // This procedure will encrypted and it will decrypted only if user have correct registration key
    procedure ActionForRegisteredUsers;
    begin
    {$I include\delphi_svkp_block_begin.inc}
    RegMessage := 'Registered version!';
    MessageBox(0,PChar (RegMessage),'',0);
    {$I include\delphi_svkp_block_end.inc}
    end;

    procedure Start;
    begin
    try

    // this code will decrypted before using and after use removed
    // tip: This type of blocks is very good use in initialize part of program
    // (load DLL(s), initialize data, fill some special variables and etc.)
    {$I include\delphi_svkp_block_type2_begin.inc}
    RegMessage := 'Encryption blocks example';
    {$I include\delphi_svkp_block_type2_end.inc}

    // This code will decrypted before using and encrypted again after use
    {$I include\delphi_svkp_block_type1_begin.inc}
    MessageBox(0,PChar (RegMessage),'',0);
    ActionForRegisteredUsers; //this procedure is only for registered users
    {$I include\delphi_svkp_block_type1_end.inc}
    except
    end;
    end;
    end.


    در كد بالا از يك Uses به نام special استفاده شده است كه ممكن است براي شما سوال پيش بيايد كه اين فايل چيست . معمولا Protectorها علاوه بر تغييراتي كه برروي فايل اجرايي انجام مي دهند يك سري كدهاي سودمند براي مقابله با Debugger ها و ساير سيستمهاي نفوذي مي نويسند كه با توجه به نوع زبان برنامه نويسي قابل استفاده است . كه در اينجا با استفاده از اين فايل كه در اصل براي استفاده از يك Dll كه همراه package پروتكتور عرضه شده استفاده شده است . عدم استفاده از اين فايل اشكالي در سيستمي حفاظتي از كدها نمي كند . فقط جهت افزايش امنيت است .


    حالا براي اينكه بتوان كدها را حفاظت نمود پس از توليد فايل اجرايي شما بايد به وسيله پروتكتور فايل را محافظت كنيد . در هنگامي كه پروتكتور در حال تغيير موقعيت احضار توابع و رويه ها است . وقتي به كدهاي ما رسيد :

    procedure ActionForRegisteredUsers;
    begin
    {$I include\delphi_svkp_block_begin.inc}
    RegMessage := 'Registered version!';
    MessageBox(0,PChar (RegMessage),'',0);
    {$I include\delphi_svkp_block_end.inc}
    end;


    اطلاعات موجود در فايل هاي مشخص شده را با اطلاعات كد هاي ما و يك سري كد كه با ااگوريتم RSA توليد مي شود تركيب مي نمايد . و باعث تغيير فيزيكي محتواي فايل اجرايي مي شود . يا اصطلاحاْ به نوعي محتواي فايل را خراب مي كند .

    حالا براي اجراي برنامه به صورت صحيح و رجيستر شده حتما نياز به كد فعال سازي جهت Decrypt شدن اطلاعات خراب شده در فايل اجرايي برنامه است كه اين فايل توسط پروتكتور توليد مي شود .

    كه در اين مثال SVKP فايل را به نام regkey.key توليد مي كند كه حاوي كد فعال سازي و بازسازي اطلاعات تخريب شده در زمان اجراست است.

    به يك نمونه از محتواي اين فايل توجه كنيد :

    -----BEGIN RSA PUBLIC KEY-----
    AAG/aAN0uqBYL7SxnMqOHJouq3Yhz2nV3KW6pfhDQ29qbIlFRJWrYn i8fVTud9Gli5rJft
    jAYy/pf0Ee2aKcD2t+j6+y2pweECBTfOjVwBw9bmFWTOchMBG8b7xzh 3wZ+6S/2/QeYILI
    0Gmop/wuCrZzm3MkekGSRspC2v2R8dtgDl3ZGsHwMYpmOqWnNSrpxzea nGAS4D3iUyo50H
    tVKGOHqba96HD4yG5G+suc3tZObR1rJveXpCU9WLCFltVxkXhp DYQFr7XhEJTi3H9TEfJ1
    coH8MQla3j1vwPLtyVD4hpeyyOHJ5qbTyLXmyjavIouaOBOSZB YlLi332qLiPI4DAQADA
    -----END RSA PUBLIC KEY-----


    در صورتي كه اين فايل وجود داشته باشد برنامه اجرا و در غير اين صورت امكان اجراي برنامه وجود نخواهد داشت .

    براي پيدا كردن اين كد بايد به روش سعي و خطا عمل كرد مانند روش پيدا كردن رمز فايلهاي RAR يا Zip يا از روش نقل قول (Fh_prg) : (Bruteforce) مي توان استفاده نمود كه كار بسيار وقت گير و مشكلي است .

    البته من براي اين كار از پروتكتورها استفاده نمي كنم . من در برنامه ها از كامپوننت SecureCode استفاده مي كنم . به دليل كپي رايت از ارائه اين كامپوننت در اينجا شرمنده هستم

    البته اگر فايل رجيستر را ارائه دهيد و سيستم امنيني برنامه شما پايين باشد به راحتي مي توان با مثلا OLLY آن را dump كرد و از آنجايي كه فايل به صورت صحيح در Ram لود شده است اين محدوديت از بين مي رود .

    از دوستان تقاضا مي شود كه الگوريتمهاي antidebug خود دريق نكنند . با همكاري و هم فكري هم ميشه سد بسيار بسيار بزرگي در مقابل كركرها ايجاد نمود .
    از دوستان كركر كلاه سفبد تقاضا مي شود از الگوريتمهاي ضد ديباگ و مشكل ساز براي كركها بگذارند .

    باي تا روز بدون كركر

  18. #18
    VIP آواتار دنیای دلفی
    تاریخ عضویت
    فروردین 1403
    محل زندگی
    یک جایی توی جنوب ایران
    پست
    1,298
    سلام به دوستان امروز مي خوام ابزاري رو معرفي كنم كه رايگان و بسيار قدرتمند است براي كد كردن رشته ها در دلفي يا اصطلاحا مخفي كردن آنها اين ابزار بسيار مفيد براي كركرها تازه كار و كار كركرهاي حرفه اي را بسيار مشكل در پيدا كردن و شناسايي رشته هاي برنامه ها شما مي كند .

    دقت كنيد : نام اين مجموعه Delphi Strings Killer (DSKiller) مي باشد . شما به صورت عادي برنامه را نوشته و كليه رشته ها را در برنامه تعريف مي كنيد سپس برنامه DSKiller را اجرا و فايل pas خود را مثلا اگر نامش unit1.pas باشد را open مي كنيد در فايل رشته ها را تعريف كرده ايد . حالا فايل شما باز شده و كليه رشته هاي شما ظاهر مي شود آنهايي را كه مي خواهيد كد كنيد را انتخاب و كليد كد شدن را بزنيد .
    من يك مثال قبل از كد و يكي بعد از كد براي شما مي زنم

    قبل از كد شدن :

     
    unit Unit1;
    interface
    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls;
    type
    TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;
    var
    Form1: TForm1;
    implementation
    {$R *.dfm}
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if edit1.Text='HiProgrammer' then
    showmessage('Hoooooooooooooo')
    end;
    end.




    بعد از كد شدن : (كركر)


     
    unit Unit1;
    interface
    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls;
    type
    TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;
    var
    Form1: TForm1;
    implementation
    const
    dbs: array [0..26] of Byte= (
    $78,$EB,$94,$6C,$AC,$D9,$B6,$27,$F4,$A2,$CE,$21,$7 8,$ED,$0E,$29,
    $0D,$39,$6C,$6C,$80,$BC,$F4,$82,$D8,$80,$D4
    );

    function dcf(aBegPos, aLength: Integer): string;
    var tmp: string;
    i, endPos: Integer;
    MyKey: word;
    begin
    MyKey:= 12345;
    SetLength(Result, aLength);
    tmp:= '';
    endPos:= aBegPos+ aLength -1;
    for i:= aBegPos to endPos do
    tmp:= tmp+ Chr(dbs[i]);
    for i:= 1 to Length(tmp) do
    begin
    Result[i]:= Char(Byte(tmp[i]) xor (MyKey shr 8));
    MyKey:= (Byte(tmp[i])+ MyKey)* 52845+ 22719;
    end;
    end;

    {$R *.dfm}
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if edit1.Text=dcf(0 ,12) then
    showmessage(dcf(12 ,15))
    end;
    end.


    خوب اميد وارم كه استفاده كرده باشيد .
    ما هرچه داريم رو مي كنيم . منتظر دارايهاي شما هم هستيم .
    فایل های ضمیمه فایل های ضمیمه

  19. #19
    VIP آواتار دنیای دلفی
    تاریخ عضویت
    فروردین 1403
    محل زندگی
    یک جایی توی جنوب ایران
    پست
    1,298
    سيستم Encrypt , Decrypt , Hash مربوط به رشته ها و فايلها :

    روشهايي پياده سازي Sha1 و Twofish و Base64

    اين مجموعه بسيار قدرتمند به صورت رايگان جهت استفاده براي برنامه نويسان عزيز قرار مي گيريد اميد است كه جهت بالا بردن امنيت نرم افزارهاي خود استفاده لازمه را ببريد .

    كل مجموعه به صورت تفكيك شده و به همراه سورس در پايين ضميمه شده است .

    در مرحله اول Uses هاي مورد نياز را تعريف مي كنيد :

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
    Dialogs, SHA1, Twofish, Base64, StdCtrls, ExtCtrls;



    سه Edit تعريف مي كنيد اولي براي مسير و نام فايل دومي براي كليد رمز گذاري و سومي براي نمايش كد Hash شده :

    براي كد كردن فايل با رشته به روش زير عمل مي كنيد :

    // produces a hash of a file
    procedure _HashFile(filename: string; var Digest: TSHA1Digest);
    var
    Context: TSHA1Context; // record to store intermediate
    // data
    Source: file; // source file
    Buffer: array[1..8192] of byte; // read buffer
    Read: integer; // number of bytes read
    begin
    AssignFile(Source,filename);
    try
    Reset(Source,1);
    except
    MessageDlg('Unable to open source file.',mtInformation,[mbOK],0);
    Exit;
    end;
    SHA1Init(Context); // initialize the data structure
    repeat
    BlockRead(Source,Buffer,Sizeof(Buffer),Read);
    SHA1Update(Context,@Buffer,Read); // update the hash
    until Read<> Sizeof(Buffer);
    SHA1Final(Context,Digest); // produce the final hash
    CloseFile(Source);
    end;

    procedure TForm1.EncrytpClick(Sender: TObject);
    var
    KeyData: TTwofishData; // the initialized key data
    Digest: TSHA1Digest;
    IV: array[0..15] of byte; // the initialization vector needed for
    //chaining modes
    Buffer: array[0..8191] of byte;
    Source,source2: file;
    i, j, n: integer;
    Key: string;
    NumRead, NumWritten: Integer;

    begin
    Key:= edit2.Text; //you wrote the password in edit2
    _HashString(Key,Digest);
    TwofishInit(KeyData,@Digest,Sizeof(Digest),nil); // initialize the
    // key data using a hash of the key
    FillChar(IV,Sizeof(IV),0); // make the IV all zeros
    TwofishEncryptCBC(KeyData,@IV,@IV); // encrypt the IV to
    // get a 'random' IV
    Move(IV,KeyData.InitBlock,Sizeof(KeyData.InitBlock )); // move the
    // IV into the keydata so can use chaining
    TwofishReset(KeyData); // reset the keydata so
    // it uses the new IV
    AssignFile(Source, edit1.Text); // file to encrypt in edit1
    try
    Reset(Source,1);
    except
    TwofishBurn(KeyData); // get rid of the data in memory
    MessageDlg('File cannot be opened...', mtInformation, [mbOK], 0);
    Edit2.text:='00000000000000000000000000000000';
    Edit2.text:='';
    Exit;
    end;

    repeat
    n:= FilePos(Source);
    BlockRead(Source,Buffer,Sizeof(Buffer),i);
    for j:= 1 to (i div 16) do // 16 is the blocksize of Twofish
    // so process in 16 byte blocks
    TwofishEncryptCBC(KeyData,@Buffer[(j-1)*Sizeof(IV)], //encrypt!
    @Buffer[(j-1)*Sizeof(IV)]);

    if (i mod 16)<> 0 then // encrypt the last bytes that don't
    // fit in to a full block
    begin
    Move(KeyData.LastBlock,IV,Sizeof(IV));
    TwofishEncryptCBC(KeyData,@IV,@IV); // encrypt the full block
    // again (so that it is encrypted twice)
    for j:= 1 to (i mod 16) do
    // xor this encrypted block with the short block
    Buffer[(i and not 15)+j]:= Buffer[(i and not 15)+j] xor IV[j];
    end;
    Seek(Source,n);
    BlockWrite(Source,Buffer,i); // write out the buffer to the file
    until i<> Sizeof(Buffer);

    CloseFile(Source);
    TwofishBurn(KeyData); //get rid of data
    Edit2.text:='00000000000000000000000000000000';
    Edit2.text:='';
    Edit1.text:='';
    MessageDlg('All done. File Encrypted with the same name as the ' +
    'original.', mtInformation,[mbOK],0);
    end;




    براي Decrypt كردن رشته يا فايل :

    // produces a hash of a string
    procedure _HashString(s: string; var Digest: TSHA1Digest);
    var
    Context: TSHA1Context; // record to store intermediate
    // data
    begin
    SHA1Init(Context); // initialize the data record
    SHA1Update(Context,@S[1],Length(S)); // update the data record with
    // the string
    SHA1Final(Context,Digest); // produce the final hash
    end;


    procedure TForm1.DecryptClick(Sender: TObject);
    var
    KeyData: TTwofishData; // the initialized key data
    Digest: TSHA1Digest;
    IV: array[0..15] of byte; // the initialization vector needed for
    //chaining modes
    Buffer: array[0..8191] of byte;
    Source,source2: file;
    i, j, n: integer;
    Key: string;
    NumRead, NumWritten: Integer;

    begin
    Key:= edit2.Text; //you wrote the password in edit2
    _HashString(Key,Digest);
    TwofishInit(KeyData,@Digest,Sizeof(Digest),nil); // initialize the
    // key data using a hash of the key
    FillChar(IV,Sizeof(IV),0); // make the IV all zeros
    TwofishEncryptCBC(KeyData,@IV,@IV); // encrypt the IV to
    // get a 'random' IV
    Move(IV,KeyData.InitBlock,Sizeof(KeyData.InitBlock )); // move the
    // IV into the keydata so can use chaining
    TwofishReset(KeyData); // reset the keydata so
    // it uses the new IV
    AssignFile(Source, edit1.Text); // file to encrypt in edit1
    try
    Reset(Source,1);
    except
    TwofishBurn(KeyData); // get rid of the data in memory
    MessageDlg('File cannot be opened...', mtInformation, [mbOK], 0);
    Edit2.text:='00000000000000000000000000000000';
    Edit2.text:='';
    Exit;
    end;

    repeat
    n:= FilePos(Source);
    BlockRead(Source,Buffer,Sizeof(Buffer),i);
    for j:= 1 to (i div 16) do // 16 is the blocksize of Twofish
    // so process in 16 byte blocks
    TwofishDecryptCBC(KeyData,@Buffer[(j-1)*Sizeof(IV)], // Decrypt
    @Buffer[(j-1)*Sizeof(IV)]);

    if (i mod 16)<> 0 then // encrypt the last bytes that don't
    // fit in to a full block
    begin
    Move(KeyData.LastBlock,IV,Sizeof(IV));
    TwofishEncryptCBC(KeyData,@IV,@IV); // encrypt the full block
    // again (so that it is encrypted twice)
    for j:= 1 to (i mod 16) do
    // xor this encrypted block with the short block
    Buffer[(i and not 15)+j]:= Buffer[(i and not 15)+j] xor IV[j];
    end;
    Seek(Source,n);
    BlockWrite(Source,Buffer,i); // write out the buffer to the file
    until i<> Sizeof(Buffer);

    CloseFile(Source);
    TwofishBurn(KeyData); //get rid of data
    Edit2.text:='00000000000000000000000000000000';
    Edit2.text:='';
    Edit1.text:='';
    MessageDlg('All done. File Decrypted with the same name as the ' +
    'original.', mtInformation,[mbOK],0);
    end;





    براي Hash نمودن رشته يا فايل :


    procedure TForm1.HashClick(Sender: TObject);
    var
    Digest: TSHA1Digest; // binary form of the hash
    i: integer;
    begin
    if Edit1.Text='' then exit; // make sure we have a file to hash
    _HashFile(Edit1.Text,Digest); // calculate the hash
    // and store in Digest
    if radiohex.ItemIndex=0 then // we want to show the
    // hash in hexadecimal
    begin
    Edit3.Text:= '0x';
    for i:= 0 to (Sizeof(Digest)-1) do
    Edit3.Text:= Edit3.Text+IntToHex(Digest[i],2); // convert Digest
    // to a hexadecimal string
    end
    else // in base64
    begin
    Edit3.Text:= '';
    for i:= 0 to (Sizeof(Digest)-1) do
    Edit3.Text:= Edit3.Text+chr(Digest[i]); // convert Digest to a
    // base64
    Edit3.Text:=B64Encode(Edit3.Text);
    end;
    end;


    اميد است مورد استفاده قرار بگيريد
    فایل های ضمیمه فایل های ضمیمه

  20. #20
    VIP آواتار دنیای دلفی
    تاریخ عضویت
    فروردین 1403
    محل زندگی
    یک جایی توی جنوب ایران
    پست
    1,298
    اين مقاله يكي از كاملترين و جامع ترين مطالبي را كه شما در هنگام برنامه نويسي بايد رعايت كنيد . تا كار كركرها را در نفوذ به برنامه هاي خود مشكل و مشكل تر نمائيد .



    1. How to make cracking your app a little bit harder...
    2. More tips you might take into consideration...
    3. Advanced tips given by Assembler freaks...
    4. Special on Delphi reverse engineering...
    5. Some notes on registration numbers...
    6. Some notes on timebombs...
    7. How to find cracks for your apps...
    8. What to do if you found a crack for your app...
    9. Facts and Myths about Software pirating...
    10. Thoughts and letters from crackers
    11. Links of interest...
    12. Visitor comments...

    عناوين مطالب در بالا آورده شده است :
    بيش از 30 صفحه مطالب مفيد و كارآمد . . .
    اميد وارم كه استفاده كامل را ببريد .

    زبان اصلي

    فایل های ضمیمه فایل های ضمیمه

  21. #21
    کاربر دائمی آواتار joker
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    اصفهان
    سن
    42
    پست
    1,326
    نقل قول نوشته شده توسط bashiry مشاهده تاپیک
    1)میشه با برنامه نویسی محلهای حساس برنامه رو چک کرد و اگر دستورات پچ شده بودن متوجه شد. فرض کنید دستور JE رو در فلان آفست و سگمنت میان و Nop می کنن.
    باید راهی وجود داشته باشه که با برنامه نویسی اینو فهمید.

    2)حالتی دیگه هم CRC هست. که مجموع چک سام رو با چک سام اصلی مقایسه می کنه اگه برابر نبود که یعنی فایل دستکاری شده.

    3) راه بعدی هدایت کردن برنامه به Exception های مختلفه. به طوری که کرک فکر کنه اشتباهی این نقطه رو پچ کرده
    از دوستان خواهشمندم در مورد 1 و 2 و 3 اگه سورسی دارن اتچ کنن تا صحبت ها جنبه عملی پیدا کنه
    جواب 1-2-3
    ReadProcessMemory میشه هر قسمتی از حافظه فایل اجرائی را چک کرد و دید که با چی برابره بر فرض اگه فلان آفست برابر با کد 74 نبود یعنی برنامه پچ شده و الی آخر ...
    راههای دیگر کرک مثل مجیک بایتها را هم باید در این مورد نظر گرفت...
    خطاهای عجیب غریب هم که ماشالا شما برنامه تون را با دلفی بنویسید خودش منبع خطاهای عجیب غریبه :)
    ولی به عنوان مثال شما آدرس بازگشت را توی حافظه تغییر بده و یک WriteProcessMemory

    هم از اینجا به بعد خرجش کن و هرچی دلت خواست توی حافظه بنویس ، کرکر به همچین خطاهایی برسه که هیچ وقت ندیده :)


    پیوست:
    میخواستم ازتون بپرسم که از این جور کد ها واسه دات نت هم دارید یا نه ؟
    نه متاسفانه ، من دات نت کار نکردم.
    آخرین ویرایش به وسیله joker : جمعه 27 اردیبهشت 1387 در 21:19 عصر

  22. #22
    کاربر دائمی آواتار joker
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    اصفهان
    سن
    42
    پست
    1,326

    نقل قول: سورس هایی جهت محافظت برنامه در مقابل کرکرها

    یه کم سربه سر گذاشتن دیباگر olly
    با LordPe تغییر بدین و نتیجه را موقع باز شدن توی Olly ببینید :)
    عکس های ضمیمه عکس های ضمیمه  

  23. #23
    VIP آواتار دنیای دلفی
    تاریخ عضویت
    فروردین 1403
    محل زندگی
    یک جایی توی جنوب ایران
    پست
    1,298
    نتيجه گيري تاپيك مربوط به TLS CALLBACK :

    دو روش وجود دارد يكي استفاده از DLL و روش دوم در خود برنامه :

    روش اول :

    مرحله اول ايجاد DLL :
    کد:

    library DLL_EntryPoint;

    uses
    SysUtils,
    Windows,
    Forms,
    Classes,
    Dialogs;
    {$R *.res}

    procedure book; stdcall;
    begin
    //Dummy

    end;

    procedure DLLEntryPoint(dwReason: DWORD); stdcall; //register; //stdcall;
    begin
    case dwReason of
    DLL_THREAD_DETACH : ShowMessage('Thread Detach'); //0
    DLL_PROCESS_ATTACH: //1
    begin
    // بررسي قفل

    end;
    DLL_THREAD_ATTACH : ShowMessage('Thread Attach'); //2
    DLL_PROCESS_DETACH: //3
    begin

    // بررسي قفل
    end;
    end;
    end;


    exports
    DLLEntryPoint,book;

    begin
    //DLLEntryPoint is specifically a Win32 and C++‎ implementation
    //DLLProc is a pointer variable from the SYSTEM Unit (automatically included)
    //The SYSTEM Unit is responsible for executing code assinged to DLLEntryPoint
    DLLProc := @DLLEntryPoint; //Assign the address of DLLEntryPoint to DLLProc
    DLLEntryPoint(DLL_PROCESS_ATTACH); //Indicate that the DLL is attaching to the process
    end.
    استفاده در برنامه اصلي :
    کد:


    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls;

    type
    TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;
    procedure book ;
    stdcall; external 'Dll_EntryPoint.DLL';

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    book;
    end;

    end.
    منتظر كد هاي شما هستم






    روش دوم استفاده در خود برنامه :

    B-Vedadian :

    در مورد نحوه استفاده صحیح از TLS CallBack هم روش اینه:

    1-تو برنامه خودت یکی با بیشتر رویه مشابه DLLEntryPoint که تو بالا نوشتی مینویسی.
    2-آدرس رویه های مذکور رو به جدول TlsTable هدر فایل اجرایی اضافه میکنی.(یکی از راهاش استفاده از LordPEیه، راه بهتری رو من بلد نیستم)

    با این کار بدون DLL هم همون اتفاق میافته (قبل رسیدن به Entry Point توابع مورد نظر شما اجرا میشند)

    ----------------------

    چون خود دلفي يک Callback براي ترد اصلي داره، بهترين راه اينه که آدرس فعلي Callback رو يه جايي يادداشت کني. بعد تو پروسه DLLEntry جديدي که نوشتي بعد کارهاي اوليه، رويه قديمي(آدرسي که يادداشت کردي) رو هم صدا بزني. در نهايت تو جدول Tls بجاي آدرس قديمي، آدرس رويه خودت رو بنويس.

  24. #24
    کاربر دائمی آواتار joker
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    اصفهان
    سن
    42
    پست
    1,326

    Windows Anti-Debug Reference

    از اسمش پیداست که چیه ، بنظرم خیلی جالب اومد....

    Windows Anti-Debug Reference

    خواستم pdfش را همینجا ضمیمه کنم که توی صفحه اتچ فایل پیغام زیر اومد
    ---
    از اینجا مطالبشو میتونید بخونید
    http://www.securityfocus.com/infocus/1893

  25. #25
    VIP آواتار دنیای دلفی
    تاریخ عضویت
    فروردین 1403
    محل زندگی
    یک جایی توی جنوب ایران
    پست
    1,298

    Talking آموزش گام به گام ايجاد كرك مي جهت محافظت از كدها سطح برنامه C

    آموزش گام به گام ايجاد كرك مي جهت محافظت از كدها سطح برنامه C

    من يك فرم ايجاد كردم و يك كليد روي فرم گذاشتم و دوتا پروسس بار سپس كدهاي زير را درون كليد نوشتم گذاشتم .

    procedure TForm1.Button1Click(Sender: TObject);
    var
    i:Byte;
    begin

    ProgressBar1.Max:=10;
    ProgressBar2.Max:=10;
    for i :=1 to 10 do
    begin
    ProgressBar1.Position:=i;
    ProgressBar2.Position:=i;
    Sleep(100);
    end;
    ProgressBar1.Position:=0;
    ProgressBar2.Position:=0;

    end;
    سپس يك تابع نوشتم كه بتواند در حافظه بعد از اجرا كدهاي مورد نظرم را بنويسد به صورت زير:

    procedure WriteCurrectDataToAddress(Address : Longint;B:Integer;NameBuf:PChar);
    var
    BytesToWrite :Integer;
    BytesWrite : cardinal;
    window , ProcessId : integer;
    HandleWindow : cardinal;
    begin
    BytesToWrite :=B;
    Window := FindWindow(nil, PChar('crack me'));
    GetWindowThreadProcessId(Window,@ProcessId);
    HandleWindow := OpenProcess(PROCESS_ALL_ACCESS,False,ProcessId);

    WriteProcessMemory(HandleWindow, ptr(Address), NameBuf ,
    BytesToWrite, BytesWrite);
    CloseHandle(HandleWindow);
    end;
    اين تابع همانطور كه مشاهده مي شود داراي سه ورودي است آدرسي كه بايد از آنجا شروع به نوشتن كند . تعداد بايتهايي كه بايد بنويسد و مهم تر از همه اطلاعاتي كه بايد بنويسد .

    بعد برنامه را كامپايل كردم و فايل اجرايي را ساختم سپس به وسيله برنامه بسيار بسيار قدرتمند PE Explorer فايل اجرايي را باز و كدهاي اسمبلي مربوط به درون كليد را پيدا كردم
    در اصل كدهاي دلفي به صورت زير بود .



    ProgressBar1.Max:=10;
    ProgressBar2.Max:=10;
    for i :=1 to 10 do
    begin
    ProgressBar1.Position:=i;
    ProgressBar2.Position:=i;
    Sleep(100);
    end;
    ProgressBar1.Position:=0;
    ProgressBar2.Position:=0;
    من معال كدهاي بالا را از اسمبلي به Hex در آوردم كه خود PE Explorer اين كار را انجام مي داد.

    كدها به صورت زير شدند .

    BA0A0000008B86FC020000E84577FDFFB3018BFB81E7FF0000 008BD78B86
    F8020000E83E77FDFF8BD78B86FC020000E83177FDFF6A64E8 B2DA
    FBFF4380FB0B75D133D28B86F8020000E81777FDFF33D28B86 F
    C020000E80A77FDFF
    اين كدها و قتي به زبان ماشين ترجمه شوند به معادل دلفي كه در بالا ديديد تبديل مي شوند.

    حالا تابعي نوشتم كه بتواند كدهاي هگز را به زبان ماشين ترجمه كند .
    به صورت زير :

    function MainData:PChar;
    var
    i:integer;
    Str,Data:String;
    begin
    Str:=
    'BA0A0000008B86FC020000E84577FDFFB3018BFB81E7FF000 0008BD
    78B86F8020000E83E77FDFF8BD78B86FC020000E83177FDFF6 A64E8B
    2DAFBFF4380FB0B75D133D28B86F8020000E81777FDFF33D28 B86
    FC020000E80A77FDFF';
    Data:='';
    i:=1;
    while i<=Length(Str) do
    begin
    Data:=Data+Char(StrToInt('$'+Str[i]+Str[i+1]));
    i:=i+2;
    end;
    Result:=PChar(Data);
    end;
    در بالاي برنامه هم آدرس شروع و تعداد بايتهايي را كه قرار است در حافظه نوشته شود را به صورت ثابت تعريف كردم :

    const
    add=$44E94B;
    b=91;
    بعد يك خط به كدهاي درون كليد در ابتدا اضافه كردم تا به شكل زير در آمد :

    procedure TForm1.Button1Click(Sender: TObject);
    var
    i:Byte;
    begin
    WriteCurrectDataToAddress(add,b,MainData);

    ProgressBar1.Max:=10;
    ProgressBar2.Max:=10;
    for i :=1 to 10 do
    begin
    ProgressBar1.Position:=i;
    ProgressBar2.Position:=i;
    Sleep(100);
    end;
    ProgressBar1.Position:=0;
    ProgressBar2.Position:=0;

    end;

    اين خط WriteCurrectDataToAddress(add,b,MainData); باعث مي شود كه اطلاعات صحيح در آدرس مشخص شده نوشته شود اصطلاحا برنامه نويسي ثابت RunTime.

    با استفاده از نرم افزار بسيار قدرتمند OlyDBG فايل كامپايل شده را باز كردم و كدهاي مربوط به كليد را پيدا كردم و همه را NOP كردم يعني اينوجوري .

    909090909090909090909090909090909090909090
    9090909090909090909090909090909090909090909
    0909090909090909090909090909090909090909090
    90909090909090909090909090
    9090909090909090909090909090

    حالا فايلم به صورتي در آمده كه اگر روي كليد كليك كنيد هيچ اتفاقي نمي افتد يا به زبان ساده تر كدي وجود ندارد كه اجرا شود.

    حالا يك تابع نوشتم كه بعد از اجراي صحيح برنامه اطلاعات را دوباره NOP تبديل كند :

    function MainData1:PChar;
    var
    i:integer;
    Str,Data:String;
    begin
    Str:=
    '909090909090909090909090909090909
    0909090909090909090909090909090909090909090
    90909090909090909090909090909090909090909090
    9090909090909090909090909090909090909
    0909090909090909090909090';
    Data:='';
    i:=1;
    while i<=Length(Str) do
    begin
    Data:=Data+Char(StrToInt('$'+Str[i]+Str[i+1]));
    i:=i+2;
    end;
    Result:=PChar(Data);
    end;
    حالا اين خط را به انتهاي فرامين كليدم اضافه كردم و فارمين كليد به شكل زير درآمد :

    procedure TForm1.Button1Click(Sender: TObject);
    var
    i:Byte;
    begin
    WriteCurrectDataToAddress(add,b,MainData);

    ProgressBar1.Max:=10;
    ProgressBar2.Max:=10;
    for i :=1 to 10 do
    begin
    ProgressBar1.Position:=i;
    ProgressBar2.Position:=i;
    Sleep(100);
    end;
    ProgressBar1.Position:=0;
    ProgressBar2.Position:=0;

    WriteCurrectDataToAddress(add,b,MainData1);

    end;
    هدف از اضافه كدن اين كد WriteCurrectDataToAddress(add,b,MainData1); اين است كه اطلاعات حذف شده را دوباره بعد از ترميم شدن حذف كند .

    حالا وقتي روي كليد كليك مي كند اطلاعات حذف شده بازسازي مي شوند و سپس بعد از اجرا دوباره حذف مي شوند .
    اين برنامه كاملا ايده اش از خودم بود و هدفم اين بود امكان استفاده از لودر را منتفي كنم مي دونم الان يكي با لودر كركش مي كنه

    منتظر مقالات بعدي و كدهاي مفيد من باشيد


  26. #26
    VIP آواتار دنیای دلفی
    تاریخ عضویت
    فروردین 1403
    محل زندگی
    یک جایی توی جنوب ایران
    پست
    1,298

    نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    اين فايل يك مقاله خوب و ايده هاي مناسبي را در خصوص روشهاي قفل گذاري و آنتي ديباگ كردن نرم افزارها آموزش مي دهد .

    براي آشنايي با اصول مقدماتي حتما دانلود كنيد .

    اين مطالب از بخش آموزش قفل منشور سيمين ميباشد .
    اميد است مورد استفاده قرار گيريد .
    فایل های ضمیمه فایل های ضمیمه

  27. #27
    VIP آواتار دنیای دلفی
    تاریخ عضویت
    فروردین 1403
    محل زندگی
    یک جایی توی جنوب ایران
    پست
    1,298

    نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    همانطو كه در دو پست قبلي ديديد نحوه ساختن يك كرك مي را ديديد حالا مي خواهيم نحوه كرك كردن آن را نيز آموزش دهيم : (با تشكر ويژه از آقاي افشين زوار)

    اول برنامه رو با PEid باز میکنیم، این برنامه واسه فهمیدن زبان یا پکر مورد استفاده، خیلی کاربرد داره.
    PEid میگه که زبان مورد استفاده Borland Delphi 6.0 - 7.0 بوده بعلاوه یکسری توضیحات دیگه که فعلا کاری باهاشون نداریم.
    من تقریباهمیشه وقتی به برنامه ای که با Delphi نوشته شده باشه برخورد کنم اون رو با PE Explorer باز میکنم و Disassemble میکنم... یه تب داره به اسم VCL Methods که Event های مورد استفاده برنامه رو نشون میده...
    آدرس0044E920 رو یادداشت میکنیم. حالا برنامه رو با Ollydbg باز میکنیم و کلید Gtrl+G رو میزنیم و آدرس 0044E920 رو که از قبل بدست آوردیم تایپ میکنیم... اینکار ما رو مستقیما به آدرس مورد نظر میبره... حالا یک بار کلید F2 رو میزنیم تا یه BreakPoint گذاشته بشه.



    0044E920 PUSH EBX ; buttonClick
    0044E921 PUSH ESI
    0044E922 PUSH EDI
    0044E923 MOV ESI, EAX
    0044E925 CALL Project1.0044E5A8 ;function MainData
    0044E92A MOV ECX, EAX
    0044E92C MOV EDX, 5B
    0044E931 MOV EAX, Project1.0044E94B
    0044E936 CALL Project1.0044E54C ;WriteCurrectDataToAddreses
    0044E93B MOV EDX, 0A
    0044E940 MOV EAX, DWORD PTR DS:[ESI+2F8]
    0044E946 CALL Project1.004260A0
    ...
    0044E9A6 CALL Project1.0044E764 ; Function MainData1
    0044E9AB MOV ECX, EAX
    0044E9AD MOV EDX, 5B
    0044E9B2 MOV EAX, Project1.0044E94B
    0044E9B7 CALL Project1.0044E54C ;WriteCurrectDataToAddreses


    یکبار F9 رو بزنین تا برنامه اجرا بشه... بلافاصله بعد از کلیک، به همون BreakPoint میرسین حالا اگه با F7 خط به خط برنامه رو Trace کنین، به همون توضیحات "دنیای دلفی" میرسین؛ واسه همین اسم توابع مورد نیاز رو جلوشون نوشتم.
    همونوطور که مهران گفت، کافیه رشتهBA0A00 رو که برنامه همیشه در آدرس0044E94B مینویسه رو در برنامه درج کنیم و بعد دو تابعی که MainData و MainData1 رو می نویسن رو ناتوان کنیم. (اگه با MainData کار نداشته باشیم، تغییراتمون بی تاثیر میشن و اگه با MainData1 کاری نداشته باشیم، تغییرات NOP میشن)

    همین طور که دارید F7 رو میزنین به این خطوط می رسین


    0044E54C         53                PUSH    EBX
    0044E54D |. 56 PUSH ESI
    0044E54E |. 57 PUSH EDI
    0044E54F |. 55 PUSH EBP
    0044E550 |. 83C4 F8 ADD ESP, -8
    0044E553 |. 8BE9 MOV EBP, ECX
    0044E555 |. 8BF8 MOV EDI, EAX
    0044E557 |. 8BF2 MOV ESI, EDX
    0044E559 |. 68 9CE54400 PUSH Project1.0044E59C ; /Title = "crack me"
    0044E55E |. 6A 00 PUSH 0 ; |Class = 0
    0044E560 |. E8 5F7DFBFF CALL <JMP.&user32.FindWindowA> ; \FindWindowA
    0044E565 |. 8D5424 04 LEA EDX, DWORD PTR SS:[ESP+4]
    0044E569 |. 52 PUSH EDX ; /pProcessID
    0044E56A |. 50 PUSH EAX ; |hWnd
    0044E56B |. E8 BC7EFBFF CALL <JMP.&user32.GetWindowThreadProc>; \GetWindowThreadProcessId
    0044E570 |. 8B4424 04 MOV EAX, DWORD PTR SS:[ESP+4]
    0044E574 |. 50 PUSH EAX ; /ProcessId
    0044E575 |. 6A 00 PUSH 0 ; |Inheritable = FALSE
    0044E577 |. 68 FF0F1F00 PUSH 1F0FFF ; |Access = PROCESS_ALL_ACCESS
    0044E57C |. E8 DB79FBFF CALL <JMP.&kernel32.OpenProcess> ; \OpenProcess
    0044E581 |. 8BD8 MOV EBX, EAX
    0044E583 |. 54 PUSH ESP ; /pBytesWritten
    0044E584 |. 56 PUSH ESI ; |BytesToWrite
    0044E585 |. 55 PUSH EBP ; |Buffer
    0044E586 |. 57 PUSH EDI ; |Address
    0044E587 |. 53 PUSH EBX ; |hProcess
    0044E588 |. E8 3F7AFBFF CALL <JMP.&kernel32.WriteProcessMemor>; \WriteProcessMemory
    0044E58D |. 53 PUSH EBX ; /hObject
    0044E58E |. E8 4978FBFF CALL <JMP.&kernel32.CloseHandle> ; \CloseHandle
    0044E593 |. 59 POP ECX
    0044E594 |. 5A POP EDX
    0044E595 |. 5D POP EBP
    0044E596 |. 5F POP EDI
    0044E597 |. 5E POP ESI
    0044E598 |. 5B POP EBX
    0044E599 \. C3 RETN


    این آدرس همون تابع WriteCurrectDataToAddreses هست که ما رو کلافه کرده.اگه این تابع اجرا بشه می بینین که Olly خطوط بین آدرس 0044E94B تا 0044E9A5 رو با رنگ قرمز نوشته، این به این معنیه که خطوط تغییر کردن، خطوط تغییر کرده همون رشته طولانی BA0A00 هستن
    olly رو ببندین و با فشار Ctrl +G به آدرس0044E54C بیاین و SpaceBar رو بزنین و عبارت Retn رو تایپ کنین. اینکار باعث میشه که تابع WriteCurrectDataToAddreses هیچوقت اجرا نشه، یعنی بلافاصله بعد از ورود، خروج کنه...! اینطوری دیگه اون و مشکلی که داشتیم رفع میشن.
    حالا خطوط بین آدرس 0044E94B تا 0044E9A5 رو انتخاب کنید و Ctrl+E رو فشار بدید تا بتونیم رشته BA0A00 جایگزین NOP ها کنیم.(رشته BA0A00 رو که "دنیای دلفی" نوشته بود رو کپی و در قسمت هگز، Paste کنید)
    این مشکل هم رفع شد حالا برنامه رو اگه اجرا کنین، همون دو تا ProgressBar رو نشون میده ... پس تا اینجای کارمون درست بوده... حالا باید یکی از نوارها رو غیرفعال کنیم.


    0044E94B         BA 0A000000       MOV     EDX, 0A
    0044E950 8B86 FC020000 MOV EAX, DWORD PTR DS:[ESI+2FC]
    0044E956 E8 4577FDFF CALL Project1.004260A0
    0044E95B B3 01 MOV BL, 1
    0044E95D 8BFB MOV EDI, EBX
    0044E95F 81E7 FF000000 AND EDI, 0FF
    0044E965 8BD7 MOV EDX, EDI
    0044E967 8B86 F8020000 MOV EAX, DWORD PTR DS:[ESI+2F8]
    0044E96D E8 3E77FDFF CALL Project1.004260B0 ; progress1
    0044E972 8BD7 MOV EDX, EDI
    0044E974 8B86 FC020000 MOV EAX, DWORD PTR DS:[ESI+2FC]
    0044E97A E8 3177FDFF CALL Project1.004260B0 ; progress2
    0044E97F 6A 64 PUSH 64
    0044E981 E8 B2DAFBFF CALL <JMP.&kernel32.Sleep>
    0044E986 43 INC EBX
    0044E987 80FB 0B CMP BL, 0B
    0044E98A ^ 75 D1 JNZ SHORT Project1.0044E95D
    0044E98C 33D2 XOR EDX, EDX
    0044E98E 8B86 F8020000 MOV EAX, DWORD PTR DS:[ESI+2F8]
    0044E994 E8 1777FDFF CALL Project1.004260B0
    0044E999 33D2 XOR EDX, EDX
    0044E99B 8B86 FC020000 MOV EAX, DWORD PTR DS:[ESI+2FC]
    0044E9A1 E8 0A77FDFF CALL Project1.004260B0


    به دلخواه یکی از دو آدرسی رو که مربوط به Progress هاست رو NOP میکنیم تا اجرا نشه.

    0044E96D         E8 3E77FDFF       CALL    Project1.004260B0                ;  progress1
    0044E972 8BD7 MOV EDX, EDI
    0044E974 8B86 FC020000 MOV EAX, DWORD PTR DS:[ESI+2FC]
    0044E97A 90 NOP ; progress2
    0044E97B 90 NOP
    0044E97C 90 NOP
    0044E97D 90 NOP
    0044E97E 90 NOP
    0044E97F 6A 64 PUSH 64
    0044E981 E8 B2DAFBFF CALL <JMP.&kernel32.Sleep>


    حالا right-click کنید و Copy to Executable->All Modification->Copy All->Save File رو انتخاب کنین تا کلیه Patch ها، در فایل جدید ذخیره شوند.

    اميد وارم كه استفاده لازم را برده باشيد .

  28. #28
    مدیر بخش آواتار Securebit
    تاریخ عضویت
    آبان 1386
    محل زندگی
    تهران
    پست
    761

    نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    Anti BreakPoint & Hide Exit

    کد HTML:
    unit Unit1;
    interface
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    var
      Form1: TForm1;
    implementation
    {$R *.dfm}
    procedure KillMe();
    begin
      Application.Terminate();
    end;
    procedure Test();
    var
      Msg : String;
    begin
      msg := 'Barnamenevis';
      ShowMessage(Msg);
      asm
        mov eax, [ebp + 4]
        mov ebx, [eax]
        and ebx, $FF
        sub ebx, $CC
        jne @def
        add eax,5
        mov [ebp + 4], eax
    @def:
      end;
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      Test();
      asm
        jmp @def
        nop
        nop
        nop
        nop
        call KillMe
    @def:
      end;
    end;
    end.
    آخرین ویرایش به وسیله Securebit : یک شنبه 13 مرداد 1387 در 15:45 عصر

  29. #29
    VIP آواتار دنیای دلفی
    تاریخ عضویت
    فروردین 1403
    محل زندگی
    یک جایی توی جنوب ایران
    پست
    1,298

    نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    سلام

    اين روش براي محافظت از رمز بانك اطلاعاتي DBISAM كه درون فايل اجرايي به صورت رشته به بانك تزريق مي شود شامل دو بخش حفاظتي در فايل اجرايي و يك DLL است .
    من با استفاده از يك AESٍEncrypt رمز را كد كردم . براي اين كار از يك كليد استفاده نمودم .
    حالا با استفاده از اين كار يك رشته كد شده دارم و يك كليد . كه بايد در كد نويسي با استفاده از AESDecrypt آن را بوسيله كليد تبديل به رشته اصلي كنم و به بانك تزريق كنم .

    من با استفاده از يك روش ابداعي هم كليد و هم رشته كد شده را نابود كردم و آنها را در زمان طراحي توليد كردم . كليد را در DLL قرار دادم و رشته كد شده را در EXE .
    نحوه نابود كردن رشته كد شده و كليد به اين صورت است .

    در فايل اجرايي براي رشته كد شده :

    const
    dbs: array [0..43] of Byte= (
    $B5,$F1,$74,$49,$B1,$AF,$48,$7F,$31,$14,$36,$A7,$3 B,$51,$BB,$40,
    $81,$D6,$46,$2C,$9D,$87,$BB,$E8,$ED,$CB,$BC,$B6,$1 A,$A4,$05,$CE,
    $2E,$97,$E0,$E5,$4B,$B8,$44,$11,$F0,$A5,$E6,$67
    );
    function dcf(aBegPos, aLength: Integer): string;
    var tmp: string;
    i, endPos: Integer;
    MyKey: word;
    begin
    {$I VM_Start_WithLevel.inc}
    MyKey:= 63444;
    SetLength(Result, aLength);
    tmp:= '';
    endPos:= aBegPos+ aLength -1;
    for i:= aBegPos to endPos do
    tmp:= tmp+ Chr(dbs[i]);
    for i:= 1 to Length(tmp) do
    begin
    Result[i]:= Char(Byte(tmp[i]) xor (MyKey shr 8));
    MyKey:= (Byte(tmp[i])+ MyKey)* 34523+ 34623;
    end;
    {$I VM_End.inc}
    همانطور كه در بالا مي بينيد از سيستم ماشين مجازي TheMida همراه با Level استفاده كرده ام اين كار باعث مي شود كه يك پيچيدگي بسيار زيادي به كدها اعمال شود و روند تريس را بسيار كند و درهم كند .
    من از Level پانزده استفاده كردم اين لول مي تواند تا 255 باشد كه يك پيچيدگي بسيار بالا و بسيار كند است .


    در DLL براي كليد :

    library Special;


    {$R *.res}


    function DBPASS:String; stdcall;
    function dcf(aBegPos, aLength: Integer): string;
    const
    dbs: array [0..19] of Byte= (
    $51,$72,$F2,$09,$24,$82,$51,$65,$C9,$5E,$CD,$23,$0 1,$B7,$3A,$CE,
    $3F,$7C,$23,$43
    );
    var tmp: string;
    i, endPos: Integer;
    MyKey: word;
    begin
    MyKey:= 12345;
    SetLength(Result, aLength);
    tmp:= '';
    endPos:= aBegPos+ aLength -1;
    for i:= aBegPos to endPos do
    tmp:= tmp+ Chr(dbs[i]);
    for i:= 1 to Length(tmp) do
    begin
    Result[i]:= Char(Byte(tmp[i]) xor (MyKey shr 8));
    MyKey:= (Byte(tmp[i])+ MyKey)* 52845+ 22719;
    end;
    end;

    begin
    {$I CodeReplace_Start.inc}
    Result:=dcf(0 ,20);
    {$I CodeReplace_End.inc}
    end;




    exports
    DBPASS;

    begin
    end.
    در dll از روش جايگزيني كد نيز براي ارسال كليد استفاده شده در اين روش كد ها به يك مكان خالي حافظه در هنگام اجرا منتقل شده در حالتي بسيار امن داده پس از توليد ارسال مي شود و دوباره كدها نابود مي شوند . اين روش به اين سبك فقط مخصوص Themida است .

    دوستان از آن استفاده كنيد و لذت ببريد

    حالا در فايل اجرايي درون كليد اين كدها به اينصورت نوشتم :

    {$I CodeReplace_Start.inc}

    DBISAMSession1.AddPassword(AESDecrypt(dcf(0 ,44),DBPASS));
    Table1.Open;
    MessageBox(0,pchar(Table1.fieldbyname('Message').a sstring),'',0);
    Application.Terminate;
    {$I CodeReplace_End.inc}
    در انجا نيز اگر دقت كنيد از كد ريپليس استفاده شده است .

    و در كل اين روش تا 80 درصد مي تواند كدهاي و رشته هاي شما از دست قوي ترين كركرها در امان بگذارد . و نهايتا كار هركسي نيست كه بتواند كدها و رمزهاي شما را پيدا كند .

    يا به زبان ساده تر نفراتي كه مي توانند برنامه شما را كرك كنند كمتر و كمتر خواهد شد.

    امدوارم استفاده لازم را برده باشيد .

    در آخر هم با TheMida پكش كردم كه هركسي تواند حتي بازش كند .


  30. #30
    VIP آواتار دنیای دلفی
    تاریخ عضویت
    فروردین 1403
    محل زندگی
    یک جایی توی جنوب ایران
    پست
    1,298

    نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    راهكارهايي براي شناسايي ديباگر ها . بسيار مفيد و جالب با تشكر فراوان از جاج مجيك :


    unit AntiDbg;


    interface

    uses Windows,SysUtils,TlHelp32;

    function IsDBG:Boolean;

    implementation

    var
    Found:Boolean=False;
    hSnapmod: THANDLE;
    ModInfo: MODULEENTRY32;
    hSnap: THANDLE;
    ProcessInfo: PROCESSENTRY32;
    ProcID:DWORD;
    Tm1,Tm2:Int64;

    function IsDebuggerPresent():BOOL; stdcall;external 'kernel32.dll' name 'IsDebuggerPresent';

    function GetSys:string;
    var
    Gsys : array[0..MAX_PATH] of Char;
    begin
    GetSystemDirectory(Gsys,MAX_PATH);
    Result:=Gsys;
    if length(Result)>0 then
    if Result[length(Result)]<>'\' then Result:=Result+'\';
    end;

    function UpCaseStr(S:string):String;
    var i:integer;
    begin
    Result:=s;
    if s='' then exit;
    for i:=1 to length(s) do
    Result[i]:=upcase(Result[i]);
    end;

    function RDTSC: Int64; assembler;
    asm
    DB 0fh ,031h
    end;

    function IsRing0DBG(S:string): boolean;
    var hFile: Thandle;
    begin
    Result := False;
    hFile := CreateFileA(Pchar(S), GENERIC_READ or GENERIC_WRITE,
    0, nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, 0);
    if( hFile <> INVALID_HANDLE_VALUE ) then begin
    CloseHandle(hFile);
    Result := TRUE;
    end;
    end;

    function IsDBG:Boolean;
    var i: Integer;
    begin
    Tm1:=RDTSC;
    for i:=0 to 255 do
    OutputDebugStringA('kernel32.dll');
    Tm2:=RDTSC-Tm1;
    if Tm2<9999 then Found:=True;
    if Tm2>299999999 then Found:=True;
    hSnap:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS ,0);
    ProcessInfo.dwSize:=sizeof(PROCESSENTRY32);
    Process32First(hSnap,ProcessInfo);
    repeat
    if Pos('OLLYDBG',UpCaseStr(ProcessInfo.szExeFile))<>0 then Found:=True;
    if Pos('DBG',UpCaseStr(ProcessInfo.szExeFile))<>0 then Found:=True;
    if Pos('DEBUG',UpCaseStr(ProcessInfo.szExeFile))<>0 then Found:=True;
    if Pos('IDAG',UpCaseStr(ProcessInfo.szExeFile))<>0 then Found:=True;
    if Pos('W32DSM',UpCaseStr(ProcessInfo.szExeFile))<>0 then Found:=True;
    ProcID:=ProcessInfo.th32ProcessID;
    hSnapMod:=CreateToolhelp32Snapshot(TH32CS_SNAPMODU LE,ProcID);
    ModInfo.dwSize:=sizeof(MODULEENTRY32);
    Module32First(hSnapMod,ModInfo);
    repeat
    if Pos('DBGHELP',UpCaseStr(ModInfo.szExePath))<>0 then Found:=True;
    if Pos('OLLYDBG',UpCaseStr(ModInfo.szExePath))<>0 then Found:=True;
    if Pos('W32DSM',UpCaseStr(ModInfo.szExePath))<>0 then Found:=True;
    until (not Module32Next(hSnapMod,ModInfo));
    CloseHandle(hSnapMod);
    until (not Process32Next(hSnap,ProcessInfo));
    CloseHandle(hSnap);
    if FileExists(GetSys+'drivers\sice.sys') then Found:=True;
    if FileExists(GetSys+'drivers\ntice.sys') then Found:=True;
    if FileExists(GetSys+'drivers\syser.sys') then Found:=True;
    if FileExists(GetSys+'drivers\winice.sys') then Found:=True;
    if FileExists(GetSys+'drivers\sice.vxd') then Found:=True;
    if FileExists(GetSys+'drivers\winice.vxd') then Found:=True;
    if FileExists(GetSys+'winice.vxd') then Found:=True;
    if FileExists(GetSys+'vmm32\winice.vxd') then Found:=True;
    if FileExists(GetSys+'sice.vxd') then Found:=True;
    if FileExists(GetSys+'vmm32\sice.vxd') then Found:=True;
    if IsDebuggerPresent then Found:=True;
    if IsRing0DBG('\\.\SICE') then Found:=True;
    if IsRing0DBG('\\.\SIWVID') then Found:=True;
    if IsRing0DBG('\\.\NTICE') then Found:=True;
    if IsRing0DBG('\\.\TRW') then Found:=True;
    if IsRing0DBG('\\.\TWX') then Found:=True;
    if IsRing0DBG('\\.\ICEEXT') then Found:=True;
    Result:=Found;
    end;

    end.
    آخرین ویرایش به وسیله دنیای دلفی : یک شنبه 24 شهریور 1387 در 05:06 صبح

  31. #31
    کاربر تازه وارد آواتار MFiRE
    تاریخ عضویت
    مهر 1386
    محل زندگی
    كيانپارس
    پست
    98

    نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    برای کامل کردن بحث بعضی از دوستان :

    برای شناساییه پیشرفته تر برنامه هایه دیباگر ، مانیتورینگ و ...

    حتما تا حالا برنامه هایی که مشخصات اشیا رو می دن رو دیدین ! مثله برنامه هایی که رمزایه ستاره دار رو نمایش می دن !

    نحوه ی کارکردشون :
    ماوس رو رویه شیء مورد نظر می برید و بهتون اطلاعاتی در مورد شی میده ... از جمله : عنوان شی ، کلاس شی ، هندل شی و ... !

    روشه کار به این صورته که گرفتن اطلاعات همیشه اتفاق بیفته (حداقل هر نیم ثانیه و حداکثر 100 میلی ثانیه کافیه) ! ما اینجا با عنوان و کلاس شی کار داریم !
    مثلاً برایه شناختن پنجره ی دی اسمبلر برنامه ی ollydbg از کلاسه "ACPUASM" استفاده می کنیم !
    اگر عنوان لازم بود که از اون استفاده می کنیم !
    وقتی کاربر می ره سراغ برنامه هایه شیطانی ، از این روش می شه تا حدودی بعضی از برنامه ها رو شناخت.


    .::Timer::.
    .
    Detector "process"
    Detector "pe"
    Detector "task"
    .
    .
    .
    همین !

    سورسایه زیادی در این مورد پیدا می شه که می شه اونا رو به دلخواه تغییر داد.
    آخرین ویرایش به وسیله MFiRE : سه شنبه 04 اسفند 1388 در 00:55 صبح

  32. #32

    Smile نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    تقریبا همه پروتکتورهای قوی مثل Armadillo از تکنیک API Redirection استفاده می کنن
    شاید بد نباشه شما هم یه پروتکتور شخصی با قابلیت Api redirection بنویسین و اونرو داخل Import Table فایل پنهان کنین.
    فایل های ضمیمه فایل های ضمیمه

  33. #33

    نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    اغلب پکر و پروتکتورها، به زبان تلخ C نوشته میشن... اما AHPacker یه Packer که به زبان شیرین دلفی 7 نوشته شده.
    اینم سورسش
    فایل های ضمیمه فایل های ضمیمه

  34. #34

    نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    مقاله peter ferrie در مورد روشهای جلوگیری از آنپک کردن برنامه.
    فایل های ضمیمه فایل های ضمیمه

  35. #35
    کاربر دائمی آواتار joker
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    اصفهان
    سن
    42
    پست
    1,326

    نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    یک قسمتهایی از روتینهای پروتکتور سابقم که مدتیه به خاطر افزایش کالیبر نمیرسم تکمیلش کنم


    asm
    cmp esi,-1
    jne @OllyNotfound
    push 10h
    ADD eax,34354510h
    push 310h
    POP EAX
    ADD eax,43524510h
    push 3232510h
    ADD eax,54510h
    call EBX
    @OllyNotfound:
    end;// end of ASM



    function enumwindowsproc( wnd:Hwnd ):boolean;export; {$ifdef win32} stdcall ;{$endif}
    var
    buffer : array[0..250] of char ;
    HREG :HWND;
    Stemp:string;
    begin
    Stemp :='';

    getwindowtext( wnd,buffer,100);
    if strlen(buffer)<> 0 then

    STemp := strpas(buffer);
    if POS('main thread',Stemp)<> 0 then
    begin
    HREG := FindWindow(nil,Pchar(Stemp));
    if hREG<>0 then PostMessage(hReg,WM_CLOSE,0,0);
    end;

    STemp := strpas(buffer);
    if POS('Dbg',Stemp)<> 0 then
    begin
    HREG := FindWindow(nil,Pchar(Stemp));
    if hREG<>0 then PostMessage(hReg,WM_CLOSE,0,0);
    end;

    if POS('Olly',Stemp)<> 0 then
    begin
    HREG := FindWindow(nil,Pchar(Stemp));
    if hREG<>0 then PostMessage(hReg,WM_CLOSE,0,0);
    end;

    if POS('yoda',Stemp)<> 0 then
    begin
    HREG := FindWindow(nil,Pchar(Stemp));
    if hREG<>0 then PostMessage(hReg,WM_CLOSE,0,0);
    end;


    if POS('Import',Stemp)<> 0 then
    begin
    HREG := FindWindow(nil,Pchar(Stemp));
    if hREG<>0 then PostMessage(hReg,WM_CLOSE,0,0);
    end;

    STemp := strpas(buffer);
    if POS('[CPU]',Stemp)<> 0 then
    begin
    HREG := FindWindow(nil,pChar(Stemp));
    if hREG<>0 then PostMessage(hReg,WM_CLOSE,0,0);
    BLOK_KEY;
    end;
    STemp := strpas(buffer);
    if POS('Region',Stemp)<> 0 then
    begin
    HREG := FindWindow(nil,pChar(Stemp));
    if hREG<>0 then PostMessage(hReg,WM_CLOSE,0,0);
    BLOK_KEY;
    end;

    STemp := strpas(buffer);
    if POS('DeDe',Stemp)<> 0 then
    begin
    HREG := FindWindow(nil,pChar(Stemp));
    if hREG<>0 then PostMessage(hReg,WM_CLOSE,0,0);
    BLOK_KEY;
    Sleep(50);
    BLOK_KEY;

    HREG := FindWindow(nil,pChar('confirm'));
    if hREG<>0 then PostMessage(hReg,WM_CLOSE,0,0);
    BLOK_KEY;
    end;


    result := true ;
    end;


    enumwindows(@enumwindowsproc,longint(self));



    Procedure DBGDetect();
    var
    x:byte;
    begin
    asm
    call GetTickCount
    xchg ebx, eax
    call GetTickCount
    sub eax, ebx
    cmp eax, 1
    jnb @being_debugged
    mov x,0
    jmp @eend
    @being_debugged:
    mov x,1
    @eend:
    end;
    if x=1 then
    begin
    //ShowMessage('Debugger Detected');
    Halt;
    end
    else
    end;
    //--------------

  36. #36
    کاربر تازه وارد آواتار Naruto
    تاریخ عضویت
    شهریور 1387
    محل زندگی
    تهران
    پست
    79

    نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    سلام.

    IsDebuggerPresent به روایت اسمبلی :




    Procedure IsDebuggerPresent;
    Begin
    Asm
    call @@Check
    test eax,eax
    jnz @@Detected
    call @@ExitBlock
    @@Check:
    mov eax, large fs:18h
    mov eax, [eax+30h]
    movzx eax, byte ptr [eax+2]
    retn
    @@Detected:
    jmp @@ExitApp
    @@ExitApp:
    call ExitProcess
    @@ExitBlock:
    NOP
    end;
    End;
    آخرین ویرایش به وسیله Naruto : چهارشنبه 02 بهمن 1387 در 21:53 عصر

  37. #37

    نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    این هم یک سورس VB برای تابع IsDebuggerPresent
    فایل های ضمیمه فایل های ضمیمه

  38. #38

    نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

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

    [لطفا در این تاپیک سوال نکنید و آنها را در یک موضوع جدید بپرسید،بزودی از این موضوع حذف خواهد شد]
    آخرین ویرایش به وسیله whitehat : یک شنبه 23 فروردین 1388 در 08:51 صبح

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

    نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    بهتره یه تاپیک جدید ایجاد کنید و اونجا بحث رو ادامه بدید.

  40. #40
    VIP آواتار دنیای دلفی
    تاریخ عضویت
    فروردین 1403
    محل زندگی
    یک جایی توی جنوب ایران
    پست
    1,298

    نقل قول: محافظت از برنامه فايل اجرايي (براي استفاده عموم)

    يك سري مطالب و مقاله بسيار جالب در خصوص ADS حالشو ببريد
    The Dark Side Of NTFS

    Introduction
    Microsoft platforms continue to proliferate and multiply. Corporate server and desktop systems are running Windows NT (NT) and Windows 2000 (2K), while home user and student systems are running Windows XP (XP). These platforms are extremely popular, and in widespread use. However, very little is known by the administrators and users of these systems about a feature of the NTFS file system called 'alternate data streams'.
    NTFS is the preferred file system due to its stability, functionality, and the level of security it provides. NTFS alternate data streams (ADSs) are provided for compatibility with the Macintosh Hierarchical File System (HFS), which uses resource forks to maintain information associated with a file, such as icons, etc (RUSS00). While Microsoft provides a means for creating specific ADSs via Windows Explorer, the necessary tools and functionality for detecting the presence of arbitrary ADSs is conspicuously absent. Oddly enough, the operating systems have the necessary native functionality and tools to allow a user to create ADSs and to execute code hidden within those streams. Microsoft KnowledgeBase article Q101353 acknowledges the fact that the Win32 base API supports ADSs inconsistently.
    The purpose of this paper is to describe in detail how ADSs are created and manipulated, and how code hidden in ADSs can be executed. Specific differences in the treatment of ADSs by NT, 2K, and XP will be noted.

    Creating ADSs
    The syntax used to create ADSs is relatively simple and straightforward. To create an ADS associated with the file 'myfile.txt', simply separate the default stream name from the ADS name with a colon.

    c:\ads>echo This is an ADS > myfile.txt:hidden
    Additionally, an ADS can be created using the contents of another file.

    c:\ads>echo This is a test file > test.txt
    c:\ads>type test.txt > myfile.txt:hidden
    The ADS can then be verified using Notepad.
    c:\ads>notepad myfile.txt:hidden
    However, none of the variations of the ‘dir’ command nor any available switches or settings for Windows Explorer will detect the presence of this newly created ADS.
    Additionally, ADSs can be created and associated with the directory listing, rather than a file. This peculiarity will take on some significance later in this article, but for now it’s sufficient to describe how such ADSs can be created.
    c:\ads>echo This ADS is tied to the directory listing >    :hidden
    ADSs of this type can be created with Notepad and the ‘type’ command, as well.
    The content of ADSs should not be considered limited to simply text data. Any stream of binary information can constitute a file, and the ADS is nothing more than a file. Executables can be hidden in ADSs quite easily.
    c:\ads>type c:\winnt\notepad.exe > myfile.txt:np.exe
    c:\ads>type c:\winnt\system32\sol.exe > myfile.txt:sol2.exe
    Similarly, image files, audio files, or any other stream of data can be hidden in ADSs.
    Finally, Windows Explorer provides a means by which very specific ADSs can be created (RUSS00). If the user opens Explorer and chooses a file, and then right-clicks on that file, a drop-down menu appears. Choosing 'Properties' will open a Properties dialogue, and choosing the Summary tab (see Fig. 1) will reveal fields in which the user can insert information.


    Figure 1: Summary Tab of Properties Dialogue


    ADSs have no attributes of their own, per se. The access rights assigned to the default unnamed stream control access for creating or viewing ADSs. Quite simply, if a user cannot write to a file, that user cannot add an ADS to that file. Further, while Windows File Protection prevents the replacement of protected system files, it does not prevent a user with the appropriate permissions from adding ADSs to those system files. The System File Checker (sfc.exe) will verify that protected system files have not been overwritten, but will not detect ADSs.
    Users and administrators should also be aware of KB article Q319300 , which states that the Windows 2000 Content Indexing Server adds alternate data streams named '?Q30lsldxJoudresxAssqpcawXc' to image files on NTFS volumes. These ADSs contain thumbnails of the images.

    Detecting, Viewing, and Manipulating ADSs
    As previously stated, Microsoft provides no tools or utilities either within the operating system software distribution or the Resource Kits for detecting the presence of ADSs. One of the best tools available for this is lads.exe, written by Frank Heyne . Lads.exe is currently available as version 3.01, and does an excellent job of reporting the availability of ADSs. For administrators used to working with graphical tools, lads.exe is a command line interface (CLI) tool that reports its findings to the screen (i.e., standard output or STDOUT). Figure 2 shows an example lads.exe output, run against the test directory, c:\ads.



    Figure 2: LADS Output for c:\ads


    Figure 2 shows just how useful lads.exe can be. Not only does the utility report the presence of ADSs, but it also reports the full path and size for each ADS. Particular note should be taken of the three of the ADSs associated with myfile.txt. Two begin with an ASCII character resembling the spade from a playing card, and the third is a long series of numbers and letters between two curly braces. These are the ADSs that were associated with the file using the Summary tab of the Properties dialogue (fig. 1).
    Once an ADS is detected, what can be done to view its contents? Notepad is a very handy utility for viewing files, and can be used for viewing the contents of ADSs. However, there is a catch. For example, the following command produces unexpected results:
    c:\ads>notepad myfile.txt:hidden
    When this command is executed, Notepad opens and asks if the user wishes to create a new file. This is an unusual request, because the ADS was created earlier. In order to observe the expected results enter the following commands:
    c:\ads>echo This is another ADS > myfile.txt:hidden.txt
    c:\ads>notepad myfile.txt:hidden.txt
    The same effects can be observed when the ADS is associated the directory listing, as in ':hidden.txt'. The addition of the extension on the end of the filename allows the ADS to be opened in Notepad. This will also work for other ADSs, such as:
    c:\ads>notepad myfile.txt:np.exe
    ADSs are a feature of the NTFS file system, so if a file with an ADS is moved to a disparate file system, such as FAT, FAT32, or ext2, the ADS is removed, as it is not supported on these other file systems. ADSs are preserved if the default unnamed stream (i.e., myfile.txt from the previous examples) is copied or moved across NTFS partitions, or even to a mapped NTFS drive. This can be accomplished using the ‘copy’ or ‘move’ commands, as appropriate.
    Removing all ADSs from a default stream is relatively simple, using the following commands:
    c:\ads>type myfile.txt > myfile.bat
    c:\ads>del myfile.txt
    c:\ads>ren myfile.bat myfile.txt
    Using LADS, it is easy to verify that all ADS created in the above examples have vanished.

    Executing ADSs
    In previous examples, executables were hidden in ADSs. This information seems fairly useless unless the executables themselves can be launched, without the overhead of having to copy them out of the ADS first. In fact, the ‘start’ command can be used to do just that. Since the executables hidden earlier were deleted, rerunning the commands will serve the purpose of an example. Using the ‘type’ command, hide Notepad and Solitaire in ADSs associated with myfile.txt.
    On NT, a simple command will launch either executable (MCCL99):
    c:\ads>start myfile.txt:np.exe
    c:\ads>start myfile.txt:sol2.exe
    However, these commands generate an error on 2K. From the error message, it appears as if the information pointing to the executable wasn’t sufficient. Therefore, either absolute or relative paths should suffice, and running either of the following commands will demonstrate this:
    c:\ads>start c:\ads\myfile.txt:np.exe
    c:\ads>start .\myfile.txt:np.exe
    An interesting item to note is how the process appears while running. For example, running pslist.exe from SysInternals after executing either of the above two commands displays a process called 'myfile.txt' running with a PID of 1512, as shown in figure 3.





    Figure 3: Process listing using pslist.exe

    Figure 4 shows the process running in the Process tab of the TaskManager.


    Figure 4: Process Tab of 2K Task Manager

    Oddly enough, the Process tab on 2K shows that PID 1512 has an Image Name of 'myfile.txt'. Figure 5 shows the Application tab of the Task Manager.



    Figure 5: Applications Tab of 2K Task Manager



    Figure 6 shows that the Process tab of the Task Manager on XP displays when the same command is executed on that operating system.


    Figure 6: Process Tab of XP Task Manager

    Figure 6: Process Tab of XP Task Manager Finally, obtaining information about the process with listdlls.exe from SysInternals will display 'c:\ads\myfile.txt:np.exe' as the command line for the above command (see fig. 7), on both 2K and XP.



    Figure 7: Output of listdlls.exe on 2K


    An alternative method for launching hidden executables on 2K is a shortcut (KASP01). To demonstrate the point, create a shortcut on the desktop. The location of the item for this shortcut should be 'c:\ads\myfile.txt'. Once the shortcut has been created, observe the icon on the desktop. Assuming the ADS for Solitaire was created, edit the Properties of the shortcut so that the target now refers to 'c:\ads\myfile.txt:sol2.exe'. Wait a few seconds and observe any changes to the icon. Launch the executable by double-clicking the icon.

    Interestingly enough, as similar technique works by adding an entry to the Windows Startup Folder (KASP01) or to the ‘Run’ key in the Registry (KASP01). The full path to the key is:

    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr  entVersion\Run
    Specifying the complete path to the hidden executable will guarantee that it is launched the next time the system is started.

    Yet another method for launching executables hidden in ADSs is via the ‘Run’ box in the Start menu (KASP01). Clicking on the Start button, then 'Run', and typing the following command will launch the Solitaire ADS:

    file:///c:/ads/myfile.txt:sol2.exe
    For administrators using Perl , the Perl interpreter handles ADSs quite easily. For example, the following lines of Perl code make use of backticks to launch an ADS:
    my $file = 'c:\ads\myfile.txt:sol2.exe';

    `$file`;

    Save the above code as ‘ads.pl’, and execute the code by typing:

    c:\perl>ads.pl
    As an interesting variation, the following code also works:
    c:\perl>type ads.pl > myfile.txt:ads.pl

    c:\perl>perl myfile.txt:ads.pl

    The Windows Scripting Host (WSH) began shipping with 2K and presents some interesting possibilities with regards to ADSs (KASP01). This is particularly important because WSH is native to the 2K and XP distributions, while Perl must be installed separately. To demonstrate the capabilities of WSH, type the following command:

    c:\ads>echo MsgBox 'VBS file to test ADSs' > ads.vbs
    To execute the script using WSH, type:

    c:\ads>wscript ads.vbs
    Alternatively, type:

    c:\ads>cscript ads.vbs
    Or, simply double-click the file in Windows Explorer. All three of these methods will run the VBScript code. Now type the following commands:
    c:\ads>type ads.vbs > myfile.txt:ads.vbs

    c:\ads>wscript myfile.txt:ads.vbs

    Or:

    c:\ads>start .\myfile.txt:ads.vbs
    Cscript.exe also runs the script. Alternatively, the shortcut and Run box methods mentioned above also run the script (KASP01).


    The Really, Really Dark Side

    If the script hidden in an ADS ends with a different extension (i.e., other than '.vbs'), WSH has trouble recognizing the type of file, and will complain that an engine for executing the file cannot be found. For example:
    c:\ads>type ads.vbs > myfile.txt:ads.txt

    c:\ads>wscript myfile.txt:ads.txt

    Executing the second command above results in the error described. However, both wscript.exe and cscript.exe have switches that allow the administrator to control the execution of the program. The command syntax can be seen by typing:

    c:\ads>wscript /?
    The '//E' switch allows the user to specify an engine to be used. The new command looks like:

    c:\ads>wscript //E:vbs myfile.txt:ads.txt
    This provides some interesting opportunities for malicious use. For example, the earlier example of ADSs produced via Windows Explorer (i.e., the Summary tab of the Properties dialogue for a file) produced on ADS with the name '♣SummaryInformation'. Code, such as VBScript, can be created and written to an ADS with the same name, and then launched. The following Perl code illustrates this:


    my $file = 'c:\\ads\\myfile.txt:'.chr(5).'SummaryInformation' ;

    my $src = 'c:\ads\ads.vbs';

    `type $src > $file`;

    `wscript //E:vbs $file`;


    The final command in the script is the one of interest. For both wscript.exe and cscript.exe, the '//E' switch forces the application to use a particular script engine. In this case, the ADS containing the script to be launched has no file extension, so the scripting host has no means for determining the scripting engine to be used. This example could also apply quite easily to ADSs created by the Content Indexing Server, as mentioned above.


    Conclusion

    ADSs are a feature of the NTFS file system intended to provide compatibility with HFS, which may still be necessary for compatibility. However, the lack of visibility of this 'feature' poses a significant risk for administrators. There has already been one virus released that employed ADSs, W2K.Stream written by Bennie and Ratter of the group 29A (KASP01). As the release of malware and incidents of cybercrime increase, the malicious use of ADSs will likely increase as well.

    The solution is not to stop using the NTFS file system, as the benefits in security and reliability are too great. This 'feature' has remained part of the file system since NT 3.1. Given the circumstances, a far more prudent solution would have been to include support for HFS files in the File and Print Services for the Macintosh, rather than the file system. As it is, administrators should make judicious use of discretionary access control lists (DACLs) on files and directories (CARV00), and regularly scan their critical systems using utilities such as lads.exe. In addition, Microsoft should be lobbied to add the ability to detect and view ADSs to Windows Explorer and the command interpreter. A more than appropriate measure would be to have ADSs appear in Windows Explorer by default, using an icon with a scarlet 'A' to signify an ADS. Additionally, Microsoft should provide restrictions within the operating system for creating processes from executable files whose names contain a colon.

    Further, antivirus software vendors should include support for ADSs within their products by default. While many of the worms seen over the past year or more have been executables written in Visual Basic or Delphi, others have been Visual Basic scripts. This malware has been capable of wreaking considerable havoc, and all prudent steps should be taken to protect systems.


    منابع :

    References

    RUSS00 Russinovich, M., Inside Win2K NTFS, Part 2 , Windows 2000 Magazine, November, 2000

    MCCL99 McClure, S., Scambray, J., and Kurtz, G., Hacking Exposed: Network Security Secrets and Solutions, Berkeley: Osbourne, 1999

    KASP01 Kaspersky, E. and Zenkin, D., NTFS Alternate Data Streams , Windows and .Net Magazine, Spring 2001

    CARV00 Carvey, H., Network Trojans: What You REALLY Need To Know , Information Security Bulletin, Vol. 5, Issue 8


صفحه 1 از 2 12 آخرآخر

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

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