(04-04-2020, 02:26 AM)Hs32-Idir كتب : في حالتي ، تتحقق الوظيفة مما إذا كانت process is Being Debugged ، لذا إذا كان صحيحًا ، فيمكنك محاولة فصلها عن Debugger
هذه ترجمة C ++ ، في دلفي PVOID = POINTER
لجعلها تعمل حاولRunAsAdmin
اجعله يعمل تحت المؤقت (Timer)
فيمكنك محاولة فصلها ب NtRemoveProcessDebug
آسف للغتي ، لدي لوحة مفاتيح ,qwerty
هل يمكنني النشر باللغة الإنجليزية أو لغات أخرى
للتحقق ما اذا كان ال Process تحت التنقيح يكفي كتابة الكود التالي و استبدال dword ptr fs:[$30] بمؤشر للبنية PEB و يمكن جلبه بالدلة NtQueryInformationProcess التي يجب ان يكون المقبض الممرر اليها هو مقبض ال Process
PHP كود :
begin asm mov eax, dword ptr fs:[$30] // pointer to PEB struct movzx eax, byte ptr ds:[eax+$2] {eax + $2 holds the value of mov check,eax BeingDebugged Flag} end; if check <> 0 then showmessage('The application is under a Debugger');
حسنا أعتقد انني اوشكت على ايجاد الحل , قمت بجلب مقبض الملف الذي هو قيد التنقيح و قمت بجلب قيمة ال Flag BeingDebugged الان المشكل في استعمالي للدالة WriteProcessMemory اريد تغيير البايت 01 (BeingDebbuged) لكن لا يتم تغييره
أكرر المشكل الوحيد الان هو بالسطر :
function ODBG_Plugininit(ollydbgversion:Integer;hWndOlly:HWND;features:PULONG):Integer;cdecl; begin g_hwndOlly := hWndOlly; Addtolist(0, 0, pchar(PLUGIN_NAME)); Result := 0; end;
function ODBG_Plugindata(name: PChar): integer; cdecl; begin StrLCopy(name, PChar(PLUGIN_NAME), 32); Result := PLUGIN_VERSION; end;
var NtQueryInformationProcess: TNtQueryInformationProcess; NtRemoveProcessDebug: TNtRemoveProcessDebug; NtSetInformationDebugObject: TNtSetInformationDebugObject; NtClose: TNtClose;
function GetProcessIsBeingDebugged(ProcessHandle: THandle; var IsBeingDebugged: Boolean): Boolean; var DebugPort: PVOID; TargetProcessHandle: THandle; SourceProcessHandle: THandle; DuplicateResult: BOOL; DesiredAccess: ACCESS_MASK; begin Result := False; try if (@NtQueryInformationProcess <> nil) then begin DuplicateResult := False; TargetProcessHandle := 0; DuplicateResult := DuplicateHandle(GetCurrentProcess(), ProcessHandle, GetCurrentProcess(), @TargetProcessHandle, 0, False, DUPLICATE_SAME_ACCESS); if DuplicateResult then begin try if NtQueryInformationProcess( TargetProcessHandle, 7, @DebugPort, SizeOf(PVOID), nil ) = 0 then Result := True; if DebugPort <> nil then IsBeingDebugged := True; finally if TargetProcessHandle <> 0 then CloseHandle(TargetProcessHandle); end; end; end; except end; end;
function DetachProcessFromDebugger(ProcessHandle: THandle): Boolean; var DebugObjectHandle: THandle; DebugFlags: ULONG; TargetProcessHandle: THandle; SourceProcessHandle: THandle; DuplicateResult: BOOL; DesiredAccess: ACCESS_MASK; begin Result := False; try if (@NtQueryInformationProcess <> nil) then begin DebugObjectHandle := 0; if NtQueryInformationProcess( ProcessHandle, 30, @DebugObjectHandle, SizeOf(THandle), nil) = 0 then begin try if (@NtSetInformationDebugObject <> nil) and (@NtRemoveProcessDebug <> nil) then begin DebugFlags := 0; NtSetInformationDebugObject( DebugObjectHandle, 2, @DebugFlags, SizeOf(ULONG), nil);
if NtRemoveProcessDebug(ProcessHandle, DebugObjectHandle) = 0 then Result := True; end; finally if DebugObjectHandle <> 0 then NtClose(DebugObjectHandle); end; end; end; except end; end;
function _AddCurrentProcessPrivileges(PrivilegeName: WideString): Boolean; var TokenHandle: THandle; TokenPrivileges: TTokenPrivileges; ReturnLength: DWORD; begin Result := False; try if OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, TokenHandle) then begin try LookupPrivilegeValueW(nil, PWideChar(PrivilegeName), TokenPrivileges.Privileges[0].Luid); TokenPrivileges.PrivilegeCount := 1; TokenPrivileges.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; if AdjustTokenPrivileges(TokenHandle, False, TokenPrivileges, 0, nil, ReturnLength) then Result := True; finally CloseHandle(TokenHandle); end; end; except end; end;
var LibraryHandle: HMODULE; HProcess:Thandle; _IsDebugged:Boolean; begin _AddCurrentProcessPrivileges('SeDebugPrivilege'); LibraryHandle := LoadLibrary('ntdll.dll'); if LibraryHandle <> 0 then begin try @NtQueryInformationProcess := GetProcAddress(LibraryHandle, 'NtQueryInformationProcess'); @NtRemoveProcessDebug := GetProcAddress(LibraryHandle, 'NtRemoveProcessDebug'); @NtSetInformationDebugObject := GetProcAddress(LibraryHandle, 'NtSetInformationDebugObject'); @NtClose := GetProcAddress(LibraryHandle, 'NtClose'); finally LibraryHandle := 0; FreeLibrary(LibraryHandle); end; end; hProcess := OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId); if hProcess <> INVALID_HANDLE_vALUE then begin GetProcessIsBeingDebugged(hProcess, _IsDebugged); if _isDebugged then begin WriteLn('Process Is Debugged'); if DetachProcessFromDebugger(hProcess) then WriteLn('Process Detached') else WriteLn('Process Can''t be Detached'); end else WriteLn('Process not debugged'); end; ReadLn;
@Rever7eR
في مثالك ، أعتقد أنه يجب عليك تخصيص عنوان للكتابة ، VirtualAllocEx
في رأيي ، لا يمكننا الكتابة في PROCESS دون تحديد العنوان ADDRESS
ملحوظة: في CurrentProcess تعمل بشكل جيد عند Debugged مع دلفي
كل من 1 user says قال شكرا ل Hs32-Idir على المشاركة المفيدة1 user says Thank You to Hs32-Idir for this post • Rever7eR
شكرا أخي العزيز Hs32-Idir أتعبتك معي , سأراجع الكود الاخير الذي قمت بنشره بعد اخذ قسط من الراحة
شكرا لكل من شارك بالموضوع و ابدى اهتمامه .
المشروع مرفق لمن يريد تجربته
function ODBG_Plugininit(ollydbgversion:Integer;hWndOlly:HWND;features:PULONG):Integer;cdecl; begin g_hwndOlly := hWndOlly; Addtolist(0, 0, pchar(PLUGIN_NAME)); Result := 0; end;
function ODBG_Plugindata(name: PChar): integer; cdecl; begin StrLCopy(name, PChar(PLUGIN_NAME), 32); Result := PLUGIN_VERSION; end;