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
88add06f
Commit
88add06f
authored
Dec 30, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Long.toByteArray
parent
d61a2df1
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
767 additions
and
442 deletions
+767
-442
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/Tlv.kt
.../net/mamoe/mirai/qqandroid/network/protocol/packet/Tlv.kt
+629
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/TouchPacket.kt
...oe/mirai/qqandroid/network/protocol/packet/TouchPacket.kt
+0
-27
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt
...ai/qqandroid/network/protocol/packet/login/LoginPacket.kt
+124
-14
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/tlv/Tlv.kt
.../mamoe/mirai/qqandroid/network/protocol/packet/tlv/Tlv.kt
+0
-401
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/TypeConversion.kt
...monMain/kotlin/net.mamoe.mirai/utils/io/TypeConversion.kt
+14
-0
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/Tlv.kt
0 → 100644
View file @
88add06f
This diff is collapsed.
Click to expand it.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/TouchPacket.kt
deleted
100644 → 0
View file @
d61a2df1
package
net.mamoe.mirai.qqandroid.network.protocol.packet
import
kotlinx.io.core.ByteReadPacket
import
net.mamoe.mirai.data.Packet
import
net.mamoe.mirai.network.BotNetworkHandler
import
net.mamoe.mirai.qqandroid.network.protocol.packet.login.PacketId
import
net.mamoe.mirai.utils.cryptor.DecrypterByteArray
import
net.mamoe.mirai.utils.cryptor.DecrypterType
object
TouchKey
:
DecrypterByteArray
,
DecrypterType
<
TouchKey
>
{
override
val
value
:
ByteArray
get
()
=
TODO
(
"not implemented"
)
}
object
TouchPacket
:
PacketFactory
<
TouchPacketResponse
,
TouchKey
>(
TouchKey
)
{
@UseExperimental
(
ExperimentalUnsignedTypes
::
class
)
override
suspend
fun
ByteReadPacket
.
decode
(
id
:
PacketId
,
sequenceId
:
UShort
,
handler
:
BotNetworkHandler
):
TouchPacketResponse
{
TODO
(
"not implemented"
)
}
}
interface
TouchPacketResponse
:
Packet
\ No newline at end of file
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt
View file @
88add06f
...
...
@@ -2,32 +2,142 @@ package net.mamoe.mirai.qqandroid.network.protocol.packet.login
import
kotlinx.io.core.ByteReadPacket
import
kotlinx.io.core.buildPacket
import
kotlinx.io.core.readBytes
import
net.mamoe.mirai.data.Packet
import
net.mamoe.mirai.network.BotNetworkHandler
import
net.mamoe.mirai.qqandroid.network.QQAndroidDevice
import
net.mamoe.mirai.qqandroid.network.protocol.packet.EncryptMethod
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.buildOutgoingPacket
import
net.mamoe.mirai.qqandroid.network.protocol.packet.tlv.writeTLVList
import
net.mamoe.mirai.qqandroid.network.QQAndroidClient
import
net.mamoe.mirai.qqandroid.network.protocol.packet.*
import
net.mamoe.mirai.qqandroid.utils.GuidSource
import
net.mamoe.mirai.qqandroid.utils.MacOrAndroidIdChangeFlag
import
net.mamoe.mirai.qqandroid.utils.guidFlag
import
net.mamoe.mirai.utils.cryptor.DecrypterByteArray
import
net.mamoe.mirai.utils.cryptor.DecrypterType
import
net.mamoe.mirai.utils.io.toByteArray
class
LoginPacketDecrypter
(
override
val
value
:
ByteArray
)
:
DecrypterByteArray
{
companion
object
:
DecrypterType
<
LoginPacketDecrypter
>
{
}
companion
object
:
DecrypterType
<
LoginPacketDecrypter
>
}
@UseExperimental
(
ExperimentalUnsignedTypes
::
class
)
object
LoginPacket
:
PacketFactory
<
LoginPacket
.
LoginPacketResponse
,
LoginPacketDecrypter
>(
LoginPacketDecrypter
)
{
internal
object
LoginPacket
:
PacketFactory
<
LoginPacket
.
LoginPacketResponse
,
LoginPacketDecrypter
>(
LoginPacketDecrypter
)
{
operator
fun
invoke
(
client
:
QQAndroidClient
):
OutgoingPacket
=
buildOutgoingPacket
(
client
,
EncryptMethod
.
ByECDH135
)
{
writeECDHEncryptedPacket
(
client
.
ecdh
)
{
writeShort
(
9
)
// subCommand
writeShort
(
LoginType
.
PASSWORD
.
value
.
toShort
())
client
.
run
{
client
.
device
.
run
{
val
appId
=
16L
val
subAppId
=
2L
t18
(
appId
,
appClientVersion
,
account
.
id
)
t1
(
account
.
id
,
ipAddress
)
t106
(
appId
,
subAppId
/* maybe 1*/
,
appClientVersion
,
account
.
id
,
ipAddress
,
1
,
account
.
passwordMd5
,
0
,
account
.
id
.
toByteArray
(),
tgtgtKey
,
true
,
guid
,
LoginType
.
PASSWORD
)
/* // from GetStWithPasswd
int mMiscBitmap = this.mMiscBitmap;
if (t.uinDeviceToken) {
mMiscBitmap = (this.mMiscBitmap | 0x2000000);
}
// defaults true
if (ConfigManager.get_loginWithPicSt()) appIdList = longArrayOf(1600000226L)
*/
t116
(
miscBitMap
,
subSigMap
,
longArrayOf
(
1600000226L
))
t100
(
appId
,
subAppId
,
appClientVersion
,
mainSigMap
or
0
xC0
)
t107
(
0
)
t108
(
byteArrayOf
())
// ignored: t104()
t142
(
apkId
)
// if login with non-number uin
// t112()
t144
(
androidId
=
androidId
,
androidDevInfo
=
generateDeviceInfoData
(),
osType
=
osType
,
osVersion
=
version
.
release
,
ipv6NetType
=
ipv6NetType
,
simInfo
=
simInfo
,
unknown
=
byteArrayOf
(),
apn
=
apn
,
isGuidFromFileNull
=
false
,
isGuidAvailable
=
true
,
isGuidChanged
=
false
,
guidFlag
=
guidFlag
(
GuidSource
.
FROM_STORAGE
,
MacOrAndroidIdChangeFlag
.
NoChange
),
buildModel
=
model
,
guid
=
guid
,
buildBrand
=
brand
,
tgtgtKey
=
tgtgtKey
)
fun
invoke
(
device
:
QQAndroidDevice
):
OutgoingPacket
=
buildOutgoingPacket
(
device
,
EncryptMethod
.
ByECDH135
)
{
writeTLVList
{
t145
(
guid
)
t147
(
appId
,
apkVersionName
,
apkSignatureMd5
)
if
(
miscBitMap
and
0
x80
!=
0
)
{
t166
(
1
)
}
// ignored t16a because array5 is null
t154
(
ssoSequenceId
)
t141
(
simInfo
,
ipv6NetType
,
apn
)
t8
(
2052
)
// ignored t511 because domain is null
// ignored t172 because rollbackSig is null
// ignored t185 because loginType is not SMS
// ignored t400 because of first login
t187
(
macAddress
)
t188
(
androidId
)
if
(
imsiMd5
.
isNotEmpty
())
{
t194
(
imsiMd5
)
}
t191
()
t201
(
N
=
byteArrayOf
())
val
bssid
=
wifiBSSID
val
ssid
=
wifiSSID
if
(
bssid
!=
null
&&
ssid
!=
null
)
{
t202
(
bssid
,
ssid
)
}
t177
()
t516
()
t521
()
t525
(
buildPacket
{
t536
(
buildPacket
{
//com.tencent.loginsecsdk.ProtocolDet#packExtraData
writeByte
(
1
)
// const
writeByte
(
0
)
// data count
}.
readBytes
())
})
// ignored t318 because not logging in by QR
}
}
}
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/tlv/Tlv.kt
deleted
100644 → 0
View file @
d61a2df1
This diff is collapsed.
Click to expand it.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/TypeConversion.kt
View file @
88add06f
...
...
@@ -22,6 +22,20 @@ fun Int.toByteArray(): ByteArray = byteArrayOf(
(
shr
(
0
)
and
0
xFF
).
toByte
()
)
/**
* 255 -> 00 00 00 FF
*/
fun
Long
.
toByteArray
():
ByteArray
=
byteArrayOf
(
(
shr
(
56
)
and
0
xFF
).
toByte
(),
(
shr
(
48
)
and
0
xFF
).
toByte
(),
(
shr
(
40
)
and
0
xFF
).
toByte
(),
(
shr
(
32
)
and
0
xFF
).
toByte
(),
(
shr
(
24
)
and
0
xFF
).
toByte
(),
(
shr
(
16
)
and
0
xFF
).
toByte
(),
(
shr
(
8
)
and
0
xFF
).
toByte
(),
(
shr
(
0
)
and
0
xFF
).
toByte
()
)
fun
Int
.
toUHexString
(
separator
:
String
=
" "
):
String
=
this
.
toByteArray
().
toUHexString
(
separator
)
/**
...
...
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