Domain information is a core component of any penetration test, and it is not just about the subdomains but about the entire presence on the Internet.
When enumerating passively, the first thing you should do is scrutinize the company's main website - Read through texts, keeping in mind what technologies and structures are needed for these services.
IT companies may offer app dev, iot, hosting, datascience, it security svcs, depending on industry. If there's a service that sticks out, it makes sense to figure out what activities it consists of and what opportunities that opens for you as the tester.
IE - First and second principle of enumeration - What do you see, and what do you not see? We see services, but not their functionality. But services are bound to certain technical aspects necessary to provide a service. Therefore, take a dev's view - Look at the whole thing from their POV.
The first point of presence on the Internet may be the SSL certificate from the company's main website that we can examine.
Certificates often include more than just subdomains.
tool - crt.sh to check Certificate Transparency logs. CT is a process intended to verify issued digital certs for encrypted internet connections - Intended to enable detection of false/malicious certificates for a domain. SSL cert providers like Let's Encrypt share this with crt.sh, which stores new entries in a DB.
Interesting usage of crt.sh:
stejwes@htb[/htb]$ curl -s https://crt.sh/\?q\=inlanefreight.com\&output\=json | jq . | grep name | cut -d":" -f2 | grep -v "CN=" | cut -d'"' -f2 | awk '{gsub(/\\n/,"\n");}1;' | sort -u
account.ttn.inlanefreight.com
blog.inlanefreight.com
bots.inlanefreight.com
console.ttn.inlanefreight.com
ct.inlanefreight.com
data.ttn.inlanefreight.com
*.inlanefreight.com
inlanefreight.com
[...]
This may give us a list of sites outside of scope, so you will need to cross-reference these with domains within the scope of engagement.
stejwes@htb[/htb]$ for i in $(cat subdomainlist);do host $i | grep "has address" | grep inlanefreight.com | cut -d" " -f1,4;done
blog.inlanefreight.com 10.129.24.93
inlanefreight.com 10.129.27.33
matomo.inlanefreight.com 10.129.127.22
[...]
Once we see which hosts can be investigated further, we can generate a list of IP addresses with a minor adjustment to the cut command and run them through Shodan.
Shodan can be used to find devices and systems permanently connected to the Internet like Internet of Things (IoT). It searches the Internet for open TCP/IP ports and filters the systems according to specific terms and criteria. For example, open HTTP or HTTPS ports and other server ports for FTP, SSH, SNMP, Telnet, RTSP, or SIP are searched. As a result, we can find devices and systems, such as surveillance cameras, servers, smart home systems, industrial controllers, traffic lights and traffic controllers, and various network components.
Shodan filtering reference:
stejwes@htb[/htb]$ for i in $(cat subdomainlist);do host $i | grep "has address" | grep inlanefreight.com | cut -d" " -f4 >> ip-addresses.txt;done
stejwes@htb[/htb]$ for i in $(cat ip-addresses.txt);do shodan host $i;done
DNS Records
stejwes@htb[/htb]$ dig any inlanefreight.com
Let us look at what we have learned here and come back to our principles. We see an IP record, some mail servers, some DNS servers, TXT records, and an SOA record.
- `A` records: We recognize the IP addresses that point to a specific (sub)domain through the A record. Here we only see one that we already know.
- `MX` records: The mail server records show us which mail server is responsible for managing the emails for the company. Since this is handled by google in our case, we should note this and skip it for now.
- `NS` records: These kinds of records show which name servers are used to resolve the FQDN to IP addresses. Most hosting providers use their own name servers, making it easier to identify the hosting provider.
- **`NS`** stands for **Name Server**. An `NS` record is a type of DNS (Domain Name System) record that specifies the authoritative name servers for a domain.
- A nameserver, also known as a DNS server, is a specialized server on the internet that handles the domain name system (DNS) queries. Its primary role is to translate human-readable domain names (like [www.example.com](http://www.example.com)) into machine-readable IP addresses (like 192.0.2.1).
- `TXT` records: this type of record often contains verification keys for different third-party providers and other security aspects of DNS, such as [SPF](https://datatracker.ietf.org/docs/html/rfc7208), [DMARC](https://datatracker.ietf.org/docs/html/rfc7489), and [DKIM](https://datatracker.ietf.org/docs/html/rfc6376), which are responsible for verifying and confirming the origin of the emails sent. Here we can already see some valuable information if we look closer at the results.