黑客风云——风云网络
设为首页 加入收藏 我要投稿 网站地图

您现在的位置: 黑客风云 >> 黑客文章 >> 黑客入门 >> 电脑新手 >> 正文
·没有路由密码权限时的鸽08-23·上网安全 Vista自我防范10-11
·让濒临崩溃的Windows XP10-11·有备无患,快速自制救急10-11
·要你好看!Windows看图工10-11·空间赞助网提供不同类型10-11
·讨论net.exe和net1.exe的10-10·让3389远程桌面传输更通10-10
·巧妙入侵渗透赌博站10-10·Aspx空间扫权限工具10-10
·Windows2003最新提权工具10-10·易淘乐提供100M免费全能10-10
·系统开机密码忘了不着急10-09·中意网络提供免费100M免10-09
·与众不同 Windows XP开始10-08·让桌面图标翻跟斗 在XP上10-08
·上海宽元站长资助计划-提10-08·个性化Windows XP的任务10-07
·趣盘提供3G免费网络硬盘10-07·秀山热线提供200MB免费全10-07
·一次艰辛的提权过程10-06·成功入侵IT大卖场的渗透10-06
·mysqlhack- MYSQL利用工10-06·lanker一句话PHP后门客户10-06
·WIXI提供3G免费多媒体网10-06·新人网络提供100M/ftp免10-06
·如何利用QQ带来高流量10-05·UuShare提供免费网络文件10-05
[推荐]替换运行中的文件(深入浅出)
      ★★★★★

替换运行中的文件(深入浅出)

文章整理发布:黑客风云 文章来源:www.05112.com 更新时间:2006-4-25 9:02:34

三、操作系统启动过程中相关操作

关注了一下NT的启动过程,想了解系统在启动的时候是如何执行上面提到的移动或者删除行为的。

在初始化内核阶段,ntoskrnl.exe从NTLDR手中接管了控制权,在最后一步,Session Manager启动了Windows XP的高级子系统以及服务,Session Manager启动控制所有输入、输出设备以及访问显示器屏幕的Win32子系统以及Winlogon进程,初始化内核完毕。

Session Manager实际上就是smss.exe,我们经常可以在内存进程中看到他的身影。反汇编的时候,在sub_48584D01中看到XP有考虑识别的CPU有:

0 x86
1 MIPS
2 ALPHA
3 PPC
4 IA64
5 ALPHA64
other UNKNOWN

我在smss.exe里面找到了PendingFileRenameOperations,可见应该是此文件负责了在引导的时候执行其中的文件移动操作。只可惜,我没有找到何处调用了PendingFileRenameOperations,反汇编功底不佳啊。

从sysinternals.com中看到一段关于Session Manager调用PendingFileRenameOperations的话

[http://www.sysinternals.com/ntw2k/info/regboot.shtml]


After you pass the point in the log where boot and system driver initialization is complete you’ll begin to see records created by the smss.exe process, which is called the Session Manager. Session Manager is the first user-mode process launched during a boot. You’ll see it immediately check to see if there are any rename operations it should perform before the system is up and running by looking at the value HKLM\System\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations. Next you’ll see it determine what DOS device mappings it should create (e.g. COM1, LPT1), what environment variables are defined, what DLL’s it "knows about" (standard DLLs in the system32 directory), and which protected subsystems it should start (e.g. OS/2, POSIX).

Session Manager typically launches Chkdsk (autocheck.exe), which is specified in the Session Manager’s BootExecute value along with direction to run other boot-time native applications. After Autocheck finishes Session Manager starts Winlogon and the Win32 subsystem (CSRSS.EXE). Both of these generate interleaved Registry accesses as they start up concurrently. Winlogon can be seen querying the .Default key’s display settings, including colors and mouse settings under HKU\.Default\Control Panel. The .Default key’s contents are user preferences that are active when no one is logged in, and Winlogon uses them for the screen on which it displays the logon dialog box.


不过这个和微软所说的先Autochk,然后再PendingFileRenameOperations,不同。

从另一份文档中(http://freehost02.websamba.com/brittanyfoo/BootProcess.html),提到了初始化进程问题:

Smss 的主线程进行以下的初始化步骤:

1、创建 LPC 端口对象( \SmApiPort )和两个等待客户请求的线程。客户请求包括装载一个新的子系统或者创建一个会话等。

2、为 MS-DOS 设备名,如 COM1 和 LPT1 定义符号链接。

3、如果安装了终端服务(Terminal Services),在对象管理器的名字空间创建 \Sessions 目录。

4、运行 HKLM\SYSTEM\CurrentControlSet\ Control\Session Manager\BootExecute 定义的程序,典型的是运行 Autochk (Chkdsk在引导其间的版本)。

5、按照 HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations 的指令,进行延迟文件改名操作。挂起文件删除在 PendingFileRenameOperations2 。

6、打开已知的 DLL 。

7、创建另外的分页文件。

8、初始化注册表。配置管理器刷新注册表, 为HKLM\SAM, HKLM\SECURITY, 和 HKLM\SOFTWARE 关键字装载注册文件。HKLM\SYSTEM\ CurrentControlSet\Control\hivelist 在硬盘上搜索注册表文件,配置管理器在 \Winnt\System32\Config 寻找。

9、创建系统环境变量。

10、装载Win32子系统内核模式部分(Win32k.sys)。Smss 在 HKLM\SYSTEM\CurrentControlSet\Control\Session Manager 下寻找 Win32k.sys 和其它要装载组件的路径,确定它们的位置。Win32k.sys 中的初始化代码使用视频驱动程序,屏幕的分辨率转换到缺省概貌文件定义的值。因此,屏幕从引导视频驱动程序使用的VGA模式转到系统选择的缺省的分辨率。

11、启动子系统进程,包括 Csrss 。

12、启动登陆进程 (Winlogon) 。

13、为调试事件信息创建LPC口(DbgSsApiPort 和 DbgUiApiPort),并创建监听这些口的线程。

这个算是描述最清楚的了。


四、总结

至此,对替换正在使用中的文件有了初步的理解。

既MoveFileExW -> MoveFileWithProgressW -> BasepMoveFileDelayed -> HKLM\System\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations

然后,ntldr引导,ntoskrnl.exe结果引导权,启动smss.exe(Session Manager),在Autochk之后,检查PendingFileRenameOperations,然后执行其中的文件替换操作。最后smss启动Winlogon进程,允许用户登录。

因此此种方法可以替换几乎所有的系统文件,因为smss是系统的第一个UserMode的进程,此时被使用的文件极少,不可能有人在它之前占用文件。

如果是替换系统文件的话,比如smss.exe,就使用微软的办法,先把smss.exe移动到临时文件夹去,然后把新的smss.exe放到正确的目录中。把临时文件家里的smss.exe移动到NULL,并且是MOVEFILE_DELAY_UNTIL_REBOOT。这样如果系统重新启动的话,自然使用的是新的smss.exe,然后它再把临时文件夹里的垃圾清除掉即可。其实此时不清除,等起来之后再清除也是可以的了,因为已经没有东西在占用那个临时文件夹里的垃圾了。

如果是替换普通应用程序的话,只需要重新启动应用程序即可,因为此时应用程序目录里的东西已经为新的文件了。重新启动只不过是为了删除那个临时文件夹里的垃圾而已。

上一页  [1] [2] 

文章录入:cainiaowang    责任编辑:cainiaowang 
【字体:
Copyright @2006 黑客风云 ●业务联系:QQ 联系怪人 联系奇人 Email:给怪人发邮件 给奇人发邮件
ICP备案:冀06009886