windows 中的服务隔离在windows vista 以及server 2008之后就有了,可以让管理员控制本地资源的使用(如文件、注册表等等)。之前windows版本中,系统内置了一些高权限的服务账号,大家所熟悉的有Local System,Network,LocalService

为了最小化权限使用,通常我们需要创建账号来赋予最小权限,然后配置服务以这个账号运行,但是如果服务较多,那么有许许多多的账号要维护,而且如果你有严格的密码策略的话,比如定期要更改服务账号的密码,那真是头疼。

window 中的Service SID(另外一个称呼是Virutal Account) 可以针对每个服务启用,它可以让管理员针对Service SID来隔离服务使用的资源。同时不必维护服务账号的密码。Service SID 账号访问网络资源是使用的凭据是计算机账号,DomainName\ComputerName$.

创建Service ID 可以使用

sc sidtype <service_name> unrestricted

sc sidtype <service_name> restricted

当然也可以使用sc qsidtype <serviec_name>来查询Service SID ,我这里针对微软的SCOM Agent health service 服务进行查询。

sidtype 有三种

  • None (0x0) – the service will not have a per-service SID.  服务默认设置为none
  • Unrestricted (0x1) – the service has a per-service SID  服务有一个service SID
  • Restricted (0x3) – the service has a per-service SID and a write-restricted token.服务有一个Service SID,同时加上了写保护 标签。

当服务配置使用Service SID时(无论restricted 或unrestricted) ,Service SID是一串SHA1 Hash.如果想看这个SID的具体值,可以使用

sc showsid <servicename>

然后我们看看wsearch 的执行账号配置为本地系统账号

那这个Service SID起了什么作用呢,拿SQL Server为例,SQL Server 2008 r2 之前的版本会默认让local system 账号放在数据库sysadmin 中,但是sql server 2012 之后就不放了,那么之前如果你有个服务运行在local system 账号,比如我们的SCOM监控服务访问SQL应该是没有权限问题的,但是在sql server 2012 上,你可能需要额外设置,因为这个时候会没有权限。这个时候我假设你给SCOM监控客户端服务启用了Service SID ,那么会在healthservice的服务进程上就会增加 nt service\healthservice 的令牌,这个时候如果你单独在SQL中创建nt service\healthservice 的登录,并赋予相应权限,那么这个healthservice 虽然是运行在local system 账号,但是他却能访问sql了。然后你可能还有另外的其他服务B也是以local system 账号运行,但是这个sql 的权限却只给了healthservice 服务,这个服务B却不能访问SQL。(之前在没有Service SID 的时候,你可能一股脑把权限开给了local system ,然后所有使用local system 登陆的服务都有了访问SQL 的权限)。

那么这个Service SID的实战作用在哪里呢?这就是这篇文章的终极目的。如果你用SCOM 监控SQL,那么更高版本的SQL Server的执行账号管理的问题,你可能已经很头痛了。使用service SID 可以轻松解决这个问题,然后还有个人专门另外创建了管理包,可以监视有SQL Server的机器上的healthservice 的Service SID有没有开启,然后可以用恢复任务来开启(这个恢复任务默认是禁用的)。然后还可以监控healthservice 的SID账号有没有数据库的权限。参考这个链接:

https://gallery.technet.microsoft.com/SQL-Server-RunAs-Addendum-0c183c32#content

