Python: TCP/IP Socket Client, how to send login packet?

0

I wanted to create a bot to send login/join packets to a game server. So it will join then send more packets for it to write something in the chat, but I'm not sure how to do this. If someone could help me, I'd appriciate it so much!

This is the code I got so far:

import socket

# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Connect the socket to the port where the server is listening
server_address = ('79.133.198.11x', 23073)
sock.connect(server_address)

# Trying to send something
PACKET = "Hello World!".encode('utf-8')
sock.send(PACKET)

# Close connection
sock.close()

FYI, the game I picked to try on is "Soldat" a old 2d shooting game. Also, someone told me I could use wireshark or some packet sniffer but I have no clue in what form to put it into the code and how to send it.

--

EDIT: I installed Wireshark and listened to port 23073 while I connected to the server and gave me this data (UDP protocol):

0e:e9:6e:00:31:2e:36:2e:38:4d:61:6a:6f:72:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:0b:32:31:45:39:33:35:42:41:44:37:30:00

How could I apply that to the code and send that packet to the established connection?

Exid

Posted 2015-10-19T18:39:36.553

Reputation: 43

your UDP segment contains the strings en, 1.6.8Major, and 21E935BAD70, which probably represent your langague, version and serial number, but the rest is empty. http://www.rapidtables.com/convert/number/hex-to-ascii.htm

– Frank Thomas – 2015-10-19T18:55:03.220

Oh, yes you're right. That's my choosen language, the game version I'm on, my name and the last part I'm not sure. But, I have no clue what kind of system they use, I just wanted to make a bot to be able to login and chat. Would there be another way if without using packets? – Exid – 2015-10-19T18:58:58.397

Also note your code is for TCP. for UDP you want to check this out: https://wiki.python.org/moin/UdpCommunication

– Frank Thomas – 2015-10-19T18:59:56.533

Thank you, I'm looking at it now. So could I possibly get this to work if I sent this data, or maybe it have some kind of authentication system I have to pass first? The game does not require any login tho. – Exid – 2015-10-19T19:04:39.817

Thats the question. we just don't know. It is unclear as to whether you can send a replay of the segment you captured to accomplish a login. that would be extremely insecure on their end. try a segment with "enNULNUL1.6.8Major" followed by 19bytes of NUL, and finally "21E935BAD70". you may have to mess with it to get the null encoding right (it should be hex 00). – Frank Thomas – 2015-10-19T19:05:58.647

Would it be something like this (sorry, im new to python & coding)? \xen\x1\x6\x8Major\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x21E935BAD70\x – Exid – 2015-10-19T19:37:02.580

1well, the first byte should be an ascii "Shift Out" character (0x0e), rather than a null, but yeah, that looks about right. try sending it and observe the segment in wireshark to confirm that they are the same in HEX. – Frank Thomas – 2015-10-19T19:41:41.777

Let us continue this discussion in chat.

– Exid – 2015-10-20T07:13:03.217

Answers

0

There isn't really such a thing as a login packet. Packets contain Application Protocol commands so the contents of a packet which contains login information would be defined as specified by the system implementing the application protocol. As example here are the commands for the HTTP application protocol: http://papa.det.uvigo.es/~theiere/cursos/Curso_WWW/codes.html

Without knowing the authentication system and protocols in use, it won't be possible to write packets that contain valid command sequences, so you will have to learn more about the system you want to login to.

Frank Thomas

Posted 2015-10-19T18:39:36.553

Reputation: 29 039