我找到这方面的资料,可是真正写成批处理后出现一点问题,路径无法写入,还有就是说该服务没有停止控制响应功能.
现在很多的木马、后门、蠕虫病毒都是通过修改注册表中的RUN键值来实现自启动,这种自启动模式不是很隐蔽,稍微懂点安全的人,一般发现电脑被黑,都会查看RUN键值,于是系统服务便成为了一种相对隐蔽的自启动模式,比如冲击波杀手就采用系统服务来自启动病毒程序。
现在添加系统服务的工具很多,最典型的就是netservice,但是我们这里讲的是手工添加系统服务,所以工具的使用不在本文的讨论范围之内:WINDOWS里的很多东西都是跟注册表息息相关的,系统服务也不例外,系统服务跟以下的注册表几个项目相关:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services
我们完全可以找到在系统服务中已注册的服务的键值来依样画葫芦:在以上任何注册表列中添加一个新项,名字是你想要添加系统服务的名字,比如Backdoor,在BACKDOOR项下新建一个字符串,数值名称Displayname数值数据为要添加服务的名称Backdoor。下面列出一个表,会直观一些:
名称 类型 数据 备注
Displayname REG_SZ 想要添加服务的名称 想要添加服务的名称
Description REG_SZ 服务的描述 服务的描述
ImagePath REG EXPAND SZ 程序的路径
Start REG_DWORD 0,2,3,4 2代表自动启动,3代表手动启动服务.4代表禁用服务,0代表系统对底层设备驱动(一般不需要这个)
ErrorControl REG_DWORD 1
Type REG_DWORD 10 or 20 一般应用程序都是10,其他的对应20
ObjectName REG_SZ LocalSystem 显示本地登陆
注意:在XP/2003下可以完全手工来添加REG EXPAND SZ类型,但是在WIN2000下却不可以,于是在WIN2000下我们只好自己写一个REG来直接注册系统服务,这样WIN2000下添加系统也能很轻松了——这里同样需要注意的是注册表文件里的ImagePath的数值类型必须是HEX(16进制),可以拿WINHEX来把程序的绝对路径转换成16进制的,每一个数值用逗号搁开,比如我的ImagePath键值是C:\winnt\nukegroup.exe那就应该转换成:
63,3A,5C,77,69,6E,6E,74,5C,6E,75,6B,65,2E,65,78,65
打开记事本,敲入以下内容:
Windows Registry Editor Version 5.00
"Type"=dword:00000010
"Start"=dword:00000002
"ErrorControl"=dword:00000001
"ImagePath"=hex(2):63,3A,5C,77,69,6E,6E,74,5C,6E,75,6B,65,2E,65,78,65
"DisplayName"="SRVTEST"
"ObjectName"="LocalSystem"
"Description"="系统服务测试"
把以上信息保存为addsrv.reg,我们就可以依靠命令来导入注册表,从而达到添加系统服务的目的,我们在命令控制台输入regedit /s addsrv.reg,等机器重新启动,这个服务就被成功添加了——但很不幸的是:我在真正实验的时候遇到了困难,ImagePath的数值是乱码。
怎么想也不明白,还是把乱码修改成绝对路径吧:如果直接把REG信息写成这样:
"ImagePath"=hex(2):C:\WINNT\NUKEGROUP.EXE
其他的键值都可以添加,这个键值就不可以了?总之我们可以先添加乱码的ImagePath,然后再修改成C:\winnt\nukegroup.exe 这样也是可能的。
以上是Windows 2000手工添加系统服务的方法,对于Windows 98 注册表结构是不一样的,但是Windows 98仍然可以通过注册表来实现添加系统服务,而且还要更简单一些。
在项目“HKLM/SOFTWARE/Microsoft/WindowsCurrentVersion/RunServices”下添加一个新字符串数值。比如,如果程序的名字叫做“BACKDOOR”,就建立一个名为“BACKDOOR”的字符串数值,然后在数据域中输入执行程序的完整路径。
手工添加一个系统服务就这么简单,手工删除系统也是一个道理。通过注册表来实现,这里就不多说了,为方便广大读者深入了解系统服务的各方面,我推荐以下文章,希望有所帮助:
http://www.microsoft.com/china/community/program/originalarticles/TechDoc/WinXPStart.mspx
http://sinbad.zhoubin.com/read.html?board=Win&num=89
I found relevant information in this regard, but when I actually wrote it into a batch script, there were some issues. The path couldn't be written, and also it was said that this service didn't have the function of responding to stop control.
Now many trojans, backdoors, and worm viruses all achieve self-startup by modifying the RUN key values in the registry. This self-startup mode is not very hidden. Generally, people who know a little about security will check the RUN key values when they find that the computer has been hacked. So system services have become a relatively hidden self-startup mode. For example, Slammer Killer uses system services to self-start the virus program.
There are many tools for adding system services now. The most typical one is netservice. But what we are talking about here is adding system services manually, so the use of tools is not within the scope of this article: Many things in WINDOWS are closely related to the registry, and system services are no exception. System services are related to the following several registry items:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services
We can completely find the key values of the services registered in the system services and follow suit: Add a new item in any of the above registry columns. The name is the name of the system service you want to add, such as Backdoor. Under BACKDOOR, create a new string. The value name Displayname and the value data are the name of the service to be added, Backdoor. The following table is listed, which will be more intuitive:
Name Type Data Remarks
Displayname REG_SZ Name of the service to be added Name of the service to be added
Description REG_SZ Description of the service Description of the service
ImagePath REG EXPAND SZ Path of the program
Start REG_DWORD 0,2,3,4 2 represents automatic startup, 3 represents manual startup of the service. 4 represents disabling the service, 0 represents the system for the underlying device driver (generally not needed for this)
ErrorControl REG_DWORD 1
Type REG_DWORD 10 or 20 Generally, application programs are 10, and others correspond to 20
ObjectName REG_SZ LocalSystem Display local login
Note: Under XP/2003, the REG EXPAND SZ type can be added completely manually, but under WIN2000, it cannot. So under WIN2000, we have to write a REG ourselves to directly register the system service, so that adding the system under WIN2000 can also be very easy - here we also need to pay attention that the value type of ImagePath in the registry file must be HEX (hexadecimal). We can use WINHEX to convert the absolute path of the program into hexadecimal, and each value is separated by a comma. For example, if my ImagePath key value is C:\winnt\nukegroup.exe, it should be converted to:
63,3A,5C,77,69,6E,6E,74,5C,6E,75,6B,65,2E,65,78,65
Open Notepad and type in the following content:
Windows Registry Editor Version 5.00
"Type"=dword:00000010
"Start"=dword:00000002
"ErrorControl"=dword:00000001
"ImagePath"=hex(2):63,3A,5C,77,69,6E,6E,74,5C,6E,75,6B,65,2E,65,78,65
"DisplayName"="SRVTEST"
"ObjectName"="LocalSystem"
"Description"="System service test"
Save the above information as addsrv.reg, and we can rely on the command to import the registry to achieve the purpose of adding the system service. We enter regedit /s addsrv.reg in the command console. When the machine restarts, this service is successfully added - but unfortunately: I encountered difficulties in the actual experiment, and the value of ImagePath is garbled.
I can't figure it out no matter how I think. Let's change the garbled code to the absolute path. If we directly write the REG information like this:
"ImagePath"=hex(2):C:\WINNT\NUKEGROUP.EXE
Other key values can be added, but this key value can't? Anyway, we can first add the garbled ImagePath, and then modify it to C:\winnt\nukegroup.exe. This is also possible.
The above is the method of manually adding system services in Windows 2000. The registry structure of Windows 98 is different, but Windows 98 can still realize adding system services through the registry, and it is even simpler.
Add a new string value under the item "HKLM/SOFTWARE/Microsoft/WindowsCurrentVersion/RunServices". For example, if the name of the program is "BACKDOOR", create a string value named "BACKDOOR", and then enter the complete path of the execution program in the data field.
Manually adding a system service is so simple, and manually deleting the system is also the same principle. It is realized through the registry, and I won't say more here. To facilitate readers to have an in-depth understanding of various aspects of system services, I recommend the following articles, hoping to be helpful:
http://www.microsoft.com/china/community/program/originalarticles/TechDoc/WinXPStart.mspx
http://sinbad.zhoubin.com/read.html?board=Win&num=89