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
9f27cea3
Commit
9f27cea3
authored
Dec 07, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make checker inline
parent
2832330f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
+17
-10
mirai-core/src/jvmTest/kotlin/mirai/test/packetdebugger/PacketDebugger.kt
...vmTest/kotlin/mirai/test/packetdebugger/PacketDebugger.kt
+17
-10
No files found.
mirai-core/src/jvmTest/kotlin/mirai/test/packetdebugger/PacketDebugger.kt
View file @
9f27cea3
...
@@ -12,7 +12,6 @@ import kotlinx.serialization.json.Json
...
@@ -12,7 +12,6 @@ import kotlinx.serialization.json.Json
import
mirai.test.packetdebugger.PacketDebugger.dataReceived
import
mirai.test.packetdebugger.PacketDebugger.dataReceived
import
mirai.test.packetdebugger.PacketDebugger.dataSent
import
mirai.test.packetdebugger.PacketDebugger.dataSent
import
mirai.test.packetdebugger.PacketDebugger.qq
import
mirai.test.packetdebugger.PacketDebugger.qq
import
mirai.test.packetdebugger.PacketDebugger.recorder
import
mirai.test.packetdebugger.PacketDebugger.sessionKey
import
mirai.test.packetdebugger.PacketDebugger.sessionKey
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.network.BotNetworkHandler
import
net.mamoe.mirai.network.BotNetworkHandler
...
@@ -127,7 +126,7 @@ suspend fun main() {
...
@@ -127,7 +126,7 @@ suspend fun main() {
listenDevice
(
localIp
,
it
)
listenDevice
(
localIp
,
it
)
}
}
println
(
"Using sessionKey = ${sessionKey.value.toUHexString()}"
)
println
(
"Using sessionKey = ${sessionKey.value.toUHexString()}"
)
println
(
"Filter QQ = ${qq.toLong()}"
)
println
(
"Filter QQ = ${qq
?
.toLong()}"
)
PacketDebugger
.
recorder
?.
let
{
println
(
"Recorder is enabled"
)
}
PacketDebugger
.
recorder
?.
let
{
println
(
"Recorder is enabled"
)
}
Runtime
.
getRuntime
().
addShutdownHook
(
thread
(
false
)
{
Runtime
.
getRuntime
().
addShutdownHook
(
thread
(
false
)
{
PacketDebugger
.
recorder
?.
writeTo
(
File
(
GMTDate
().
toString
()
+
".record"
))
?.
also
{
println
(
"${PacketDebugger.recorder.list.size} records saved."
)
}
PacketDebugger
.
recorder
?.
writeTo
(
File
(
GMTDate
().
toString
()
+
".record"
))
?.
also
{
println
(
"${PacketDebugger.recorder.list.size} records saved."
)
}
...
@@ -135,25 +134,28 @@ suspend fun main() {
...
@@ -135,25 +134,28 @@ suspend fun main() {
println
(
"Ready perfectly"
)
println
(
"Ready perfectly"
)
}
}
suspend
fun
decryptRecordedPackets
()
{
suspend
fun
decryptRecordedPackets
(
filename
:
String
)
{
File
(
"GMTDate(seconds=12, minutes=20, hours=7, dayOfWeek=SATURDAY, dayOfMonth=7, dayOfYear=341, month=DECEMBER, year=2019, timestamp=1575703212612).record"
).
toRecorder
()
File
(
filename
).
toRecorder
()
.
list
.
forEach
{
.
list
.
forEach
{
if
(
it
.
isSend
)
{
if
(
it
.
isSend
)
{
try
{
try
{
dataSent
(
it
.
data
)
dataSent
(
it
.
data
)
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
}
else
{
}
else
{
try
{
try
{
dataReceived
(
it
.
data
)
dataReceived
(
it
.
data
)
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
}
}
}
}
}
}
decryptRecordedPackets
()
decryptRecordedPackets
(
"GMTDate(seconds=3, minutes=46, hours=7, dayOfWeek=SATURDAY, dayOfMonth=7, dayOfYear=341, month=DECEMBER, year=2019, timestamp=1575704763731).record"
)
//startPacketListening()
}
}
/**
/**
...
@@ -178,10 +180,13 @@ internal object PacketDebugger {
...
@@ -178,10 +180,13 @@ internal object PacketDebugger {
* 7. 运行完 `mov eax,dword ptr ss:[ebp+10]`
* 7. 运行完 `mov eax,dword ptr ss:[ebp+10]`
* 8. 查看内存, `eax` 到 `eax+10` 的 16 字节就是 `sessionKey`
* 8. 查看内存, `eax` 到 `eax+10` 的 16 字节就是 `sessionKey`
*/
*/
val
sessionKey
:
SessionKey
=
SessionKey
(
"
D4 4F 0A 89 E6 A6 10 CE CF F8 AF C0 7E FA F4 32
"
.
hexToBytes
())
val
sessionKey
:
SessionKey
=
SessionKey
(
"
98 4C 42 37 0F 87 BB A2 97 57 A1 77 A9 A9 74 37
"
.
hexToBytes
())
// TODO: 2019/12/7 无法访问 internal 是 kotlin bug, KT-34849
// TODO: 2019/12/7 无法访问 internal 是 kotlin bug, KT-34849
const
val
qq
:
UInt
=
1040400290
u
/**
* null 则不筛选
*/
val
qq
:
UInt
?
=
null
/**
/**
* 打开后则记录每一个包到文件.
* 打开后则记录每一个包到文件.
*/
*/
...
@@ -200,7 +205,8 @@ internal object PacketDebugger {
...
@@ -200,7 +205,8 @@ internal object PacketDebugger {
discardExact
(
3
)
discardExact
(
3
)
val
id
=
matchPacketId
(
readUShort
())
val
id
=
matchPacketId
(
readUShort
())
val
sequenceId
=
readUShort
()
val
sequenceId
=
readUShort
()
if
(
id
==
KnownPacketId
.
HEARTBEAT
||
readUInt
()
!=
qq
)
val
packetQQ
=
readUInt
()
if
(
id
==
KnownPacketId
.
HEARTBEAT
||
(
qq
!=
null
&&
packetQQ
!=
qq
))
return
@
read
return
@
read
if
(
IgnoredPacketIdList
.
contains
(
id
))
{
if
(
IgnoredPacketIdList
.
contains
(
id
))
{
...
@@ -296,7 +302,8 @@ internal object PacketDebugger {
...
@@ -296,7 +302,8 @@ internal object PacketDebugger {
if
(
IgnoredPacketIdList
.
contains
(
id
))
{
if
(
IgnoredPacketIdList
.
contains
(
id
))
{
return
return
}
}
if
(
readUInt
()
!=
qq
)
{
val
packetQQ
=
readUInt
()
if
(
qq
!=
null
&&
packetQQ
!=
qq
)
{
return
@
read
return
@
read
}
}
println
(
"---------------------------"
)
println
(
"---------------------------"
)
...
@@ -382,7 +389,7 @@ internal object DebugNetworkHandler : BotNetworkHandler<DataPacketSocketAdapter>
...
@@ -382,7 +389,7 @@ internal object DebugNetworkHandler : BotNetworkHandler<DataPacketSocketAdapter>
get
()
=
bot
get
()
=
bot
}
}
override
val
bot
:
Bot
=
Bot
(
qq
,
""
,
coroutineContext
)
override
val
bot
:
Bot
=
Bot
(
qq
?:
0
u
,
""
,
coroutineContext
)
override
val
session
=
BotSession
(
bot
)
override
val
session
=
BotSession
(
bot
)
override
suspend
fun
login
():
LoginResult
=
LoginResult
.
SUCCESS
override
suspend
fun
login
():
LoginResult
=
LoginResult
.
SUCCESS
...
...
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