Labanswers
Labanswers
Objectives
Passive reconnaissance is a method of information gathering in which the tools do
not interact directly with the target device or network. In this lab, you will explore
common tools used to gather information about a target through the Domain Name
System (DNS).
Background / Scenario
Before beginning any penetration test or other ethical hacking engagement, you
need to covertly obtain as much information about the target organization as
possible. There is a wealth of information that can be obtained from publicly
available domain registration data. In this lab, you will investigate the output of
the nslookup, whois, and dig commands.
Required Resources
Kali VM customized for Ethical Hacker course
Internet access
Instructions
Part 1: Use nslookup to Obtain Domain and IP
Address Information.
Step 1: Log into Kali Linux and access the terminal environment.
a. Log into the Kali system with the username kali and the password kali. You
are presented with the Kali desktop.
b. Open a terminal window by clicking on the Terminal icon located near the top
of the screen.
Nslookup is a command line tool that is available in Linux and Windows. Its basic
usage is to convert a domain name to an IP address. Nslookup has other
functionality that can provide additional information.
a. Access the manual pages for nslookup using the man command:
┌──(kali㉿Kali)-[~]
└─$ man nslookup
b. To review the manual pages, press the spacebar to advance the pages.
When you are finished reviewing the manual pages, press q to quit and return
to the command line.
Which set keyword would you use to query for the mail server mx record within a
domain?
Answer Area
set querytype=mx or set type=mx
Hide Answer
> cisco.com
The output of the command will be similar to that shown. The A record contains
the IPv4 address assigned to the root domain and the AAAA record contains
the IPv6 address.
┌──(kali㉿Kali)-[~]
└─$ nslookup
> cisco.com
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
Name: cisco.com
Address: 72.163.4.185
Name: cisco.com
Address: 2001:420:1101:1::185
>
c. To find the domain name servers configured for cisco.com, use the set
type command to change the query type to “ns” to return the name server
information.
> set type=ns
> cisco.com
The output of the command should be similar to that shown below. The servers
are listed by fully qualified domain name and are further listed as authoritative
servers for both IPv4 and IPv6 addresses.
Non-authoritative answer:
cisco.com nameserver = ns1.cisco.com.
cisco.com nameserver = ns3.cisco.com.
cisco.com nameserver = ns2.cisco.com.
Answer Area
The IPv4 address is 72.163.5.201 and the IPv6 address is 2001:420:1101:6::a
Hide Answer
d. Enter exit to leave interactive mode and return to the CLI prompt.
a. In this query, use the one-line nslookup command syntax to change the
server to look up skillsforall.com. The syntax for the command is nslookup
[hostname] [server IP].
┌──(kali㉿Kali)-[~]
└─$ nslookup skillsforall.com 8.8.8.8
In interactive mode, you change the server using the server keyword.
┌──(kali㉿Kali)-[~]
└─$ nslookup
> server 8.8.8.8
> skillsforall.com
b. The any query type can retrieve much, or all, of the information contained in
the DNS record for a host name. Often text records that can provide
additional details about the domain are contained in DNS records. Using the
8.8.8.8 Google DNS server, find the DNS records for skillsforall.com.
┌──(kali㉿Kali)-[~]
└─$ nslookup
> server 8.8.8.8
> set type=any
> skillsforall.com
┌──(kali㉿Kali)-[~]
└─$ nslookup
> server 8.8.8.8
Default server: 8.8.8.8
Address: 8.8.8.8#53
> set type=any
> skillsforall.com
;; Connection to 8.8.8.8#53(8.8.8.8) for skillsforall.com
failed: timed out.
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: skillsforall.com
Address: 13.225.142.127
Name: skillsforall.com
Address: 13.225.142.7
Name: skillsforall.com
Address: 13.225.142.73
Name: skillsforall.com
Address: 13.225.142.9
skillsforall.com nameserver = ns-1130.awsdns-
13.org.
skillsforall.com nameserver = ns-1652.awsdns-
14.co.uk.
skillsforall.com nameserver = ns-489.awsdns-61.com.
skillsforall.com nameserver = ns-588.awsdns-09.net.
skillsforall.com
origin = ns-1130.awsdns-13.org
mail addr = awsdns-hostmaster.amazon.com
serial = 1
refresh = 7200
retry = 900
expire = 1209600
minimum = 86400
skillsforall.com mail exchanger = 10 inbound-
smtp.us-east-1.amazonaws.com.
skillsforall.com text =
"d1g1l9y74sxj8m.cloudfront.net"
skillsforall.com text = "facebook-domain-
verification=8cg08gu4eikp0d2d1quqhjwh5ti1vv"
skillsforall.com text = "google-site-
verification=Q5NIWRygJYTSLxuHReNKw1kvgC8IXKTOyPf5zITDv40"
skillsforall.com text =
"identrust_validate=tadDBgWwQAKpw6QCCQDCagqsZgxHELybnPOCQH
NU+rsV"
What record types are displayed in the output of the nslookup command with the
type set to any?
Answer Area
All permitted record types, including A, AAAA, ns, mx, and text.
Hide Answer
The whois tool queries domain registration information, rather than the DNS server
records. It is another form of passive reconnaissance that can identify where the
domain is registered, technical and administrative contact information, and physical
locations. Be aware that information contained in domain registrations can be set to
private and often the contact information is that of the hosting service, rather than the
organization itself.
a. The whois tool is available from the CLI prompt ion Kali Linux. Use
the whois command to obtain information about cisco.com.
┌──(kali㉿Kali)-[~]
└─$ whois cisco.com
b. Now use the whois command to obtain information about the skillsforall.com
domain.
What conclusion can you make about the two domains (cisco.com and
skillsforall.com) based on the output of the whois commands?
Answer Area
Both domains are owned by Cisco and hosted in the cloud.
Hide Answer
Step 2: Use whois to determine IP address registration information.
The whois tool can also be used to gather information about IP address ranges that
are assigned to an organization. In the previous part of this lab, we discovered the IP
addresses assigned to various domain DNS server host names. Now you can use
that address information to obtain additional details about the external IP address
ranges that are assigned to those organizations.
a. Review the output you obtained from using nslookup to obtain the DNS
server IP addresses for cisco.com. Record the IP addresses of the Cisco DNS
servers.
b. Use the Whois tool to find what IP address ranges are assigned to Cisco and
are used on the networks hosting their DNS servers. At the time of this lab,
ns1.cisco.com resolved to the IP address 72.163.5.201, however this may
vary. At the prompt, enter whois 72.163.5.201.
┌──(kali㉿Kali)-[~]
└─$ whois 72.163.5.201
#
# ARIN WHOIS data and services are subject to the Terms of
Use
# available at:
https://www.arin.net/resources/registry/whois/tou/
#
# If you see inaccuracies in the results, please report at
#
https://www.arin.net/resources/registry/whois/inaccuracy_r
eporting/
#
# Copyright 1997-2023, American Registry for Internet
Numbers, Ltd.
#
OrgTechHandle: CAMT-ARIN
OrgTechName: Cisco address management team
<output omitted>
What is the IP address range for the IPv4 addresses allocated to Cisco? The
ns1.cisco.com server is addressed within this block.
Answer Area
72.163.0.0 – 72.163.255.255 or 172.163.0.0/16
Hide Answer
c. Because organizations may use the same IP networks for other externally
facing servers, knowing the address ranges is valuable for determining which
networks to target during a penetration test. Use the whois tool to obtain the
IP address allocations for the IP networks where the other Cisco DNS servers
are located.
a. Dig is a Linux function that performs DNS queries. The format of a Dig query
is similar to that of Nslookup. To resolve the hostname cisco.com to an IP
address, use the syntax dig [hostname].
┌──(kali㉿Kali)-[~]
└─$ dig cisco.com
What is the difference between the default record types queried by Dig and those
queried by Nslookup?
Answer Area
Dig queries only the A record type and Nslookup queries both the A and AAAA
records.
Hide Answer
b. To obtain the IPv6 address of cisco.com it is necessary to add a type to the
command structure. The syntax to instruct Dig to query a specific record type
is dig [hostname] [record type].
┌──(kali㉿Kali)-[~]
└─$ dig cisco.com AAAA
a. In the earlier part of this lab, nslookup was used to obtain the DNS servers for
cisco.com. Use the 8.8.8.8 Google DNS server to query for the DNS server
records. The syntax to use a dig command to perform a query using a
different DNS server is dig [hostname] @[DNS server IP] [type]. At the
prompt, enter dig cisco.com 8.8.8.8 ns.
┌──(kali㉿Kali)-[~]
└─$ dig cisco.com 8.8.8.8 ns
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;cisco.com. IN NS
;; ANSWER SECTION:
cisco.com. 1493 IN NS
ns3.cisco.com.
cisco.com. 1493 IN NS
ns1.cisco.com.
cisco.com. 1493 IN NS
ns2.cisco.com.
b. Earlier, nslookup was used with the set type=any option to find additional
information about the skillsforall.com hostname. The any record type can also
be queried using Dig.
┌──(kali㉿Kali)-[~]
└─$ dig skillsforall.com any
Compare the output of the Dig function with the output of Nslookup for
the any record type. Which output is easier to read to obtain the values contained in
the various record types?
Answer Area
The dig output displays the records in a tabular format grouped by type.
Hide Answer
Now that you can perform DNS lookups and use Whois to determine IP address
ranges, use Dig to find additional host names. Reverse DNS (rDNS) lookups use the
IP address to query for the host names of the services that resolve to that address.
a. Enter the dig command using the -x option to retrieve the hostname and
record type of the ns1.cisco.com DNS server (72.163.5.201).
┌──(kali㉿Kali)-[~]
└─$ dig -x 72.163.5.201
What type of record is returned with the host name?
Answer Area
A pointer record (PTR) is returned with the hostname.
Hide Answer
b. Use the dig -x command to query for another IP address in the same subnet.
┌──(kali㉿Kali)-[~]
└─$ dig -x 72.163.1.1
Examine the output returned from the dig command. What type of device do you
think is assigned the 72.163.1.1 address?
Answer Area
Because the host is named hsrp-72-163-1-1, it is probably the default gateway
address assigned to an HSRP router configuration.
Hide Answer
The Host utility is a function in Linux that performs lookups to convert IP addresses
to host names. Use this utility to find another host on the 72.163.0.0/16 network.
a. The syntax of the host command is host [ip address or hostname]
┌──(kali㉿Kali)-[~]
└─$ host 72.163.10.1
b. Host can also be used to perform a quick IP address lookup for a known
hostname.
┌──(kali㉿Kali)-[~]
└─$ host hsrp-72-163-10-1.cisco.com
How does the output of the host command differ from Dig or Nslookup when
querying for an IP address assigned to a known host?
Answer Area
The host output only contains the IP address, not the DNS server or other
information.
Hide Answer
c. URLs often contain aliases for the host name of the server hosting the
website. The output of the host command can list the servers that respond to
that URL.
┌──(kali㉿Kali)-[~]
└─$ host hsrp-72-163-10-1.cisco.com
The information about aliases is useful when trying to determine where the
actual website or service is located.
Nslookup is used primarily to perform IP address lookups for known host names. It
can also be used to perform rDNS lookups to return a host name assigned to a
known IP address.
┌──(kali㉿Kali)-[~]
└─$ nslookup 72.163.5.201
To use interactive mode, enter nslookup with no options. At the > prompt, enter the
target IP address.
┌──(kali㉿Kali)-[~]
└─$ nslookup
> 72.163.5.201
Reflection
In this lab, you used nslookup, dig, and host to obtain information from DNS zone
files. Which tool would you use to begin a passive reconnaissance effort against a
targeted domain? Why?
Answer Area
Answers will vary.