Advertisement
Underworld1337

obfuscation-class

Nov 29th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.45 KB | None | 0 0
  1. <?php
  2. /**
  3.   * s=(rot13)%{if num}[SALT](rot5){else}(rot13)[EXPLODER](rot13)%{if num}[SALT](rot5){else}(rot13) ...
  4.   **/
  5.  
  6. class obfuscation
  7. {
  8.     private $request;
  9.     private $equal;
  10.     private $int_salt;
  11.     private $exploder;
  12.     private $debugging;
  13.    
  14.     public function __construct()
  15.     {
  16.         if(isset($_GET['s']))
  17.             $this->request = $_GET['s'];
  18.         else
  19.             $this->request = "";
  20.        
  21.         $this->equal = md5("hahaha");
  22.         $this->int_salt = "999999";
  23.         $this->exploder = "gghztfjafdsg";
  24.         $this->debugging = array();
  25.     }
  26.    
  27.     public function getDebuginfo(){
  28.         $ret = "";
  29.         foreach($this->debugging as $x){
  30.             $ret .= $x;
  31.         }
  32.         return $ret;
  33.     }
  34.    
  35.     // buggy
  36.     private function rot5($str, $n=5){
  37.         $replace = [];
  38.         for($i=0;$i<26;$i++){
  39.             $replace[chr(65+$i)] = chr(65+(($i+$n)%26));
  40.             $replace[chr(97+$i)] = chr(97+(($i+$n)%26));
  41.         }
  42.         return strtr($str, $replace);
  43.     }
  44.    
  45.     public function encode($link)
  46.     {
  47.         $e = explode('?', $link);
  48.         $f = $e[0];
  49.         $p = explode('&', $e[1]);
  50.         unset($e);
  51.         $arr = array();
  52.         foreach($p as $part){
  53.             $e = explode('=', $part);
  54.             $param = $e[0];
  55.             $value = $e[1];
  56.             unset($e);
  57.             if(is_numeric($value))
  58.                 $nval = "" . $this->int_salt . "" . self::rot5($value) . "";
  59.             else
  60.                 $nval = str_rot13($value);
  61.            
  62.             $arr[] = "" . str_rot13($param) . "" . $this->equal . "" . $nval . "";
  63.         }
  64.         $crypted = implode($this->exploder, $arr);
  65.         $out = $f . "?s=" . $crypted . "";
  66.         return $out;
  67.     }
  68.    
  69.     public function decode($debug = false)
  70.     {
  71.         $e = explode($this->exploder, $this->request);
  72.         foreach($e as $p){
  73.             $c = explode($this->equal, $p);
  74.             $pa = str_rot13($c[0]);
  75.             if(is_numeric($c[1])){
  76.                 $re = "";
  77.                 $va = str_replace($this->int_salt, $re, $c[1]);
  78.                 $va = self::rot5($va);
  79.             }else{
  80.                 $va = str_rot13($c[1]);
  81.             }
  82.             $_GET[$pa] = $va;
  83.             if($debug)
  84.                 $this->debugging[] = " " . $pa . " => " . $va . ",<br>";
  85.             //array_push($_GET,array($pa => $va));
  86.         }
  87.         return $_GET;
  88.     }
  89.  
  90. }
  91. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement