3.10.2017
The regular penetration testing could significantly improve the company's security. The auditor shall obtain all necessary rights and permissions to conduct penetration tests from the owner of the target network or from the owner of target system before conducting any audit.
All the content and resources have been provided in the hope that it will be useful. Author does not take responsibility for any misapplication of it. The document is distributed in the hope that will be useful, but WITHOUT ANY WARRANTY.
The security assessment could be performed using open-source Kali Linux distribution and by various tools which are included in this distribution. This document is providing selected steps and is presenting approaches which could be used to perform the security assessment effectively within the limited allocated time.
The document is provided with intentions to security professionals and security community which would like to asset the security of their corporate or home network or perform the security assessment towards the infrastructure only where they have all the permissions and authorisation required.
The overall IT security could be improved by educating the users and security professionals by learning how to effectively use the available open-source tools.
Nmap scanner is one of the most powerful tool to perform the initial reconnaissance and attack surface discovery. By initial probing it is possible to quickly detect the live hosts in the given network segment.
During the initial reconnaissance it should be evaluated how large is the target network segment to use optimal method and if it is likely that the target hosts would be answering to ping requests in the target environment. (e.g. in some networks the ICMP pings could be allowed globally over the firewalls, however in some other network the ICMP ping is filtered).
https://tools.kali.org/information-gathering/nmap
https://nmap.org/book/man.html
The following are the nmap command examples which could be used to perform the hosts detection.
By scanning it should be understood detailed scanning and probing of the services running on the target system and also the vulnerability scanning. The goal is to detect the services, their software version and possibly the vulnerabilities on the target system.
https://tools.kali.org/information-gathering/nmap
https://nmap.org/book/man.html
The following are the nmap command examples which could be used to perform the scanning. The proper method should be chosen based on the performance, target network conditions and based on the time available to perform the scanning.
https://github.com/scipag/vulscan
Nmap can be enhanced and used as vulnerability scanner by using vulscan script.
It can be installed by using the following commands:
and used by the following command:
https://www.kali.org/penetration-testing/openvas-vulnerability-scanning/
The OpenVAS vulnerability scanner could be in automated way used to perform the vulnerability scanning. For OpenVAS installation follow the instructions on the above link. It is the free alternative to commercial vulnerability scanners like Nessus, Qualys, Nexpose and others.
The added way is relatively easy setup and fast run, but it should be considered that the scanning could be quite intensive and could affect the production systems. Additionally also the results could contain False Positives or False Negatives. Therefore it should be considered also to manually verify every vulnerability reported by the scanner.
Always before scanning the user should update the OpenVAS NVT feeds to scan for the latest vulnerabilities.
Installation:
# setup openvas in Kaliroot@kali:~# openvas-setupFigure 1: OpenVAS report example
https://tools.kali.org/web-applications/skipfish
Skipfish could be used as web vulnerability scanner after detecting a web server on the target system. The added value is that the web vulnerability scanner is web oriented. It is more optimized and more specific for web vulnerabilities (e.g. to detect the OWASP top 10 vulns). This is the main difference compared to network vulnerabilities scanners like OpenVAS, where the scanners are more universals but are not deeply scanning the detected web servers. The common method used by the web scanners is the web crawling of the target web. This approach tries to detect new ULRs from the links on the already detected pages.
The example of the execution scanner is bellow.
# basic scanskipfish -o out_dir https://www.host.comFigure 2: Skipfish report example
https://tools.kali.org/web-applications/dirbuster
Always it useful tool to try to bruteforce the files and directories on the web server. The web servers are commonly used service on the most of the systems and it could be worth to try to find files or directories which are not authenticated or just hidden (e.g. admin console).
The common web vulnerability (e.g. skipfish, Vega, or other commercials scanner) are commonly just crawling the target side (recursively following the links present on the web pages). Therefore it is not uncommon that the web vulnerability scanners could miss some vulnerabilities, or even miss the not authenticated pages, but the URL bruteforcing could reveal hidden pages or administration consoles.
The useful wordlist could be found on the following link
https://blog.thireus.com/web-common-directories-and-filenames-word-lists-collection/
Figure 3: Dirbuster GUI
After finding the vulnerabilities, it is possible to try to exploit them. For the exact vulnerability should be reviewed and checked if there is some public working exploit (in Metaploit project, ExploitDB or other sources).
https://docs.kali.org/general-use/starting-metasploit-framework-in-kali
https://help.rapid7.com/metasploit/Content/home.html
Metasploit is modular framework to perform penetration testing.
Figure 4: Metasploit
Tutorials:
There exist many public resources with tutorials and the documentation. The following links can be used to get started.
https://jonathansblog.co.uk/metasploit-tutorial-for-beginners
http://www.hackingtutorials.org/metasploit-tutorials/metasploit-commands/
Example of ssh_login:
root@kali:~# msfconsolemsf > use auxiliary/scanner/ssh/ssh_loginmsf auxiliary(ssh_login) > show optionshttps://tools.kali.org/exploitation-tools/exploitdb
ExploitDB is online database providing publicly known exploits which could be used to verify and demonstrate the vulnerability and gain further access. The resources contain most time scripts and source code which can be compiled and used to exploit certain vulnerability.
Figure 5: ExploitDB Web Page
https://tools.kali.org/vulnerability-analysis/sqlmap
Sqlmap can be used to try to find vulnerabilities in the web server using the GET or POST HTTP methods or COOKIES to find the injection in vulnerable web server. This method could be very effective while testing custom web applications, CGI scripts, PHP pages, that are not well tested products or open-source application.
To try to find the GET, POST parameters or cookies the useful method is to trace the traffic towards the web server or use the Burp Suite proxy to capture the HTTP/HTTPs communication.
https://tools.kali.org/web-applications/burpsuite
Integrated platform, providing full control of HTTP/HTTPs session allowing manipulation of the requests, run local proxy, run scanner, intruder and additional tools.
Very useful and easy to use is the Proxy feature, which can be used to intercept and modify the HTTP/HTTPs messages towards the web server.
Figure 6: Burp Suite GUI
After gaining the access to the operating system, it is possible to try to escalate privileges.
The following resources could be useful to perform some automated detection on the Linux systems. However always should be performed also manual investigation on the target system.
https://tools.kali.org/vulnerability-analysis/unix-privesc-check
http://pentestmonkey.net/tools/audit/unix-privesc-check
https://github.com/rebootuser/LinEnum
https://www.rebootuser.com/?p=1623
https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/
http://security-geek.in/2016/09/01/linux-privilege-escalation-cheat-sheet/
After finding some hashes located on the machine it is possible to try to crack them depending on the hash algorithm and if the salt has been used.
https://tools.kali.org/password-attacks/john
https://github.com/magnumripper/JohnTheRipper
John the Ripper is publicly well known tool used for password cracking containing several cracking modules.
Example of cracking the linux OS passwords from passwd and shadow files:
unshadow /etc/passwd /etc/shadow > mypasswd.txt
$ /usr/sbin/john mypasswd.txt
The effective way for writing the audit reports could be just to write the finding directly into nmap output.
If it is required to document the finding separately in the final report, it could be still good practice to include the nmap output in the report annex and reference there the findings.
Example of such nmap result with manually documented vulnerability inside is bellow:
The security assessment and vulnerability scanning is complex task. The above document is describing only the very basics and just few tools which could be used effectively to perform such assessment with quite good coverage. The Kali Linux distribution contains much more tools, and the proper tools selection depends always on the goal of the auditor and also on the target network and technology under audit.