Abusing file inclusions and uploads
As we saw in the previous recipe, file inclusion vulnerabilities occur when developers use poorly validated input to generate file paths and use those paths to include source code files. Modern versions of server-side languages, such as PHP since 5.2.0, have disabled the ability to include remote files by default, so it has been less common to find an RFI since 2011.
In this recipe, we will first upload a malicious file, namely a webshell
(a web page capable of executing system commands in the server), and execute it using LFI.
Getting ready
In this recipe, we will upload a file to the server. We need to know where is it going to be stored in order to be able to access it via programming. To get the upload location, go to Upload
in DVWA and upload any JPG image. If the upload is successful, it will display the path to which it was uploaded (../../hackable/uploads/
). Now we know the relative path where the application saves the uploaded files; that's enough...