ITSAFE Fnal Project - Gilo
ITSAFE Fnal Project - Gilo
Gilo Yosef
Copyright © 2021 ITSafe Ltd. All rights reserved.
No part of this publication, in whole or in part, may be reproduced, copied, transferred or any other right reserved to its copyright owner,
including photocopying and all other copying, any transfer or transmission using any network or other means of communication, any broadcast
for distant learning, in any form or by any means such as any information storage, transmission or retrieval system, without prior written
permission from ITSAFE Cyber College.
Table of Contents
3 | Page
1.0 ITSafe Penetration Project Reports
1.1 Introduction
The ITSAFE Lab penetration test report contains all efforts that were conducted in order to pass the
ITSAFE Project Lab. This report will be graded from a standpoint of correctness and fullness to all
aspects of the Lab. The purpose of this report is to ensure that the student has a full understanding of
penetration testing methodologies as well as the technical knowledge to pass the qualifications for the
ITSAFE Certified Professional.
1.2 Objective
The objective of this assessment is to perform an internal penetration test against the ITSAFE Lab
network. The student is tasked with following a methodical approach in obtaining access to the objective
goals. This test should simulate an actual penetration test and how you would start from beginning to end,
including the overall report. An example page has already been created for you at the latter portions of
this document that should give you ample information on what is expected to pass this course. Use the
sample report as a guideline to get you through the reporting.
1.3 Requirements
The student will be required to fill out this penetration testing report fully and to include the following
sections:
4 | Page
2.0 High-Level Summary
I was tasked with performing an internal penetration test towards ITSAFE Project. An internal penetration
test is a dedicated attack against internally connected systems. The focus of this test is to perform attacks,
similar to those of a hacker and attempt to infiltrate HackTheBox\VulnHub internal Lab systems –My
overall objective was to evaluate the network, identify systems, and exploit flaws while reporting the
findings back to ITSAFE.
When performing the internal penetration test, there were several alarming vulnerabilities that were
identified on Offensive Security’s network. When performing the attacks, I was able to gain access to
multiple machines, primarily due to outdated patches and poor security configurations. During the
testing, I had administrative level access to multiple systems. All systems were successfully exploited and
access granted. These systems as well as a brief description on how access was obtained are listed below:
● 10.10.10.4 (Legacy) - Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)
● 10.10.10.56 (Shocker) - Apache mod_cgi Bash Environment Variable Code Injection
(Shellshock)
● 10.10.10.3 (Lame) – outdated samba version – Remote code execution
● 10.10.10.68 (Bashed) - This machine involved exploiting a PHP bash shell to gain initial access,
misconfigured Sudo rules to escalate to the “scriptmanager” user and a cron job to escalate to
root.
● 10.10.10.75 (Nibbles) – Arbitrary File Upload
● 10.10.10.40 (Blue) – MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption
● 10.10.10.5 (Devel) - FTP login enabled, Remote File Execution
● 10.10.10.95 (Jerry) – Arbitrary File Upload
● 10.10.10.8 (Optimum) – Remote code execution
● 10.10.10.14 (Grandpa) – Buffer Overflow
5 | Page
2.1 Recommendations
I recommend patching the vulnerabilities identified during the testing to ensure that an attacker cannot
exploit these systems in the future. One thing to remember is that these systems require frequent patching
and once patched, should remain on a regular patch program to protect additional vulnerabilities that are
discovered at a later date.
3.0 Methodologies
I utilized a widely adopted approach to performing penetration testing that is effective in testing how well
the HackTheBox\VulnHub environments is secured. Below is a breakout of how I was able to identify
and exploit the variety of systems and includes all individual vulnerabilities found.
The information gathering portion of a penetration test focuses on identifying the scope of the penetration
test. During this penetration test, I was tasked with exploiting the Lab network. The specific IP addresses
were:
Lab Network
● 10.10.10.4 ● 10.10.10.40
● 10.10.10.56 ● 10.10.10.5
● 10.10.10.3 ● 10.10.10.95
● 10.10.10.68 ● 10.10.10.8
● 10.10.10.75 ● 10.10.10.14
6 | Page
7 | Page
3.2 Penetration
The penetration testing portions of the assessment focus heavily on gaining access to a variety of systems.
During this penetration test, I was able to successfully gain access to 10.10.10.4 out of the 10.10.14.15
systems.
Service Enumeration
The service enumeration portion of a penetration test focuses on gathering information about what
services are alive on a system or systems. This is valuable for an attacker as it provides detailed
information on potential attack vectors into a system. Understanding what applications are running on the
system gives an attacker needed information before performing the actual penetration test. In some cases,
some ports may not be listed.
UDP:
8 | Page
Nmap Scan Results:
9 | Page
Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010).
Vulnerability Explanation: Microsoft Security Bulletin MS17-010 was published last March 14, 2017 to
address multiple vulnerabilities in Microsoft Server Message Block 1.0 (SMBv1). The most severe of the
vulnerabilities could allow remote code execution (RCE).
Vulnerability Fix: Security Update for Microsoft Windows SMB Server (4013389), Published:
March 14, 2017
Severity: Critical
10 | Page
Initial Shell Screenshot:
Privilege Escalation
Gained admin privileges straight from this exploit (NT AUTHORITY\SYSTEM
11 | Page
System IP: 10.10.10.56
Service Enumeration
Dirb http://10.10.10.56/cgi-bin -X .sh found a suspicious file path named user.sh
12 | Page
10.10.10.56 TCP: 80, 2222
UDP:
Vulnerability Explanation: Shellshock is a critical bug in Bash versions 1.0.3 - 4.3 that can enable an
attacker to execute arbitrary commands.
13 | Page
Vulnerability Fix: The easiest way to fix the vulnerability is to use your default package manager to
update the version of Bash. The following subsections cover updating Bash on various Linux
distributions, including Ubuntu, Debian, CentOS, Red Hat, and Fedora.
Severity: Critical
Privilege Escalation
To gain root I simply used this command sudo perl -e 'exec "/bin/sh";'
14 | Page
Vulnerability Exploited:
Vulnerability Explanation: We can execute Perl as root user without any password . And -e means that
it allows you to define Perl code to be executed by the compiler ,And exec is like a function in Perl which
allows us to run /bin/bash
Vulnerability Fix: Reduce the information leaked by applications, remove complier or restrict
access to them, apply linux updates and patches, run file integrity monitoring software, perform
system auditing, privilege escalation checkers like LinEnum/ unix-privesc-check to perform
enumeration and check for possible linux privilege escalation options and to gather information
and determine possible attacks.
Severity: High
Exploit Code:
System IP 10.10.10.3
Service Enumeration
15 | Page
10.10.10.3 TCP: 21, 22, 139, 445,3632
UDP:
Additional info about where the initial shell was acquired from
Vulnerability Explanation: The MS-RPC functionality in smbd in Samba 3.0.0 through 3.0.25rc3 allows remote
attackers to execute arbitrary commands via shell metacharacters involving the (1) SamrChangePassword function,
16 | Page
when the "username map script" smb.conf option is enabled, and allows remote authenticated users to execute
commands via shell metacharacters involving other MS-RPC functions in the (2) remote printer and (3) file share
management.
http://www.samba.org/samba/security/
Severity: Critical
I used a script from github to gain this shell, afterwards I found a way to gain a reverse-shell via
Metasploit with this module exploit(multi/samba/usermap_script).
17 | Page
Privilege Escalation
Straight root privileges
Vulnerability Exploited:
Vulnerability Explanation:
http://www.samba.org/samba/security/
Severity: Critical
18 | Page
19 | Page
System IP: 10.10.10.68
Service Enumeration
10.10.10.68 TCP: 80
UDP:
involved exploiting a PHP bash shell to gain initial access, misconfigured Sudo rules.
Vulnerability Explanation: After enumeration I’ve found /dev/ path folder that gain me a php bash
shell, I escalated to root because a misconfigured sudo rules to escalate to the scriptmanager user
and cron job to escalate to root.
Vulnerability Fix: Installing an OS updates, changing the Sudo configuration & application
configuration and installing an application patch.
20 | Page
Severity: Critical
Privilege Escalation
misconfigured Sudo rules to escalate to the “scriptmanager” user and a cron job to escalate to root.
Vulnerability Exploited: I had access to run sudo commands as scriptmanager user, I ran the command
“sudo -u scriptmanager /bin/bash”.
There is a simple script in ‘test.py’ which writes output on file ‘test.txt’. One more interesting thing we
got is that creation time of file test.txt is keep updating to the latest time. This mean there is a cron job is
running which runs test.py script automatically. If we replace the test.py file with our test.py file
containing reverse shell code and check, might we can get reverse shell of root.
In my local machine I created a script on python named also test.py, I opened a web server where I saved
the test.py file and then, I removed the original test.py file and I used wget to download my reverse shell
21 | Page
python script and change the file permissions with chmod command. Afterwards I opened a new listener
on the same port as the python script, I waited a minute, and I got root user access
Vulnerability Explanation:
Vulnerability Fix: Installing an OS updates, changing the Sudo configuration & application
configuration and installing an application patch.
Severity: Critical
Service Enumeration
22 | Page
Server IP Address Ports Open
UDP:
I started the enumeration on port 80 and I gained a root permission in the end.
I located a path named /nibbleblog/ and after more enumeration I succeed to find more paths via
dirb,
I located the admin.php path and successfully logged in due a weak password.
Then I uploaded my trojan to the web server and I gained a reverse shell.
Vulnerability Explanation: An arbitrary file upload vulnerability is a type of security flaw that allows an
attacker to upload malicious files onto a server. This can be done by exploiting a vulnerability in a web
23 | Page
application that doesn't properly validate the file type or by tricking the user into uploading a malicious
file.
Vulnerability Fix: -Take the whitelist approach to accept only a certain file extension. It can reduce the
risk involved with uncommon or unknown extensions.
Verify the files downloaded from the internet just like direct uploads. It helps to prevent arbitrary file
upload vulnerabilities. The downloaded files from the internet or uploaded directly by users should be
stored in a location that is not publicly accessible.
Restrict the user base to authenticate users so that the files they upload would be authorized easily. It
reduces the chance of random or unauthorized users uploading files to your website.
Prefer using the files downloaded from the application rather than from the web server directly.
Severity: Critical
Privilege Escalation
I found that monitor.sh uses root permission, I edited it to a reverse shell script and I gained a root
access
Vulnerability Exploited: I removed the original monitor.sh file and I used WGET to transfer the
monitor.sh file I created on my local machine, I changed its permissions so ill be able to execute.
24 | Page
Afterwards I opened a listener on my local machine with Netcat and then I used the sudo command with
the full file path name to gain a reverse shell.
Severity: High
25 | Page
Proof.txt Contents:
26 | Page
System IP: 10.10.10.40
Service Enumeration
49156,49157
UDP:
Additional info about where the initial shell was acquired from
27 | Page
Vulnerability Explanation: MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption
Vulnerability Fix: Microsoft released in March 14 th 2017 a security update for Microsoft Windows SMB
Server, The security update addresses the vulnerabilities by correcting how SMBv1 handles specially
crafted requests.
Severity: Critical
Privilege Escalation
This exploit gained access as NT-AUTHORITY\SYSTEM and a full control of the kernrel in ring 0
Vulnerability Fix: Microsoft released in March 14 th 2017 a security update for Microsoft Windows SMB
Server, The security update addresses the vulnerabilities by correcting how SMBv1 handles specially
crafted requests.
Severity: Critical
28 | Page
Exploit Code:
Proof.txt Contents:
29 | Page
System IP: 10.10.10.5
Service Enumeration
UDP:
Vulnerability Explanation: aspx trojan file has been uploaded, afterwards I opened the file path on
the browser meanwhile listening on Metasploit.
30 | Page
Vulnerability Fix: Anonymous FTP login must be disable.
Anonymous FTP is disabled by default for the security of your account. We do not recommend using
anonymous FTP because it allows any person to access FTP without identifying themselves, it is a
security risk
Severity: High
Privilege Escalation
Vulnerability Exploited:
Vulnerability Fix: In July 09th 2013 Microsoft released security update for this vulnerability,
This security update resolves two publicly disclosed and six privately reported vulnerabilities in
Microsoft Windows. The most severe vulnerability could allow remote code execution if a user views
shared content that embeds TrueType font files. An attacker who successfully exploited this vulnerability
could take complete control of an affected system.
Severity: High
Exploit Code:
31 | Page
Proof Screenshot Here:
Proof.txt Contents:
User’s flag
Root’s flag
32 | Page
System IP: 10.10.10.95
Service Enumeration
UDP:
After open in browser the following URL (http://10.10.10.95:8080) and conrfirming that the Tomcat
server is accessible, I noticed on the ‘Manager App’ portal.
This portal is password protected, after trying default tomcat password, but I was able to see it on the
“Authentication Denied” page due a developer mistake.
Vulnerability Explanation: Since there is an option to upload WAR files I created a WAR trojan file
with msfvenom named jerry.war, I created a listener and opened the torjan WAR file and I received a
Reverse Shell
33 | Page
Vulnerability Fix: Using a strong password to avoid from hackers getting access with defaults
passwords.
Severity: High
34 | Page
Privileg
e Escalation
35 | Page
System IP: 10.10.10.8
Service Enumeration
10.10.10.8 TCP: 80
UDP:
Additional info about where the initial shell was acquired from- found port 80 is open with vulnerable
HttpFileServer version.
36 | Page
Vulnerability Explanation: A remote, unauthenticated user may be able to run arbitrary operating
system commands on the server.
Vulnerability Fix: This issue is addressed in HFS version 2.3c and later.
Severity: Critical
Privilege Escalation
For the PE I used the post(multi/recon/local_exploit_suggester) module on Metasploit.
37 | Page
Vulnerability Exploited: The remote Windows host is affected by an elevation of privilege vulnerability
in the Windows Secondary Logon Service due to improper management of request handles in memory.
An authenticated, remote attacker can exploit this, via a specially crafted application, to elevate
privileges, allowing the execution of arbitrary code.
Vulnerability Explanation:
Vulnerability Fix: Microsoft has released a set of patches for Windows Vista, 2008, 7, 2008 R2, 2012,
8.1, RT 8.1, 2012 R2, and 10.
Severity:
38 | Page
Proof.txt Contents: PFA the walkthrough file.
use (windows/local/ms16_032_secondary_logon_handle_prives)
set session 1
exploit
Service Enumeration
10.10.10.14 TCP: 80
UDP:
39 | Page
Nmap result found a vulnerable Microsoft IIS 6.0 version.
Vulnerability Explanation: This is a typical buffer overflow vulnerability . The affected system reported
(by the researcher) is Windows 2003 and IIS version 6. The vulnerability could be exploited with an
overly large ‘IF’ header in the ‘PROPFIND’ request with at least two http resource in the IF header. If
successfully exploited, this vulnerability could lead to remote code execution. Sometimes, an
unsuccessful attack could still lead to denial-of-service conditions.
Vulnerability Fix: IIS 6.0 was included with Windows Server 2003; unfortunately, Microsoft isn't
supporting and won't be patching the old OS version anymore. To mitigate the risk, disabling the
WebDAV service on the vulnerable IIS 6.0 installation is recommended. Newer versions of Windows
Server shipped with newer versions of IIS are not affected by this vulnerability.
Severity: Critical
40 | Page
Privilege Escalation
For the Privilege Escalation I used the Suggester ((multi/recon/local_exploit_suggester) module on
Metasploit, after trying some modules offered by the suggester, I gained a root access with
exploit(windows/local/ms10_015_kitrap0d) module
Vulnerability Explanation: This module will create a new session with SYSTEM privileges via the
KiTrap0D exploit by Tavis Ormandy. If the session in use is already elevated then the exploit will not
run. The module relies on kitrap0d.x86.dll, and is not supported on x64 editions of Windows.
Vulnerability Fix: Microsoft released on February 09th 2010, an important update to fix this
vulnerability.
This security update resolves one publicly disclosed and one privately reported vulnerability in
Microsoft Windows
This security update is rated Important for all supported editions of Microsoft Windows 2000,
Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, and Windows 7 for
32-bit Systems. For more information, see the subsection, Affected and Non-Affected Software, in
this section.
The following update addresses the vulnerabilities by ensuring that the Windows Kernel handles
exceptions properly.
Severity: Critical
Proof.txt Contents:
41 | Page
4.0 Additional Items
42 | Page