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
23c060fb
Commit
23c060fb
authored
Sep 29, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bugs
parent
97c86eba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
15 deletions
+15
-15
mirai-core/src/main/java/net/mamoe/mirai/event/events/network/ServerPacketReceivedEvent.java
...mirai/event/events/network/ServerPacketReceivedEvent.java
+2
-2
mirai-core/src/main/java/net/mamoe/mirai/network/BotNetworkHandlerImpl.kt
...ain/java/net/mamoe/mirai/network/BotNetworkHandlerImpl.kt
+4
-4
mirai-core/src/main/java/net/mamoe/mirai/network/packet/ServerPacket.kt
.../main/java/net/mamoe/mirai/network/packet/ServerPacket.kt
+1
-1
mirai-core/src/main/java/net/mamoe/mirai/network/packet/VerificationCode.kt
...n/java/net/mamoe/mirai/network/packet/VerificationCode.kt
+8
-8
No files found.
mirai-core/src/main/java/net/mamoe/mirai/event/events/network/ServerPacketReceivedEvent.java
View file @
23c060fb
...
@@ -2,12 +2,12 @@ package net.mamoe.mirai.event.events.network;
...
@@ -2,12 +2,12 @@ package net.mamoe.mirai.event.events.network;
import
net.mamoe.mirai.Bot
;
import
net.mamoe.mirai.Bot
;
import
net.mamoe.mirai.event.Cancellable
;
import
net.mamoe.mirai.event.Cancellable
;
import
net.mamoe.mirai.network.packet.ServerCatchaPacket
;
import
net.mamoe.mirai.network.packet.ServerPacket
;
import
net.mamoe.mirai.network.packet.ServerPacket
;
import
net.mamoe.mirai.network.packet.ServerVerificationCodePacket
;
/**
/**
* 服务器接到某数据包时触发这个事件.
* 服务器接到某数据包时触发这个事件.
* 注意, 当接收到数据包的加密包(如 {@link Server
VerificationCode
Packet.Encrypted})也会触发这个事件, 随后才会
* 注意, 当接收到数据包的加密包(如 {@link Server
Catcha
Packet.Encrypted})也会触发这个事件, 随后才会
*
*
* @author Him188moe
* @author Him188moe
*/
*/
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/BotNetworkHandlerImpl.kt
View file @
23c060fb
...
@@ -290,7 +290,7 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler {
...
@@ -290,7 +290,7 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler {
return
return
}
}
is
Server
VerificationCode
CorrectPacket
->
{
is
Server
Captcha
CorrectPacket
->
{
this
.
randomTgtgtKey
=
getRandomByteArray
(
16
)
this
.
randomTgtgtKey
=
getRandomByteArray
(
16
)
this
.
token00BA
=
packet
.
token00BA
this
.
token00BA
=
packet
.
token00BA
socket
.
sendPacket
(
ClientLoginResendPacket3105
(
bot
.
account
.
qqNumber
,
bot
.
account
.
password
,
this
.
loginTime
,
this
.
loginIP
,
this
.
randomTgtgtKey
,
this
.
token0825
,
this
.
token00BA
))
socket
.
sendPacket
(
ClientLoginResendPacket3105
(
bot
.
account
.
qqNumber
,
bot
.
account
.
password
,
this
.
loginTime
,
this
.
loginIP
,
this
.
randomTgtgtKey
,
this
.
token0825
,
this
.
token00BA
))
...
@@ -307,8 +307,8 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler {
...
@@ -307,8 +307,8 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler {
}
}
}
}
is
Server
VerificationCode
TransmissionPacket
->
{
is
Server
Captcha
TransmissionPacket
->
{
if
(
packet
is
Server
VerificationCode
WrongPacket
)
{
if
(
packet
is
Server
Captcha
WrongPacket
)
{
bot
.
error
(
"验证码错误, 请重新输入"
)
bot
.
error
(
"验证码错误, 请重新输入"
)
captchaSectionId
=
1
captchaSectionId
=
1
this
.
captchaCache
=
byteArrayOf
()
this
.
captchaCache
=
byteArrayOf
()
...
@@ -390,7 +390,7 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler {
...
@@ -390,7 +390,7 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler {
}
}
is
Server
VerificationCode
Packet
.
Encrypted
->
socket
.
distributePacket
(
packet
.
decrypt
())
is
Server
Catcha
Packet
.
Encrypted
->
socket
.
distributePacket
(
packet
.
decrypt
())
is
ServerLoginResponseVerificationCodeInitPacket
.
Encrypted
->
socket
.
distributePacket
(
packet
.
decrypt
())
is
ServerLoginResponseVerificationCodeInitPacket
.
Encrypted
->
socket
.
distributePacket
(
packet
.
decrypt
())
is
ServerLoginResponseKeyExchangePacket
.
Encrypted
->
socket
.
distributePacket
(
packet
.
decrypt
(
this
.
randomTgtgtKey
))
is
ServerLoginResponseKeyExchangePacket
.
Encrypted
->
socket
.
distributePacket
(
packet
.
decrypt
(
this
.
randomTgtgtKey
))
is
ServerLoginResponseSuccessPacket
.
Encrypted
->
socket
.
distributePacket
(
packet
.
decrypt
(
this
.
randomTgtgtKey
))
is
ServerLoginResponseSuccessPacket
.
Encrypted
->
socket
.
distributePacket
(
packet
.
decrypt
(
this
.
randomTgtgtKey
))
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/packet/ServerPacket.kt
View file @
23c060fb
...
@@ -111,7 +111,7 @@ abstract class ServerPacket(val input: DataInputStream) : Packet {
...
@@ -111,7 +111,7 @@ abstract class ServerPacket(val input: DataInputStream) : Packet {
"00 58"
->
ServerHeartbeatResponsePacket
(
stream
)
"00 58"
->
ServerHeartbeatResponsePacket
(
stream
)
"00 BA"
->
Server
VerificationCode
Packet
.
Encrypted
(
stream
,
idHex
)
"00 BA"
->
Server
Catcha
Packet
.
Encrypted
(
stream
,
idHex
)
"00 CE"
,
"00 17"
->
ServerEventPacket
.
Raw
.
Encrypted
(
stream
,
idHex
.
hexToBytes
())
"00 CE"
,
"00 17"
->
ServerEventPacket
.
Raw
.
Encrypted
(
stream
,
idHex
.
hexToBytes
())
...
...
mirai-core/src/main/java/net/mamoe/mirai/network/packet/VerificationCode.kt
View file @
23c060fb
...
@@ -126,7 +126,7 @@ class ClientVerificationCodeRefreshPacket(
...
@@ -126,7 +126,7 @@ class ClientVerificationCodeRefreshPacket(
* 验证码输入错误, 同时也会给一部分验证码
* 验证码输入错误, 同时也会给一部分验证码
*/
*/
@PacketId
(
"00 BA 32"
)
@PacketId
(
"00 BA 32"
)
class
Server
VerificationCodeWrongPacket
(
input
:
DataInputStream
,
dataSize
:
Int
,
packetId
:
ByteArray
)
:
ServerVerificationCode
TransmissionPacket
(
input
,
dataSize
,
packetId
)
class
Server
CaptchaWrongPacket
(
input
:
DataInputStream
,
dataSize
:
Int
,
packetId
:
ByteArray
)
:
ServerCaptcha
TransmissionPacket
(
input
,
dataSize
,
packetId
)
/**
/**
* 服务器发送验证码图片文件一部分过来
* 服务器发送验证码图片文件一部分过来
...
@@ -134,7 +134,7 @@ class ServerVerificationCodeWrongPacket(input: DataInputStream, dataSize: Int, p
...
@@ -134,7 +134,7 @@ class ServerVerificationCodeWrongPacket(input: DataInputStream, dataSize: Int, p
* @author Him188moe
* @author Him188moe
*/
*/
@PacketId
(
"00 BA 31"
)
@PacketId
(
"00 BA 31"
)
open
class
Server
VerificationCodeTransmissionPacket
(
input
:
DataInputStream
,
private
val
dataSize
:
Int
,
private
val
packetId
:
ByteArray
)
:
ServerVerificationCode
Packet
(
input
)
{
open
class
Server
CaptchaTransmissionPacket
(
input
:
DataInputStream
,
private
val
dataSize
:
Int
,
private
val
packetId
:
ByteArray
)
:
ServerCatcha
Packet
(
input
)
{
lateinit
var
captchaSectionN
:
ByteArray
lateinit
var
captchaSectionN
:
ByteArray
lateinit
var
verificationToken
:
ByteArray
//56bytes
lateinit
var
verificationToken
:
ByteArray
//56bytes
...
@@ -177,7 +177,7 @@ fun main() {
...
@@ -177,7 +177,7 @@ fun main() {
* @author Him188moe
* @author Him188moe
*/
*/
@PacketId
(
"00 BA 32"
)
@PacketId
(
"00 BA 32"
)
class
Server
VerificationCodeCorrectPacket
(
input
:
DataInputStream
)
:
ServerVerificationCode
Packet
(
input
)
{
class
Server
CaptchaCorrectPacket
(
input
:
DataInputStream
)
:
ServerCatcha
Packet
(
input
)
{
lateinit
var
token00BA
:
ByteArray
//56 bytes
lateinit
var
token00BA
:
ByteArray
//56 bytes
...
@@ -187,24 +187,24 @@ class ServerVerificationCodeCorrectPacket(input: DataInputStream) : ServerVerifi
...
@@ -187,24 +187,24 @@ class ServerVerificationCodeCorrectPacket(input: DataInputStream) : ServerVerifi
}
}
}
}
abstract
class
Server
VerificationCode
Packet
(
input
:
DataInputStream
)
:
ServerPacket
(
input
)
{
abstract
class
Server
Catcha
Packet
(
input
:
DataInputStream
)
:
ServerPacket
(
input
)
{
@PacketId
(
"00 BA"
)
@PacketId
(
"00 BA"
)
class
Encrypted
(
input
:
DataInputStream
,
private
val
id
:
String
)
:
ServerPacket
(
input
)
{
class
Encrypted
(
input
:
DataInputStream
,
private
val
id
:
String
)
:
ServerPacket
(
input
)
{
fun
decrypt
():
Server
VerificationCode
Packet
{
fun
decrypt
():
Server
Catcha
Packet
{
this
.
input
goto
14
this
.
input
goto
14
val
data
=
TEA
.
decrypt
(
this
.
input
.
readAllBytes
().
cutTail
(
1
),
Protocol
.
key00BA
.
hexToBytes
())
val
data
=
TEA
.
decrypt
(
this
.
input
.
readAllBytes
().
cutTail
(
1
),
Protocol
.
key00BA
.
hexToBytes
())
if
(
id
.
startsWith
(
"00 BA 32"
))
{
if
(
id
.
startsWith
(
"00 BA 32"
))
{
return
when
(
data
.
size
)
{
return
when
(
data
.
size
)
{
66
,
66
,
95
->
Server
VerificationCode
CorrectPacket
(
data
.
dataInputStream
())
95
->
Server
Captcha
CorrectPacket
(
data
.
dataInputStream
())
//66 -> ServerVerificationCodeUnknownPacket(data.dataInputStream())
//66 -> ServerVerificationCodeUnknownPacket(data.dataInputStream())
else
->
return
Server
VerificationCode
WrongPacket
(
data
.
dataInputStream
(),
data
.
size
,
this
.
input
.
readNBytesAt
(
3
,
4
))
else
->
return
Server
Captcha
WrongPacket
(
data
.
dataInputStream
(),
data
.
size
,
this
.
input
.
readNBytesAt
(
3
,
4
))
}.
setId
(
this
.
idHex
)
}.
setId
(
this
.
idHex
)
}
}
return
Server
VerificationCode
TransmissionPacket
(
data
.
dataInputStream
(),
data
.
size
,
this
.
input
.
readNBytesAt
(
3
,
4
)).
setId
(
this
.
idHex
)
return
Server
Captcha
TransmissionPacket
(
data
.
dataInputStream
(),
data
.
size
,
this
.
input
.
readNBytesAt
(
3
,
4
)).
setId
(
this
.
idHex
)
}
}
override
fun
getFixedId
():
String
=
this
.
getFixedId
(
id
)
override
fun
getFixedId
():
String
=
this
.
getFixedId
(
id
)
...
...
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