Board index Games... Mods... Multiplayer! Deus Ex ]

A Python 3 script for querying Deus Ex master server info


Author
Message
DxPlayer
Angel/0A
Angel/0A
User avatar

Posts: 14
Joined:
 07 Sep 2009, 18:44
Nationality:
Brazil


A Python 3 script for querying Deus Ex master server info - Postby DxPlayer » 27 Mar 2017, 06:28


Made this just for the sake of curiosity and nostalgia:

Code: Select all
import socket
import sys

# UDP Socket used for communications with each particular Deus Ex game servers
particularQuery = "\\info\\"
sockUDP = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sockUDP.settimeout(1.0)

def queryNormalDeusExServer(ip, port):
    try:
        sockUDP.sendto(bytes(particularQuery,"utf-8"), (ip, port))
        data = sockUDP.recvfrom(2048) # buffer size is 2048 bytes
        print("Received message ::: ", data[0])
    except:
        print("This server did not respond our query ::: ", ip, ":", port)
    return

# TCP/IP socket for communications with the Master Server
sockTCP = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
masterServerAddress = ('master.deusexnetwork.com', 28900)
masterServerAuth = '\\gamename\\deusex\\location\\0\\validate\\FZcjB4YA\\final\\'
masterServerQuery = '\\list\\\\gamename\\deusex\\final\\'


# Communications begin here ---->
print("Connecting to ", str(masterServerAddress), "...")
sockTCP.connect(masterServerAddress)

try:
    # Send TCP auth
    print("Sending authentication ::: ", masterServerAuth)
    sockTCP.sendall(bytes(masterServerAuth,"utf-8"))

    # Receive TCP ACK
    data = sockTCP.recv(1024)
    print("Received ack ::: ", data)

    # Send TCP query
    print("Sending query to master server ::: ", masterServerQuery)
    sockTCP.sendall(bytes(masterServerQuery,"utf-8"))

    # Receive servers Ips and ports by TCP from master server
    data = sockTCP.recv(4096)
    print("Received answer ::: ", data)

    # Master server sends stuff in a big string, each server info separated by \\
    arr = str(data).split('\\\\')

    # For each received server info, UDP queries for infos
    print('Now querying each Deus Ex server .... ')
    for i in arr:
        pos = str(i)
        # Received from master server a bunch of IP:Port
        svr = pos.split(':')
        if len(svr) == 2:
            queryNormalDeusExServer(svr[0],int(svr[1]))
    print("Closing Communication Socket used for normal game servers ...")
    sockUDP.close()

finally:
    print("Closing Communication Socket for Master Server ...")
    sockTCP.close()


This is a Python script that functions like the multiplayer game servers list inside Deus Ex. Queries the master server and lists each known game server and their status.

I used the original client, captured the packages it sent/received to/from the master server and normal game servers (using Wireshark, a network package sniffer) and studied them a little. DeusEx uses TCP for master server communications and UDP for querying each game server individually.

After the master server tells it where are the game servers (master server sends a single string, each game server address:port separated by "\\"), the game client sends a simple query to each server and expects the answer in the format of another simple char array, each information also separated by "\\".

Save this script and run into Python.

