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
d4bfbb80
Commit
d4bfbb80
authored
Dec 24, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add TLV
parent
4261e201
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
278 additions
and
0 deletions
+278
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/packet/OutgoingPacketHelperAndroid.kt
...i/qqandroid/network/packet/OutgoingPacketHelperAndroid.kt
+95
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/packet/TouchPacket.kt
...n/net/mamoe/mirai/qqandroid/network/packet/TouchPacket.kt
+25
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/packet/tlv/Tlv.kt
...otlin/net/mamoe/mirai/qqandroid/network/packet/tlv/Tlv.kt
+158
-0
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/packet/OutgoingPacketHelperAndroid.kt
0 → 100644
View file @
d4bfbb80
package
net.mamoe.mirai.qqandroid.network.packet
import
kotlinx.atomicfu.AtomicInt
import
kotlinx.atomicfu.atomic
import
kotlinx.io.core.BytePacketBuilder
/*
private open fun writeHead(
always_8001: Int,
command: Int,
uin: Long,
encryptType: Int,
const8_always_0: Int,
appClientVersion: Int,
constp_always_0: Int,
bodyLength: Int
) {
val j: Int = this.j + 1
this.j = j
this.pos = 0
util.int8_to_buf(this.buffer, this.pos, 2)
++this.pos
util.int16_to_buf(this.buffer, this.pos, this.d + 2 + bodyLength)
this.pos += 2
util.int16_to_buf(this.buffer, this.pos, always_8001)
this.pos += 2
util.int16_to_buf(this.buffer, this.pos, command)
this.pos += 2
util.int16_to_buf(this.buffer, this.pos, j)
this.pos += 2
util.int32_to_buf(this.buffer, this.pos, uin.toInt())
this.pos += 4
util.int8_to_buf(this.buffer, this.pos, 3)
++this.pos
util.int8_to_buf(this.buffer, this.pos, encryptType)
++this.pos
util.int8_to_buf(this.buffer, this.pos, const8_always_0)
++this.pos
util.int32_to_buf(this.buffer, this.pos, 2)
this.pos += 4
util.int32_to_buf(this.buffer, this.pos, appClientVersion)
this.pos += 4
util.int32_to_buf(this.buffer, this.pos, constp_always_0)
this.pos += 4
}
*/
@UseExperimental
(
ExperimentalUnsignedTypes
::
class
)
private
fun
BytePacketBuilder
.
writeHead
(
always_8001
:
Short
=
8001
,
command
:
Short
,
uin
:
Long
,
encryptType
:
Int
,
//
sequenceId
:
Int
=
SequenceIdCounter
.
nextSequenceId
(),
const8_always_0
:
Byte
=
0
,
appClientVersion
:
Int
,
constp_always_0
:
Int
=
0
,
bodyLength
:
Int
)
{
writeByte
(
2
)
writeShort
((
27
+
2
+
bodyLength
).
toShort
())
writeShort
(
always_8001
)
writeShort
(
command
)
writeShort
(
sequenceId
.
toShort
())
writeInt
(
uin
.
toInt
())
writeByte
(
3
)
writeByte
(
encryptType
.
toByte
())
writeByte
(
const8_always_0
)
writeInt
(
2
)
writeInt
(
appClientVersion
)
writeInt
(
constp_always_0
)
}
fun
buildOutgoingPacket
(
command
:
Short
///uin: Long,
)
{
}
//private b
private
object
SequenceIdCounter
{
private
val
sequenceId
:
AtomicInt
=
atomic
(
0
)
fun
nextSequenceId
():
Int
{
val
id
=
sequenceId
.
getAndAdd
(
1
)
if
(
id
>
Short
.
MAX_VALUE
.
toInt
()
*
2
)
{
sequenceId
.
value
=
0
return
nextSequenceId
()
}
return
id
}
}
\ No newline at end of file
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/packet/TouchPacket.kt
0 → 100644
View file @
d4bfbb80
package
net.mamoe.mirai.qqandroid.network.packet
import
kotlinx.io.core.ByteReadPacket
import
net.mamoe.mirai.data.Packet
import
net.mamoe.mirai.network.BotNetworkHandler
import
net.mamoe.mirai.network.packet.DecrypterByteArray
import
net.mamoe.mirai.network.packet.DecrypterType
import
net.mamoe.mirai.network.packet.PacketFactory
import
net.mamoe.mirai.network.packet.PacketId
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/packet/tlv/Tlv.kt
0 → 100644
View file @
d4bfbb80
package
net.mamoe.mirai.qqandroid.network.packet.tlv
import
kotlinx.io.core.BytePacketBuilder
import
kotlinx.io.core.buildPacket
import
kotlinx.io.core.readBytes
import
kotlinx.io.core.writeFully
import
net.mamoe.mirai.utils.io.*
import
net.mamoe.mirai.utils.md5
import
kotlin.random.Random
object
Tlv
{
fun
BytePacketBuilder
.
t1
(
qq
:
Long
,
ip
:
ByteArray
)
{
require
(
ip
.
size
==
4
)
writeShort
(
0
x0001
)
writeShortLVPacket
{
writeShort
(
1
)
// ip_ver
writeInt
(
Random
.
nextInt
())
writeInt
(
qq
.
toInt
())
writeTime
()
writeFully
(
ip
)
writeShort
(
0
)
}
}
fun
BytePacketBuilder
.
t2
(
captchaCode
:
String
,
captchaToken
:
ByteArray
,
sigVer
:
Short
=
0
)
{
writeShort
(
0
x0002
)
writeShortLVPacket
{
writeShort
(
sigVer
)
writeShortLVString
(
captchaCode
)
writeShortLVByteArray
(
captchaToken
)
}
}
fun
BytePacketBuilder
.
t8
()
{
writeShort
(
0
x0008
)
writeShortLVPacket
{
writeShort
(
0
)
writeInt
(
2052
)
// localId
writeShort
(
0
)
}
}
fun
BytePacketBuilder
.
t18
(
appId
:
Long
,
appClientVersion
:
Int
,
uin
:
Long
,
constant1_always_0
:
Int
)
{
writeShort
(
0
x18
)
writeShortLVPacket
{
writeShort
(
1
)
//ping_version
writeInt
(
1536
)
//sso_version
writeInt
(
appId
.
toInt
())
writeInt
(
appClientVersion
)
writeInt
(
uin
.
toInt
())
writeShort
(
constant1_always_0
.
toShort
())
writeShort
(
0
)
}
}
fun
BytePacketBuilder
.
t106
(
appId
:
Long
,
subAppId
:
Long
,
appClientVersion
:
Int
,
uin
:
Long
,
ipAddress
:
ByteArray
,
n5_always_1
:
Int
=
1
,
temp_pwd
:
ByteArray
,
salt
:
Long
,
uinAccount
:
ByteArray
,
tgtgtKey
:
ByteArray
,
n7
:
Int
,
array_6_may_be_null
:
ByteArray
?,
n8
:
Int
=
1
)
{
writeShort
(
0
x106
)
writeShortLVPacket
{
encryptAndWrite
(
if
(
salt
==
0L
)
{
md5
(
buildPacket
{
writeFully
(
temp_pwd
);
writeInt
(
uin
.
toInt
())
}.
readBytes
())
}
else
{
md5
(
buildPacket
{
writeFully
(
temp_pwd
);
writeInt
(
salt
.
toInt
())
}.
readBytes
())
}
)
{
writeShort
(
4
)
//TGTGTVer
writeInt
(
Random
.
nextInt
())
writeInt
(
5
)
//ssoVer
writeInt
(
appId
.
toInt
())
writeInt
(
appClientVersion
)
if
(
uin
==
0L
)
{
writeLong
(
salt
)
}
else
{
writeLong
(
uin
)
}
writeTime
()
writeFully
(
ipAddress
)
writeByte
(
n5_always_1
.
toByte
())
writeFully
(
temp_pwd
)
writeFully
(
tgtgtKey
)
writeInt
(
0
)
writeByte
(
n7
.
toByte
())
if
(
array_6_may_be_null
==
null
)
{
repeat
(
4
)
{
writeInt
(
Random
.
nextInt
())
}
}
else
{
writeFully
(
array_6_may_be_null
)
}
writeInt
(
subAppId
.
toInt
())
writeInt
(
n8
)
writeShortLVByteArray
(
uinAccount
)
}
}
}
fun
BytePacketBuilder
.
t100
(
appId
:
Long
,
subAppId
:
Long
,
appClientVersion
:
Int
,
mainSigMap
:
Int
)
{
writeShort
(
0
x100
)
writeShortLVPacket
{
writeShort
(
1
)
//db_buf_ver
writeInt
(
5
)
//sso_ver
writeInt
(
appId
.
toInt
())
writeInt
(
subAppId
.
toInt
())
writeInt
(
appClientVersion
)
writeInt
(
mainSigMap
)
}
shouldEqualsTo
22
}
fun
BytePacketBuilder
.
t107
(
picType
:
Int
,
const1_always_0
:
Int
=
0
,
const2_always_0
:
Int
=
0
,
const3_always_1
:
Int
=
1
)
{
writeShort
(
0
x107
)
writeShortLVPacket
{
writeShort
(
picType
.
toShort
())
writeByte
(
const1_always_0
.
toByte
())
writeShort
(
const2_always_0
.
toShort
())
writeByte
(
const3_always_1
.
toByte
())
}
shouldEqualsTo
6
}
}
private
infix
fun
Int
.
shouldEqualsTo
(
int
:
Int
)
=
require
(
this
==
int
)
fun
randomAndroidId
():
String
=
buildString
(
15
)
{
repeat
(
15
)
{
append
(
Random
.
nextInt
(
10
))
}
}
fun
generateGuid
(
androidId
:
String
,
macAddress
:
String
):
ByteArray
{
return
md5
(
androidId
+
macAddress
)
}
fun
getMacAddr
():
String
=
"02:00:00:00:00:00"
\ No newline at end of file
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