mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-16 17:05:03 +01:00
Progress with binary8 encoding
This commit is contained in:
@@ -9,6 +9,77 @@ import (
|
||||
"github.com/Andoryuuta/byteframe"
|
||||
)
|
||||
|
||||
func paddedString(x string, size uint) []byte {
|
||||
out := make([]byte, size)
|
||||
copy(out, x)
|
||||
|
||||
// Null terminate it.
|
||||
out[len(out)-1] = 0
|
||||
return out
|
||||
}
|
||||
|
||||
func uint8PascalString(bf *byteframe.ByteFrame, x string) {
|
||||
bf.WriteUint8(uint8(len(x) + 1))
|
||||
bf.WriteNullTerminatedBytes([]byte(x))
|
||||
}
|
||||
|
||||
func uint16PascalString(bf *byteframe.ByteFrame, x string) {
|
||||
bf.WriteUint16(uint16(len(x) + 1))
|
||||
bf.WriteNullTerminatedBytes([]byte(x))
|
||||
}
|
||||
|
||||
func makeSignInResp(username string) []byte {
|
||||
bf := byteframe.NewByteFrame()
|
||||
|
||||
bf.WriteUint8(1) // resp_code
|
||||
bf.WriteUint8(0) // file/patch server count
|
||||
bf.WriteUint8(1) // entrance server count
|
||||
bf.WriteUint8(1) // character count
|
||||
bf.WriteUint32(0xFFFFFFFF) // login_token_number
|
||||
bf.WriteBytes(paddedString("logintokenstrng", 16)) // login_token (16 byte padded string)
|
||||
bf.WriteUint32(1576761190)
|
||||
|
||||
// file patch server PascalStrings here
|
||||
|
||||
// Array(this.entrance_server_count, PascalString(Byte, "utf8")),
|
||||
uint8PascalString(bf, "localhost:53310")
|
||||
|
||||
// Characters:
|
||||
bf.WriteUint32(1039336769) // character ID
|
||||
bf.WriteUint16(30)
|
||||
bf.WriteUint16(7)
|
||||
bf.WriteUint32(1576761172)
|
||||
bf.WriteUint8(0)
|
||||
bf.WriteUint8(0)
|
||||
bf.WriteUint8(0)
|
||||
bf.WriteUint8(0)
|
||||
bf.WriteBytes(paddedString("username", 16))
|
||||
bf.WriteBytes(paddedString("", 32))
|
||||
|
||||
bf.WriteUint8(0) // friends_list_count
|
||||
bf.WriteUint8(0) // guild_members_count
|
||||
bf.WriteUint8(0) // notice_count
|
||||
bf.WriteUint32(0xDEADBEEF) // some_last_played_character_id
|
||||
bf.WriteUint32(14) // unk_flags
|
||||
uint8PascalString(bf, "") // unk_data_blob PascalString
|
||||
|
||||
bf.WriteUint16(51728)
|
||||
bf.WriteUint16(20000)
|
||||
uint16PascalString(bf, "1000672925")
|
||||
|
||||
bf.WriteUint8(0)
|
||||
|
||||
bf.WriteUint16(51729)
|
||||
bf.WriteUint16(1)
|
||||
bf.WriteUint16(20000)
|
||||
uint16PascalString(bf, "203.191.249.36:8080")
|
||||
|
||||
bf.WriteUint32(1578905116)
|
||||
bf.WriteUint32(0)
|
||||
|
||||
return bf.Data()
|
||||
}
|
||||
|
||||
func handleSignServerConnection(conn net.Conn) {
|
||||
// Client initalizes the connection with a one-time buffer of 8 NULL bytes.
|
||||
nullInit := make([]byte, 8)
|
||||
@@ -25,7 +96,7 @@ func handleSignServerConnection(conn net.Conn) {
|
||||
for {
|
||||
pkt, err := cc.ReadPacket()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return
|
||||
}
|
||||
|
||||
bf := byteframe.NewByteFrameFromBytes(pkt)
|
||||
@@ -33,9 +104,11 @@ func handleSignServerConnection(conn net.Conn) {
|
||||
username := string(bf.ReadNullTerminatedBytes())
|
||||
password := string(bf.ReadNullTerminatedBytes())
|
||||
unk := string(bf.ReadNullTerminatedBytes())
|
||||
fmt.Println("Got signin, type: %s, username: %s, password %s, unk: %s", loginType, username, password, unk)
|
||||
fmt.Printf("Got signin, type: %s, username: %s, password %s, unk: %s", loginType, username, password, unk)
|
||||
|
||||
resp := makeSignInResp(username)
|
||||
cc.SendPacket(resp)
|
||||
|
||||
//fmt.Printf("Got:\n%s", hex.Dump(pkt))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user