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
3f30bb4d
Commit
3f30bb4d
authored
Oct 22, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Image uploading is now available
parent
cfd5b2e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
17 deletions
+67
-17
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/UploadGroupImage.kt
...moe.mirai/network/protocol/tim/packet/UploadGroupImage.kt
+60
-15
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/HexComparator.kt
...src/jvmMain/kotlin/net/mamoe/mirai/utils/HexComparator.kt
+4
-0
mirai-debug/src/main/java/PacketDebuger.kt
mirai-debug/src/main/java/PacketDebuger.kt
+3
-2
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/UploadGroupImage.kt
View file @
3f30bb4d
...
@@ -113,22 +113,45 @@ class GroupImageIdRequestPacket(
...
@@ -113,22 +113,45 @@ class GroupImageIdRequestPacket(
// 80 01 00
// 80 01 00
/*
//00 00 00 07 00 00 00
// 5B 08 01 12 03 98 01 01 10 01 1A
// 57
// 08 A0 89 F7 B6 03
// 10 A2 FF 8C F0 03
// 18 00
// 22 10 39 F7 65 32 E1 AB 5C A7 86 D7 A5 13 89 22 53 85
// 28 90 23
// 32 1A
// 28 00 52 00 49 00 5F 00 36 00 31 00 28 00 32 00 52 00 59 00 4B 00 59 00 43 00
// 38 01
// 48 01
// 50 2D
// 58 2D
// 60 03
// 6A 05 32 36 39 33 33
// 70 00
// 78 03
// 80 01 00
writeQQ
(
bot
)
writeQQ
(
bot
)
writeHex(TIMProtocol.version0x04)
writeHex
(
"04 00 00 00 01 01 01 00 00 68 20 00 00 00 00 00 00 00 00"
)
//writeHex(TIMProtocol.version0x02)
encryptAndWrite
(
sessionKey
)
{
encryptAndWrite
(
sessionKey
)
{
writeHex
(
"00 00 00 07 00 00 00"
)
writeHex
(
"00 00 00 07 00 00 00"
)
writeUVarintLVPacket {
writeUVarintLVPacket
(
lengthOffset
=
{
it
-
6
})
{
writeByte
(
0
x08
)
writeByte
(
0
x08
)
writeHex
(
"01 12 03 98 01 01 10 01 1A"
)
writeHex
(
"01 12 03 98 01 01 10 01 1A"
)
writeUVarintLVPacket(lengthOffset = { it +
7
}) {
writeUVarintLVPacket
(
lengthOffset
=
{
it
+
1
})
{
writeTUVarint
(
0
x08u
,
groupId
)
writeTUVarint
(
0
x08u
,
groupId
)
writeTUVarint
(
0
x10u
,
bot
)
writeTUVarint
(
0
x10u
,
bot
)
writeTV
(
0
x1800u
)
writeTV
(
0
x1800u
)
writeTLV(0x22u, image.md5)
writeUByte
(
0
x22u
)
writeUByte
(
0
x10u
)
writeFully
(
image
.
md5
)
writeTUVarint
(
0
x28u
,
image
.
fileSize
.
toUInt
())
writeTUVarint
(
0
x28u
,
image
.
fileSize
.
toUInt
())
writeUVarintLVPacket
(
tag
=
0
x32u
)
{
writeUVarintLVPacket
(
tag
=
0
x32u
)
{
writeTV
(
0
x5B_00u
)
writeTV
(
0
x5B_00u
)
...
@@ -149,19 +172,40 @@ class GroupImageIdRequestPacket(
...
@@ -149,19 +172,40 @@ class GroupImageIdRequestPacket(
writeTV
(
0
x48_01u
)
writeTV
(
0
x48_01u
)
writeTUVarint
(
0
x50u
,
image
.
width
.
toUInt
())
writeTUVarint
(
0
x50u
,
image
.
width
.
toUInt
())
writeTUVarint
(
0
x58u
,
image
.
height
.
toUInt
())
writeTUVarint
(
0
x58u
,
image
.
height
.
toUInt
())
writeTV(0x60_0
2u)
writeTV
(
0
x60_0
4u
)
//这个似乎会变 有时候是02, 有时候是03
writeTByteArray
(
0
x6Au
,
value0x6A
)
writeTByteArray
(
0
x6Au
,
value0x6A
)
writeTV
(
0
x70_00u
)
writeTV
(
0
x78_03u
)
writeTV
(
0
x80_01u
)
writeUByte
(
0
u
)
}
}
}
}
writeTV(0x70_00u)
writeTV(0x78_03u)
writeTV(0x80_01u)
writeUByte(0u)
// this.debugColorizedPrintThis(compareTo = "00 00 00 07 00 00 00 5D 08 01 12 03 98 01 01 10 01 1A 59 08 FB D2 D8 94 02 10 A2 FF 8C F0 03 18 00 22 10 1D D2 2B 9B BC F2 10 83 DC 99 D2 2E 20 39 CC 0E 28 8A 03 32 1A 5B 00 40 00 33 00 48 00 5F 00 58 00 46 00 51 00 45 00 51 00 40 00 24 00 4F 00 38 01 48 01 50 EF 01 58 C2 01 60 02 6A 05 32 36 39 33 33 70 00 78 03 80 01 00")
/*
}*/
this.debugColorizedPrintThis(compareTo = buildPacket {
writeHex("00 00 00 07 00 00 00 5E 08 01 12 03 98 01 01 10 01 1A")
writeHex("5A 08")
writeUVarInt(groupId)
writeUByte(0x10u)
writeUVarInt(bot)
writeHex("18 00 22 10")
writeFully(image.md5)
writeUByte(0x28u)
writeUVarInt(image.fileSize.toUInt())
writeHex("32 1A 37 00 4D 00 32 00 25 00 4C 00 31 00 56 00 32 00 7B 00 39 00 30 00 29 00 52 00")
writeHex("38 01 48 01 50")
writeUVarInt(image.width.toUInt())
writeUByte(0x58u)
writeUVarInt(image.height.toUInt())
writeHex("60 04 6A 05 32 36 36 35 36 70 00 78 03 80 01 00")
}.readBytes().toUHexString())
*/
}
//以下仅支持中等大小图片
/*
writeQQ(bot)
writeQQ(bot)
writeHex("04 00 00 00 01 01 01 00 00 68 20 00 00 00 00 00 00 00 00")
writeHex("04 00 00 00 01 01 01 00 00 68 20 00 00 00 00 00 00 00 00")
...
@@ -182,10 +226,11 @@ class GroupImageIdRequestPacket(
...
@@ -182,10 +226,11 @@ class GroupImageIdRequestPacket(
writeUVarInt(image.height.toUInt())
writeUVarInt(image.height.toUInt())
writeHex("60 04 6A 05 32 36 36 35 36 70 00 78 03 80 01 00")
writeHex("60 04 6A 05 32 36 36 35 36 70 00 78 03 80 01 00")
}
}
*/
}
}
companion
object
{
companion
object
{
private
val
value0x6A
:
UByteArray
=
ubyteArrayOf
(
0
x05u
,
0
x32u
,
0
x36u
,
0
x3
9u
,
0
x33u
,
0
x33
u
)
private
val
value0x6A
:
UByteArray
=
ubyteArrayOf
(
0
x05u
,
0
x32u
,
0
x36u
,
0
x3
6u
,
0
x35u
,
0
x36
u
)
}
}
@PacketId
(
0
x0388u
)
@PacketId
(
0
x0388u
)
...
@@ -210,7 +255,6 @@ class GroupImageIdRequestPacket(
...
@@ -210,7 +255,6 @@ class GroupImageIdRequestPacket(
//}
//}
// 已经有了的一张图片
// 已经有了的一张图片
// 00 3B 12 03 98 01 01
// 00 3B 12 03 98 01 01
// 08 AB A7 89 D8 02 //群ID
// 08 AB A7 89 D8 02 //群ID
...
@@ -226,8 +270,9 @@ class GroupImageIdRequestPacket(
...
@@ -226,8 +270,9 @@ class GroupImageIdRequestPacket(
}
}
fun
main
()
{
fun
main
()
{
(
"
8E 4B
"
).
hexToBytes
().
read
{
(
"
A2 FF 8C F0 03
"
).
hexToBytes
().
read
{
println
(
readUnsignedVarInt
())
println
(
readUnsignedVarInt
())
}
}
println
(
0
x40
)
}
}
\ No newline at end of file
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/HexComparator.kt
View file @
3f30bb4d
...
@@ -47,6 +47,10 @@ internal object HexComparator {
...
@@ -47,6 +47,10 @@ internal object HexComparator {
.
replace
(
" "
,
" "
)
.
replace
(
" "
,
" "
)
val
FONT_10404
=
"E5 BE AE E8 BD AF E9 9B 85 E9 BB 91"
val
FONT_10404
=
"E5 BE AE E8 BD AF E9 9B 85 E9 BB 91"
val
varint580266363
=
"FB D2 D8 94 02"
val
varint1040400290
=
"A2 FF 8C F0 03"
var
varint1994701021
=
"DD F1 92 B7 07"
}
}
@Suppress
(
"SpellCheckingInspection"
)
@Suppress
(
"SpellCheckingInspection"
)
...
...
mirai-debug/src/main/java/PacketDebuger.kt
View file @
3f30bb4d
...
@@ -73,7 +73,7 @@ object Main {
...
@@ -73,7 +73,7 @@ object Main {
* 6. 运行到 `mov eax,dword ptr ss:[ebp+10]`
* 6. 运行到 `mov eax,dword ptr ss:[ebp+10]`
* 7. 查看内存, 从 `eax` 开始的 16 bytes 便是 `sessionKey`
* 7. 查看内存, 从 `eax` 开始的 16 bytes 便是 `sessionKey`
*/
*/
val
sessionKey
:
ByteArray
=
"
F1 ED F2 BC 55 17 7B FE CC CC F3 08 D1 8D A7 0E
"
.
hexToBytes
()
val
sessionKey
:
ByteArray
=
"
B7 E2 A6 3D 90 4F 4F 74 7D 55 9C 0E 91 20 40 A5
"
.
hexToBytes
()
val
qq
:
UInt
=
1040400290
u
val
qq
:
UInt
=
1040400290
u
fun
dataReceived
(
data
:
ByteArray
)
{
fun
dataReceived
(
data
:
ByteArray
)
{
...
@@ -155,7 +155,8 @@ object Main {
...
@@ -155,7 +155,8 @@ object Main {
println
(
"fixVer2="
+
when
(
val
flag
=
readByte
().
toInt
())
{
println
(
"fixVer2="
+
when
(
val
flag
=
readByte
().
toInt
())
{
2
->
byteArrayOf
(
2
)
+
readBytes
(
TIMProtocol
.
fixVer2
.
hexToBytes
().
size
-
1
)
2
->
byteArrayOf
(
2
)
+
readBytes
(
TIMProtocol
.
fixVer2
.
hexToBytes
().
size
-
1
)
4
->
byteArrayOf
(
4
)
+
readBytes
(
TIMProtocol
.
fixVer2
.
hexToBytes
().
size
-
1
+
8
)
//8个0
4
->
byteArrayOf
(
4
)
+
readBytes
(
TIMProtocol
.
fixVer2
.
hexToBytes
().
size
-
1
+
8
)
//8个0
else
->
error
(
"unknown fixVer2 flag=$flag"
)
0
->
byteArrayOf
(
0
)
+
readBytes
(
2
)
else
->
error
(
"unknown fixVer2 flag=$flag. Remaining =${readBytes().toUHexString()}"
)
}.
toUHexString
())
}.
toUHexString
())
//39 27 DC E2 04 00 00 00 00 00 00 00 1E 0E 89 00 00 01 05 0F 05 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 3E 03 3F A2 00 00 00 00 00 00 00 00 00 00 00
//39 27 DC E2 04 00 00 00 00 00 00 00 1E 0E 89 00 00 01 05 0F 05 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 3E 03 3F A2 00 00 00 00 00 00 00 00 00 00 00
...
...
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