Initial Enumeration of the Domain

Setting Up

Ta sẽ bắt đầu trên một máy chủ cho phép tấn công mà ta được truy cập vào vùng mạng của nó. Đây cũng là cách phổ biến mà khách hàng có thể chọn foothold cho việc pentest. Danh sách các setting up mà khách hàng có thể chọn:

  • Một máy ảo (thường là linux) được đặt trong cơ sở hạ tầng nội bộ mà ta có thể jump host qua VPN và SSH vào.

  • Một thiết bị vật lý được cắm vào cổng ethernet qua VPN và ta có thể SSH vào.

  • Có thể đến onsite trực tiếp tại văn phòng và cắm cổng ethernet vào laptop của mình.

  • Một máy ảo Linux trong Azure hoặc AWS có quyền truy cập vào mạng internal mà ta có thể SSH sử dụng xác thực public key và IP được whitelist.

  • Khách hàng cung cấp cấu hình VPN (bị hạn chế bởi nhiều yếu tố kể đến như Zero-Trust).

  • Trên workstation được quản lý (thường là Windows), ngồi trong văn phòng của khách hàng với quyền truy cập internet hạn chế, cũng có thể chọn tùy chọn này nhưng cung cấp cho mình quyền truy cập internet đầy đủ, quản trị đặc biệt và đưa vào chế độ theo dõi manual.

  • Trên VDI (virtual desktop) được truy cập bằng VMWare Horizon hoặc tương tự, với một trong các cấu hình được mô tả giống workstation được quản lý thường có thể truy cập qua VPN từ xa.

Trên đây là một số cách thức phổ biến nhất mặc dù khách hàng có thể nghĩ ra một số biến thể khác, chỉ cung cấp cho chúng ta một danh sách các địa chỉ IP trong phạm vi mạng CIDR internal.

⇒ Kiểu pentest blackbox này rất thường gặp tại Việt Nam.

Tasks

  • Enum được network internal, xác định được các hosts, các dịch vụ quan trọng và các foothold.

  • Tận dụng các máy chủ và lỗ hổng để tiếp tục truy cập

  • Ghi lại bất kì phát hiện nào. Cực kì quan trọng!

Chúng ta sẽ bắt đầu từ một máy Linux mà không cần thông tin đăng nhập người dùng domain nào.

Nhiều tổ chức sẽ muốn xem bạn có thể làm gì từ blind perspective, chẳng hạn như thế này, trước khi cung cấp cho bạn thêm thông tin cho bài test. Nó cung cấp một cái nhìn thực tế hơn hướng đi mà attacker sẽ sử dụng khi xâm nhập vào domain.

Nó có thể giúp họ xem attacker có thể làm gì nếu họ truy cập trái phép qua internet (phishing), truy cập wireless từ bên ngoài (nếu wireless kết nối tới AD) hoặc thậm chí là lừa đảo một nhân viên. Tùy thuộc vào mức độ thành công của giai đoạn này, khách hàng có thể cung cấp cho chúng ta quyền truy cập vào máy chủ tham gia miền hoặc một bộ thông tin đăng nhập cho mạng để đẩy nhanh quá trình này.

Key Data Points

Data Point

Description

AD Users

Enum các user account hợp lệ mà có thể spray passwords

AD Joined Computers

Key Computers bao gồm Domain Controllers, file servers, SQL servers, web servers, Exchange mail servers, database servers, etc.

Key Services

Kerberos, NetBIOS, LDAP, DNS

Vulnerable Hosts and Services

Anything (có thể đặt làm foothold)

Identifying Hosts

Đầu tiên rất quan trọng ta cần listen network xem có packet hay traffic nào đang trao đổi trong mạng thông qua thiết bị này không:

Wireshark:

sudo -E wireshark

Tcpdump:

sudo tcpdump -i <network interface>

Responder:

sudo responder -I <network interface> -A

FPing Active Checks:

fping -asgq <CIDR subnet>

Nmap Scanning:

