كيف تعمل لودر لملفات dll
#1
السلام عليكم
كيف تعمل لودر لملفات dll
او هل هناك برنامج يقوم بنفس المهمة
تحياتي
الرد
#2
و عليكم السلام و رحمة الله
أنظر دروس الدورة أخي
http://www.delphi4arab.net/forum/showthread.php?tid=889
الرد
#3
اخي الكريم انا لا اقصد هذا
عندما تعدل في ملف محمي
ماذا تفعل ؟
تبحث عن لودر يحقن الملف في الذاكره

المشكله هناك لودرات لملفات التنفيذية وليس لل لملفات dll

بما ان dll مستدعاة من EXE
اذن يمبغي حقن EXE ولكن لم ينجح
الرد
#4
السلام عليكم
أنظر هذه الدالة أخي

كود :
function InjectDLL( DLLSource : string; ProcessDestination : string ) : Boolean; var LibName : Pointer; hProcess : THandle; ThreadHandle: THandle; OctEcrit : Cardinal; TheadID : DWORD; begin Result := False; AjustePrivileges; hProcess := OpenProcess( PROCESS_ALL_ACCESS, FALSE, FindProcess( ProcessDestination ) ); if (hProcess = 0) then Exit; LibName := VirtualAllocEx( hProcess, nil, Length(DLLSource) + 1, MEM_COMMIT, PAGE_READWRITE ); if ( LibName <> nil ) then begin WriteProcessMemory( hProcess, LibName, PChar(DLLSource), Length(DLLSource) + 1, OctEcrit ); if ( (Length(DLLSource) + 1) <> OctEcrit ) then Exit; le process ThreadHandle := CreateRemoteThread( hProcess, nil, 0, GetProcAddress( LoadLibrary('kernel32.dll'), 'LoadLibraryA' ), LibName, 0, TheadID ); Result := ( ThreadHandle <> 0 ); WaitForSingleObject( ThreadHandle, INFINITE ); end else Result := False; VirtualFreeEx( hProcess, LibName, 0, MEM_RELEASE ); CloseHandle( hProcess ); end;
و هنالك مثال في المرفقات


الملفات المرفقة
.rar   Inject Dll Process.rar (الحجم : 405.9 ك ب / التحميلات : 60)
الرد
#5
شكرا
سأرى المثال واعود بالجواب
الرد
#6
لقد حولت المثال الى DXE
لو تتكرم بشوية توضيح
في Injecteur عملية ربط للdll مع اي process شغال في الذاكرة
في client ماذا تبحث
عن سرفرات!!
والثالث انشاء للdll

إقتباس :FindProcess(ProcessDestination)
إقتباس :AjustePrivileges;
اين المرجع (الاسناد)

اخي لدي مجموعة بايتات ينبغي حقنها في لل
dll
الرد
#7
السلام عليكم و رحمة الله
ا عذرني أخي لم افهم مقصودك جيدا

لي ايجاد PID من اسم Process
FindProcess(ProcessDestination)

ضبط الامتيازات في وضعDebug لتنفيذ إجراءات معينة

AjustePrivileges;

