mirror of https://github.com/hykilpikonna/AquaDX
[+] Send AllNet and obtain poweron url
parent
4be340c723
commit
af734b7814
|
@ -0,0 +1,53 @@
|
||||||
|
package icu.samnyan.aqua.sega.chusan
|
||||||
|
|
||||||
|
import ext.header
|
||||||
|
import ext.post
|
||||||
|
import ext.request
|
||||||
|
import icu.samnyan.aqua.api.model.resp.sega.chuni.v2.external.Chu3DataExport
|
||||||
|
import icu.samnyan.aqua.sega.util.AllNetBillingDecoder
|
||||||
|
|
||||||
|
|
||||||
|
val keychipPattern = Regex("([A-Z\\d]{4}-[A-Z\\d]{11}|[A-Z\\d]{11})")
|
||||||
|
|
||||||
|
class AllNetHost(val dns: String, val keychip: String, val game: String, val version: String, val card: String) {
|
||||||
|
init {
|
||||||
|
// Check if keychip is valid
|
||||||
|
// TODO : Use a more appropriate exception
|
||||||
|
if (!keychipPattern.matches(keychip)) throw Exception("Invalid keychip")
|
||||||
|
}
|
||||||
|
|
||||||
|
val requestKeychip by lazy {
|
||||||
|
// A123-45678901337 -> A1234567890
|
||||||
|
if (keychip.length == 11) keychip
|
||||||
|
else keychip.substring(0, 4) + keychip.substring(5, 11)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send AllNet PowerOn request to obtain game URL
|
||||||
|
val gameUrl by lazy {
|
||||||
|
"$dns/sys/servlet/PowerOn".request()
|
||||||
|
.header("Content-Type" to "application/x-www-form-urlencoded")
|
||||||
|
.post(AllNetBillingDecoder.encodeAllNet(mapOf(
|
||||||
|
"game_id" to game,
|
||||||
|
"ver" to version,
|
||||||
|
"serial" to requestKeychip,
|
||||||
|
"ip" to "127.0.0.1", "firm_ver" to "60001", "boot_ver" to "0000",
|
||||||
|
"encode" to "UTF-8", "format_ver" to "3", "hops" to "1", "token" to "2864179931"
|
||||||
|
)))
|
||||||
|
.body()
|
||||||
|
.split("&")
|
||||||
|
.map { it.split("=") }
|
||||||
|
.filter { it.size == 2 }
|
||||||
|
.associate { it[0] to it[1] }["uri"]
|
||||||
|
?: throw Exception("PowerOn Failed: No game URL returned")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class ChusanDataBroker {
|
||||||
|
|
||||||
|
fun pull(host: AllNetHost): Chu3DataExport {
|
||||||
|
// Send AllNet PowerOn request to obtain game URL
|
||||||
|
|
||||||
|
return Chu3DataExport()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -21,8 +21,20 @@ object AllNetBillingDecoder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun encode(src: Map<String, String>, base64: Boolean): ByteArray {
|
||||||
|
// Join the key-value pairs with '&' symbol
|
||||||
|
val output = src.map { "${it.key}=${it.value}" }.joinToString("&")
|
||||||
|
|
||||||
|
// Compress the joined string
|
||||||
|
val bytes = ZLib.compress(output.toByteArray(UTF_8))
|
||||||
|
|
||||||
|
// Encode the compressed byte array to Base64 MIME encoding
|
||||||
|
return if (!base64) bytes else Base64.getMimeEncoder().encode(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun decodeAllNet(src: ByteArray) = decode(src, base64 = true, nowrap = false)
|
fun decodeAllNet(src: ByteArray) = decode(src, base64 = true, nowrap = false)
|
||||||
|
fun encodeAllNet(src: Map<String, String>) = encode(src, base64 = true)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun decodeBilling(src: ByteArray) = decode(src, base64 = false, nowrap = true)
|
fun decodeBilling(src: ByteArray) = decode(src, base64 = false, nowrap = true)
|
||||||
|
|
Loading…
Reference in New Issue