Mega Code Archive

 
Categories / Delphi / Examples
 

Hafızaya enjekte olma

aşağıdaki kod ile bi exeyi memoriye yükler be çalışmasını sağlarsınız. exeyi sildiğinizde exenin hala çalıştığını göreceksiniz... ********************************************************************* program Project1; {$IMAGEBASE $13140000} uses Windows; function Main(dwEntryPoint: Pointer): longword; stdcall; begin LoadLibrary('kernel32.dll'); LoadLibrary('user32.dll'); MessageBox(0, 'selam dostum.ben şu anda başka bi işlemin içindeyim!', 'hahahahhaa', 0); MessageBox(0, 'istediğimizi yapabiliriz. :)', 'hahahahhaa', 0); MessageBox(0, 'exeyi sil.ama göreceksinki hala bu mesajlar gelecek.', 'hahahahhaa', 0); MessageBox(0, 'Nolduuuuuuuuu...', 'hahahahhaa', 0); MessageBox(0, 'sana söledim memorideyim.', 'hahahahhaa', 0); MessageBox(0, 'nese fazla uzatmayalım.', 'hahahahhaa', 0); MessageBox(0, 'senin için notepadi kapatırım ;)', 'hahahahhaa', 0); ExitProcess(0); Result := 0; end; procedure Inject(ProcessHandle: longword; EntryPoint: pointer); var Module, NewModule: Pointer; Size, BytesWritten, TID: longword; begin Module := Pointer(GetModuleHandle(nil)); Size := PImageOptionalHeader(Pointer(integer(Module) + PImageDosHeader(Module)._lfanew + SizeOf(dword) + SizeOf(TImageFileHeader))).SizeOfImage; VirtualFreeEx(ProcessHandle, Module, 0, MEM_RELEASE); NewModule := VirtualAllocEx(ProcessHandle, Module, Size, MEM_COMMIT or MEM_RESERVE, PAGE_EXECUTE_READWRITE); WriteProcessMemory(ProcessHandle, NewModule, Module, Size, BytesWritten); CreateRemoteThread(ProcessHandle, nil, 0, EntryPoint, Module, 0, TID); end; var ProcessHandle, PID: longword; StartupInfo: TStartupInfo; ProcessInfo: TProcessInformation; begin CreateProcess(nil, 'notepad', nil, nil, False, 0, nil, nil, StartupInfo, ProcessInfo); Sleep(500); GetWindowThreadProcessId(FindWindow('Notepad', nil), @PID); ProcessHandle := OpenProcess(PROCESS_ALL_ACCESS, False, PID); Inject(ProcessHandle, @Main); CloseHandle(ProcessHandle); end. ***********************************************************************