Web scanning represents one of the core constructs of modern pen testing. Quite simply, most of what we interact with on a daily basis is the internet, and therein there is a multitude of ever-widening number of vulnerabilities. Within this room, we will investigate two of the most common scanners: Nikto and Zap. – tryhackme
Kicking off the Nikto section of the room, I need to clear a little bit of confusion I ran across, and that will help you going forward. The room says all you need for this is the help menu and that is true. My mind interpreted that as looking at Nikto’s manual page.
Nikto’s manual page does not include many of the options the help page does. We can reach the help page with the command:
The -H is important, as we will see in the first task.
#1 First and foremost, what switch do we use to set the target host?
The expected answer format is two characters in length. Here’s a little confusion that I was unable to clear up: Nowhere in the nikto manual or help page does it say that ‘-h’ lets you specify the target host. Both the manual and help page show this for host:
Host(s) to target. Can be an IP address, hostname or text file of hosts. A single dash (-) maybe used for stdin. Can also parse nmap -oG style output
But alas, if you use the option -h <Target_IP> it works, so there’s that.
#2 Websites don’t always properly redirect to their secure transport port and can sometimes have different issues depending on the manner in which they are scanned. How do we disable secure transport?
Let’s look at the help page and look for anything that is related to secure transport. I assume secure transport means transport layer security, which would be TLS or SSL.
The only option that relates is -nossl.
#3 How about the opposite, how do we force secure transport?
Only test SSL on the ports specified. Using this option will dramatically speed up requests to HTTPS ports, since otherwise the HTTP request will have to timeout first.
The opposite option would be -ssl
#4 What if we want to set a specific port to scan?
TCP port(s) to target. To test more than one port on the same host, specify the list of ports in the -p (-port) option. Ports can be specified as a range (i.e., 80-90), or as a comma-delimited list, (i.e., 80,88,90). If not specified, port 80 is used.
Unlike the host option, this one says we can use -p to specify the port.
#5 As the web is constantly evolving, so is Nikto. A database of vulnerabilities represents a core component to this web scanner, how do we verify that this database is working and free from error?
The relevant option in the help page is -dbcheck.
-dbcheckCheck the scan databases for syntax errors.
#6 If instructed to, Nitko will attempt to guess and test both files within directories as well as usernames. Which switch and numerical value do we use to set Nikto to enumerate usernames in Apache? Keep in mind, this option is deprecated in favor of plugins, however, it’s still a great option to be aware of for situational usage.
The related option in the help page is -mutate.
-mutateSpecify mutation technique. A mutation will cause Nikto to combine tests or attempt to guess values. These techniques may cause a tremendous amount of tests to be launched against the target. Use the reference number to specify the type, multiple may be used:
1 – Test all files with all root directories
2 – Guess for password file names
3 – Enumerate user names via Apache (/~user type requests)
4 – Enumerate user names via cgiwrap (/cgi-bin/cgiwrap/~user type requests)
5 – Attempt to brute force sub-domain names, assume that the host name is the parent domain
6 – Attempt to guess directory names from the supplied dictionary file
And the option for guessing/testing usernames for Apache servers is 3.
Therefore, the command is -mutate 3.
#7 Suppose we know the username and password for a web forum, how do we set Nikto to do a credentialed check? Suppose the username is admin and the password is PrettyAwesomePassword1234
The related option is -id.
ID and password to use for host Basic host authentication. Format is “id:password”.
Matching the format, the answer is -id admin:PrettyAwesomePassword1234.
#8 Let’s scan our target machine, what web server do we discover and what version is it?
From task #1, we know how to use nikto. Lets specify our target host with -h and then the target IP address.
nikto -h <target_ip>
Running this command results in the following information:
The web server is Apache/2.4.7.
#9 This box is vulnerable to very poor directory control due to it’s web server version, what directory is indexed that really shouldn’t be?
From the above results, we can see:
OSVDB-3268: /config/: Directory indexing found.
Nikto found the config directory.
#10 Nikto scans can take a while to fully complete, which switch do we set in order to limit the scan to end at a certain time?
This is the question that threw off my mojo. I was cruising through this room when all of a sudden, I couldn’t find anything relevant on the man page!
After slapping my head against the wall and maybe a meditation session, I decided to check the help page. Turns out the help page is HUGE and includes many more options than the man page. WTF.
-untilRun until the specified time or duration, then pause.
The answer is -until.
#11 But wait, there’s more! How do we list all of the plugins are available?
In the help page, there is an option called -list-plugins.
-list-pluginsWill list all plugins that Nikto can run against targets and then will exit without performing a scan. These can be tuned for a session using the
#12 On the flip-side of the database, plugins represent another core component to Nikto. Which switch do we use to instruct Nikto to use plugin checks to find out of date software on the target host? Keep in mind that when testing this command we need to specify the host we intend to run this against. For submitting your answer, use only the base command with the out of date option.
For this task, we need to run the -list-plugins option. This results in a long list of plugins; too long to list here.
The plugins are not sorted in alphabetical order, so I needed to use grep to find it.
nikto -list-plugins | grep outdated
The answer is outdated.
#13 Finally, what if we’d like to use our plugins to run a series of standard tests against the target host?
There is a plugin called test; we can find it with same method from task #12
To use a plugin, there is a -Plugin option, and we can specify the test plugin.
The answer is the option: -Plugin test
We just finished the first half of the room! Let’s check out the next tool, OWASP ZAP.
The OWASP Zed Attack Proxy (ZAP) is an easy to use integrated penetration testing tool for finding vulnerabilities in web applications.
So, the Kali Linux page for zaproxy (package name) says that it is included in Kali. But I used Tryhackme’s virtual Kali machine and it was not included in the software list.
I installed ZAP by visiting https://www.zaproxy.org/download/ and following their install directions for whatever operating system you are on. They support Windows, Linux, and MacOS.
#1 Let’s start simple and launch zap. This can be done in a number of ways (Commands: owasp-zap, zaproxy) or through launching it in the Kali gui.
After I installed ZAP, I can run it from the command line or find it in my list of installed programs.
#2 Launch ZAP, what option to we set in order to specify what we are attacking?
When ZAP starts, we are met with a welcome screen. The first option, and the answer is
URL to attack
#3 Launch the attack against our target! Throughout the course of this attack you may notice this is very similar to Nikto. Similar to Nessus vs. OpenVAS, Nikto and ZAP and both offer different perspectives on a host and, as such, it’s useful to know how to leverage both scanning tools in order to maximize your own visibility in a situation wherein ‘noise’ doesn’t particularly matter.
Click attack and examine the output!
#4 ZAP will discover a file that typically contains pages which well-behaved web indexing engines will read in order to know which sections of a site to avoid. What is the name of this file? (Lucky for us, our scanner isn’t what we would call ‘well-behaved’!)
The lower section of the window has a bunch of tabs. The Spider tab shows a list of URIs that presumably returned an OK http response. This means that the URIs are all valid and we can visit them.
From that list, we can see a “robots.txt” file.
#5 One entry is included in the disallow section of this file, what is it?
Lets navigate to /robots.txt and see what is in it.
The entry in the disallow section is: /, the root folder
#6 ZAP will find a directory that contains images for our application, what is the path for that directory? (This is what will follows the name/ip of the website)
From the URIs column in the Spider tab, we can see image files in the directory /dvwa/images/.
#7 This website doesn’t force a secure connection by default and ZAP isn’t pleased with it. Which related cookie is ZAP upset about?
This one also threw off my mojo. I assumed the question was asking for the name of a cookie, right?
Which related cookie is ZAP upset about?
I found two named cookies: “PHPSESSID”, and “security”. Neither of those worked, and “security” even matches the expected answer format.
Well, the question was asking about the HttpOnly flag. PHPSESSID does not have the HttpOnly flag set.
#8 Featured in various rooms on TryHackMe, Cross-Site Scripting is a vicious attack that is becoming ever more common on the open web. What Alert does ZAP produce to let us know that this site is vulnerable to XSS? Note, there are often a couple warnings produced for this, look for one more so directly related to the web client.
The relevant alert is Web Browser XSS Protection Not Enabled.
#9 The ZAP proxy spider represents the component responsible for ‘crawling’ the site. What site is found to be out of scope?
We have already seen this, and the URI out of scope is the one that does not share the same IP address as the web app. This would be http://www.dvwa.co.uk.
#10 ZAP will use primarily two methods in order to scan a website, which of these two HTTP methods requests content?
This is pretty common knowledge. An http GET method requests content.
#11 Which option attempts to submit content to the website?
Again, one of the most basic http fundamentals, a POST request submits content to the website.
Woohoo! End of the room! I learned quite a bit and will now use Nikto to help scan a server for vulnerabilities. ZAP provides so much information, its kind of overwhelming. I will continue to learn about these two tools and will update the blog when I do!