sudo nmap -v -A -iL hosts.txt -oN /path/to/output.txt
Nmap scan report for inlanefreight.local (172.16.5.5)
Host is up (0.069s latency).
Not shown: 987 closed tcp ports (conn-refused)
PORT     STATE SERVICE       VERSION
53/tcp   open  domain        Simple DNS Plus
88/tcp   open  kerberos-sec  Microsoft Windows Kerberos (server time: 2022-04-04 15:12:06Z)
135/tcp  open  msrpc         Microsoft Windows RPC
139/tcp  open  netbios-ssn   Microsoft Windows netbios-ssn
389/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: INLANEFREIGHT.LOCAL0., Site: Default-First-Site-Name)
|_ssl-date: 2022-04-04T15:12:53+00:00; -1s from scanner time.
| ssl-cert: Subject:
| Subject Alternative Name: DNS:ACADEMY-EA-DC01.INLANEFREIGHT.LOCAL
| Issuer: commonName=INLANEFREIGHT-CA
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2022-03-30T22:40:24
| Not valid after:  2023-03-30T22:40:24
| MD5:   3a09 d87a 9ccb 5498 2533 e339 ebe3 443f
|_SHA-1: 9731 d8ec b219 4301 c231 793e f913 6868 d39f 7920
445/tcp  open  microsoft-ds?
464/tcp  open  kpasswd5?
593/tcp  open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
636/tcp  open  ssl/ldap      Microsoft Windows Active Directory LDAP (Domain: INLANEFREIGHT.LOCAL0., Site: Default-First-Site-Name)
<SNIP>  
3268/tcp open  ldap          Microsoft Windows Active Directory LDAP (Domain: INLANEFREIGHT.LOCAL0., Site: Default-First-Site-Name)
3269/tcp open  ssl/ldap      Microsoft Windows Active Directory LDAP (Domain: INLANEFREIGHT.LOCAL0., Site: Default-First-Site-Name)
3389/tcp open  ms-wbt-server Microsoft Terminal Services
| rdp-ntlm-info:
|   Target_Name: INLANEFREIGHT
|   NetBIOS_Domain_Name: INLANEFREIGHT
|   NetBIOS_Computer_Name: ACADEMY-EA-DC01
|   DNS_Domain_Name: INLANEFREIGHT.LOCAL
|   DNS_Computer_Name: ACADEMY-EA-DC01.INLANEFREIGHT.LOCAL
|   DNS_Tree_Name: INLANEFREIGHT.LOCAL
|   Product_Version: 10.0.17763
|_  System_Time: 2022-04-04T15:12:45+00:00
<SNIP>
5357/tcp open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-title: Service Unavailable
|_http-server-header: Microsoft-HTTPAPI/2.0
Service Info: Host: ACADEMY-EA-DC01; OS: Windows; CPE: cpe:/o:microsoft:windows
$> nmap -A 172.16.5.100

