Advertisement
Guest User

Duetro's submission - Skript Challenge (Deobfuskator 1.0))

a guest
May 7th, 2018
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.50 KB | None | 0 0
  1. function script_looksvalid($code) {
  2.     $code = str_replace("\t", ' ', $code);
  3.     $keywords = [' set ', ' add ', 'command ', ' trigger:', ' else', ' if ', ' send ', ' message ', 'every ', 'loop ', ' player ', ' to ', 'on '];
  4.  
  5.     foreach ($keywords as $word) {
  6.         if (stripos($code, $word) !== false) {
  7.             return true;
  8.         }
  9.     }
  10.     return false;
  11. }
  12.  
  13. function deobfuscate($code) {
  14.     $read = false;
  15.     $options = null;
  16.     $code = str_replace("\r", null, $code);
  17.  
  18.     foreach (explode(PHP_EOL, $code) as $line) {
  19.         if (($line == 'options:') && ($read == false)) {
  20.             $read = true;
  21.             $code = str_replace($line, null, $code);
  22.  
  23.         } else if ($read == true) {
  24.             if ((strpos($line, ' ') === 0) || (strpos($line, "\t") === 0)) {
  25.                 $option = explode(': ', trim($line), 2);
  26.                 $options['{@' . $option[0] . '}'] = $option[1];
  27.                 $code = str_replace($line.PHP_EOL, '', $code);
  28.                
  29.             } else {
  30.                 $read = false;
  31.  
  32.             }
  33.         }
  34.     }
  35.     if (is_array($options)) {
  36.         $temp_keys = array_map('strlen', array_keys($options));
  37.         array_multisort($temp_keys, SORT_DESC, $options);
  38.         $code = str_replace(array_keys($options), array_values($options), $code);
  39.  
  40.         if (!script_looksvalid($code)) {
  41.             $notice['warning'] = 'This code doesn\'t look like valid script code. Are you sure this is a script that has been obfuscated using <b>Deobfuskator</b>?';
  42.         }
  43.     } else {
  44.         $notice['error'] = 'Oops! Something went wrong while reading the file. Are you sure that this is a script that has been obfuscated using <b>Deobfuskator</b>? (ERR1)';
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement