-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtea_decrypt.php
More file actions
113 lines (95 loc) · 3.29 KB
/
Copy pathtea_decrypt.php
File metadata and controls
113 lines (95 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?
function charsToLongs($_arg1)
{
$_local2 = array();
$_local3 = 0;
while ($_local3 < ceil((sizeof($_arg1) / 4)))
{
$_local2[$_local3] = ((($_arg1[($_local3 * 4)] + ($_arg1[(($_local3 * 4) + 1)] << 8)) + ($_arg1[(($_local3 * 4) + 2)] << 16)) + ($_arg1[(($_local3 * 4) + 3)] << 24));
$_local3++;
}
return ($_local2);
}
function longsToChars($_arg1)
{
$_local3 = 0;
while ($_local3 < sizeof($_arg1))
{
$_local2.=chr($_arg1[$_local3] & 0xFF).chr(($_arg1[$_local3] >> 8) & 0xFF).chr(($_arg1[$_local3] >> 16) & 0xFF).chr(($_arg1[$_local3] >> 24) & 0xFF);
$_local3++;
}
return ($_local2);
}
function _rshift($integer, $n){
// convert to 32 bits
if (0xffffffff < $integer || -0xffffffff > $integer){
$integer = fmod($integer, 0xffffffff + 1);
}
// convert to unsigned integer
if (0x7fffffff < $integer){
$integer -= 0xffffffff + 1.0;
}elseif (-0x80000000 > $integer){
$integer += 0xffffffff + 1.0;
}
// do right shift
if (0 > $integer){
$integer &= 0x7fffffff; // remove sign bit before shift
$integer >>= $n; // right shift
$integer |= 1 << (31 - $n); // set shifted sign bit
}else{
$integer >>= $n; // use normal right shift
}
return $integer;
}
function tea_decrypt($str,$key)
{
$_local5 = sizeof($str);
$_local6 = $str[($_local5 - 1)];
$_local7 = $str[0];
$_local8 = 2654435769;
$_local11 = (int)((6 + (52 / $_local5)));
$_local12 = ($_local11 * $_local8);
while ($_local12 != 0)
{
$_local10 = (($_local12 >> 2) & 3);
$_local14 = ($_local5 - 1);
while ($_local14 >= 0)
{
$_local6 = $str[((($_local14 > 0)) ? ($_local14 - 1) : ($_local5 - 1))];
$_local91 = (_rshift($_local6,5)^($_local7 << 2)) + (_rshift($_local7,3)^($_local6 << 4));
$_local92 = ($_local12^$_local7) + ($key[($_local14 & 3^$_local10)]^$_local6);
$_local9 = $_local91 ^ $_local92;
$_local7 = ($str[$_local14] = ($str[$_local14] - $_local9));
$_local14--;
}
$_local12 = ($_local12 - $_local8);
}
return longsToChars($str);
}
function transform_r2($r2)
{
$_local2 = "";
$_local3 = 0;
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMabcdefghijklmnopqrstuvwxyzabcdefghijklm";
while ($_local3 < strlen($r2))
{
$_local5 = $r2[$_local3];
if (strpos($chars,$_local5))
{
$_local5 = $chars[strpos($chars,$_local5) + 13];
}
$_local2.= $_local5;
$_local3++;
}
return $_local2;
}
/*
sample for 3dbuff
this._connection.call("rr", null, $decrypt);
*/
$r2 = "5n251623p7q688po5s9o89p8249so8oqs399r7os8982srs70852662qpq14r2409r6q58r8";
$r2 =charsToLongs(array_values(unpack("C*",pack("H*",transform_r2($r2)))));
$key=charsToLongs(array_values(unpack("C*",substr('92J3ax!077M6%.EZckS776^J$i8=}I',0,16))));
// 55a7b6f3-ba33-4596-8965-b46d2247ea51
$decrypt=tea_decrypt($r2,$key);
?>