![]() |
|
[Python] Properly sending TCP packages through a specific port - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Properly sending TCP packages through a specific port (/showthread.php?tid=6040779) |
Properly sending TCP packages through a specific port - thejhexclamation - Jan 13, 2020 Currently trying to create requests that were extracted from Wireshark for honing my networking skills. I've got the location, destination port, and the message itself, but each time I attempt to send the request I am returned with just a blank empty byte. All I could conclude is that the difference between the original packets and mine are that my ports must be different, as the sending ports are different. This is the code I have tested: TCP_IP = '111.111.111.111' # destination address TCP_PORT = 19999 #destination port BUFFER_SIZE = 20 # for quicker receiving MESSAGE = b'<Message />' # dest message s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((TCP_IP, TCP_PORT)) s.send(MESSAGE) data = s.recv(BUFFER_SIZE) s.close() print("received data:", data) #b'' Which nets me with the empty byte after hanging for a few seconds. So, the trouble seems to be from the differing packet sending ports on my own computer. Any help/thoughts are greatly appreciated. RE: Properly sending TCP packages through a specific port - Goodies - Jan 14, 2020 The source port is randomly generated by the operating system and is not your issue. Inspect the packets more. Check and see if there are any additional bytes that are within the message. Could be a \x0a byte that you're missing or something. The protocol may be line-delimited and you're simply not sending the terminating line. RE: Properly sending TCP packages through a specific port - thejhexclamation - Jan 14, 2020 (Jan 14, 2020 12:41 AM)Goodies Wrote: The source port is randomly generated by the operating system and is not your issue. Inspect the packets more. Check and see if there are any additional bytes that are within the message. Could be a \x0a byte that you're missing or something. The protocol may be line-delimited and you're simply not sending the terminating line. Appreciate this reply - I'll give this a shot! RE: Properly sending TCP packages through a specific port - b3twiise - Feb 16, 2020 I would also suggest checking if the server is supposed to speak first or if you are |