Jarvis HTB Penetration Test Report
Jarvis HTB Penetration Test Report
The main vulnerabilities identified in the Jarvis penetration test included a website SQL injection (SQLi) vulnerability, insufficient input sanitization in the simpler.py script, and a systemctl SUID bit misconfiguration. The SQLi vulnerability was exploited using sqlmap, bypassing the WAF to gain a shell as www-data. Input sanitization flaws in simpler.py allowed command injection via the $() operator, enabling lateral movement to the user 'pepper'. The systemctl SUID bit was exploited to escalate privileges to root by running a malicious service at a root level .
According to the report, the highest priority should be given to securing the web application against SQL injection due to its immediate risk and exploitability. Input sanitization should be promptly applied to mitigate this vulnerability. The input sanitization adjustment in simpler.py is assigned a medium priority because, while it allows command injection, there are conditions and restrictions that somewhat limit the attack. Disabling the systemctl SUID bit is also given medium priority as it poses a known privilege escalation threat but might not be directly exploited without additional vulnerabilities .
The reverse shell execution as user 'pepper' involved exploiting the simpler.py script, which had inadequate input sanitization. The tester used command injection by writing a script that executed a bash command within the $() operator. They then triggered this command using the script’s functionality, leading to a reverse shell as the 'pepper' user. This method showcased the impact of omitted input checks and how they can be leveraged in scripted environments .
Disabling the systemctl SUID bit is significant as it addresses a known privilege escalation vulnerability. With the SUID bit enabled, systemctl can be executed with root privileges, allowing attackers to execute arbitrary services as root. This vulnerability provides a straightforward path to gaining root-level access, which is why the report recommends disabling it as a medium priority security measure .
The simpler.py script played a crucial role in lateral movement during the penetration test on Jarvis by allowing command injection due to insufficient input sanitization. The script used an os.system call for its ping function, enabling the penetration tester to inject commands using the $() operator. This facilitated obtaining a shell on the box as the user 'pepper', demonstrating the critical impact of improper input validation in facilitating unauthorized access .
The PHP backdoor file was utilized on Jarvis to achieve remote command execution by writing it to the website via SQLi exploitation. Once deployed, the attacker used curl to send HTTP requests to the backdoor file, which executed system commands on the box. By using nc through the PHP backdoor, a full shell on the target system was achieved, enabling further exploitation and control .
During the enumeration phase, indicators of vulnerability included the ability to break the page by adjusting a parameter in the URL and adding an apostrophe, suggesting a potential SQL injection vulnerability. Additionally, ports 22, 80, and 64999 were found open with an HTTP server running on 64999, and an accessible phpMyAdmin login page was identified, further indicating potential places for deeper probes .
The report suggests mitigating the SQLi vulnerability by implementing input sanitization on the website. This includes rejecting unexpected or potentially malicious characters, such as apostrophes, in input parameters like 'cod'. Inputs should not undergo processing until they are validated to prevent SQLi, which is considered extremely dangerous and easily exploitable .
The primary limitation encountered when using sqlmap was interference from a Web Application Firewall (WAF) or Intrusion Prevention System (IPS), which blocked standard enumeration attempts. This limitation was overcome by using additional sqlmap flags, such as --random-agent, to alter the User Agent string and bypass the WAF, enabling the discovery of the SQLi vulnerability and subsequent data dump of credentials .
The WAF deployed against SQLmap employed a mechanism that detected multiple requests in a short time span targeting the same vulnerable URL and temporarily banned the originating IP. This forced the penetration tester to incorporate strategies, such as using the --random-agent option, to alter the client fingerprint, thereby evading the WAF's pattern recognition and allowing further exploit attempts. This defensive mechanism highlights the importance of employing dynamic response measures in security configurations .