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
7bdaa9b1
Commit
7bdaa9b1
authored
Dec 30, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use passwordMd5, more secure
parent
76dd2814
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
15 deletions
+19
-15
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt
...n/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt
+3
-3
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/packet/login/PasswordSubmission.kt
...oe.mirai.timpc/network/packet/login/PasswordSubmission.kt
+6
-7
mirai-core-timpc/src/jvmTest/kotlin/BadQQFilter.kt
mirai-core-timpc/src/jvmTest/kotlin/BadQQFilter.kt
+1
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotAccount.kt
...-core/src/commonMain/kotlin/net.mamoe.mirai/BotAccount.kt
+7
-2
mirai-demos/mirai-demo-1/src/main/java/demo/subscribe/SubscribeSamples.kt
...i-demo-1/src/main/java/demo/subscribe/SubscribeSamples.kt
+1
-1
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
...rai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
+1
-1
No files found.
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt
View file @
7bdaa9b1
...
@@ -339,7 +339,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
...
@@ -339,7 +339,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
socket
.
sendPacket
(
socket
.
sendPacket
(
SubmitPasswordPacket
(
SubmitPasswordPacket
(
bot
=
bot
.
qqAccount
,
bot
=
bot
.
qqAccount
,
password
=
bot
.
account
.
password
,
password
Md5
=
bot
.
account
.
passwordMd5
,
loginTime
=
loginTime
,
loginTime
=
loginTime
,
loginIP
=
loginIP
,
loginIP
=
loginIP
,
privateKey
=
privateKey
,
privateKey
=
privateKey
,
...
@@ -369,7 +369,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
...
@@ -369,7 +369,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
socket
.
sendPacket
(
socket
.
sendPacket
(
SubmitPasswordPacket
(
SubmitPasswordPacket
(
bot
=
bot
.
qqAccount
,
bot
=
bot
.
qqAccount
,
password
=
bot
.
account
.
password
,
password
Md5
=
bot
.
account
.
passwordMd5
,
loginTime
=
loginTime
,
loginTime
=
loginTime
,
loginIP
=
loginIP
,
loginIP
=
loginIP
,
privateKey
=
privateKey
,
privateKey
=
privateKey
,
...
@@ -434,7 +434,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
...
@@ -434,7 +434,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
socket
.
sendPacket
(
socket
.
sendPacket
(
SubmitPasswordPacket
(
SubmitPasswordPacket
(
bot
=
bot
.
qqAccount
,
bot
=
bot
.
qqAccount
,
password
=
bot
.
account
.
password
,
password
Md5
=
bot
.
account
.
passwordMd5
,
loginTime
=
loginTime
,
loginTime
=
loginTime
,
loginIP
=
loginIP
,
loginIP
=
loginIP
,
privateKey
=
privateKey
,
privateKey
=
privateKey
,
...
...
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/packet/login/PasswordSubmission.kt
View file @
7bdaa9b1
...
@@ -51,7 +51,7 @@ internal inline class SubmitPasswordResponseDecrypter(private val privateKey: Pr
...
@@ -51,7 +51,7 @@ internal inline class SubmitPasswordResponseDecrypter(private val privateKey: Pr
internal
object
SubmitPasswordPacket
:
PacketFactory
<
SubmitPasswordPacket
.
LoginResponse
,
SubmitPasswordResponseDecrypter
>(
SubmitPasswordResponseDecrypter
)
{
internal
object
SubmitPasswordPacket
:
PacketFactory
<
SubmitPasswordPacket
.
LoginResponse
,
SubmitPasswordResponseDecrypter
>(
SubmitPasswordResponseDecrypter
)
{
operator
fun
invoke
(
operator
fun
invoke
(
bot
:
Long
,
bot
:
Long
,
password
:
String
,
password
Md5
:
ByteArray
,
loginTime
:
Int
,
loginTime
:
Int
,
loginIP
:
String
,
loginIP
:
String
,
privateKey
:
PrivateKey
,
privateKey
:
PrivateKey
,
...
@@ -68,7 +68,7 @@ internal object SubmitPasswordPacket : PacketFactory<SubmitPasswordPacket.LoginR
...
@@ -68,7 +68,7 @@ internal object SubmitPasswordPacket : PacketFactory<SubmitPasswordPacket.LoginR
// shareKey 极大可能为 publicKey, key0836 计算得到
// shareKey 极大可能为 publicKey, key0836 计算得到
encryptAndWrite
(
TIMProtocol
.
shareKey
)
{
encryptAndWrite
(
TIMProtocol
.
shareKey
)
{
writePart1
(
bot
,
password
,
loginTime
,
loginIP
,
privateKey
,
token0825
,
randomDeviceName
,
tlv0006
)
writePart1
(
bot
,
password
Md5
,
loginTime
,
loginIP
,
privateKey
,
token0825
,
randomDeviceName
,
tlv0006
)
if
(
token00BA
!=
null
)
{
if
(
token00BA
!=
null
)
{
writeHex
(
"01 10"
)
writeHex
(
"01 10"
)
writeHex
(
"00 3C"
)
writeHex
(
"00 3C"
)
...
@@ -272,7 +272,7 @@ internal inline class SessionResponseDecryptionKey(private val delegate: IoBuffe
...
@@ -272,7 +272,7 @@ internal inline class SessionResponseDecryptionKey(private val delegate: IoBuffe
private
fun
BytePacketBuilder
.
writePart1
(
private
fun
BytePacketBuilder
.
writePart1
(
qq
:
Long
,
qq
:
Long
,
password
:
String
,
password
:
ByteArray
,
loginTime
:
Int
,
loginTime
:
Int
,
loginIP
:
String
,
loginIP
:
String
,
privateKey
:
PrivateKey
,
privateKey
:
PrivateKey
,
...
@@ -314,9 +314,8 @@ private fun BytePacketBuilder.writePart1(
...
@@ -314,9 +314,8 @@ private fun BytePacketBuilder.writePart1(
this
.
writeHex
(
"60 C9 5D A7 45 70 04 7F 21 7D 84 50 5C 66 A5 C6"
)
//key
this
.
writeHex
(
"60 C9 5D A7 45 70 04 7F 21 7D 84 50 5C 66 A5 C6"
)
//key
}
}
private
fun
BytePacketBuilder
.
writeTLV0006
(
qq
:
Long
,
password
:
String
,
loginTime
:
Int
,
loginIP
:
String
,
privateKey
:
PrivateKey
)
{
private
fun
BytePacketBuilder
.
writeTLV0006
(
qq
:
Long
,
passwordMd5
:
ByteArray
,
loginTime
:
Int
,
loginIP
:
String
,
privateKey
:
PrivateKey
)
{
val
firstMD5
=
md5
(
password
)
val
secondMD5
=
md5
(
passwordMd5
+
byteArrayOf
(
0
,
0
,
0
,
0
)
+
qq
.
toUInt
().
toByteArray
())
val
secondMD5
=
md5
(
firstMD5
+
byteArrayOf
(
0
,
0
,
0
,
0
)
+
qq
.
toUInt
().
toByteArray
())
this
.
encryptAndWrite
(
secondMD5
)
{
this
.
encryptAndWrite
(
secondMD5
)
{
writeRandom
(
4
)
writeRandom
(
4
)
...
@@ -325,7 +324,7 @@ private fun BytePacketBuilder.writeTLV0006(qq: Long, password: String, loginTime
...
@@ -325,7 +324,7 @@ private fun BytePacketBuilder.writeTLV0006(qq: Long, password: String, loginTime
writeFully
(
TIMProtocol
.
constantData2
)
writeFully
(
TIMProtocol
.
constantData2
)
writeHex
(
"00 00 01"
)
writeHex
(
"00 00 01"
)
writeFully
(
firstMD
5
)
writeFully
(
passwordMd
5
)
writeInt
(
loginTime
)
writeInt
(
loginTime
)
writeByte
(
0
)
writeByte
(
0
)
writeZero
(
4
*
3
)
writeZero
(
4
*
3
)
...
...
mirai-core-timpc/src/jvmTest/kotlin/BadQQFilter.kt
View file @
7bdaa9b1
...
@@ -58,5 +58,5 @@ suspend fun main() {
...
@@ -58,5 +58,5 @@ suspend fun main() {
}
}
println
(
"Filtering finished"
)
println
(
"Filtering finished"
)
println
(
goodBotList
.
joinToString
(
"\n"
)
{
it
.
account
.
id
.
toString
()
+
" "
+
it
.
account
.
password
})
println
(
goodBotList
.
joinToString
(
"\n"
)
{
it
.
account
.
id
.
toString
()
+
" "
+
it
.
account
.
password
Md5
})
}
}
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotAccount.kt
View file @
7bdaa9b1
...
@@ -2,7 +2,12 @@
...
@@ -2,7 +2,12 @@
package
net.mamoe.mirai
package
net.mamoe.mirai
import
kotlinx.io.core.toByteArray
import
net.mamoe.mirai.utils.md5
data class
BotAccount
(
data class
BotAccount
(
val
id
:
Long
,
val
id
:
Long
,
val
password
:
String
val
passwordMd5
:
ByteArray
// md5
)
){
\ No newline at end of file
constructor
(
id
:
Long
,
passwordPlainText
:
String
)
:
this
(
id
,
md5
(
passwordPlainText
.
toByteArray
()))
}
\ No newline at end of file
mirai-demos/mirai-demo-1/src/main/java/demo/subscribe/SubscribeSamples.kt
View file @
7bdaa9b1
...
@@ -41,7 +41,7 @@ suspend fun main() {
...
@@ -41,7 +41,7 @@ suspend fun main() {
val
bot
=
TIMPC
.
Bot
(
val
bot
=
TIMPC
.
Bot
(
readTestAccount
()
?:
BotAccount
(
//填写你的账号
readTestAccount
()
?:
BotAccount
(
//填写你的账号
id
=
1994701121
,
id
=
1994701121
,
password
=
"123456"
password
PlainText
=
"123456"
)
)
)
{
)
{
// 覆盖默认的配置
// 覆盖默认的配置
...
...
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
View file @
7bdaa9b1
...
@@ -47,7 +47,7 @@ suspend fun main() {
...
@@ -47,7 +47,7 @@ suspend fun main() {
val
bot
=
Bot
(
val
bot
=
Bot
(
readTestAccount
()
?:
BotAccount
(
readTestAccount
()
?:
BotAccount
(
id
=
913366033
,
id
=
913366033
,
password
=
"a18260132383"
password
PlainText
=
"a18260132383"
)
)
)
{
)
{
// override config here.
// override config here.
...
...
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