Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
01c478e4
Commit
01c478e4
authored
Jan 29, 2020
by
jiahua.liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MsgSvc data packets
parent
933eb1c2
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
153 additions
and
487 deletions
+153
-487
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
...moe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
+1
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/Tlv.kt
.../net/mamoe/mirai/qqandroid/network/protocol/packet/Tlv.kt
+19
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/data/MsgSvc.kt
...rai/qqandroid/network/protocol/packet/chat/data/MsgSvc.kt
+3
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.GetMessage.kt
...ork/protocol/packet/chat/receive/MessageSvc.GetMessage.kt
+82
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt
...ork/protocol/packet/chat/receive/MessageSvc.PushNotify.kt
+12
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt
...ai/qqandroid/network/protocol/packet/login/LoginPacket.kt
+16
-6
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/TgtgtKey.kt
...onMain/kotlin/net/mamoe/mirai/qqandroid/utils/TgtgtKey.kt
+2
-1
mirai-core-qqandroid/src/jvmTest/kotlin/androidPacketTests/clientToServer.kt
...d/src/jvmTest/kotlin/androidPacketTests/clientToServer.kt
+0
-478
mirai-core-qqandroid/src/jvmTest/kotlin/test/SmsTest.kt
mirai-core-qqandroid/src/jvmTest/kotlin/test/SmsTest.kt
+18
-0
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
View file @
01c478e4
...
@@ -67,7 +67,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
...
@@ -67,7 +67,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
is
SMSVerifyCodeNeeded
->
{
is
SMSVerifyCodeNeeded
->
{
val
result
=
bot
.
configuration
.
loginSolver
.
onGetPhoneNumber
()
val
result
=
bot
.
configuration
.
loginSolver
.
onGetPhoneNumber
()
response
=
LoginPacket
.
SubCommand
7
(
response
=
LoginPacket
.
SubCommand
8
(
bot
.
client
,
bot
.
client
,
response
.
t174
,
response
.
t174
,
response
.
t402
,
response
.
t402
,
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/Tlv.kt
View file @
01c478e4
...
@@ -203,6 +203,25 @@ fun BytePacketBuilder.t174(
...
@@ -203,6 +203,25 @@ fun BytePacketBuilder.t174(
}
}
}
}
fun
BytePacketBuilder
.
t17a
(
value
:
Int
=
0
)
{
writeShort
(
0
x17a
)
writeShortLVPacket
{
writeInt
(
value
)
}
}
fun
BytePacketBuilder
.
t197
(
value
:
ByteArray
)
{
writeShort
(
0
x197
)
writeShortLVPacket
{
writeFully
(
value
)
}
}
fun
BytePacketBuilder
.
t19e
(
fun
BytePacketBuilder
.
t19e
(
value
:
Int
=
0
value
:
Int
=
0
)
{
)
{
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/data/MsgSvc.kt
View file @
01c478e4
...
@@ -2,7 +2,9 @@ package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.data
...
@@ -2,7 +2,9 @@ package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.data
import
kotlinx.serialization.SerialId
import
kotlinx.serialization.SerialId
import
kotlinx.serialization.Serializable
import
kotlinx.serialization.Serializable
import
net.mamoe.mirai.data.Packet
import
net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
import
net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
import
net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory
import
net.mamoe.mirai.qqandroid.network.protocol.protobuf.ProtoBuf
import
net.mamoe.mirai.qqandroid.network.protocol.protobuf.ProtoBuf
@Serializable
@Serializable
...
@@ -24,7 +26,7 @@ class MsgSvc : ProtoBuf {
...
@@ -24,7 +26,7 @@ class MsgSvc : ProtoBuf {
@SerialId
(
8
)
val
pubaccountCookie
:
ByteArray
=
EMPTY_BYTE_ARRAY
,
@SerialId
(
8
)
val
pubaccountCookie
:
ByteArray
=
EMPTY_BYTE_ARRAY
,
@SerialId
(
9
)
val
isPartialSync
:
Boolean
=
false
,
@SerialId
(
9
)
val
isPartialSync
:
Boolean
=
false
,
@SerialId
(
10
)
val
msgCtrlBuf
:
ByteArray
=
EMPTY_BYTE_ARRAY
@SerialId
(
10
)
val
msgCtrlBuf
:
ByteArray
=
EMPTY_BYTE_ARRAY
)
:
ProtoBuf
)
:
ProtoBuf
,
Packet
@Serializable
@Serializable
class
PbGroupMsgWithDrawReq
(
class
PbGroupMsgWithDrawReq
(
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.GetMessage.kt
0 → 100644
View file @
01c478e4
package
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive
import
kotlinx.io.core.ByteReadPacket
import
kotlinx.serialization.protobuf.ProtoBuf
import
net.mamoe.mirai.qqandroid.QQAndroidBot
import
net.mamoe.mirai.qqandroid.network.QQAndroidClient
import
net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
import
net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
import
net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory
import
net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgingPacket
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.data.Cmd0x352Packet
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.data.MsgSvc
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.data.RequestPushNotify
internal
object
GetMsgRequest
:
PacketFactory
<
MsgSvc
.
PbGetMsgResp
>(
"MessageSvc.PbGetMsg"
)
{
override
suspend
fun
ByteReadPacket
.
decode
(
bot
:
QQAndroidBot
):
MsgSvc
.
PbGetMsgResp
{
println
(
"received MsgSvc.PbGetMsgResp"
)
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
/**
@Serializable
class PbGetMsgReq(
@SerialId(1) val syncFlag: Int /* enum */
=
0
,
@SerialId
(
2
)
val
syncCookie
:
ByteArray
=
EMPTY_BYTE_ARRAY
,
@SerialId
(
3
)
val
rambleFlag
:
Int
=
1
,
@SerialId
(
4
)
val
latestRambleNumber
:
Int
=
20
,
@SerialId
(
5
)
val
otherRambleNumber
:
Int
=
3
,
@SerialId
(
6
)
val
onlineSyncFlag
:
Int
=
1
,
@SerialId
(
7
)
val
contextFlag
:
Int
=
0
,
@SerialId
(
8
)
val
whisperSessionId
:
Int
=
0
,
@SerialId
(
9
)
val
msgReqType
:
Int
=
0
,
@SerialId
(
10
)
val
pubaccountCookie
:
ByteArray
=
EMPTY_BYTE_ARRAY
,
@SerialId
(
11
)
val
msgCtrlBuf
:
ByteArray
=
EMPTY_BYTE_ARRAY
,
@SerialId
(
12
)
val
serverBuf
:
ByteArray
=
EMPTY_BYTE_ARRAY
)
:
ProtoBuf
@Serializable
internal
class
RequestPushNotify
(
@SerialId
(
0
)
val
uin
:
Long
=
0L
,
@SerialId
(
1
)
val
ctype
:
Byte
=
0
,
@SerialId
(
2
)
val
strService
:
String
?,
@SerialId
(
3
)
val
strCmd
:
String
?,
@SerialId
(
4
)
val
vNotifyCookie
:
ByteArray
?
=
EMPTY_BYTE_ARRAY
,
@SerialId
(
5
)
val
usMsgType
:
Int
?,
@SerialId
(
6
)
val
wUserActive
:
Int
?,
@SerialId
(
7
)
val
wGeneralFlag
:
Int
?,
@SerialId
(
8
)
val
bindedUin
:
Long
?,
@SerialId
(
9
)
val
stMsgInfo
:
MsgInfo
?,
@SerialId
(
10
)
val
msgCtrlBuf
:
String
?,
@SerialId
(
11
)
val
serverBuf
:
ByteArray
?,
@SerialId
(
12
)
val
pingFlag
:
Long
?,
@SerialId
(
13
)
val
svrip
:
Int
?
)
:
JceStruct
,
Packet
*/
operator
fun
invoke
(
client
:
QQAndroidClient
,
notify
:
RequestPushNotify
):
OutgoingPacket
=
buildOutgingPacket
(
client
,
key
=
client
.
wLoginSigInfo
.
d2Key
)
{
val
req
=
MsgSvc
.
PbGetMsgReq
(
serverBuf
=
notify
.
serverBuf
?:
EMPTY_BYTE_ARRAY
,
msgReqType
=
notify
.
usMsgType
?:
0
,
syncFlag
=
0
,
rambleFlag
=
0
,
contextFlag
=
1
,
latestRambleNumber
=
20
,
otherRambleNumber
=
3
,
onlineSyncFlag
=
1
)
val
data
=
ProtoBuf
.
dump
(
MsgSvc
.
PbGetMsgReq
.
serializer
(),
req
)
writeInt
(
data
.
size
)
writeFully
(
data
,
0
,
data
.
size
)
}
}
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt
View file @
01c478e4
...
@@ -8,9 +8,12 @@ import net.mamoe.mirai.qqandroid.QQAndroidBot
...
@@ -8,9 +8,12 @@ import net.mamoe.mirai.qqandroid.QQAndroidBot
import
net.mamoe.mirai.qqandroid.io.JceStruct
import
net.mamoe.mirai.qqandroid.io.JceStruct
import
net.mamoe.mirai.qqandroid.io.serialization.loadAs
import
net.mamoe.mirai.qqandroid.io.serialization.loadAs
import
net.mamoe.mirai.qqandroid.io.serialization.readRemainingAsJceStruct
import
net.mamoe.mirai.qqandroid.io.serialization.readRemainingAsJceStruct
import
net.mamoe.mirai.qqandroid.network.QQAndroidClient
import
net.mamoe.mirai.qqandroid.network.protocol.jce.RequestDataVersion2
import
net.mamoe.mirai.qqandroid.network.protocol.jce.RequestDataVersion2
import
net.mamoe.mirai.qqandroid.network.protocol.jce.RequestPacket
import
net.mamoe.mirai.qqandroid.network.protocol.jce.RequestPacket
import
net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
import
net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory
import
net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.data.MsgSvc
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.data.RequestPushNotify
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.data.RequestPushNotify
import
net.mamoe.mirai.utils.cryptor.contentToString
import
net.mamoe.mirai.utils.cryptor.contentToString
import
net.mamoe.mirai.utils.firstValue
import
net.mamoe.mirai.utils.firstValue
...
@@ -35,9 +38,18 @@ class MessageSvc {
...
@@ -35,9 +38,18 @@ class MessageSvc {
println
(
requestPushNotify
.
contentToString
())
println
(
requestPushNotify
.
contentToString
())
with
(
bot
.
network
)
{
GetMsgRequest
(
bot
.
client
,
requestPushNotify
).
sendAndExpect
<
MsgSvc
.
PbGetMsgResp
>()
}
return
requestPushNotify
return
requestPushNotify
}
}
}
}
}
}
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt
View file @
01c478e4
...
@@ -46,7 +46,7 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>("wt
...
@@ -46,7 +46,7 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>("wt
}
}
}
}
object
SubCommand
7
{
object
SubCommand
8
{
private
const
val
appId
=
16L
private
const
val
appId
=
16L
private
const
val
subAppId
=
537062845L
private
const
val
subAppId
=
537062845L
...
@@ -59,16 +59,26 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>("wt
...
@@ -59,16 +59,26 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>("wt
):
OutgoingPacket
=
buildLoginOutgoingPacket
(
client
,
bodyType
=
2
)
{
sequenceId
->
):
OutgoingPacket
=
buildLoginOutgoingPacket
(
client
,
bodyType
=
2
)
{
sequenceId
->
writeSsoPacket
(
client
,
subAppId
,
commandName
,
sequenceId
=
sequenceId
)
{
writeSsoPacket
(
client
,
subAppId
,
commandName
,
sequenceId
=
sequenceId
)
{
writeOicqRequestPacket
(
client
,
EncryptMethodECDH7
(
client
.
ecdh
),
0
x0810
)
{
writeOicqRequestPacket
(
client
,
EncryptMethodECDH7
(
client
.
ecdh
),
0
x0810
)
{
writeShort
(
7
)
// subCommand
writeShort
(
8
)
// subCommand
writeShort
(
7
)
// count of TLVs, probably ignored by server?TODO
writeShort
(
6
)
// count of TLVs, probably ignored by server?TODO
t8
(
2052
)
t8
(
2052
)
t104
(
client
.
t104
)
t104
(
client
.
t104
)
t116
(
150470524
,
66560
)
t116
(
150470524
,
66560
)
t174
(
t174
)
t174
(
t174
)
t17c
(
phoneNumber
.
toByteArray
())
t17a
(
9
)
t401
(
md5
(
client
.
device
.
guid
+
"1234567890123456"
.
toByteArray
()
+
t402
))
t197
(
byteArrayOf
(
0
.
toByte
()))
t19e
(
0
)
//==tlv408
//t401(md5(client.device.guid + "12 34567890123456".toByteArray() + t402))
//t19e(0)//==tlv408
}
}
/**
*
* 0x00000008(8)=00 00 00 00 08 04 00 00,//2052固定
0x00000104(260)=41 69 78 39 46 68 4E 44 6C 41 42 30 54 79 46 30 4B 36 67 78 37 45 6E 2B 30 7A 39 35 65 35 30 6E 66 41 3D 3D,//服务器给的tv104
0x00000116(278)=00 08 F7 FF 7C 00 01 04 00 01 5F 5E 10 E2//116(this.mMiscBitmap, this.mSubSigMap, var10._sub_appid_list)
0x00000174(372)=45 66 43 39 46 4B 63 70 47 30 5F 5A 55 41 4F 6A 4E 4C 6F 72 56 30 77 66 4B 67 49 4D 33 33 6E 58 44 37 5F 4B 61 75 56 6D 4F 6F 54 68 6A 64 38 62 72 44 64 69 5F 62 48 51 5A 66 37 6E 4F 6B 78 43 35 6E 47 4E 38 6B 6A 35 39 6D 37 32 71 47 66 78 4E 76 50 51 53 39 33 66 37 6B 72 71 66 71 78 63 5F//服务器给的tv174
0x0000017A(378)=00 00 00 09, //9 固定
0x00000197(407)=00//固定
*/
}
}
}
}
}
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/TgtgtKey.kt
View file @
01c478e4
...
@@ -4,4 +4,5 @@ import net.mamoe.mirai.utils.io.getRandomByteArray
...
@@ -4,4 +4,5 @@ import net.mamoe.mirai.utils.io.getRandomByteArray
import
net.mamoe.mirai.utils.md5
import
net.mamoe.mirai.utils.md5
fun
generateTgtgtKey
(
guid
:
ByteArray
):
ByteArray
=
fun
generateTgtgtKey
(
guid
:
ByteArray
):
ByteArray
=
md5
(
getRandomByteArray
(
16
)
+
guid
)
md5
(
getRandomByteArray
(
16
)
+
guid
)
\ No newline at end of file
mirai-core-qqandroid/src/jvmTest/kotlin/androidPacketTests/clientToServer.kt
deleted
100644 → 0
View file @
933eb1c2
This diff is collapsed.
Click to expand it.
mirai-core-qqandroid/src/jvmTest/kotlin/test/SmsTest.kt
0 → 100644
View file @
01c478e4
package
test
import
kotlinx.io.core.ByteReadPacket
import
net.mamoe.mirai.utils.cryptor.contentToString
import
net.mamoe.mirai.utils.io.hexToBytes
import
net.mamoe.mirai.utils.io.readTLVMap
import
net.mamoe.mirai.utils.io.toIoBuffer
fun
main
(){
//server to client
val
s2c
=
"01 46 00 33 00 00 00 A3 00 0F E9 AA 8C E7 9F AD E4 BF A1 E5 A4 B1 E8 B4 A5 00 18 E9 AA 8C E8 AF 81 E7 A0 81 E8 BE 93 E5 85 A5 E9 94 99 E8 AF AF E3 80 82 00 00 00 00 05 08 00 22 01 00 00 0B B8 00 1B 02 00 00 00 10 20 02 ED BD 08 10 00 00 00 A3 00 00 00 00 3E 03 3F A2 00 00 00 A3"
.
hexToBytes
().
toIoBuffer
().
readTLVMap
()
//client to server
val
c2s
=
"00 08 00 08 00 00 00 00 08 04 00 00 01 04 00 24 41 69 78 39 46 68 4E 44 6C 41 42 30 54 79 46 30 4B 36 67 78 37 45 6E 2B 30 7A 39 35 65 35 30 6E 66 41 3D 3D 01 16 00 0E 00 08 F7 FF 7C 00 01 04 00 01 5F 5E 10 E2 01 74 00 61 45 66 43 39 46 4B 63 70 47 30 5F 5A 55 41 4F 6A 4E 4C 6F 72 56 30 77 66 4B 67 49 4D 33 33 6E 58 44 37 5F 4B 61 75 56 6D 4F 6F 54 68 6A 64 38 62 72 44 64 69 5F 62 48 51 5A 66 37 6E 4F 6B 78 43 35 6E 47 4E 38 6B 6A 35 39 6D 37 32 71 47 66 78 4E 76 50 51 53 39 33 66 37 6B 72 71 66 71 78 63 5F 01 7A 00 04 00 00 00 09 01 97 00 01 00"
.
hexToBytes
().
toIoBuffer
().
readTLVMap
()
println
(
s2c
.
contentToString
())
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment