---
title: "5. Initial enumeration"
date: 2024-09-01
draft: false
---

#### Key Data Points

|**Data Point**|**Description**|
|---|---|
|`AD Users`|We are trying to enumerate valid user accounts we can target for password spraying.|
|`AD Joined Computers`|Key Computers include 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 that can be a quick win. ( a.k.a an easy host to exploit and gain a foothold)|

---


### Identifying Hosts

First, let's take some time to listen to the network and see what's going on. We can use `Wireshark` and `TCPDump` to "put our ear to the wire" and see what hosts and types of network traffic we can capture. This is particularly helpful if the assessment approach is "black box." We notice some [ARP](https://en.wikipedia.org/wiki/Address_Resolution_Protocol) requests and replies, [MDNS](https://en.wikipedia.org/wiki/Multicast_DNS), and other basic [layer two](https://www.juniper.net/documentation/us/en/software/junos/multicast-l2/topics/topic-map/layer-2-understanding.html) packets (since we are on a switched network, we are limited to the current broadcast domain) some of which we can see below. This is a great start that gives us a few bits of information about the customer's network setup.
```shell-session
┌─[htb-student@ea-attack01]─[~]
└──╼ $sudo -E wireshark

11:28:20.487     Main Warn QStandardPaths: runtime directory '/run/user/1001' is not owned by UID 0, but a directory permissions 0700 owned by UID 1001 GID 1002
<SNIP>
```

https://linux.die.net/man/8/tcpdump
https://github.com/DanMcInerney/net-creds
https://www.netminer.com/en/product/netminer.php
Above are tools to network inspect without GUI access.

As a note for testing - It's always a good idea to save the PCAP data you capture. You can review it again later to look for more hints. 
Our first look at network traffic pointed us to a couple of hosts via `MDNS` and `ARP`. Now let's utilize a tool called `Responder` to analyze network traffic and determine if anything else in the domain pops up.

[Responder](https://github.com/lgandx/Responder-Windows) is a tool built to listen, analyze, and poison `LLMNR`, `NBT-NS`, and `MDNS` requests and responses. It has many more functions, but for now, all we are utilizing is the tool in its Analyze mode. This will passively listen to the network and not send any poisoned packets. We'll cover this tool more in-depth in later sections.

```bash
sudo responder -I ens224 -A 
```
We can identify some hosts using Responder in analysis mode and inspect some requests. 
Passive checks give us some hosts to look at. We can sweep those hosts with `fping`
`fping` has similar capability as ping but works round-robin and issues icmp requests asynchronously. Doesn't wait for a response before moving on. 

```bash
fping -asgq 172.16.5.0/23
```
`-a` alive 
`-s` print stats 
`-g` generate target list from a cidr range
`-q` don't show per-target results. 

With a list of live targets, we can enumerate those hosts further. We can determine what services each host is running and identify critical hosts- Domain controllers, web servers
```bash
 With our focus on AD, after doing a broad sweep, it would be wise of us to focus on standard protocols typically seen accompanying AD services, such as DNS, SMB, LDAP, and Kerberos name a few. Below is a quick example of a simple Nmap scan.

sudo nmap -v -A -iL hosts.txt -oN /home/htb-student/Documents/host-enum
```
`-A` aggressive scan options - most important is quick enum of wellknown ports to include web services, domain services etc. 
Be sure to use the `-oA` flag as a best practice when performing Nmap scans. This will ensure that we have our scan results in several formats for logging purposes and formats that can be manipulated and fed into other tools.
Also, be aware of what nmap scripts are actually being run. Some scripted scans run active vuln checks against a host that could cause system instability or send it offline. 
- EX: Running a large discovery scan against a network with devices such as sensors or logic controllers could potentially overload them and disrupt the customer's industrial equipment causing a loss of product or capability. Take the time to understand the scans you run. 

## Identifying users in AD pre-exploitation 
We need to find a way to establish a foothold:
- Cleartext creds
- NTLM pw hashes
- SYS shell on domain-joined host 
- Shell in domain user context 
Obtaining creds is critical in early stages of a pentest. 

KERBRUTE 
[Kerbrute](https://github.com/ropnop/kerbrute) can be a stealthier option for domain account enumeration. It takes advantage of the fact that Kerberos pre-authentication failures often will not trigger logs or alerts. We will use Kerbrute in conjunction with the `jsmith.txt` or `jsmith2.txt` user lists from [Insidetrust](https://github.com/insidetrust/statistically-likely-usernames).

Insidetrust repo contains many different user lists that can be extremely useful attempting to enumerate users from unauth perspective. 
Point kerbrute at the DC we found earlier and feed it a wordlist. 

https://github.com/ropnop/kerbrute/releases/latest
```bash
 sudo git clone https://github.com/ropnop/kerbrute.git
 make help 
 (make help will show compiling options available when building binaries from source)
```
after compilation we can move it into our path

```bash
echo $PATH
sudo mv kerbrute_linux_amd64 /usr/local/bin/kerbrute
```

now run kerbrute
```bash
kerbrute userenum -d INLANEFREIGHT.LOCAL --dc 172.16.5.5 jsmith.txt -o valid_ad_users
```
