You should check Path traversal Theory ๐ต
Nice articcles to read
Classic ones
- If you find the php code with the filter like:
- You can just apply a filter like:
http://mafialive.thm/test.php?view=/var/www/html/development_testing/..//..//..//..//../etc/passwd
Adding parameter file to url
- Linux File Inclussion
- Check the
url
adding parameterfile
- Check the
Fuzzing it
- FUZZ it using this command:
Bypassing filters with encodings
- If the backend is filtering by checking the input, try this:
- Check out the &ext variable and put it empty because it wonโt get the file extension
Log poisoning
-
To perform this, first check out if you have access to the log file in an apache with Burpsuite:
-
Log file contamination
Exploiting the User-Agent field
- Exploit the User-Agent Field:
- First create a shell like the PentestMonkey one
- Create a python server
- Load the petition (like log file contamination petition) and capture it with BurpSuite
- Modify the User-Agent field with this command:
- Then access to
http://IP/shell.php
and you got the reverse shell
Regex filtering
When we can echo commands try and itโs using a regex like: /[#!@%^&*()$_=\[\]\';,{}:>?~\\\\]/
try:
Web filtering
If a web shell filters your input, try to encode it into base64
- If it doesnโt work, try some Command Injection ๐
XML file inclusion (XXE)
-
Detailed info about XXE in Portswiger.net
-
If a web accepts XML, it could be vulnerable to XXE.
-
You can try to upload a code like this to inspect the system:
- Change the
"file:///etc/passwd"
for the one you want
Lfi to RCE
If you can read some files by some kind of escape, we can bruteforce the /proc/self/
directory in Apache.
This directory holds information about different processes. Each process is distinguished by its PID as shown below:
Every process can access its available information by requesting theย /proc/self
ย directory.
As Apache is requesting this file (via the LFI vulnerability) and since the file is located inside Apacheโs proc directory, we can useย /proc/self
ย instead of searching for Apacheโs PID. In a brief recap we could say thatย /proc/self/environ
ย is โ roughly- equal toย /proc/<apache_pid>/environ
.
The contents of this directory areย symbolic linksย pointing to the actual file of the processโ open file handlers:
It goes without saying that during the attack we do not know which symbolic link points to which file. The file we will be interested in is the Apacheย access log. We choose this file as itโs dynamic and can be changed based on our input.
To identify the file, we will use Burp Intruder.
First, we set up the position of our payload.
As File Descriptors are identified by a numeric id, we choose the proper payload.ย
Payloads > Payload type: Numbers
A successfull attack should look like:
Now we would perform a Log Poisoning attack.
Path traversal
- Nice tool to use (automatic tool): PathTraversal
Example:
Otherwise, if you want to do it manual you can use BurpSuite and try some combinations.
Blind OS command injection
If youโve got this kind of request:
Use the following payload: