From 0f1328ef00b21640756f294382f71e6a6ee6e206 Mon Sep 17 00:00:00 2001 From: Him188 Date: Tue, 7 Jan 2020 14:56:46 +0800 Subject: [PATCH] Add protocol overview --- .../qqandroid/network/protocol/README.md | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/README.md diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/README.md b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/README.md new file mode 100644 index 000000000..cac694de7 --- /dev/null +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/README.md @@ -0,0 +1,115 @@ +# QQAndroid Protocol + +## Overview + +Note: `head` and `body` functions does nothing. They just work as +notations + +PseudoCode: +``` +OutgoingPacket { + head { + int remaining.length + 4 + int 0x0A + byte 0x02 + int extra data size + 4 + byte[] extra data // initially={} + byte 0 + int uinAccount.length + 4 + byte[] uinAccount // =qqNumber.toString() + } + body { // encrypted by `ByteArray(16)` when login, after which by sessionKey + SSOPacket { + int head.size + 4 + head { + int sequenceId + int subAppId + int subAppId + hex "01 00 00 00 00 00 00 00 00 00 01 00" // unknown values + int extraData.size + 4 + byte[] extraData + int commandName.length + 4 + byte[] commandName + int 4 + 4 + int 0x02B05B8B + int imei.length + 4 + byte[] imei + int 0 + 4 + int ksid.length + 4 + byte[] ksid + int 0 + 4 + } + + int body.size + 4 + body { + OicqRequestPacket { + head { + byte 2 // head flag + short 27 + 2 + remaining.length + ushort client.protocolVersion // const 8001 + ushort 0x0001 + uint client.account.id + byte 3 // const + ubyte encryptMethod.value // [EncryptMethod] + byte 0 // const + int 2 // const + int client.appClientVersion + int 0 // const + } + + body { + // only write one of the following two structures!! + + // if encryption method is ECDH + EncryptionMethodECDH { + head { + byte 1 + byte 1 + byte[] [ECDH.privateKey] + short 258 + short [ECDH.publicKey].size // always 49 + byte[] [ECDH.publicKey] + } + + body { + // real body + } + } + + // if encryption method is SessionKey + EncryptionMethodSessionKey { + head { + byte 1 + byte if (currentLoginState == 2) 3 else 2 + fully key + short 258 + short 0 + } + + body { + // real body + } + } + } + tail { + byte 3 // tail flag + } + } + } + } + } +} +``` + +## Packet bodies + +### LoginPacket - SubCommand 9 +**TO BE UPDATED** + +PseudoCode: +``` +short 9 // subCommand +tlvList { + +} +```