Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 168 lines (144 sloc) 5.783 kb
d77354d9 »
2011-10-10 working draft
1 <?php
2
3 class Obfuscators {
4
5 /*
6 * Random Generators
7 */
8
9 public static function rand_tag_name() {
10 $tag_name = array ('p', 'div', 'b','u','i');
11 $count_tag_name = count($tag_name);
12
13 return $tag_name[rand(0, $count_tag_name-1)];
14 }
15
16 public static function get_random_string_array($len, $c) {
17 $srt_array = array();
18 for ($a = 0; $a <= $c; $a++) {
19 $result = "";
20 $nums = "1234567890";
21 $syms = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
22 $sux = $nums.$syms;
23 for ($i = 0; $i < $len; $i++) {
24 $num = rand(0, strlen($sux)-1);
25 $result .= $sux[ $num ];
26 }
27 $srt_array[] = $syms[rand(0,strlen($syms)-1)].$result;
28 }
29
30 return $srt_array;
31 }
32
33 /*
34 * Encryptions
35 */
36
37 public static function gen_key($len) {
38 $result = "";
39 $symb = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
40 for ($i = 0; $i < $len; $i++) {
41 $num = rand(0, strlen($symb)-1);
42 if (ereg($symb[ $num ],$result)) {
43 $i=$i-1;
44 } else {
45 $result .= $symb[ $num ];
46 }
47 }
48
49 return $result;
50 }
51
52 public static function mkcrypt($code,$rnd_split) {
53 $i = strlen($code);
54 for ($a=0;$a<$i;$a++) {
55 $csnc = ord($code[$a]);
56 $csnc--;
57 $res .= $csnc.$rnd_split;
58 }
59
60 return $res;
61 }
62
63 public static function crypt_with_key($orig,$key) {
64 for($l=0;$l<strlen($orig);$l++) {
65 $symb=$orig[$l];
66 $pos_in_key=strpos($key,$symb);
67 if($pos_in_key >= -1) {
68 if($pos_in_key==(strlen($key)-1)) {
69 $pos_in_key =-1;
70 }
71 $crypt .= $key[$pos_in_key+1];
72 } else {
73 $crypt.=$symb;
74 }
75 }
76
77 return $crypt;
78 }
79
80 public static function unescape($s) {
81 $out = "";
82 $res = strtoupper(bin2hex($s));
83 $g = round(strlen($res)/4);
84 if ($g != (strlen($res)/4)) $res.="00";
85 for ($i=0; $i<strlen($res);$i+=4) {
86 $out.="%u".substr($res,$i+2,2).substr($res,$i,2);
87 }
88
89 return $out;
90 }
91
92 public static function encrypt($original) {
93 $symb = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
94 $rnd_split = $symb[rand(0, strlen($symb) - 1)];
95 $original = Obfuscators::mkcrypt($original, $rnd_split);
96
97 $key = Obfuscators::gen_key(rand(40, 60));
98 $crypt = Obfuscators::crypt_with_key($original, $key);
99
100 $ii = 0;
101 while (strlen($crypt) > 0) {
102 $pos = rand(50, 590);
103 $var_array[$ii] = substr($crypt, 0, $pos);
104 $crypt = substr($crypt, $pos);
105 $ii++;
106 }
107
108 for ($ii = 0; $ii < count($var_array); $ii++) {
109 $rnd_div_name = Obfuscators::get_random_string_array(rand(2, 10), count($var_array));
110 $tag_name = Obfuscators::rand_tag_name();
111 if (rand(0, 3) == 0) $rn = " \r\n";
112 else $rn = "";
113 //$TESTECH.= $var_array[$ii];
114 $div_echo .= "<$tag_name id ='$rnd_div_name[$ii]'>".$var_array[$ii]."</".$tag_name.">".$rn;
115 if ($ii == (count($var_array) - 1)) {
116 $js_array .= '"'.$rnd_div_name[$ii].'"';
117 }
118 else {
119 $js_array .= '"'.$rnd_div_name[$ii].'",';
120 }
121 }
122 $div_echo = "<div style='display: none;'>".$div_echo."</div>";
123 $js_array = "new Array(".$js_array.");";
124
125 $rnd_nm_crypt = Obfuscators::get_random_string_array(rand(3, 10), 19);
126 $script_body = '';
127 $script_body .= "<script>";
128 $script_body .= "var $rnd_nm_crypt[10] = '';";
129 $script_body .= "var $rnd_nm_crypt[8] = $js_array";
130 $script_body .= "var $rnd_nm_crypt[12] = '';";
131 $script_body .= "function $rnd_nm_crypt[7]($rnd_nm_crypt[8],$rnd_nm_crypt[9]) {";
132 $script_body .= "return $rnd_nm_crypt[9] = document.getElementById($rnd_nm_crypt[8][$rnd_nm_crypt[9]]).innerHTML;}";
133 $script_body .= "function $rnd_nm_crypt[13] ($rnd_nm_crypt[14]) {";
134 $script_body .= "return String.fromCharCode($rnd_nm_crypt[14]);}";
135 $script_body .= "function decryptor($rnd_nm_crypt[15]) {";
136 $script_body .= "$rnd_nm_crypt[16] = $rnd_nm_crypt[15].split('$rnd_split');";
137 $script_body .= "for (var i=0;i<$rnd_nm_crypt[16].length-1;i++) {";
138 $script_body .= "$rnd_nm_crypt[16][i]++;";
139 $script_body .= "$rnd_nm_crypt[12] += $rnd_nm_crypt[13]($rnd_nm_crypt[16][i]);} return($rnd_nm_crypt[12]);}";
140 $script_body .= "function $rnd_nm_crypt[17]($rnd_nm_crypt[5]) {";
141 $script_body .= "var $rnd_nm_crypt[1],$rnd_nm_crypt[2],$rnd_nm_crypt[3],$rnd_nm_crypt[4] = '',";
142 $script_body .= "$rnd_nm_crypt[6] ='$key';";
143 $script_body .= "for($rnd_nm_crypt[1] = 0;$rnd_nm_crypt[1]<$rnd_nm_crypt[5].length;$rnd_nm_crypt[1]++){";
144 $script_body .= "$rnd_nm_crypt[2] = $rnd_nm_crypt[5].charAt($rnd_nm_crypt[1]);";
145 $script_body .= "$rnd_nm_crypt[3] = $rnd_nm_crypt[6].indexOf($rnd_nm_crypt[2]);";
146 $script_body .= "if($rnd_nm_crypt[3]>=0) {";
147 $script_body .= "if($rnd_nm_crypt[3] == 0){ $rnd_nm_crypt[3] = " . (strlen($key) - 1) . ";}";
148 $script_body .= "else { $rnd_nm_crypt[3] = $rnd_nm_crypt[3] -1;} $rnd_nm_crypt[4] += $rnd_nm_crypt[6].charAt($rnd_nm_crypt[3]);}";
149 $script_body .= "else { $rnd_nm_crypt[4] += $rnd_nm_crypt[2]; }};";
150
151 $script_body .= "xvx = decryptor($rnd_nm_crypt[4]); return xvx;}";
152 $script_body .= "var $rnd_nm_crypt[11] = $rnd_nm_crypt[8].length;";
153 $script_body .= "for ($rnd_nm_crypt[9] = 0; $rnd_nm_crypt[11] > $rnd_nm_crypt[9]; $rnd_nm_crypt[9]++) {var $rnd_nm_crypt[10] = $rnd_nm_crypt[10] + $rnd_nm_crypt[7]($rnd_nm_crypt[8],$rnd_nm_crypt[9]);}";
154 $script_body .= "var $rnd_nm_crypt[9] = $rnd_nm_crypt[17]($rnd_nm_crypt[10]);";
155 $script_body .= "var gogle=document; var yandex=document;";
156 $script_body .= "gogle.write('<scri'+'pt>');";
157 $script_body .= "yandex.write($rnd_nm_crypt[9]);";
158 $script_body .= "document.write('</sc'+'ript>');";
159 $script_body .= "</script>";
160
161 $script_body = str_replace("\r\n", ' ', $script_body);
162 $out = $div_echo.$script_body;
163
164 return $out;
165 }
166 }
167
168 ?>
Something went wrong with that request. Please try again.