Output sample:
Code: Select all
$ python script.py
Connecting to  ('master.deusexnetwork.com', 28900) ...
Sending authentication :::  \gamename\deusex\location\0\validate\FZcjB4YA\final\
Received ack :::  b'\\basic\\\\secure\\ZLIDRS\\'
Sending query to master server :::  \list\\gamename\deusex\final\
Received answer :::  b'\\basic\\\\ip\\46.163.66.75:7791\\ip\\46.163.66.75:7771\\ip\\5.200.18.137:7791\\ip\\72.5.102.81:7781\\ip\\72.5.102.81:7791\\ip\\72.5.102.81:7761\\ip\\72.5.102.81:7771\\ip\\142.68.206.166:4441\\ip\\142.68.206.166:4444\\ip\\108.209.152.252:7791\\ip\\85.181.6.162:17578\\ip\\85.181.5.173:17578\\final\\'
Now querying each Deus Ex server ....
Received message :::  b'\\hostname\\~[FGS]Wunderland~ ALTFIRE 2014\\hostport\\7790\\maptitle\\Untitled\\mapname\\DXMP_Cargoyard\\gametype\\ANNATeam\\numplayers\\0\\maxplayers\\20\\gamemode\\openplaying\\gamever\\1100\\minnetver\\1100\\password\\False\\queryid\\54.1\\final\\'
Received message :::  b'\\hostname\\~[FGS]Wunderland~ Classic ZERO Aug 2016!\\hostport\\7770\\maptitle\\Untitled\\mapname\\DXMS_Iceworld\\gametype\\MTLTeam\\numplayers\\0\\maxplayers\\10\\gamemode\\openplaying\\gamever\\1100\\minnetver\\1100\\password\\False\\queryid\\26.1\\final\\'
Received message :::  b'\\hostname\\[i3D.NET] ~The Fun Zone~\\hostport\\7790\\maptitle\\Untitled\\mapname\\DXMP_G_E-corp\\gametype\\ANNADeathMatch\\numplayers\\0\\maxplayers\\8\\gamemode\\openplaying\\gamever\\1100\\minnetver\\1100\\password\\False\\queryid\\5.1\\final\\'
Received message :::  b"\\hostname\\ ~Sev's US 0a Server~\\hostport\\7780\\maptitle\\Untitled\\mapname\\DXMS_Derelict\\gametype\\ANNADeathMatch\\numplayers\\0\\maxplayers\\16\\gamemode\\openplaying\\gamever\\1100\\minnetver\\1100\\password\\False\\queryid\\1.1\\final\\"
Received message :::  b"\\hostname\\ ~Sev's US ATDM Server~\\hostport\\7790\\maptitle\\Untitled\\mapname\\DXMP_Area51Bunker\\gametype\\ANNAAdvTeam\\numplayers\\0\\maxplayers\\16\\gamemode\\openplaying\\gamever\\1100\\minnetver\\1100\\password\\False\\queryid\\2.1\\final\\"
Received message :::  b"\\hostname\\ ~Sev's Classic RPG Server~\\hostport\\7760\\maptitle\\Untitled\\mapname\\DXMP_rpg_v2t4\\gametype\\ANNADeathMatch\\numplayers\\0\\maxplayers\\16\\gamemode\\openplaying\\gamever\\1100\\minnetver\\1100\\password\\False\\queryid\\26.1\\final\\"
Received message :::  b"\\hostname\\  ~Sev's Tact Server~\\hostport\\7770\\maptitle\\Untitled\\mapname\\Tact_Smuggler\\gametype\\ANNADeathMatch\\numplayers\\0\\maxplayers\\16\\gamemode\\openplaying\\gamever\\1100\\minnetver\\1100\\password\\False\\queryid\\1.1\\final\\"
Received message :::  b'\\hostname\\- zXc - Clan Server -\\hostport\\4440\\maptitle\\Untitled\\mapname\\DXMP_Silo\\gametype\\advteamdmgame\\numplayers\\0\\maxplayers\\32\\gamemode\\openplaying\\gamever\\1100\\minnetver\\1100\\password\\False\\final\\\\queryid\\2.1'
Received message :::  b'\\hostname\\ - zXc - Party Server -\\hostport\\4443\\maptitle\\Untitled\\mapname\\DXMP-[AK]-Frag-Zone\\gametype\\ANNABasicTeam\\numplayers\\0\\maxplayers\\16\\gamemode\\openplaying\\gamever\\1100\\minnetver\\1100\\password\\False\\final\\\\queryid\\1.1'
Received message :::  b'\\hostname\\Sharpshooter Mod Server with Pure UT99 Maps\\hostport\\7790\\maptitle\\HiSpeed \\mapname\\UT_HiSpeed\\gametype\\Sharpshooter\\numplayers\\0\\maxplayers\\12\\gamemode\\openplaying\\gamever\\1100\\minnetver\\1100\\password\\False\\final\\\\queryid\\73.1'
This server did not respond our query :::  85.181.6.162 : 17578
Received message :::  b'\\hostname\\Sunny Side\\hostport\\17577\\maptitle\\Untitled\\mapname\\DXMP_Abandoned\\gametype\\MTLTeam\\numplayers\\0\\maxplayers\\7\\gamemode\\openplaying\\gamever\\1100\\minnetver\\1100\\password\\False\\queryid\\83.1\\final\\'
Closing Communication Socket used for normal game servers ...
Closing Communication Socket for Master Server ...


Also posted this in DxAlpha.com
http://www.dxalpha.com/forum/viewtopic. ... 42&t=18962

Cheers, long time no see both DeusEx forum boards! :-)


~][FGS][Nobody~
Illuminated
Illuminated
User avatar

Posts: 5359
Joined:
 26 Oct 2005, 16:59
Location:
 Schland!
Nationality:
Germany


Re: A Python 3 script for querying Deus Ex master server inf - Postby ~][FGS][Nobody~ » 29 Mar 2017, 16:36


Yaaay, scripty script this is! =D>


Nobody is perfect...
-----------------------
ô¿ô¥[GODZ]¥NOCHANC wrote:I can ban any one I want ANY time I want. You have no rights here.

Magus wrote:Maybe one day I will understand your arcane rituals of voting :)

chin.democ. wrote:You can use light bulbs that emit light, and when shot, do not.

synthetic wrote:and while every person is interesting in their own unique ways, there is some degree of uniqueness that a doctor can help with.

~ô¿ô~][FGS][Nobody~ said: THERE IS NO SPOON!
~¤¥ÐJ¥¤~ said: THERE IS NO CAKE!
Kuchcik
Teh gravn00b
Teh gravn00b
User avatar

Posts: 2637
Joined:
 25 Oct 2006, 20:42
Location:
 central europe shithole


Re: A Python 3 script for querying Deus Ex master server inf - Postby Kuchcik » 12 Apr 2017, 16:13


captured the packages it sent/received to/from the master server and normal game servers (using Wireshark, a network package sniffer) and studied them a little.

Neato. Wireshark is hell of a tool.
Helped me out a couple of times in troubleshooting weird issues at work, such as silently failing TLS handshakes or overloaded endpoint devices (muh TCP retransmissions).

You should extract global numplayers, put it in cron somewhere, and send out a global e-mail notification if numplayers>1... Kind of a "holy metabolic end product a DXMP player" watchdog. Or maybe we could get it up on the "Server status" ticker at the top of the board, shouldn't be too complicated.


anax
Throne/6G
Throne/6G

Posts: 942
Joined:
 11 Apr 2012, 23:06
Location:
 England
Nationality:
Great Britain


Re: A Python 3 script for querying Deus Ex master server inf - Postby anax » 14 May 2017, 13:38


Nice work!!!

Kuchcik wrote:You should extract global numplayers, put it in cron somewhere, and send out a global e-mail notification if numplayers>1... Kind of a "holy metabolic end product a DXMP player" watchdog. Or maybe we could get it up on the "Server status" ticker at the top of the board, shouldn't be too complicated.


YES, PLEASE!


AKA Knifeworld on Discord etc. Frozen brains tell no tales!


Return to Deus Ex

Who is online

Users browsing this forum: No registered users and 56 guests