Ravindra BagaleCourses & study guides मराठी Track your progress

38. Active Directory Attacks and Defence

38.3 Enumeration of AD

Foothold nantar (lab user password tumhi set kela) attacker directory map karto – users, groups, computers, sessions, ACLs.

NetExec (nxc) LDAP / SMB – modern Swiss army (lab):

# After you created lab user shahrukh (password YOU set) – lab only
nxc ldap 192.168.56.30 -u shahrukh -p 'YourLabPass!' --users
nxc smb 192.168.56.30 -u shahrukh -p 'YourLabPass!' --shares

Impacket basics (Kali often has impacket-* scripts):

# List domain users via LDAP-oriented helper (lab creds only)
GetADUsers.py sahyadri.lab/shahrukh:'YourLabPass!'@192.168.56.30 -all
# Secrets on DC need DA-level rights – do NOT run secretsdump until YOUR lab DA lab step
# secretsdump.py is Chapter theme in 38.5 – only on systems you own

BloodHound collectors: SharpHound (Windows) / bloodhound-python (from Kali) collect relationships into a zip for neo4j UI. Concept: who can admin what, who has sessions where. Run collectors only in lab with lab creds.

Defence: monitor LDAP enumeration patterns; protect privileged groups; no unnecessary nested groups; LAPS for local admin; tiering. Samjla ka?

Red team (attacker) does Blue team (defender) detects / stops
nxc ldap / GetADUsers.py / BloodHound collect after any valid user Alert on mass LDAP queries; UEBA; restrict who can read sensitive attributes
Looks for Domain Admins, AdminSDHolder, SPN accounts Privileged group change auditing (4728/4732); periodic BloodHound as Blue
Enumerates shares for creds files Share auditing; block plaintext password files; DLP

Ravindra Bagale's Tip

Students see the BloodHound GUI and say "hacked". Collection is just the map; the path still has to be abused. The Blue team also uses BloodHound to reduce paths – that is interview gold. The tool is not for attackers only.

Lab

Lab user ne nxc ldap 192.168.56.30 -u shahrukh -p '...' --users chalaa. User count note kara. Mag bloodhound-python / SharpHound lab DC/client against collect (docs on Kali). Import zip → find shortest path from shahrukh to Domain Admins (path nahi asel tar changla!). Screenshot.

Real incident: NotPetya lateral era (2017)

NotPetya (reported widely by national CERTs and major outlets) spread inside networks using stolen credentials and SMB-based lateral movement patterns after initial foothold – identity and file-share trust became the highway. Defence theme: credential hygiene, SMB hardening, segmentation, rapid isolation. Source: national CERT advisories and contemporary major news analyses (verify).

Extended teaching notes

Why this lesson matters

Enumeration maps what a network exposes. Defenders use the same ideas to close shares, fix SNMP community strings, restrict LDAP binds and stop zone transfers.

Hardening related services

[('SSH', 'Key auth, no root login, Fail2ban or equivalent, SG limited to your IP/VPN.', '', ''), ('SMB / NFS / LDAP / SNMP', 'Do not expose to the internet; patch; strong auth; disable unused versions (e.g. SMBv1).', '', ''), ('SMTP', 'Authenticated relay only; SPF/DKIM/DMARC for your domains.', '', ''), ('DNS', 'Restrict zone transfers; monitor for unexpected records (crt.sh for certs).', '', ''), ('Firewalls', 'Host firewall + cloud SG/NSG; default deny; document every allow.', '', '')]

Lab rule

Run enumeration only against host-only lab VMs you own. Then write the defensive fix for each open service you found.

Mini case study

Suppose we are on a purple-team exercise for an Indian mid-size company (sample data). Red notes a technique from this lesson against a lab clone. Blue must show the control that stops it, the log that would have fired, and the ticket that hardens production. That is the standard this course trains you for.

Defender's worksheet (do this today)

  1. Write the lesson title, date and the exact lab target you are allowed to use.
  2. List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
  3. Run one safe check from the lesson on a lab system only. Paste the command and output.
  4. Write a two-sentence fix you would give a teammate.
  5. Name one related public advisory (CERT-In, CISA, NVD, or a vendor bulletin) with its date.

Indian workplace (sample data)

Suppose we are a junior analyst at Infosys, TCS, Wipro or a fintech SOC in Bengaluru/Pune. Turn this lesson into one checklist item with an owner, a due date and a place to store evidence (ticket + screenshot).

Global practice

Compare your notes with OWASP, CIS Benchmarks, NIST CSF/IR guidance or a cloud Well-Architected security question. Write five lines on what overlaps.

Everyday analogy

Explain the risk and the fix to a family member without jargon. If they can repeat the warning, you understand it well enough to teach juniors.

Key terms

  • Control: a safeguard (patch, config, process, detection).
  • Finding: a weakness backed by evidence.
  • Remediation: the fix plus how you verified it.
  • Scope: systems you have written permission to touch.
  • Least privilege: only the access the task needs.
  • Defence in depth: several layers so one failure does not end the story.

Common mistakes

  • Skipping written permission "just for a quick scan".
  • Practising on hostel, office or public targets without authorisation.
  • Collecting tool output without writing the fix.
  • Copying attack steps onto production to "verify". Defenders verify with versions, configs and patches.
  • Publishing screenshots that contain secrets, cookies or internal hostnames.

Recap

  • Evidence, fix, owner, date.
  • Own lab only.
  • Fix > spectacle.