gpt4 book ai didi

c++ - 如何注册 Windows 服务但避免它被列在服务控制台中?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:55:04 25 4
gpt4 key购买 nike

我知道一个合法的 Windows 应用程序,一个家长控制软件,作为服务安装,但该服务未列在服务列表中,您在 services.msc 中看到的列表。

虽然它在任务管理器中列出,但不在服务器列表中。

我知道它是一个服务器,因为它与所有其他服务位于注册表部分,但是,services.msc 控制台不会列出它。

我研究了好几天都没有答案。

我发现了这个类似的问题,但在答案中他们推荐了复杂的路线,比如编写设备驱动程序: How to hide windows service from task manager in windows desktop

但是,这些人通过服务成功了。他们是怎么做到的?

这是注册表项:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\ThatTrickySoftwareSrv]
"Type"=dword:00000010
"Start"=dword:00000002
"ErrorControl"=dword:00000001
"ImagePath"=hex(2):22,00
"DisplayName"="Some display name"
"ObjectName"="LocalSystem"
"Description"="Some description"
"FailureActions"=hex:00,00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\ThatTrickySoftwareSrv\Security]
"Security"=hex:01,00

为了便于阅读,一些二进制内容被截断了。

这是在 Windows 7 32 位上。

遵循 Harry Jonhston 的建议:

**sc sdshow "ThatTrickySoftware"**
D:(D;;DCLCWPDTSD;;;IU)(D;;DCLCWPDTSD;;;SU)(D;;DCLCWPDTSD;;;BA)(A;;CCLCSWLOCRRC;;
;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRC
WDWO;;;BA)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)

所以,好吧,我想这是意料之中的,虽然它没有被列为服务,但它作为服务运行,因为它是由 Windows 自动启动的,但没有任何迹象表明 Windows 可能在任何地方运行这个应用程序。

此外,请注意,可执行文件列在 TaskManager 的“进程”选项卡中,但是,它是牢不可破的,我无法终止它,如果我尝试终止该进程,它什么也不会发生.

最佳答案

好的,我可以重现此行为:通过为服务提供与神秘服务相同的权限,我可以使其从 services.msc 的列表中消失。

sc sdset myservice D:(D;;DCLCWPDTSD;;;IU)(D;;DCLCWPDTSD;;;SU)(D;;DCLCWPDTSD;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)

所以这一切都取决于权限。

好的,让我们扩展该安全描述符字符串。这有点棘手,因为 SDDL 权限和等效安全管理器权限之间的映射似乎没有在 MSDN 或 SDK header 中得到很好的记录;幸运的是,Wayne Martin 已经为我们完成了繁重的工作并将结果发布在博客条目中 Service Control Manager Security for non-admins .

D: - this part is the DACL, the permissions on the service.

拒绝条目总是排在第一位,这也意味着它们优先于允许条目:

(D;;DCLCWPDTSD;;;IU) - deny (D) interactive users (IU) the following rights:
DC - SERVICE_CHANGE_CONFIG (the right to change the service configuration)
LC - SERVICE_QUERY_STATUS (the right to query the service status)
WP - SERVICE_STOP (the right to stop the service)
DT - SERVICE_PAUSE_CONTINUE (the right to pause and continue the service)
SD - DELETE (the right to delete the service)
(D;;DCLCWPDTSD;;;SU) - deny services (SU) the same set of rights as above
(D;;DCLCWPDTSD;;;BA) - deny the Administrators group (BA) the same as above

允许条目与默认权限相同。 (它们的顺序不同,但允许条目的顺序并不重要。)

(A;;CCLCSWLOCRRC;;;IU) - allow the interactive user the following rights:
CC - SERVICE_QUERY_CONFIG (the right to query the service configuration)
LC - overridden by the deny entry
SW - SERVICE_ENUMERATE_DEPENDENTS (the right to see service dependencies)
LO - SERVICE_INTERROGATE (the right to send SERVICE_CONTROL_INTERROGATE)
CR - SERVICE_USER_DEFINED_CONTROL (the right to send a user defined control)
RC - READ_CONTROL (the right to see the permissions)
(A;;CCLCSWLOCRRC;;;SU) - allow services the following rights:
same as for the interactive user
(A;;CCLCSWRPWPDTLOCRRC;;;SY) - allow local system the following rights:
same as for the interactive user, plus:
RP - SERVICE_START (the right to start the service)
WP - overridden by the deny entry for BA
DT - overridden by the deny entry for BA
(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA) - allow the Administrators group:
same as for local system, plus:
DC - overridden by the deny entry
LC - overridden by the deny entry
SW - overridden by the deny entry
SD - overridden by the deny entry
WD - WRITE_DAC (permission to change the permissions)
WO - WRITE_OWNER (permission to take ownership)

最后,我们有了 SACL。这也与服务的默认值相同。

S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)
S: - indicates that this is a SACL
AU - indicates that this is an audit entry
FA - indicates that failed attempts to access the object should be audited
WD - controls whose failed attempts should be audited; the Everyone SID
CCDCLCSWRPWPDTLOCRSDRCWDWO - the kinds of access attempts to audit
- appears to include every right that applies to services

所以基本上就是说“审核所有失败的访问此服务的尝试”。

应该可以显着简化这些权限,例如,通过删除所有被拒绝权限覆盖的允许权限。事实上,您真正需要的唯一访问权限似乎是本地系统的 SERVICE_START 和 SERVICE_QUERY 权限,甚至可能不是那些。 :-)

另一方面,权限的复杂性并不重要,因此可能不值得为测试更改而付出努力。


PS:要恢复默认权限你可以说:

sc sdset myservice D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)

关于c++ - 如何注册 Windows 服务但避免它被列在服务控制台中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25736268/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com