Starting Nmap 7.92 ( https://nmap.org ) at 2022-04-08 13:42 EDT
Nmap scan report for 172.16.5.100
Host is up (0.071s latency).
Not shown: 989 closed tcp ports (conn-refused)
PORT      STATE SERVICE      VERSION
80/tcp    open  http         Microsoft IIS httpd 7.5
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: Microsoft-IIS/7.5
| http-methods: 
|_  Potentially risky methods: TRACE
135/tcp   open  msrpc        Microsoft Windows RPC
139/tcp   open  netbios-ssn  Microsoft Windows netbios-ssn
443/tcp   open  https?
445/tcp   open  microsoft-ds Windows Server 2008 R2 Standard 7600 microsoft-ds
1433/tcp  open  ms-sql-s     Microsoft SQL Server 2008 R2 10.50.1600.00; RTM
| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback
| Not valid before: 2022-04-08T17:38:25
|_Not valid after:  2052-04-08T17:38:25
|_ssl-date: 2022-04-08T17:43:53+00:00; 0s from scanner time.
| ms-sql-ntlm-info: 
|   Target_Name: INLANEFREIGHT
|   NetBIOS_Domain_Name: INLANEFREIGHT
|   NetBIOS_Computer_Name: ACADEMY-EA-CTX1
|   DNS_Domain_Name: INLANEFREIGHT.LOCAL
|   DNS_Computer_Name: ACADEMY-EA-CTX1.INLANEFREIGHT.LOCAL
|_  Product_Version: 6.1.7600
Host script results:
| smb2-security-mode: 
|   2.1: 
|_    Message signing enabled but not required
| ms-sql-info: 
|   172.16.5.100:1433: 
|     Version: 
|       name: Microsoft SQL Server 2008 R2 RTM
|       number: 10.50.1600.00
|       Product: Microsoft SQL Server 2008 R2
|       Service pack level: RTM
|       Post-SP patches applied: false
|_    TCP port: 1433
|_nbstat: NetBIOS name: ACADEMY-EA-CTX1, NetBIOS user: <unknown>, NetBIOS MAC: 00:50:56:b9:c7:1c (VMware)
| smb-os-discovery: 
|   OS: Windows Server 2008 R2 Standard 7600 (Windows Server 2008 R2 Standard 6.1)
|   OS CPE: cpe:/o:microsoft:windows_server_2008::-
|   Computer name: ACADEMY-EA-CTX1
|   NetBIOS computer name: ACADEMY-EA-CTX1\x00
|   Domain name: INLANEFREIGHT.LOCAL
|   Forest name: INLANEFREIGHT.LOCAL
|   FQDN: ACADEMY-EA-CTX1.INLANEFREIGHT.LOCAL
|_  System time: 2022-04-08T10:43:48-07:00

<SNIP>

Identifying Users

Nếu khách hàng không cung cấp user để bắt đầu test (thường là vậy), mình sẽ cần tìm cách thiết lập một chỗ đứng trong tên miền bằng cách lấy thông tin xác thực cleartext hoặc hash password NTLM cho user, một shell SYSTEM trên một máy chủ join domain hoặc một shell trong user trong domain.

Việc có được một valid user có credential là rất quan trọng trong giai đoạn đầu của này. Quyền truy cập này (ngay cả ở cấp độ thấp nhất) mở ra nhiều cơ hội để thực hiện enum và attack

Kerbrute

Kerbrute là một công cụ khá là "stealth" trong việc enum user. Nó tận dựng thực tế các lỗi xác thực mà không lên cảnh báo. Mình sẽ sử dụng kerbrute kết hợp với userlist từ Insidetrust.

Download prebuild: https://github.com/ropnop/kerbrute/releases

$> ./kerbrute_linux_amd64 

    __             __               __     
   / /_____  _____/ /_  _______  __/ /____ 
  / //_/ _ \/ ___/ __ \/ ___/ / / / __/ _ \
 / ,< /  __/ /  / /_/ / /  / /_/ / /_/  __/
/_/|_|\___/_/  /_.___/_/   \__,_/\__/\___/                                        

Version: v1.0.3 (9dad6e1) - 10/20/25 - Ronnie Flathers @ropnop

This tool is designed to assist in quickly bruteforcing valid Active Directory accounts through Kerberos Pre-Authentication.
It is designed to be used on an internal Windows domain with access to one of the Domain Controllers.
Warning: failed Kerberos Pre-Auth counts as a failed login and WILL lock out accounts

Usage:
  kerbrute [command]

Available Commands:
  bruteforce    Bruteforce username:password combos, from a file or stdin
  bruteuser     Bruteforce a single user's password from a wordlist
  help          Help about any command
  passwordspray Test a single password against a list of users
  userenum      Enumerate valid domain usernames via Kerberos
  version       Display version info and quit

Flags:
      --dc string       The location of the Domain Controller (KDC) to target. If blank, will lookup via DNS
      --delay int       Delay in millisecond between each attempt. Will always use single thread if set
  -d, --domain string   The full domain to use (e.g. contoso.com)
  -h, --help            help for kerbrute
  -o, --output string   File to write logs to. Optional.
      --safe            Safe mode. Will abort if any user comes back as locked out. Default: FALSE
  -t, --threads int     Threads to use (default 10)
  -v, --verbose         Log failures and errors

Use "kerbrute [command] --help" for more information about a command.

Chuyển vào usr path:

sudo mv kerbrute_linux_amd64 /usr/local/bin/kerbrute
chmod +x /usr/local/bin/kerbrute
kerbrute userenum -d INLANEFREIGHT.LOCAL --dc 172.16.5.5 jsmith.txt -o valid_ad_users
$> kerbrute userenum -d INLANEFREIGHT.LOCAL --dc 172.16.5.5 jsmith.txt -o valid_ad_users

2021/11/17 23:01:46 >  Using KDC(s):
2021/11/17 23:01:46 >   172.16.5.5:88
2021/11/17 23:01:46 >  [+] VALID USERNAME:       [email protected]
2021/11/17 23:01:46 >  [+] VALID USERNAME:       [email protected]
2021/11/17 23:01:46 >  [+] VALID USERNAME:       [email protected]
2021/11/17 23:01:50 >  [+] VALID USERNAME:       [email protected]

 <SNIP>
 
2021/11/17 23:01:51 >  [+] VALID USERNAME:       [email protected]
2021/11/17 23:01:51 >  [+] VALID USERNAME:       [email protected]
2021/11/17 23:01:51 >  [+] VALID USERNAME:       [email protected]
2021/11/17 23:01:51 >  [+] VALID USERNAME:       [email protected]
2021/11/17 23:01:51 >  [+] VALID USERNAME:       [email protected]
2021/11/17 23:01:52 >  [+] VALID USERNAME:       [email protected]
2021/11/17 23:01:56 >  Done! Tested 48705 usernames (56 valid) in 9.940 seconds

Identifying Potential Vulnerabilities

Tài khoản local system NT AUTHORITY\SYSTEM là tài khoản built-in của hệ điều hành Windows. Đây là tài khoản chạy với quyền cao nhất trong hệ thống. Các service chạy với user này là rất phổ biến. Có quyền truy cập SYSTEM tương đương với việc có một tài khoản join domain.

Một số hướng có được truy cập SYSTEM-level access trong host:

  • Remote Windows exploits kiểu như MS08-067, EternalBlue, or BlueKeep.

  • Abuse service account có quyền SeImpersonate sử dụng Juicy Potato. Thường trên các OS Windows Server cũ.

  • Lỗ hổng LPE Windows.

  • Có quyền admin-access trên host join domain bằng local account để chạy Psexec.

Sau đó ta có thể thực hiện một số hành động như:

  • Enum domain bằng các offensive tools như: BloodHound hay PowerView.

  • Thực hiện Kerberoasting/ASREPRoasting.

  • Chạy các tools như Inveigh để thu thập Net-NTLMv2 hashes hoặc SMB relay attacks.

  • Hijack một token impersonation để chiến đoạt một user trong domain.

  • ACL attacks.

Question

From your scans, what is the "commonName" of host 172.16.5.5 ?

sudo nmap -A -v -Pn 172.16.5.5

What host is running "Microsoft SQL Server 2019 15.00.2000.00"? (IP address, not Resolved name)

sudo nmap -A -Pn -T5 -oG ./nmapOutput 172.16.5.0/23

Last updated