Hello everyone! In March, OTUS launches a new Kali Linux Workshop . In anticipation of the start of the course, we have prepared a translation of useful material for you. We also want to invite everyone to a free lesson on the topic: "Denial of Service attacks and defense against them . "
Before attacking any site, a hacker or pentester first draws up a list of goals. After he does a good reconnaissance and finds weaknesses for โaiming,โ he will need a web server scanning tool such as Nikto, which will help him find vulnerabilities โ potential attack vectors.Nikto is a simple open-source web server scanner that scans a website and reports vulnerabilities found that can be exploited or hacked. It is also one of the most widely used tools for scanning websites for vulnerabilities throughout the industry, and in many circles it is considered the industry standard.Despite the fact that this tool is extremely effective, it does not act covertly. Any site with an intrusion detection system or other security measures will understand that it is being scanned. Nikto was designed to test security, and no one thought about the secrecy of its work.How to use Nikto
If you simply run Nikto on the target website, you may not understand what to do with the information obtained after the scan. Nikto is actually more like a laser pointer, which entails a shot, and after a while you will see how it works.To start, let's talk about targets. The target can be almost any place where a hacker can strike, such as network printers or a web server. When we move on to using Nikto a bit later, we will need to provide it with one of three types of information: the IP address for the local service, the attack domain or the SSL / HTTPS website.Before you start scanning with Nikto, itโs best to conduct a preliminary exploration with an open tool like Maltego. Such tools can be useful in creating a profile and forming a more specific list of goals to focus on. Once you do this, you can use Nikto to search for potential vulnerabilities for targets from your list.If you are lucky, a vulnerability with a well-known exploit will be found, which means that there is already a tool that will help to exploit this weak point. Using an appropriate tool that automatically exploits the vulnerability, a hacker can gain access to the target to carry out any number of hidden attacks, such as, for example, adding malicious code.Step 1: Install Nikto
If you use Kali Linux, Nikto will be preinstalled, so you donโt have to download and install anything. It will be located in the Vulnerability Analysis category. If for some reason you donโt have it, you can download Nikto from its repository on GitHub or just use the command apt install
.apt install nikto
If you are using a Mac, you can use Homebrew to install Nikto.brew install nikto
Step 2: Get to Know Nikto
Before scanning web servers with Nikto, use the -Help parameter to see everything you can do with this tool:nikto -Help
Options:
-ask+ Whether to ask about submitting updates
yes Ask about each (default)
no Don't ask, don't send
auto Don't ask, just send
-Cgidirs+ Scan these CGI dirs: "none", "all", or values like "/cgi/ /cgi-a/"
-config+ Use this config file
-Display+ Turn on/off display outputs:
1 Show redirects
2 Show cookies received
3 Show all 200/OK responses
4 Show URLs which require authentication
D Debug output
E Display all HTTP errors
P Print progress to STDOUT
S Scrub output of IPs and hostnames
V Verbose output
-dbcheck Check database and other key files for syntax errors
-evasion+ Encoding technique:
1 Random URI encoding (non-UTF8)
2 Directory self-reference (/./)
3 Premature URL ending
4 Prepend long random string
5 Fake parameter
6 TAB as request spacer
7 Change the case of the URL
8 Use Windows directory separator (\)
A Use a carriage return (0x0d) as a request spacer
B Use binary value 0x0b as a request spacer
-Format+ Save file (-o) format:
csv Comma-separated-value
htm HTML Format
nbe Nessus NBE format
sql Generic SQL (see docs for schema)
txt Plain text
xml XML Format
(if not specified the format will be taken from the file extension passed to -output)
-Help Extended help information
-host+ Target host
-404code Ignore these HTTP codes as negative responses (always). Format is "302,301".
-404string Ignore this string in response body content as negative response (always). Can be a regular expression.
-id+ Host authentication to use, format is id:pass or id:pass:realm
-key+ Client certificate key file
-list-plugins List all available plugins, perform no testing
-maxtime+ Maximum testing time per host (e.g., 1h, 60m, 3600s)
-mutate+ Guess additional file names:
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
-mutate-options Provide information for mutates
-nointeractive Disables interactive features
-nolookup Disables DNS lookups
-nossl Disables the use of SSL
-no404 Disables nikto attempting to guess a 404 page
-Option Over-ride an option in nikto.conf, can be issued multiple times
-output+ Write output to this file ('.' for auto-name)
-Pause+ Pause between tests (seconds, integer or float)
-Plugins+ List of plugins to run (default: ALL)
-port+ Port to use (default 80)
-RSAcert+ Client certificate file
-root+ Prepend root value to all requests, format is /directory
-Save Save positive responses to this directory ('.' for auto-name)
-ssl Force ssl mode on port
-Tuning+ Scan tuning:
1 Interesting File / Seen in logs
2 Misconfiguration / Default File
3 Information Disclosure
4 Injection (XSS/Script/HTML)
5 Remote File Retrieval - Inside Web Root
6 Denial of Service
7 Remote File Retrieval - Server Wide
8 Command Execution / Remote Shell
9 SQL Injection
0 File Upload
a Authentication Bypass
b Software Identification
c Remote Source Inclusion
d WebService
e Administrative Console
x Reverse Tuning Options (i.e., include all except specified)
-timeout+ Timeout for requests (default 10 seconds)
-Userdbs Load only user databases, not the standard databases
all Disable standard dbs and load only user dbs
tests Disable only db_tests and load udb_tests
-useragent Over-rides the default useragent
-until Run until the specified time or duration
-update Update databases and plugins from CIRT.net
-useproxy Use the proxy defined in nikto.conf, or argument http://server:port
-Version Print plugin and database versions
-vhost+ Virtual host (for Host header)
+ requires a value
Step 3: Use the Basic Syntax
As you can see from the previous step, Nikto has many use cases, but for our purposes we will use the basic syntax <IP or hostname> with the actual IP address or host name without angle brackets.nikto -h <IP or hostname>
However, Nikto is able to scan SSL and port 443, which is used by HTTPS sites (HTTP uses port 80 by default). Thus, we are not limited only to crawling old sites, we can assess vulnerabilities of sites using SSL, which today is an almost mandatory requirement for indexing in search results.If we know that the target site has SSL, we can specify this in Nikto to save some time on crawling by adding -ssl to the end of the command.nikto -h <IP or hostname> -ssl
Step 4: Scan Sites with SSL
For example, let's start by scanning the site pbs.org
to see the types of information that Nikto crawls can provide. After it connects to port 443, we see some useful information about encryption and other details, such as, for example, that the server is running on nginx, but there is not much interesting for us here.nikto -h pbs.org -ssl
- Nikto v2.1.6
------------------------------------------------------------------------------
- STATUS: Starting up!
+ Target IP: 54.225.198.196
+ Target Hostname: pbs.org
+ Traget Port: 443
------------------------------------------------------------------------------
+ SSl Info: Subject: /CN=www.pbs.org
Altnames: account.pbs.org, admin.pgs.org, dipsy-tc.pbs.org, docs.pbs.org, ga.video.cdn.pbs.org, git.pbs.org, heart.ops.pbs.org, hub-dev.pbs.org, image.pbs.org,
jaws..pbs.org, kids.pbs.org, koth-qa.svp.pbs.org, login.pbs.org, ops.pbs.org, pbs.org, player.pbs.org, projects.pbs.org, sentry.pbs.org, teacherline.pbs.org,
urs.pbs.org, video.pbs.org, weta-qa.svp.pbs.org, whut-qa.svp.pbs.org, wnet.video-qa.pbs.org, wnet.video-staging.pbs.org, www-cache.pbs.org, www.pbs.org
Ciphers: ECDHE-RSA-AES128-GCM-SHA256
Issuer: /C-US/0=Let's Encrypt/CN=Let's Encrypt Authority X3
+ Start Time: 2018-12-05 23:34:06 (GMT-8)
------------------------------------------------------------------------------
+ Server: nginx
+ The anti-clickjacking X-Frame-Options header is not present.
+ The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS
+ Uncommon header 'x-pbs-fwsrvname' found, with contents: fwcacheproxy1
+ The site uses SSL and the Strict-Transport-Security HTTP header is not defined.
+ The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type
+ Root page / redirects to: https://www.pbs.org/
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ RC-1918 IP address found in the 'x-pbs-appsvrip' header: The IP is "10.137.181.52".
+ Uncommon header 'x-cache-fs-status' found, with contents: EXPIRED
+ Uncommon header 'x-pbs-appsvrname' found, with contents: fwcacheproxy1
+ Uncommon header 'x-pbs-appsvrip' found, with contents: 10.137.181.52
+ Server leaks inodes via ETags, header found with file /pbs.org.zip, fields: 0x5b96537e 0x1678
+ 7446 requests: 0 error(s) and 10 item(s) reported on remote host
+ End Time: 2018-12-06 00:30:29 (GMT-8) (3383 seconds)
------------------------------------------------------------------------------
+ 1 host(s) tested
Step 5: Scan IP Address
Now that we have done a quick scan of the website, we can try using Nikto on the local network to find embedded servers, such as the login page of the router or the HTTP service on another machine, which is simply a server without a website. To find out the IP address we will use ifconfig
.The IP address we need refers to inet. On it we can use ipcalc
in order to get the network range. If you do not have ipcalc, you can install it using the command apt install ipcalc
, and then try again. The range will be after "Network", in my case it is 192.168.0.0/24.ifconfig
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet 192.168.0.48 netmask 0xffffff00 broadcast 192.168.0.255
inet6 XXXX::XXX:XXXX:XXXX:XXXX%en0 prefixlen 64 secured scopeid 0x8
ether XX:XX:XX:XX:XX:XX txqueuelen 1000 (Ethernet)
inet6 XXXX::XXX:XXXX:XXXX:XXXX%en0 prefixlen 64 autoconf secured
inet6 XXXX::XXX:XXXX:XXXX:XXXX%en0 prefixlen 64 autoconf temporary
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
en2: flags=8863<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TS04,TS06>
ether XX:XX:XX:XX:XX:XX
media: autoselect <full-duplex>
status: inactive
Now we want to start Nmap to find services that work in this network range. Let's scan port 80 using our range, for this we will add -oG (grepable output) to get only those hosts that are up and running, that is, those that respond by saying that port 80 is open. Then we save all this to a file, which I will name nullbyte.txt
, you, in turn, can name it whatever you like.ipcalc 192.168.0.48
Address: 192.168.0.48 11000000.10101000.00000000. 00110000
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
=>
Network: 192.168.0.0/24 11000000.10101000.00000000. 00000000
HostMin: 192.168.0.1 11000000.10101000.00000000. 00000001
HostMax: 192.168.0.254 11000000.10101000.00000000. 11111110
Broadcast: 192.168.0.255 11000000.10101000.00000000. 11111111
Hosts/Net: 254 Class C, Private Internet
There is a small trick that will help send all hosts directly to Nikto for scanning. We use cat
to read the input stored in our document nullbyte.txt
(or as you called it yourself). After that, we use awk , a special tool in Linux that will help you find the next template, where Up means that the host is up, and print $ 2 means that you need to print the second word on each line, that is, only the IP address. Then, we will send the received data to a file called targetIP.txt
(or whatever you want).cat nullbyte.txt | awk '/Up$/{print $2}' | cat >> targetIP.txt
Now we can view the contents of our new file with cat to see all the IP addresses that have port 80 open.cat targetIP.txt
192.168.0.1
192.168.0.2
192.168.0.4
192.168.0.5
192.168.0.11
192.168.0.24
192.168.0.31
192.168.0.48
192.168.0.60
This format is ideal for Nikto, as it can easily interpret such files. Thus, we can send this output to Nikto with the following command.nikto -h targetIP.txt
The results will be similar to what we got when scanning with SSL.Step 6: Scan the HTTP Site
We scanned a secure website and IP address on the local network, now it is time to look for an insecure web domain that uses port 80. For this example, I am using afl.com.au , which did not have SSL at the time I was scanning this.nikto -h www.afl.com.au
- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP: 159.180.84.10
+ Target Hostname: www.afl.com.au
+ Target Port: 80
+ Start Time: 2018-12-05 21:48:32 (GMT-8)
---------------------------------------------------------------------------
+ Server: instart/nginx
+ Retried via header: 1.1 varnish (Varnish/6.1), 1.1 e9ba0a9a729ff2960a04323bf1833df8.cloudfront.net (CloudFront)
+ The anti-clickjacking X-Frame-Options header is not present.
+ The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS
+ Uncommon header 'x-cache' found, with contents: Miss from cloudfront
+ Uncommon header 'x-instart-cache-id' found, with contents: 17:12768802731504004780::1544075250
+ Uncommon header 'v-cache-hit' found, with contents: Hit
+ Uncommon header 'x-amz-cf-id' found, with contents: Dr-r6OwO5kk9ABt4ejzpc7R7AIF6SuH6kfJHQgP0v6xZoHwMLE55rQ==
+ Uncommon header 'x-instart-request-id' found, with contents: 12814413144077601501:BEQ01-CPVNPPRY18:1552504721:0
+ Uncommon header 'x-oneagent-js-injection' found, with contents: true
+ Uncommon header 'grace' found, with contents: cache
+ The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type
+ Uncommon header 'x-ruxit-js-agent' found, with contents: true
+ Cookie dtCookie created without the httponly flag
+ Server banner has changed from 'instart/nginx' to 'nginx' which may suggest a WAF, load balancer or proxy is in place
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ Entry '/sites/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/search/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '*.mobileapp' in robots.txt returned a non-forbidden or redirect HTTP code (400)
+ Entry '*.liveradio' in robots.txt returned a non-forbidden or redirect HTTP code (400)
+ Entry '*.smartmobile' in robots.txt returned a non-forbidden or redirect HTTP code (400)
+ Entry '*.responsive' in robots.txt returned a non-forbidden or redirect HTTP code (400)
+ Entry '/stats?*/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ "robots.txt" contains 8 entries which should be manually viewed.
+ OSVDB-3092: /sitemap.xml: This gives a nice listing of the site content.
+ OSVDB-3092: /psql_history: This might be interesting...
+ OSVDB-3092: /global/: This might be interesting...
+ OSVDB-3092: /home/: This might be interesting...
+ OSVDB-3092: /news: This might be interesting...
+ OSVDB-3092: /search.vts: This might be interesting...
+ OSVDB-3092: /stats.htm: This might be interesting...
+ OSVDB-3092: /stats.txt: This might be interesting...
+ OSVDB-3092: /stats/: This might be interesting...
+ OSVDB-3092: /Stats/: This might be interesting...
+ OSVDB-3093: /.wwwacl: Contains authorization information
+ OSVDB-3093: /.www_acl: Contains authorization information
+ OSVDB-3093: /.htpasswd: Contains authorization information
+ OSVDB-3093: /.access: Contains authorization information
+ OSVDB-3093: /.addressbook: PINE addressbook, may store sensitive e-mail address contact information and notes
+ OSVDB-3093: /.bashrc: User home dir was found with a shell rc file. This may reveal file and path information.
+ OSVDB-3093: /.bash_history: A user's home directory may be set to the web root, the shell history was retrieved. This should not be accessible via the web.
+ OSVDB-3093: /.forward: User home dir was found with a mail forward file. May reveal where the user's mail is being forwarded to.
+ OSVDB-3093: /.history: A user's home directory may be set to the web root, the shell history was retrieved. This should not be accessible via the web.
+ OSVDB-3093: /.htaccess: Contains configuration and/or authorization information
+ OSVDB-3093: /.lynx_cookies: User home dir found with LYNX cookie file. May reveal cookies received from arbitrary web sites.
+ OSVDB-3093: /.mysql_history: Database SQL?
+ OSVDB-3093: /.passwd: Contains authorization information
+ OSVDB-3093: /.pinerc: User home dir found with a PINE rc file. May reveal system information, directories and more.
+ OSVDB-3093: /.plan: User home dir with a .plan, a now mostly outdated file for delivering information via the finger protocol
+ OSVDB-3093: /.proclog: User home dir with a Procmail rc file. May reveal mail traffic, directories and more.
+ OSVDB-3093: /.procmailrc: User home dir with a Procmail rc file. May reveal subdirectories, mail contacts and more.
+ OSVDB-3093: /.profile: User home dir with a shell profile was found. May reveal directory information and system configuration.
+ OSVDB-3093: /.rhosts: A user's home directory may be set to the web root, a .rhosts file was retrieved. This should not be accessible via the web.
+ OSVDB-3093: /.sh_history: A user's home directory may be set to the web root, the shell history was retrieved. This should not be accessible via the web.
+ OSVDB-3093: /.ssh: A user's home directory may be set to the web root, an ssh file was retrieved. This should not be accessible via the web.
+ OSVDB-5709: /.nsconfig: Contains authorization information
+ /portal/changelog: Vignette richtext HTML editor changelog found.
+ 7587 requests: 4 error(s) and 55 item(s) reported on remote host
+ End Time: 2018-12-05 22:42:41 (GMT-8) (3249 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested
From the information above, we understand that there is a Varnish server and some headers that can tell how the website is configured. However, more useful information is discovered directories that can help catch configuration files containing credentials or other things that were not configured correctly and were unintentionally available.Elements prefixed with OSVDB are vulnerabilities reported on the Open Source Vulnerability Database (a site that closed in 2016). It is similar to other vulnerability databases such as SecurityFocus , Microsoft Technet, and Vulnerabilities and Exposures (https://cve.mitre.org/). Personally, I'm closer to the National Vulnerability Database .Although our scan did not reveal any critical vulnerabilities that could be exploited, you can use the CVE help tool to translate the OSVDB identifier into a CVE record so that you can use one of the sites listed above.Suppose you find something worth exploring, for example CVE-2018-10933 , the Libssh vulnerability, which we discussed in more detail earlier . The CVE contains information on how to exploit it, how serious the vulnerability is (for example, a critical vulnerability) and some other information that can help determine the attack vector. If this is something worthwhile, you can search with Metasploit, since someone most likely has already developed a module that will help to easily exploit this vulnerability.
Step 7: Scan with Metasploit
One of the best things about Nikto is that you can simply export the information you received from the scan to a format that Metasploit can read. To do this, simply use the commands to perform the scan above, but add the -Format msf + flags to them at the end . This format can help you quickly match the data obtained through the exploit.nikto -h <IP or hostname> -Format msf+
So, in today's guide, we went from defining a target to finding vulnerabilities in it, and then associated the vulnerabilities with the exploit so that we did not have to do all the work manually. Since Nikto does not work covertly, itโs wise to do these scans through a VPN, Tor, or other type of service so that your IP address is not flagged as suspicious.โ Sign up for a free lesson