思路:如何跳过CreateProcess调用底层创建进程函数

来源:互联网 发布:查看端口监听ipv6 编辑:程序博客网 时间:2024/04/29 09:01

论坛近日有人在问如何跳过CreateProcess调用底层的NtCreateProcess。

我想说的是不能单纯看这个问题,首先不同NT内核版本CreateProcess进入

底层的路径是不同的:


2k ->NtCreateProcess
xp ->NtCreateProcessEx
vista/win7/2008 ->NtCreateUserProcess


拿windows7 x64来说吧,在ntdll32!NtCreateUserProcess设置断点,中断后,查看stack内容,结合该函数原型来看:


NTSTATUS NtCreateUserProcess(PHANDLE ProcessHandle,
  PHANDLE ThreadHandle,
  PVOID Parameter2,
  PVOID Parameter3,
  PVOID ProcessSecurityDescriptor,
  PVOID ThreadSecurityDescriptor,
  PVOID Parameter6,
  PVOID Parameter7,
  PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
  PVOID Parameter9,
  PVOID pProcessUnKnow);

vals in stack :
0028f5dc 760b4338 kernel32!CreateProcessInternalW+0xe75 (ret)
0028f5e0 0028f920
0028f5e4 0028f900
0028f5e8 02000000
0028f5ec 02000000
0028f5f0 00000000
0028f5f4 00000000
0028f5f8 00000000
0028f5fc 00000001
0028f600 00755c38
0028f604 0028f7a4
0028f608 0028fb20
0028f60c d0c89b5d
0028f610 0028fcdc
0028f614 00000001

可知其最关键的ProcessParameters地址在755c38,分析其内容则有:

ntdll!_RTL_USER_PROCESS_PARAMETERS
  +0x000 MaximumLength : 0x94c
  +0x004 Length : 0x94c
  +0x008 Flags : 1
  +0x00c DebugFlags : 0
  +0x010 ConsoleHandle : 0x00001480 Void
  +0x018 ConsoleFlags : 3
  +0x020 StandardInput : 0x0000000b Void
  +0x028 StandardOutput : 0x00755ed0 Void
  +0x030 StandardError : 0x03ee03ec Void
  +0x038 CurrentDirectory : _CURDIR
  +0x000 DosPath : _UNICODE_STRING "C:\Windows\system32\notepad.exe"
  +0x000 Length : 0x3e
  +0x002 MaximumLength : 0x40
  +0x008 Buffer : 0x00180016 "--- memory read error at address 0x00180016 ---"
  +0x010 Handle : 0x00756584 Void
  +0x050 DllPath : _UNICODE_STRING ""
  +0x000 Length : 0
  +0x002 MaximumLength : 0
  +0x008 Buffer : (null)  
  +0x060 ImagePathName : _UNICODE_STRING ""
  +0x000 Length : 0
  +0x002 MaximumLength : 0
  +0x008 Buffer : (null)  
  +0x070 CommandLine : _UNICODE_STRING "C:\Windows\system32\notepad.exe"
  +0x000 Length : 0x3e
  +0x002 MaximumLength : 0x40
  +0x008 Buffer : 0x0020001e "--- memory read error at address 0x0020001e ---"
  +0x080 Environment : 0x00020000 Void
  +0x088 StartingX : 0
  +0x08c StartingY : 0
  +0x090 CountX : 0
  +0x094 CountY : 0
  +0x098 CountCharsX : 0
  +0x09c CountCharsY : 0
  +0x0a0 FillAttribute : 0
  +0x0a4 WindowFlags : 0
  +0x0a8 ShowWindowFlags : 0
  +0x0b0 WindowTitle : _UNICODE_STRING ""
  +0x000 Length : 0
  +0x002 MaximumLength : 0
  +0x008 Buffer : (null)  
  +0x0c0 DesktopInfo : _UNICODE_STRING ""
  +0x000 Length : 0
  +0x002 MaximumLength : 0
  +0x008 Buffer : (null)  
  +0x0d0 ShellInfo : _UNICODE_STRING ""
  +0x000 Length : 0
  +0x002 MaximumLength : 0
  +0x008 Buffer : (null)  
  +0x0e0 RuntimeData : _UNICODE_STRING ""
  +0x000 Length : 0
  +0x002 MaximumLength : 0
  +0x008 Buffer : (null)  
  +0x0f0 CurrentDirectores : [32] _RTL_DRIVE_LETTER_CURDIR
  +0x000 Flags : 0
  +0x002 Length : 0
  +0x004 TimeStamp : 0
  +0x008 DosPath : _STRING ""
  +0x000 Length : 0
  +0x002 MaximumLength : 0
  +0x008 Buffer : (null)  
  +0x3f0 EnvironmentSize : 0
  +0x3f8 EnvironmentVersion : 0

接下来就可以操作鸟:

1 找出 NtCreateUserProcess 地址
2 构建及填充 ProcessParameters 内容
3 调用并处理好返回值


原创粉丝点击