لحقنDll وجدت هذه الدالة في احد المواقع
كود :
function InjectDll(PID:DWORD; sDll:string):Boolean; var hLib: Pointer; hThread: THandle; pMod: Pointer; hOpen: THandle; dWritten: Cardinal; ThreadID: Cardinal; begin Result := FALSE; hOpen := OpenProcess(PROCESS_ALL_ACCESS, FALSE, PID); if hOpen <> INVALID_HANDLE_VALUE then begin hLib := GetProcAddress(GetModuleHandle(PChar('kernel32.dll')), PChar('LoadLibraryA')); pMod := VirtualAllocEx(hOpen, nil, Length(sDll) + 1, MEM_COMMIT or MEM_RESERVE, PAGE_EXECUTE_READWRITE); if WriteProcessMemory(hOpen, pMod, @sDll[1], Length(sDll), dWritten) then Result := TRUE; hThread := CreateRemoteThread(hOpen, nil, 0, hLib, pMod, 0, ThreadID); WaitForSingleObject(hThread, INFINITE); CloseHandle(hOpen); CloseHandle(hThread); end; end;
الرد
#8
للفائدة سأضيف 3 دالات و وحدة
كود :
procedure InjectDll(PID: dword; DLL: pChar); var BytesWritten, hProcess, hThread, TID: Cardinal; Parameters: pointer; pThreadStartRoutine: Pointer; begin hProcess := OpenProcess(PROCESS_ALL_ACCESS, False, PID); Parameters := VirtualAllocEx( hProcess, nil, Length(DLL)+1, MEM_COMMIT or MEM_RESERVE, PAGE_READWRITE); WriteProcessMemory(hProcess,Parameters,Pointer(DLL ),Length(DLL)+1,BytesWritten); pThreadStartRoutine := GetProcAddress(GetModuleHandle('KERNEL32.DLL'), 'LoadLibraryA'); hThread := CreateRemoteThread(hProcess, nil, 0, pThreadStartRoutine, Parameters, 0, TID); CloseHandle(hProcess); end;
كود :
Function InjectDll2(ProcessID: DWORD; LibraryName: String): Integer; const MAX_LIBRARYNAME = MAX_PATH; MAX_FUNCTIONNAME = 255; MIN_INSTRSIZE = 5; Type PLibRemote = ^TLibRemote; TLibRemote = packed record ProcessID: DWORD; LibraryName: Array [0..MAX_LIBRARYNAME] of Char; LibraryHandle: HMODULE; end; var hKernel: HMODULE; hProcess: THandle; hThread: THandle; dwNull: Cardinal; lpRemote: PLibRemote; lpLibRemote: PChar; Begin // Set default result of (-1), which means the injection failed result:=(-1); // Check library name and version of OS we are running on if (Length(LibraryName) > 0) and ((GetVersion and $80000000) = 0)then begin Result := 2; // Attempt to open the process hProcess:=OpenProcess(PROCESS_ALL_ACCESS, False, ProcessID); // Check process handle if (hProcess <> 0) then begin // Resource protection try Result:= 3; // Get module handle for kernel32 hKernel:=GetModuleHandle('kernel32.dll'); // Check handle if (hKernel <> 0) then begin Result := 4; // Allocate memory in other process lpLibRemote:=VirtualAllocEx(hProcess, nil, Succ(Length(LibraryName)), MEM_COMMIT, PAGE_READWRITE); // Check memory pointer if Assigned(lpLibRemote) then begin // Resource protection try Result := 5; // Write the library name to the memory in other process WriteProcessMemory(hProcess, lpLibRemote, PChar(LibraryName), Length(LibraryName), dwNull); // Create the remote thread hThread:=CreateRemoteThread(hProcess, nil, 0, GetProcAddress(hKernel, 'LoadLibraryA'), lpLibRemote, 0, dwNull); // Check the thread handle if (hThread <> 0) then begin // Resource protection try // Allocate a new remote injection record lpRemote:=AllocMem(SizeOf(TLibRemote)); // Set process id lpRemote^.ProcessID:=ProcessID; // Copy library name StrPLCopy(lpRemote^.LibraryName, LibraryName, MAX_LIBRARYNAME); // Wait for the thread to complete WaitForSingleObject(hThread, INFINITE); // Fill in the library handle GetExitCodeThread(hThread, DWORD(lpRemote^.LibraryHandle)); // Add to list result:=1; finally // Close the thread handle CloseHandle(hThread); end; end; finally // Free allocated memory VirtualFree(lpLibRemote, 0, MEM_RELEASE); end; end; end; finally // Close the process handle CloseHandle(hProcess); end; end; end; End;
كود :
function InjectDll(TargetProcessID : DWORD; dllName : string): boolean; var LibName : pointer; hProcess , ThreadHandle : Thandle; BytesWritten , TheadID : DWORD; begin result := false; hProcess := OpenProcess( PROCESS_ALL_ACCESS, FALSE, TargetProcessID ); if (hProcess = 0) then exit; // alocate and write the dll name to the remote process LibName := VirtualAllocEx(hProcess , 0, length(dllName) + 5 , MEM_COMMIT , PAGE_READWRITE) ; if ( LibName <> nil) then begin WriteProcessMemory(hProcess , LibName, pchar(dllName) , length(dllName) , BytesWritten ); end ; ThreadHandle := CreateRemoteThread( hProcess , nil , 0, GetProcAddress(LoadLibrary('kernel32.dll'), 'LoadLibraryA') , LibName ,0 , TheadID ); result := ThreadHandle <> 0; WaitForSingleObject( ThreadHandle , INFINITE); //wait for the thread to execute // free the memory we allocated for the dll name VirtualFreeEx( hProcess , LibName , 0 , MEM_RELEASE); CloseHandle(hProcess); end;
الرد
#9
unit DllIjection
بالتوفيق


الملفات المرفقة
.rar   DllIjection.rar (الحجم : 2.04 ك ب / التحميلات : 21)
الرد
#10
اشكرك جدا
والان شوية توضيح
اولا الهدف:
الوصول للملف (zzz.dll) مثلا
ثانيا الكيفية:
الحقن في الذاكرة للملف zzz.dll بينما ينتظر mm.exe مثلا
ثالثا التنفيذ:
ظهور البرنامج mm.exe مع كافة التعديلات
هذا كل شي ولكن كيف!!
الرد


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم