|
发表于 2009-9-21 20:52:10
|显示全部楼层
当抓到[url=http://www.52wpe.net]私服[/url]的数据包(本人用的是Sniffer Pro),用以下办法解读:
一般[url=http://www.52wpe.net]私服[/url]的数据包开始为#,结束为!,由于时间不足,只能推算出数据区的算法。控制区的协议还未验证。
举例
#5<<<<<ITG<<<<<<<<TRA]TRA]TRA]TRA]TRA]TRA]TRA]TRA]TRA]TL!
这个包为说话,首先找到4xN得对齐位,也就是
#5<<<<<ITG<<<<<<<<TRA]TRA]TRA]TRA]TRA]TRA]TRA]TRA]TRA]TL!
__________________^这里
不难看出,TRA]对应 54 52 41 5D
从我的密码表中按顺序找到一位区码,和另外3个字节,明显这4字节包含3个字,"aaa"
而汉字属于高位字节,需要用unicode解码,可能比较困难。
以上对应表为推算结果,可以读出[url=http://www.52wpe.net]私服[/url]的加密内容,并且可以按原办法反推回去,不过还有部分区域有错,可以用[url=http://www.52wpe.net]私服[/url]说标志性的话抓包来进行分析。
我时间不多,最多做到这里,希望能给大家帮助,谢谢。
声明:我本人并不是一个[url=http://www.52wpe.net]私服[/url]玩家,我对[url=http://www.52wpe.net]私服[/url]并不感兴趣,只是应朋友的要求才尝试破解[url=http://www.52wpe.net]私服[/url]的加密协议。如果有什么纰漏请大家指正,如果是[url=http://www.52wpe.net]私服[/url]玩家,不懂加密算法的请不要联系我,谢谢。如果有机会和时间我会尝试破解其他网络游戏的通讯协议。我的以上做法并不是对[url=http://www.52wpe.net]私服[/url]的公司蓄意的破坏和攻击,只是无聊间随便练习一下逃课时学习的知识。
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
加密部分
function Encode(source : string):string;
var
Source_Len,Len : integer;
Count,c : integer;
a1,a2 : byte;
ind : dword;
Encode_Str : string;
begin
Result := '';
Encode_Str := '';
Len := 0;
a1 := 0;
a2 := 0;
c := 0;
ind := 0;
Count := 0;
Source_Len := Length(source);
while Count < Source_Len do
begin
if Len >= $2710 then
break;
ind := ord(source[Count+1]);
ind := ind shr (c+2);
a1 := ind or a2;
a1 := a1 and $3f;
ind := ord(source[Count+1]);
ind := ind shl (8-(c+2));
ind := ind shr 2;
a2 := ind and $3f;
inc(c,2);
if c >= 6 then
begin
if Len >= $270f then
begin
Encode_Str := Encode_Str + chr(a1 + $3c);
inc(Len);
end
else
begin
Encode_Str := Encode_Str + chr(a1 + $3c);
Encode_Str := Encode_Str + chr(a2 + $3c);
Inc(Len,2);
end;
c := 0;
a2 := 0;
end
else
begin
Encode_Str := Encode_Str + chr(a1 + $3c);
Inc(Len);
end;
inc(Count);
end;
if c > 0 then
begin
Encode_Str := Encode_Str + chr(a2 + $3c);
Inc(Len);
end;
SetLength(Encode_Str,Len);
Result := Encode_Str;
end;
解密部分
function Decode(source : string):string;
var
Source_Len,Len : integer;
Count,c1,c2 : integer;
code : array[0..7] of byte;
a1,a2 : byte;
ind : dword;
Decode_Str : string;
label L1,L2;
begin
Result := '';
Decode_Str := '';
code[2] := $fc;
code[4] := $f0;
code[6] := $c0;
Len := 0;
a1 := 0;
a2 := 0;
c1 := 2;
c2 := 0;
ind := 0;
Count := 0;
Source_Len := Length(source);
while (Count < Source_Len) do
begin
if(ord(Source[Count+1]) - $3c) < 0 then
begin
Decode_Str := Decode_Str + Source[Count+1];
inc(Len);
inc(Count);
a1 := 0;
a2 := 0;
c1 := 2;
c2 := 0;
ind := 0;
Continue;
file://break;
end;
a1 := ord(Source[Count+1]) - $3c;
if Len >= Source_Len then
begin
break;
end;
if (c2 + 6) < 8 then
begin
goto L2;
end;
ind := a1 and $3f;
ind := ind shr (6-c1);
Decode_Str := Decode_Str + chr(ind or a2);
Inc(Len);
c2 := 0;
if c1 >= 6 then
begin
c1 := 2;
goto L1;
end;
inc(c1,2);
L2 :a2 := a1 shl c1;
a2 := a2 and code[c1];
c2 := c2 + (8 - c1);
L1 :inc(count);
end;
SetLength(Decode_Str,Len);
Result := Decode_Str;
end;
是Delphi写的,应该不难懂。
至于算法部分,不要问为什么,反正可以用就好 |
|