windows内置系统账号权限及作用参考:

  • LocalService account (preferred)

    • Name: NT AUTHORITY\LocalService
    • the account has no password (any password information you provide is ignored)
    • HKCU represents the LocalService user account
    • has minimal privileges on the local computer
    • presents anonymous credentials on the network
    • SID: S-1-5-19
    • has its own profile under the HKEY_USERS registry key (HKEY_USERS\S-1-5-19)

    A limited service account that is very similar to Network Service and meant to run standard least-privileged services. However, unlike Network Service it has no ability to access the network as the machine accesses the network as an Anonymous user.

  • NetworkService account

    • NT AUTHORITY\NetworkService
    • the account has no password (any password information you provide is ignored)
    • HKCU represents the NetworkService user account
    • has minimal privileges on the local computer
    • presents the computer's credentials (e.g. MANGO$) to remote servers
    • SID: S-1-5-20
    • has its own profile under the HKEY_USERS registry key (HKEY_USERS\S-1-5-20)
    • If trying to schedule a task using it, enter NETWORK SERVICE into the Select User or Groupdialog

    Limited service account that is meant to run standard least-privileged services. This account is far more limited than Local System (or even Administrator) but still has the right to access the network as the machine (see caveat above).

  • LocalSystem account (dangerous, don't use!)

    • Name: .\LocalSystem (can also use LocalSystem or ComputerName\LocalSystem)
    • the account has no password (any password information you provide is ignored)
    • SID: S-1-5-18
    • does not have any profile of its own (HKCU represents the default user)
    • has extensive privileges on the local computer
    • presents the computer's credentials (e.g. MANGO$) to remote servers

http://windowsitpro.com/security/q-how-can-security-windows-service-benefit-service-isolation-feature-how-can-i-set-service-

https://blogs.technet.microsoft.com/voy/2007/03/22/per-service-sid/

https://support.microsoft.com/en-us/kb/2620201

http://thoughtsonopsmgr.blogspot.com/2014/09/sql-mp-challenge-run-as-accounts.html

版权声明:原创作品,如需转载,请注明出处。否则将追究法律责任
本文转自 yoke88 51CTO博客,原文链接:http://blog.51cto.com/yoke88/1842327

windows中的服务隔离 service isolation and service SID(Virtual Account)相关推荐

  1. 看懂架构设计中的服务隔离

    前言 我们在做系统架构设计的时候,经常离不开的一个话题就是进行服务的隔离设计. 那什么是「服务隔离」呢? 顾名思义,它是指将系统按照一定的原则划分为若干个服务模块,各个模块之间相对独立,无强依赖.当有 ...

  2. Confluence 6 Windows 中以服务方式自动重启的原因

    2019独角兽企业重金招聘Python工程师标准>>> 针对长时间使用的 Confluence,我们推荐你配置 Confluence 自动随操作系统重启而启动.针对一些 Window ...

  3. Confluence 6 Windows 中以服务方式自动重启修改运行服务的用户

    2019独角兽企业重金招聘Python工程师标准>>> 基于安全的考虑,如果你希望你的 Confluence 不是在系统中以管理员的身份运行或者你使用网络驱动器来存储备份,附件和索引 ...

  4. Windows中Java服务怎么打开防火墙

    1.问题 使用部署工具winsw启动注册服务,启动服务正常,设置监听端口号为8766 使用netstat查看端口占用情况 我本机使用127.0.0.0::8766/xxxx 和 localhost:8 ...

  5. windows中Oracle服务连接不上错误排查及解决方法-实用

    windows下Oracle连接不上问题排查思路 外部连接工具plsql,Navicat无法访问oracle数据库服务的排查思路 查看所访问oracle服务的所在服务器能否ping通,oracle服务 ...

  6. windows中mysql服务无法启动

    可能原因: 1.mysql服务中,my.ini 文件中的 配置有问题 自行查看my.ini文件中配置与实际的配置或配置路径出现不一致 2.端口占用 打开cmd,输入 netstat -ano | fi ...

  7. 如何删除windows中的服务

    办法一: 用sc.exe这个Windows命令       开始--运行--cmd.exe,然后输入sc就可以看到了.使用办法很简单: sc delete "服务名" 方法二:直接 ...

  8. Windows 系统第三方服务开发者可以借助 WSH (Windows Service Hardening) 机制提高安全性

    Windows服务帐户是特权升级的首选攻击面之一,如果你能够盗用此类帐户,则获得最高特权非常容易,这主要是由于操作系统默认将强大的模拟特权授予服务. 即使Microsoft引入了WSH(Windows ...

  9. 怎样用sc命令运行服务器,windows中的sc控制服务命令

    SC的语法 SC [Servername] command Servicename [Optionname= Optionvalues] Servername 远程服务器名称,可选,使用双斜线如\\1 ...

最新文章

  1. 电路交换-报文交换-分组交换- 分组交换包括:虚电路和数据报
  2. 拼多多暴跌的原因找到了
  3. Windows10——荣耀笔记本任务栏图标显示异常且无显示/隐藏图标的箭头解决方案
  4. java akka_Akka系列(九):Akka分布式之Akka Remote
  5. Git commit your changes or stash them before you can merge
  6. 你和985硕博研究生,差了这些东西
  7. LeetCode 528. 按权重随机选择(前缀和+二分查找)
  8. 用git提交代码到远程仓库遇到的问题
  9. jquery-入门-基本使用-选择器-转移
  10. Portal-Basic Java Web应用开发框架V3.0正式发布(源码、实例及文档)
  11. Jupyter notebook基础教程(启动,汉化,操作)
  12. PPT扩展展示时,PPT展示界面背景色有时候突然变成黑底?如何解决?
  13. http 响应消息解码_响应生成所需的解码策略
  14. 最小二乘支持向量机(基于MATLAB)
  15. win10系统魔兽世界无法连接服务器地址,win10玩魔兽世界启动失败怎么办?请看过来...
  16. 网站域名被拦截,网站被流量劫持,服务器攻击,网站被跨区恶意点击,问题的定义与解答
  17. 上传遥感图像在地图上自动加载到地图上
  18. 技术贴 - 收藏集 - 掘金
  19. Ocata Neutron代码分析(一)——Neutron API启动过程分析
  20. 20220906美的集团笔试

热门文章

  1. Elasticsearch OOM(内存溢出)
  2. Ubuntu 18.04 rc.local systemd设置
  3. 用脚本实现FTP的上传和下载
  4. 对于(不是特别不合理)的指摘、的对应方式(学会调整,不要一根筋)
  5. 【Hive】Hive的数据类型
  6. Error, some other host already uses address 192.168.0.202错误解决方法
  7. Vmware由于centos升级内核不可运行(C header files matching your running kernel were not found)的解决方案
  8. 亚马逊的PuTTY连接AWS出现network error connection refused,终极解决方案。
  9. service docker start后docker stop/waiting的解决方法
  10. FutureTask的get()方法之异常处理