设为主页 | 加入收藏 | 繁體中文

浅谈NT的ACL,令牌,权限与安全性问题


  SeSynchAgentPrivilege
  Synchronize directory service data
  Allows a process to provide directory synchronization services. This privilege is relevant only on domain controllers.
  By default, this privilege is assigned to Administrators and LocalSystem accounts on domain controllers.
  SeTakeOwnershipPrivilege
  Take ownership of files or other objects
  Allows a user to take ownership of any securable object in the system, including Active Directory objects, files and folders, printers, registry keys, processes, and threads.
  By default, this privilege is assigned to Administrators.
  二.一些安全题目
  1.利用备份权限绕过拜访控制
  体系备份员(Backup Operators)和办理员(Administrator)具有一项权限:SeBackupPrivilege
  利用该权限可以拜访正常情况下被拒绝拜访的文件。当在ACL中设置拒绝某帐号读取文件时,一个备份程序可以在挪用Createprocess时,通过设置FILE_FLAG_BACKUP_SEMANTICS的标记来对文件举行读取。
  按照《writng secure code》一书给出的代码如下
  1. 假定你具有SeBackupPrivilege权限。
  2. 创立一个txt文件,内容为:writings this for cj
  3. 添加一个全部拒绝该用户拜访的ACE。
  现在,试着打开该文件,将会出现拒绝拜访的提示。现在,编译下面这段代码(来自《writng secure code》)
  /*
  WOWAccess.cpp
  */
  #include
  #include
  int EnablePriv (char *szPriv) {
  HANDLE hToken = 0;
  if (!OpenProcessToken(GetCurrentProcess(),
  TOKEN_ADJUST_PRIVILEGES,
  &hToken)) {
  printf(\\\"OpenProcessToken() failed -> %d\\\", GetLastError());
  return -1;
  }
  --------------------------------------------------------------------------------
  TOKEN_PRIVILEGES newPrivs;
  if (!LookupPrivilegeValue (NULL, szPriv,
  &newPrivs.Privileges[0].Luid)) {
  printf(\\\"LookupPrivilegeValue() failed -> %d\\\", GetLastError());
  CloseHandle (hToken);
  return -1;
  }
  newPrivs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
  newPrivs.PrivilegeCount = 1;
  if (!AdjustTokenPrivileges(hToken, FALSE, &newPrivs, 0, NULL, NULL)) {
  printf(\\\"AdjustTokenPrivileges() failed -> %d\\\", GetLastError());
  CloseHandle (hToken);
  return -1;
  }
  CloseHandle (hToken);
  return 0;
  }
  void DoIt(char *szFileName, DWORD dwFlags) {
  printf(\\\"\\\\n\\\\nAttempting to read %s, with 0x%x flags\\\\n\\\",
  szFileName, dwFlags);
  HANDLE hFile = CreateFile(szFileName,
  GENERIC_READ, FILE_SHARE_READ,
  NULL, OPEN_EXISTING,
  dwFlags,
  NULL);
  if (hFile == INVALID_HANDLE_VALUE) {
  printf(\\\"CreateFile() failed -> %d\\\", GetLastError());
  return;
  }
  char buff[128];
  DWORD cbRead=0, cbBuff = sizeof buff;
  ZeroMemory(buff, sizeof buff);
  if (ReadFile(hFile, buff, cbBuff, &cbRead, NULL)) {
  printf(\\\"Success, read %d bytes\\\\n\\\\nText is: %s\\\",
  cbRead, buff);
  } else {
  printf(\\\"ReadFile() failed -> %d\\\", GetLastError());
  }
  CloseHandle(hFile);
  }
  void main(int argc, char* argv[]) {
  if (argc < 2) {
  printf(\\\"Usage: %s \\\", argv[0]);
  return;
  }
  // Need to enable backup priv first.
  if (EnablePriv(SE_BACKUP_NAME) == -1)
  return;
  // Try with no backup flag - should get access denied.
  DoIt(argv[1], FILE_ATTRIBUTE_NORMAL);
  // Try with backup flag - should work!
  DoIt(argv[1], FILE_ATTRIBUTE_NORMAL │ FILE_FLAG_BACKUP_SEMANTICS);
  }
  运转情况如下
  C:\\\\>bkp
  Usage: bkp
  C:\\\\>bkp test.txt
  Attempting to read test.txt, with 0x80 flags
  CreateFile() failed -> 5
  Attempting to read test.txt, with 0x2000080 flags
  Success, read 20 bytes
  Text is: writings this for cj
  C:\\\\>
  如上,使用了备份的标记后(with 0x2000080 flags)就可以拜访开端拒绝拜访的文件了。
  2.利用SeTakeOwnershipPrivilege权限绕过拜访控制
  在我的盘算机上,tt是一个平凡的user帐号,当给他添加上SeTakeOwnershipPrivilege后,就可以绕过原来的拜访控制,好比,对system32目录下就可以添加完全控制的ACE,从而可以任意复制文件。对Document and Settings目录下也可以如法炮制,那么,给办理员下个套便是很简略的事变了。下面是实现历程
  首先看下tt所具有的权限
  C:\\\\>whoami /all
  [User] = \\\"DARKDEAMON\\\\tt\\\" S-1-5-21-1409082233-1957994488-472307971-1013
  [Group 1] = \\\"DARKDEAMON\\\\None\\\" S-1-5-21-1409082233-1957994488-472307971-513
  [Group 2] = \\\"Everyone\\\" S-1-1-0
  [Group 3] = \\\"BUILTIN\\\\Users\\\" S-1-5-32-545
  [Group 4] = \\\"NT AUTHORITY\\\\INTERACTIVE\\\" S-1-5-4
  [Group 5] = \\\"NT AUTHORITY\\\\Authenticated Users\\\" S-1-5-11
  [Group 6] = \\\"LOCAL\\\" S-1-2-0
  (O) SeCreatePagefilePrivilege =
  (O) SeAssignPrimaryTokenPrivilege =
  (O) SeCreateTokenPrivilege =
  (O) SeAuditPrivilege =
  (X) SeUndockPrivilege =
  (O) SeTakeOwnershipPrivilege =
  (X) SeChangeNotifyPrivilege =
  C:\\\\>
  可以看到曾经添加了SeTakeOwnershipPrivilege权限,下面,将演示如何取得对system32目录的完全控制
  这是修改前的效果.
  下面我们来更改目录的全部者以失掉完全控制.
  现在可以看到更改全部者曾经激活,所以我们只需要更改全部者就可以取得完全控制了。而在这个权限添加曩昔是无法举行这项操作的。
  3.利用SeDebugPrivilege权限来做好事
  这个权限是极为危险的。它容许用户通过调试进程来拜访机密数据。典型的例子便是findpass。利用SeDebugPrivilege调试winlogon进程来获得明文存储在里面的域名和密码。
  另一个典型的例子便是LSADUMP2,通过使用CreateRemoteThread函数来在LSASS.EXE进程中读取曾经经过LSA解密的私无数据代码,从而查看LSA中存储的机密信息。
  4.更进一步
  办理员(Administrator)默认具有16个权限
  SeChangeNotifyPrivilege
  SeSecurityPrivilege
  SeBackupPrivilege
  SeRestorePrivilege
  SeSystemtimePrivilege
  SeShutdownPrivilege
  SeRemoteShutdownPrivilege
  SeTakeOwnershipPrivilege
  SeDebugPrivilege
  SeSystemEnvironmentPrivilege
  SeSystemProfilePrivilege
  SeProfileSingleProcessPrivilege
  SeIncreaseBasePriorityPrivilege
  但是,SeTcbPrivilege和SeCreateTokenPrivilege两个权限办理员缺省是没有的. SeTcbPrivilege是具有操作体系的一部门来事变的权限,,SeCreateTokenPrivilege更为任意令牌创立权限!拥有了这两个权限,用Lu0的话来说,便是可以超越administrator!
  从而提出另一种克隆办理员帐号的途径:克隆办理员的权限,甚至包罗SeTcbPrivilege和SeCreateTokenPrivilege两个权限!
  在这里使用到RESOURCE KIT中的一个东西:ntrights.exe
  通过这个东西可以给指定帐号和组添加权限。
  下面是ntrights.exe的说明
  ntrights {-r Right │ +r Right} -u UserOrGroup [-m \\\\\\\\Computer] [-e Entry] [-?]
  Where:
  -r Right
  revokes Right from specified user or group. For a full list, see Windows 2000 Rights.
  +r Right
  grants Right to specified user or group. For a full list, see Windows 2000 Rights.
  -u UserOrGroup
  specifies the user or group for whom rights are to be granted or revoked.
  -m \\\\\\\\Computer
  specifies the computer (machine) on which to perform the operation. The default is the local computer.
  -e Entry
  adds a text string Entry to the computer\\\'s event log.
  -?
  displays a syntax screen at the command prompt.
  下面是使用实例,
  C:\\\\>ntrights +r SeDebugPrivilege -u tt
  Granting SeDebugPrivilege to tt ... successful
  C:\\\\>
  这样就乐成给tt添加了SeDebugPrivilege的权限,其他权限也可以照样添加。如果是去除权限,则只需把+r变成-r就可以了。
  这样就实现了另一种意义上的克隆帐号,不过这样失掉权限后仍旧不克不及启动服务或添加帐号,好比net user ttt /add时产生拒绝错误,不晓得这条下令是否会检查以后用户的SID,所以孕育产生失败,还请妙手指示。
  三.后记
  罗嗦写了这么多,是出于学习的目标,用wawa的话来说便是在写的历程中获益不少。由于水平无限,内容难免有错误之处,还请妙手指正。
  相干东西下载:
  whoami: http://www.3389.net/download/whoami.exe
  xcacls: http://www.3389.net/download/xcacl.exe
  bkp: http://www.3389.net/download/bkp.exe
  ntrights: http://www.3389.net/download/ntrights.exe
  findpass: http://www.3389.net/download/findpass.zip
  lsadump2: http://www.3389.net/download/lsadump2.zip
 


    文章作者: 福州军威计算机技术有限公司
    军威网络是福州最专业的电脑维修公司,专业承接福州电脑维修、上门维修、IT外包、企业电脑包年维护、局域网网络布线、网吧承包等相关维修服务。
    版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出处 、作者信息和声明。否则将追究法律责任。

TAG:
评论加载中...
内容:
评论者: 验证码: