Kali Linux Penetration Testing
Kali Linux Penetration Testing
Kali Linux Penetration Testing
Denise Mangold
Denise.Mangold@villanova.edu
Villanova University Department of Electrical and Computer Engineering
ECE 8484 Fall 2014
Table of Contents
Abstract: ....................................................................................................................................... 3
Introduction: .............................................................................................................................. 3
Conclusion: ............................................................................................................................... 16
Bibliography: ........................................................................................................................... 17
( a mix of internet research and books) .................................................................................. 17
Abstract:
Most companies as well as consumers rely on the Internet for business
transactions. This translates to roughly 10 trillion dollars in online transactions a
year. The world is vastly interconnected, while this gives rise to new business
models, it also exposes new risks of cyber-attacks by criminals, political activist, and
malicious actors. It is the responsibility of every person who uses and works with
connected devices to be knowledgeable and proactive in the area of cyber security,
for the protection of the companies they work for as well as their own personal
security. Learning how to discover vulnerabilities and remediate the vulnerabilities
is crucial to preventing costly breaches that can cost millions of dollars in revenue
also, the cost of lost confidence from consumers. In this paper Kali Linux will be
used to demonstrate penetration testing of a faux corporate system (image provided
by deterlab). The penetration testing standards for testing execution standard will
be used as if this were a real corporation. It is assumed that the pre-engagement
interaction has already taken place with the faux corporation being pen tested so
that section will not be completely detailed with legalities.
Introduction:
In the past year it appeared that no industry was immune from cyber attacks.
The following companies were victims of cyber-security breaches;
Adobe was hit for 152 million records, ebay 145 million; Bank and financial services
JP Morgan Chase 76 million; retails Target and The Home Depot for 70 million and
56 million records. [11] These breaches not only cost the companies millions they
also caused consumers; identify theft, time, and aggravation of having to notify their
banks, get credits if their cards were compromised, and ultimately the loss of
confidence in the retailers with being able to be trusted with bank information.
When a retailer is breached it affects not only the retailer, it also has an impact on
the consumer, and on the banks, passing the costs of cyber security breaches back
down to the consumer.
On November 24th 2014 a story broke that Sony Pictures computers were
hacked by a group called the GOP the attackers threatened to release data if their
demands were not met by a given deadline. It was reported that the hack on Sony
pictures was related to the release of a comedy film The Interview which depicts
the assassination of North Koreas leader. The data leaks of Sony were
unprecedented, the data included Torrents of unreleased Sony Pictures, which
undoubtedly would result in loss of revenue, financial and health information about
staff. The leak also included the salaries of Sony executives, security certificates and
other credential data. The most disturbing part of the hack was emails threatening
Sony employees. The hack is believed to be from North Korea, however, the FBI
traced the attack to a hotel in Bangkok, so the perpetrator or group has not been
positively identified, however, this caused severe damage to Sony Pictures
financially, as well as the reputation of the company as a whole.
Breaches like the one Sony experienced could have a major impact on the
economy. One security breach incident can cause a litany of costs that include legal
fees, software updates, customer reimbursement and public relations costs. Once a
company is breached it can also face serious fines for not complying with security
standards set forth by their specific industry, pharmaceutical, healthcare and
financial companies have stringent regulations to protect the information they have
about their customers.
In this paper I will demonstrate how a corporation could be victimized by
cyber security breaches. I will demonstrate vulnerabilities at the OS level; buffer
overflows, Web Application; file traversal where I will gain root by gaining access to
the /etc/shadow file, and sql injection where I am able to breach the company credit
union and transfer money. I will use Kali Linux to find these vulnerabilities, I will
remediate and document. The many tools within Kali Linux are used to find,
remediate and document these vulnerabilities.
Penetration Testing:
The methodology used for my research was from the Penetration Testing
Execution Standards, they have seven phases of Penetration testing the phases
cover everything related to penetration testing. The seven phases are Preengagement Interactions; Intelligence Gathering; Threat Modeling; Vulnerability
Analysis; Exploitation; Post Exploitation; and Reporting. [12]
actors to get the best analysis of the state of their machines. The client is trying to
financially justify advanced penetration testing to management in order to avoid
costly breaches in the future.
Information Gathering:
The first step Ill use for this demonstration in penetration testing is
Intelligence gathering. It is always important to keep in mind the Rules of
Engagement Limitations!! Never go outside the agreed rules of engagement as this
could have serious legal consequences.
Intelligence gathering is performing reconnaissance against the target to
gather as much information as possible to be utilized when penetrating the target
during the vulnerability assessment and exploitation phases. The more information
gathered the more vectors of attack that can be used.[12] The first act of
reconnaissance will be to scan the server using zenmap, the output of zenmap
showed that port 8080 was open and filtered. It also provided a lot of information
about the system such as Apache httpd 2.2.14 was running on Ubuntu, it also
showed that there is php code for the webserver. This is very useful information!
Figure 3: Zenmap output of Frozozzco.com
From the information gathered from the zenmap scan I am able to pull up
their website and poke around. I am also able to run web vulnerability scans on the
discovered site, I can customize my scans because I now have a deeper knowledge of
the system, I know its Linux, running Apache, and PHP.
Threat Modeling:
During the threat analysis phase only the website might be in scope, however
after close review and discussions with the company it appears there is a back end
database that is easily identifiable. Since we identified this server as a whole in our
Pre-engagement Interaction and have full permission to continue testing all
applications including databases we are free to penetration test the database. In our
Faux Corporation the company believes that its web server poses a significant
threat. However, since it houses a SQL database for the credit union in which
employees move, deposit and withdraw money. In general SQL Injections should be
considered a high impact security. The sql database for Frozbozz Intl. contains
sensitive information about the employees, such as social security numbers, bank
routing information, full name and email, this information gives a strong motive to
malicious attackers to exploit this system since there is financial gain to be had from
the exploitation.
Vulnerability Analysis:
The first part of vulnerability testing is the process of finding the flaws in the
system that can be exploited by a malicious attacker. Since I know that the system is
running a web server on port 8080 I start there. Ill use Web Application Scanners
to get an idea of system vulnerabilities. I run two separate scans one using Vega, the
other using OSWASP-ZAP for comparison and verification.
Figure 4: Vega output of sca
n
Vulnerabilities Found Vega:
Figure 5: alerts
n
The default settings for scans on Vega found more vulnerability, however, both
found the one that was exploited for root access to the machine.
Exploitation Phase:
File Traversal:
The one high alert that was particularly useful is one of a file traversal as
seen in figure 4. The HTTP request was able to view the /etc/shadow file, giving me
the users and hashes of their passwords. Having the output of the /etc/shadow
allows me to know the user names and hashes of their passwords. I will use Kali to
break the hash of the passwords of a user and of root so I can gain access to the
Linux system and su to the root user. Its always safe to assume that direct login
for root is disabled, but since all we need is a username of regular privilege and the
root password to gain root access, that is more than sufficient to own the box. The
next Kali Linux application I used was HashID. I was able to determine that the hash
used for the /etc/shadow file was MD5, from that knowledge Im able to use the
appropriate cracking software for that particular hash.
The next application to be used was RainbowCrack, since the type of hash was
known to be MD5 rainbow tables were created in RainbowCrack with the following
procedure:
Password Cracking:
1. Create rainbow tables
a. rtgen md5 loweralpha 1 5 0 2000 8000 testing
b. rtgen md5 loweralpha 1 5 1 2000 8000 0
2. After creating the tables the next step is to sort the tables. This is done
for all rainbow tables created.
a. rtsort md5_loweralpha#1-5_0_2000x8000_0.rt
3. The next stage is to run rcrack
a. rcrack /usr/share/rainbowcrack/*.rt h
$1$UKoOQUPw$vtrmLJpKLSKoV6LTlbJBD1
I was able to crack the hash of wilbars account. I used this same procedure
on the roots hash, which gave me the root password as well. I am all set to actually
break into the system. On a UNIX system root has power over everything! So
gaining root access from the file traversal and password cracking this vulnerability
would need to be addressed quickly. This vulnerability will be discussed in
reporting, remediating section regarding password policies.
Buffer Overflow:
Since I was able to gain root access to the Linux system I had a look around,
the first order of business was to investigate the web server code. I was able to do
this having root access. I logged on as Wilbur and did a su root using the hashed
root password. The webserver code was found in /usr/local/fhttpd/server and I
see that the webserver is written in C code.
Being a security professional hired by Frozbozz, I know that OWASP
identifies buffer overflows as vulnerabilities, I know I should check the C code that
the webserver is written in to ensure that it is protected from buffer overflow
run. For this very reason, this is the common technique for worms to exploit stack
buffer overflow vulnerabilities.
Figure 8: edb-debugger
SQL Injection:
From the vulnerability scan it is shown that the clients server is also subject
to sql injection attacks. Because of the file traversal attack with me being able to
gain root into the system, I go to the directory where the php code is stored, which is
located in /usr/lib/cgi-bin/FCCU.php. I open this file to investigate how well its
written. I can see that the DB user and password are stored in this file, I also notice
that there are no real escape string, which is used to prevent MySQL injections.
for sql
I know I could get into the database from the server, but I had to show the client that
their website was vulnerable to SQL injections as Vega and OSWASP-ZAP had both
reported. The clients in this situation decided to link this server to a test database
so we could demonstrate an sql injection and prove the severity of such an attack. I
also used sqlmap
Figure 10: SQLMap
Reporting Phase:
The reporting phase is the phase in which a detailed document of the
penetration test is documented with recommendations to the client. The report
should be well structured with the following sections as examples.
Summary; Background; Risk Ranking; General Findings/Observations;
Recommendations; Technical Report and a Roadmap for remediating the security
risks. Kali Linux does have reporting features that were not utilized for this paper,
some of the reporting tools that come with Kali Linux are ones for evidence
management, documentation, and Media capture tools, with each section having a
variable number of tools for each purpose.
Example (condensed) Report of Penetration Test:
1. Background: Frozbozz has started a new initiative to have penetration
testing all pre-production systems as part of the quality assurance cycle.
They would like to have it company policy to security test all systems before
they go into production. Their goal is to minimize the possibility of a costly
security breach as well as to protect customer, employee and company data.
2. Systematic issues: The penetration testing was successful in breaching the
OS, web application and the database.
3. Risk Ranking/Profile:
a. EXTREME: SQL Injection of the database; The MySQL database
allows for sql injections and the ability to transfer, grant and
manipulate financial information contained in that database; it also
exposes sensitive information such as employee SS#, phone, address,
and bank information.
b. EXTREME: File traversal within the web application; this
vulnerability exposes the users, and their hashed passwords; this was
easily exploited and elevated privilege was gained at the OS level.
c. HIGH: Buffer Overflow; A buffer overflow vulnerability exposes the
server to malicious code such as worms.
4. General Findings: The OS was behind on critical patches; lack of OS
hardening, there is a lack of application hardening, the credentials were
easily guessed for MySQL as well as the OS users. Lack of quality testing of
application coding; web application design flaws.
5. Recommendation Summary: Patch OS; insert mysql_real_escape_string to
protect against SQL Injection attacks. Redesign the cgi-bin web application
to run in a chroot environment to protect against file traversal attacks
exposing OS file system. The webserver.c code should have memory bounds
checking to prevent buffer overflow attacks.
6. Strategic Roadmap: This usually includes the roadmap to remediate the
security issues found. The frozbozz would have a roadmap stating the OS
would be first to be remediated, the DB and Webserver would have
dependencies on the developers time, as both would have to be re-written,
however, this would be defined in a project plan; probably utilizing the Agile
methodology.
Conclusion:
No company or individual is immune to security breaches. The past few
years has seen unprecedented breaches costing millions of dollars; security
breaches have a severe impact on the economy as a whole. The financial loss a
company takes from the breach alone, the loss in consumer confidence, and the loss
of a once solid reputation. Once a reputation has been damaged it is exceptionally
hard to overcome negative perceptions. Companies need to incorporate security
testing and governance into their IT infrastructure. Security should not be an after
thought but a continued part of the IT lifecycle. Being proactive with security is
analogist to purchasing car insurance, its not valuable until the need arises, and
however not having it can cause great devastation that can be difficult or even
impossible to recover.
Bibliography:
( a mix of internet research and books)
1. "About DeterLab | DETER." About DeterLab | DETER. N.p., n.d. Web. 16 Dec. 2014.
(http://www.isi.deterlab.net )
2. Alcorn, Wade, Christian Frichot, and
N.p.: n.p., n.d. Print.
3. Ali, S. Kali Linux: Assuring Security by Penetration Testing. S.l.: Packt Limited,
2014. Print.
4. "Behind the App: The Story of Kali Linux." Lifehacker. N.p., n.d. Web. 12 Dec. 2014.
(http://lifehacker.com/behind-the-app-the-story-of-kali-linux-1666168491)
5. Erickson, Jon. Hacking: The Art of Exploitation. San Francisco, CA: No Starch, 2008.
Print.
6. "Infographic: 2014's Top Breaches So Far." - BankInfoSecurity. N.p., n.d. Web. 16
Dec. 2014. (http://www.bankinfosecurity.com/infographic-2014s-top-breachesso-far-a-7408 )
7. "Kali Linux | Rebirth of BackTrack, the Penetration Testing Distribution." Kali Linux.
N.p., n.d. Web. 11 Dec. 2014. (https://www.kali.org )
8. "Kali Linux." BlackMORE Ops. N.p., n.d. Web. 12 Dec. 2014.
9. Kim, Peter. The Hacker Playbook: Practical Guide to Penetration Testing. North
Charleston, SC: Secure Planet, LLC, 2014. Print.
10. "Offensive Security Training and Services." Offensive Security. N.p., n.d. Web. 16
Dec. 2014. (http://www.offensive-security.com )
11. "Survey Shows the Cost of Security Breaches Is on the Rise." CSO Online. N.p., n.d.
Web. 16 Dec. 2014. (http://www.csoonline.com/article/2689346/big-datasecurity/survey-shows-the-cost-of-security-breaches-are-on-the-rise.html )
12. "Main Page." The Penetration Testing Execution Standard. N.p., n.d. Web. 16 Dec.
2014. (http://www.pentest-standard.org/index.php/Main_Page )