Vulnhub Prime: 1 — A Local File Inclusion (LFI) Vulnerability
好的,我现在需要帮用户总结这篇文章的内容。用户的要求是用中文总结,控制在100字以内,而且不需要特定的开头,直接写描述即可。 首先,我通读了整篇文章,发现它主要讲述了如何通过一系列漏洞来攻击一个名为VulnHub Prime 1的CTF虚拟机。文章详细描述了从网络侦察到利用本地文件包含漏洞(LFI)的过程。 接下来,我注意到文章提到了几个关键步骤:网络扫描、目录枚举、发现隐藏文件、利用LFI漏洞获取用户信息,然后通过SSH登录和WordPress平台的访问进一步渗透。最终,他们上传了一个反向壳脚本,并利用本地提权漏洞获得了root权限。 现在,我需要将这些关键点浓缩到100字以内。要确保涵盖主要步骤:网络扫描、LFI漏洞、获取用户信息、反向壳、提权和获取flag。 最后,组织语言时要简洁明了,避免冗长的描述。确保每个步骤都清晰明了,并且整体连贯。 </think> 文章描述了一次针对VulnHub Prime 1 CTF虚拟机的渗透测试过程。通过网络扫描发现目标后,利用WordPress站点中的本地文件包含(LFI)漏洞获取用户信息,并进一步通过反向壳脚本和本地提权漏洞获得root权限,最终获取flag。 2026-3-17 04:52:44 Author: infosecwriteups.com(查看原文) 阅读量:5 收藏

Vulnhub Prime: 1 — A Local File Inclusion (LFI) Vulnerability

This walkthrough will attempt to solve VulnHub’s Prime 1 CTF VM. The box contains several vulnerabilities, but the exploit chain centers on a local file inclusion (LFI).

As with almost every hacking attempt, we started with network reconnaissance to discover hosts and identify the target (Figure 1).

Press enter or click to view image in full size

Figure 1. ARP scan

Focusing on the target (Figure 2), we ran a port scan to identify which services were exposed. Also continued to scan the host with Nmapto identify running services in detail (Figure 3).

Figure 2. Nmap basic scan

Press enter or click to view image in full size

Figure 3. Nmap detailed scan

The target had port 80 open, serving a web page. We inspected the site (Figure 4) and ran directory discovery to find potential paths and resources (Figure 5).

Press enter or click to view image in full size

Figure 4. Target Web Page

The scan showed the target is running WordPress (Figures 5 and 6).

Press enter or click to view image in full size

Figure 5. Directory enumeration results

Press enter or click to view image in full size

Figure 6. Additional output from the directory enumeration

With the same directory scanning tool, we enumerated files ending in .txt (Figure 7). Accessing the secret.txt URL revealed a clue on the website (Figure 8).

Figure 7. Results of directory scan showing .txt file extensions

Press enter or click to view image in full size

Figure 8. secret.txt file containing a hint

Initially, the clue on the GitHub page (Figure 9) was confusing to interpret and required some trial and error.

Applying the hint from secret.txt (Figure 8) and the fuzzing command shown in Figure 9 to other potentially valid directories revealed a new clue (Figure 10).

Press enter or click to view image in full size

Figure 9. GitHub page referenced in the secret.txt file

Press enter or click to view image in full size

Figure 10. New clue found within the file=location.txt path.

We ran Dirb again, this time targeting files with the .php extension. The scan showed two php files (Figure 11).

Figure 11. Files with the .php extension

After accessing image.php and appending the clue from Figure 10 to the URL path, we tested various inputs to see if the server would load arbitrary files.

Press enter or click to view image in full size

Figure 12. Server loads files without validation

The output provided above in Figure 12 confirmed the presence of a local file inclusion (LFI) vulnerability that allowed to see the list of user account information. This happened because the web app let us control the file path it used to load files, without validating the input.

Get _m1le5’s stories in your inbox

Join Medium for free to get updates from this writer.

Remember me for faster sign in

We then used curl to retrieve the file and display its contents in a more readable format.

Press enter or click to view image in full size

Figure 13. curl for clearer output

We came across two user accounts on the system: Viktor and Saket.

Figure 14. Users Viktor and Saket

With Saket’s information and again some trial-and-error on the site, revealed a valid path containing a password-like string (Figure 15).

Press enter or click to view image in full size

Figure 15. Suspected string

With the target SSH port open, we attempted to authenticate as user ‘Saket,’ but the string provided as hint was invalid for SSH login.

But, using the same string as the password for the user ‘victor’ granted us access to the Wordpress platform (Figures 15 and 16).

Press enter or click to view image in full size

Figure 15. WordPress login page

Press enter or click to view image in full size

Figure 16. WordPress portal

We searched for writable files to inject a payload and found secret.php (Figure 17), which could allow us to add a snippet for code execution.

Press enter or click to view image in full size

Figure 17. secret.php file

We located a suitable reverse-shell script among Kali’s bundled webshells (Figure 18), edited its target IP with vim to point at our machine (Figure 19), and launched a listener to catch the incoming connection (Figure 20).

Press enter or click to view image in full size

Figure 18. Screenshot of the chosen PHP reverse-shell script

Press enter or click to view image in full size

Figure 19. IP updated to receive incoming connections
Figure 20. Listening incoming connections

We pasted the PHP reverse-shell code that was updated with our listener IP into secret.php on the WordPress site (Figure 21).

Press enter or click to view image in full size

Figure 21. Injected PHP reverse shell within secret.php

When the listener received no connection, we reviewed WordPress file-structure documentation (Figure 22) to see where the reverse-shell was stored on disk, then invoked that file via its disk path to trigger the callback.

Press enter or click to view image in full size

Figure 22. File system location where the reverse-shell was saved

Press enter or click to view image in full size

Figure 23. Reverse-shell connection established

After correcting the uploaded shell’s URL path, the reverse shell connected successfully (Figure 23).

Press enter or click to view image in full size

Figure 24. Ubuntu Version

Once we identified the target’s Ubuntu version (Figure 24), we used Searchsploit to find a matching local exploit (Figure 25), transferred the exploit to the target, and attempted privilege escalation.

Press enter or click to view image in full size

Figure 25. Ubuntu exploit

We served the exploit from an Apache host (Figure 26) downloaded it to the target via our existing access (Figures 27–28).

Press enter or click to view image in full size

Figure 26. Output indicating successful startup of the Apache server

Press enter or click to view image in full size

Figure 27. Server hosting the exploit

Press enter or click to view image in full size

Figure 28. Exploit download to target

Once the exploit was transferred and compiled with gcc (Figure 29), we executed the binary to escalate to root and capture the flag.

Press enter or click to view image in full size

Figure 29. Root privileges gained

文章来源: https://infosecwriteups.com/local-file-inclusion-vulnerability-9bdc382e389f?source=rss----7b722bfd1b8d---4
如有侵权请联系:admin#unsafe.sh