设为首页 收藏本站
查看: 1013|回复: 0

[经验分享] windows中的服务隔离 service isolation and service SID(Virtual Account)

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-8-26 10:47:09 | 显示全部楼层 |阅读模式
                      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 服务进行查询。
   wKioL1e-WbyTFOLnAAAOceOZ9yo810.jpg
  
  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>
   wKiom1e-Wb3BgvDjAAAkvbkU4n4019.jpg
  
  然后我们看看wsearch 的执行账号配置为本地系统账号
   wKioL1e-Wb6z-Y_yAAAnFgrt9t8956.jpg
  那这个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.microsof ... um-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 ... -can-i-set-service-
  https://blogs.technet.microsoft. ... 22/per-service-sid/
  https://support.microsoft.com/en-us/kb/2620201
  http://thoughtsonopsmgr.blogspot ... un-as-accounts.html
                   


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-263309-1-1.html 上篇帖子: Microsoft Operations Management Suite 配置网络性能监视 下篇帖子: 为什么我的电脑打开软件所有的软件图标都变成图片查看模式 显示Windows无法打开 因为
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表