From 0ad02a046ccf0a33a72ce14ed32e57773f3f539a Mon Sep 17 00:00:00 2001 From: HipsterCat Date: Tue, 22 Jan 2019 15:11:47 +0100 Subject: [PATCH] New byte deciphered --- dpnet/netserver.py | 30 ++++++++++++++++++++++-------- server.py | 1 + 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/dpnet/netserver.py b/dpnet/netserver.py index 064d51c..ee054a9 100644 --- a/dpnet/netserver.py +++ b/dpnet/netserver.py @@ -213,7 +213,7 @@ class Netserver: return def handle_game_packet(self, session, payload): - logger.debug("Payload: %s", payload) + #logger.debug("Payload: %s", payload) if payload[0] == 0xc1: # connect frame? _ = payload[0:4] @@ -246,11 +246,12 @@ class Netserver: payload.putLong(0x41) # unknown - 65 payload.putLong(0x14) # max players payload.putLong(0x02) # current players - payload.write(b'\x0e\x01\x00\x00') # unknown - 3585 - or \x16\x01\x00\x00 + payload.putByte(len((name + "\x00").encode("utf-16-le"))) # player name length FUN FACT: setting it to a bad value makes the client crash on connect + payload.write(b'\x01\x00\x00') # unknown - 3585 - or \x16\x01\x00\x00 payload.putLong(len((self.server.name + "\x00").encode("utf-16-le"))) # SERVERNAME LENGTH for _ in range(4): payload.putLong(0) # unknown - payload.putLong(0xda) # unknown - 218 - or 0xe2 + payload.putLong(204+len((name+"\x00").encode("utf-16-le"))) # 204+playerlen payload.putLong(0x34) # unknown - 52 payload.write(self.guid) # instance guid payload.write( @@ -275,13 +276,12 @@ class Netserver: payload.putLong(0x00) # unknown - 0 payload.putLong(0x07) # unknown - 7 payload.putLong(0xcc) # unknown - 204 - payload.putLong(0x0e) # unknown - 6 + payload.putLong(len((name + "\x00").encode("utf-16-le"))) # player name length for _ in range(4): payload.putLong(0) # unknown payload.write((name + "\x00").encode("utf-16-le")) payload.write(b'\xff') # map ID payload.write(b'\x01\x01\x00') - #payload.write(b'\x00\x04\x00') payload.write(b'\xd9\x05') # game version payload.write(b'\x02\x92') # unknown payload.write(b'\x05\x00\x01\x00\x00\x00\x00\x00') # Unknown @@ -296,10 +296,14 @@ class Netserver: elif payload[0] == 0xc3: player = self.get_player(session) - self.server.broadcast_message("%s: you should never have joined... Sorry bro." % player.name) + if not player: + return + player.session.send_cframe_sack() + + self.server.broadcast_message("%s: sorry bro, you're fucked." % player.name) player.session.send_gamedata(b'\x3c\x56\xab\x31\x96\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') player.session.send_gamedata(b'\x01\x02\x57\xab\xa1\x96\x56\xab\x31\x96\x0e\x01\x00\x00\x00') - player.session.send_gamedata(b'\x3d\x00\x5b\x53\x65\x72\x76\x65\x72\x5d') # [SERVER] + """player.session.send_gamedata(b'\x3d\x00\x5b\x53\x65\x72\x76\x65\x72\x5d') # [SERVER] player.session.send_gamedata(b'\x3d\x01'+player.name.encode("ascii")+b"\x00") # playername player.session.send_gamedata(b'\x0f\x56\xab\x31\x96\x06\x00\x00\x00\x00\x00\x00\x00\x00') # unknown player.session.send_gamedata(b'\x10\x02\x56\xab\x31\x96\x00\x00\x00\x00\x00\x00\x00\x00') # unknown @@ -310,7 +314,17 @@ class Netserver: player.session.send_gamedata(b'\x0a\x12\x00\x00\x00\x00\x28\x10\x03\x10\x12\x00\x00\x00\xc1\xff\x41\xff\x00', acknow=True) # unknown player.session.send_gamedata(b'\x0f\x56\xab\x31\x96\x08\x00\x00\x00\x00\x00\x00\x00\x00', acknow=True) # unknown - + player.session.send_gamedata(b'\x0a\x12\x00\x00\x00\x00\x2c\x10\x03\x10\x12\x00\x00\x00\x08\x00\xb6\x01\x0a\x14\x00\x00\x00\x00\x2d\x10\x03\x01\x12\x00\x00\x00\xd4\xfc\x9b\xfd\x00\x00\x00', acknow=True) # unknown + #\x00 + player.session.send_gamedata(b'\x2f\x02\x00\x00\xbe\x00\x00\x00\x00\x00\x00\x00\x00\x00', acknow=True) # unknown + player.session.send_gamedata(b'\x0a\x12\x00\x00\x00\x00\x2e\x10\x03\x10\x12\x00\x00\x00\xa8\xfd\x2d\x03\x0a\x14\x00\x00\x00\x00\x2e\x10\x03\x01\x12\x00\x00\x00\x60\xfd\x14\x03\x00\x00\x00', acknow=True) # unknown + player.session.send_gamedata(b'\x0a\x14\x00\x00\x00\x00\x28\x10\x03\x01\x12\x00\x00\x00\xbf\xff\x3f\xff\x00\x00\x00', acknow=True) # unknown + player.session.send_gamedata(b'\x0a\x12\x00\x00\x00\x00\x2a\x10\x03\x10\x12\x00\x00\x00\x73\x01\x42\x02\x0a\x14\x00\x00\x00\x00\x2a\x10\x03\x01\x12\x00\x00\x00\xbe\x01\x8c\x02\x00\x00\x00', acknow=True) # unknown + player.session.send_gamedata(b'\x2f\x02\x00\x00\xc2\x00\x00\x00\x00\x00\x00\x00\x00\x00',acknow=True) # unknown + player.session.send_gamedata(b'\x0a\x14\x00\x00\x00\x00\x2c\x10\x03\x01\x12\x00\x00\x00\x06\x00\xb5\x01\x00\x00\x00', acknow=True) # unknown + player.session.send_gamedata(b'\x0a\x12\x00\x00\x00\x00\x2e\x10\x03\x10\x12\x00\x00\x00\xa4\xfd\x2c\x03\x00',acknow=True) # unknown + player.session.send_gamedata(b'\x2f\x02\x00\x00\xc2\x00\x00\x00\x00\x00\x00\x00\x00\x00', acknow=True) # unknown + """ def send_packet(self, addr, packet): diff --git a/server.py b/server.py index 2da8dcd..ac13db3 100644 --- a/server.py +++ b/server.py @@ -18,6 +18,7 @@ class Server: self.maxplayers = kwargs.get("maxplayers", 20) self.name = kwargs.get("name", "Default Server Name") self.accept_new_players = True + self.register_with_ms = False # events self._on_new_player = []