package qqlive;
import
qqbrower.GzipUtils;
import
java.io.
File
;
import
java.io.FileInputStream;
import
java.io.FileNotFoundException;
import
java.io.IOException;
import
java.nio.ByteBuffer;
public
class
main {
private static final
int
CMD
=
65281
;
private String bytesToHex(byte[] bytes) {
StringBuilder sb
=
new StringBuilder();
for
(byte b : bytes) {
sb.append(String.
format
(
"%02x"
, b));
}
System.out.println(sb.toString());
return
sb.toString();
}
private static byte[] getJceDataFromBuffer(byte[] bArr, boolean z,
int
i,
int
[] iArr) {
bArr
=
GZIP.Decode(bArr);
ByteBuffer wrap
=
ByteBuffer.wrap(bArr);
int
position
=
wrap.position()
+
16
;
int
length
=
(bArr.length
-
position)
-
1
;
if
(length <
=
0
) {
iArr[
0
]
=
-
869
;
return
null;
}
byte[] bArr2
=
new byte[length];
System.arraycopy(bArr, position, bArr2,
0
, length);
return
bArr2;
}
public static byte[] decodeUnifiedResponse(byte[] bArr,
int
[] iArr) {
boolean z;
if
(bArr
=
=
null || bArr.length
=
=
0
) {
return
null;
}
ByteBuffer wrap
=
ByteBuffer.wrap(bArr);
if
(wrap.get() !
=
19
|| wrap.getInt() !
=
bArr.length) {
return
null;
}
wrap.getShort();
if
((wrap.getShort() &
65535
) !
=
CMD) {
return
null;
}
wrap.getShort();
int
i
=
wrap.getShort() &
65535
;
if
(i !
=
0
) {
iArr[
0
]
=
i;
return
null;
}
wrap.getLong();
int
i2
=
wrap.getInt();
if
((i2 &
2
) <
=
0
) {
z
=
false;
}
else
if
((i2 &
16
) >
0
) {
z
=
true;
}
else
{
iArr[
0
]
=
-
867
;
return
null;
}
if
(wrap.getInt()
=
=
5
) {
return
null;
}
wrap.getLong();
wrap.position(wrap.position()
+
32
);
wrap.get();
wrap.position(wrap.position()
+
10
);
wrap.get();
wrap.position(wrap.position()
+
(wrap.getShort() &
65535
));
int
i3
=
65535
& wrap.getShort();
wrap.position(wrap.position()
+
i3);
int
i4
=
83
+
i3
+
2
;
int
i5
=
wrap.getInt();
int
i6
=
i4
+
4
;
if
(wrap.get(bArr.length
-
1
) !
=
3
) {
iArr[
0
]
=
-
869
;
return
null;
}
int
length
=
(bArr.length
-
i6)
-
1
;
if
(length <
=
0
) {
iArr[
0
]
=
-
868
;
return
null;
}
byte[] bArr2
=
new byte[length];
System.arraycopy(bArr, i6, bArr2,
0
, length);
return
getJceDataFromBuffer(bArr2, z, i5, iArr);
}
public static void main(String[] args) throws IOException {
File
file
=
new
File
(
"C:\\mycode\\javatools\\src\\main\\java\\qqlive\\acc25196"
);
FileInputStream inputStream
=
new FileInputStream(
file
);
byte[] bytes
=
new byte[(
int
)
file
.length()];
inputStream.read(bytes);
main tsmain
=
new main();
int
[] iArr
=
new
int
[
1
];
main.decodeUnifiedResponse(bytes, iArr);
tsmain.bytesToHex( main.decodeUnifiedResponse(bytes, iArr));
}
}