1

I've been trying to send a message to a TCP server wrote a simple script to send a byte array to the server. The problem is I'm sending 59 bytes but the server is receiver over 13K bytes. Some info is appended when I call socket.send(MESSAGE). How can I trim that or are there arguments I can pass to bypass this?

import socket
import time
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', 7046))
s.send('39080080380000000000000400000000000000000007092250121018001'.encode())
print ('connected')
data = s.recv(1024)
s.close()
print ('Received', repr(data))  

The dumb data received by the server is as below:

30 38 30 30 38 30 33 38 30 30 30 30 30 30 30 30         0800803800000000
30 30 30 30 30 34 30 30 30 30 30 30 30 30 30 30         0000040000000000
30 30 30 30 30 30 30 30 30 37 30 39 32 32 35 30         0000000007092250
31 32 31 30 31 38 30 30 31 00 00 00 00 00 00 00         121018001.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
60 d0 4d a4 62 7f 00 00 b8 6d d1 a3 62 7f 00 00         `.M.b....m..b...
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
c0 91 28 a4 62 7f 00 00 00 00 00 00 00 00 00 00         ..(.b...........
c0 8b 28 a4 62 7f 00 00 00 00 00 00 00 00 00 00         ..(.b...........
c0 9a 28 a4 62 7f 00 00 00 00 00 00 00 00 00 00         ..(.b...........
20 00 00 9c 62 7f 00 00 00 00 00 00 00 00 00 00          ...b...........
00 00 00 00 00 00 00 00 31 32 37 2e 30 2e 30 2e         ........127.0.0.
31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         1...............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 67 d1 a3 62 7f 00 00 60 45 f6 00 00 00 00 00         .g..b...`E......
00 67 d1 a3 62 7f 00 00 01 00 00 00 00 00 00 00         .g..b...........
00 00 00 00 00 00 00 00 00 70 16 b3 de 87 5d 44         .........p....]D
1a 64 fe ed 9a 85 b9 21 00 00 00 00 00 00 00 00         .d.....!........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
70 52 33 a5 62 7f 00 00 70 52 33 a5 62 7f 00 00         pR3.b...pR3.b...
19 4e 00 00 11 4e 00 00 e0 69 d1 a3 62 7f 00 00         .N...N...i..b...
e0 69 d1 a3 62 7f 00 00 e0 ff ff ff ff ff ff ff         .i..b...........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
30 5f d1 a3 62 7f 00 00 00 00 00 00 01 00 00 00         0_..b...........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................    
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
56 d0 00 f1 04 57 1f 00 00 67 d1 a3 62 7f 00 00         V....W...g..b...
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
c4 24 40 00 00 00 00 00 70 5d 2a 08 fd 7f 00 00         .$@.....p]*.....
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 60 51 a3 62 7f 00 00 00 10 80 00 00 00 00 00         .`Q.b...........
00 10 00 00 00 00 00 00 00 10 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00         .ELF............
03 00 3e 00 01 00 00 00 80 10 00 00 00 00 00 00         ..>.............
40 00 00 00 00 00 00 00 f0 50 00 00 00 00 00 00         @........P......
00 00 00 00 40 00 38 00 07 00 40 00 1e 00 1b 00         ....@.8...@.....
01 00 00 00 05 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
a2 37 00 00 00 00 00 00 a2 37 00 00 00 00 00 00         .7.......7......
00 00 20 00 00 00 00 00 01 00 00 00 06 00 00 00         .. .............
a8 3d 00 00 00 00 00 00 a8 3d 20 00 00 00 00 00         .=.......= .....
a8 3d 20 00 00 00 00 00 58 03 00 00 00 00 00 00         .= .....X.......
60 03 00 00 00 00 00 00 00 00 20 00 00 00 00 00         `......... .....
02 00 00 00 06 00 00 00 d0 3d 00 00 00 00 00 00         .........=......
d0 3d 20 00 00 00 00 00 d0 3d 20 00 00 00 00 00         .= ......= .....
00 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00         ................
08 00 00 00 00 00 00 00 04 00 00 00 04 00 00 00         ................
c8 01 00 00 00 00 00 00 c8 01 00 00 00 00 00 00         ................
c8 01 00 00 00 00 00 00 24 00 00 00 00 00 00 00         ........$.......
24 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00         $...............
50 e5 74 64 04 00 00 00 f4 34 00 00 00 00 00 00         P.td.....4......
f4 34 00 00 00 00 00 00 f4 34 00 00 00 00 00 00         .4.......4......
5c 00 00 00 00 00 00 00 5c 00 00 00 00 00 00 00         \.......\.......
04 00 00 00 00 00 00 00 51 e5 74 64 06 00 00 00         ........Q.td....
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00         ................
52 e5 74 64 04 00 00 00 a8 3d 00 00 00 00 00 00         R.td.....=......
a8 3d 20 00 00 00 00 00 a8 3d 20 00 00 00 00 00         .= ......= .....
58 02 00 00 00 00 00 00 58 02 00 00 00 00 00 00         X.......X.......
01 00 00 00 00 00 00 00 04 00 00 00 14 00 00 00         ................
03 00 00 00 47 4e 55 00 6b 72 51 56 77 2c c6 1e         ....GNU.krQVw,..
d4 75 2b 8e 39 e9 6c 28 01 88 ab 33 00 00 00 00         .u+.9.l(...3....
03 00 00 00 21 00 00 00 02 00 00 00 07 00 00 00         ....!...........
80 10 07 08 00 01 41 59 08 04 00 05 88 04 e0 00         ......AY........
21 00 00 00 25 00 00 00 2a 00 00 00 10 98 d1 ae         !...%...*.......
ba e3 92 7c 36 5f 4f 36 43 45 d5 ec 28 c8 f2 71         ...|6_O6CE..(..q
76 4d 27 97 d8 71 58 1c f4 fb b8 68 b9 8d f1 0e         vM'..qX....h....
ea d3 ef 0e 10 c9 0d e6 0d 7e f1 d6 00 00 00 00         .........~......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 03 00 09 00         ................
b0 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
ab 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 01 00 00 00 20 00 00 00         ............ ...
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
61 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00         a... ...........
00 00 00 00 00 00 00 00 7c 01 00 00 12 00 00 00         ........|.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
c9 02 00 00 12 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 38 01 00 00 12 00 00 00         ........8.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
f9 02 00 00 12 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 6e 01 00 00 12 00 00 00         ........n.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
e1 02 00 00 12 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 1c 00 00 00 20 00 00 00         ............ ...
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
38 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00         8... ...........
00 00 00 00 00 00 00 00 f8 00 00 00 10 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
52 00 00 00 22 00 00 00 00 00 00 00 00 00 00 00         R..."...........
00 00 00 00 00 00 00 00 75 01 00 00 12 00 00 00         ........u.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
dc 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 b9 00 00 00 12 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
50 01 00 00 12 00 00 00 00 00 00 00 00 00 00 00         P...............
00 00 00 00 00 00 00 00 59 01 00 00 12 00 00 00         ........Y.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
33 01 00 00 12 00 00 00 00 00 00 00 00 00 00 00         3...............
00 00 00 00 00 00 00 00 c1 00 00 00 10 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
b2 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 3f 01 00 00 12 00 00 00         ........?.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
99 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 67 01 00 00 12 00 00 00         ........g.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
a0 01 00 00 10 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 60 01 00 00 12 00 00 00         ........`.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
19 01 00 00 10 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 c1 01 00 00 12 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
b2 01 00 00 12 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 c2 02 00 00 12 00 00 00         ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
83 01 00 00 10 00 00 00 00 00 00 00 00 00 00 00         ................
00 00 00 00 00 00 00 00 75 00 00 00 12 00 0b 00         ........u.......
65 11 00 00 00 00 00 00 dd 04 00 00 00 00 00 00         e...............
4a 03 00 00 10 00 19 00 08 41 20 00 00 00 00 00         J........A .....
00 00 00 00 00 00 00 00 22 02 00 00 12 00 0b 00         ........".......
20 20 00 00 00 00 00 00 dd 04 00 00 00 00 00 00           ..............
37 03 00 00 10 00 18 00 00 41 20 00 00 00 00 00         7........A .....
00 00 00 00 00 00 00 00 47 02 00 00 12 00 0b 00         ........G.......
fd 24 00 00 00 00 00 00 dd 04 00 00 00 00 00 00         .$..............
fa 01 00 00 12 00 0b 00 1f 1b 00 00 00 00 00 00         ................
01 05 00 00 00 00 00 00 3e 03 00 00 10 00 19 00         ........>.......
00 41 20 00 00 00 00 00 00 00 00 00 00 00 00 00         .A .............
d6 01 00 00 12 00 0b 00 42 16 00 00 00 00 00 00         ........B.......
dd 04 00 00 00 00 00 00 10 00 00 00 12 00 09 00         ................
b0 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
16 00 00 00 12 00 0c 00 24 31 00 00 00 00 00 00         ........$1......
00 00 00 00 00 00 00 00 97 02 00 00 12 00 0b 00         ................
b7 2e 00 00 00 00 00 00 0f 02 00 00 00 00 00 00         ................
6f 02 00 00 12 00 0b 00 da 29 00 00 00 00 00 00         o........)......
dd 04 00 00 00 00 00 00 00 5f 5f 67 6d 6f 6e 5f         ........._gmon
73 74 61 72 74 5f 5f 00 5f 69 6e 69 74 00 5f 66         start__._init._f
69 6e 69 00 5f 49 54 4d 5f 64 65 72 65 67 69 73         ini._ITM_deregis
74 65 72 54 4d 43 6c 6f 6e 65 54 61 62 6c 65 00         terTMCloneTable.
5f 49 54 4d 5f 72 65 67 69 73 74 65 72 54 4d 43         _ITM_registerTMC
6c 6f 6e 65 54 61 62 6c 65 00 5f 5f 63 78 61 5f         loneTable.__cxa_
66 69 6e 61 6c 69 7a 65 00 5f 4a 76 5f 52 65 67         finalize._Jv_Reg
69 73 74 65 72 43 6c 61 73 73 65 73 00 5f 5a 31         isterClasses._Z1
34 43 72 65 61 74 65 4d 65 6d 6f 72 79 49 64 50         4CreateMemoryIdP
31 31 45 7a 44 65 62 75 67 55 74 69 6c 50 4b 63         11EzDebugUtilPKc
00 5f 5a 4e 39 45 7a 43 66 67 55 74 69 6c 43 31         ._ZN9EzCfgUtilC1
45 76 00 6d 65 6d 73 65 74 00 67 65 74 65 6e 76         Ev.memset.getenv
00 73 70 72 69 6e 74 66 00 5f 5a 4e 39 45 7a 43         .sprintf._ZN9EzC
66 67 55 74 69 6c 38 63 66 67 5f 6f 70 65 6e 45         fgUtil8cfg_openE
50 4b 63 00 5f 5a 4e 31 31 45 7a 44 65 62 75 67         PKc._ZN11EzDebug
55 74 69 6c 35 74 72 61 63 65 45 50 4b 63 7a 00         Util5traceEPKcz.
5f 5a 4e 39 45 7a 43 66 67 55 74 69 6c 31 30 63         _ZN9EzCfgUtil10c
66 67 5f 73 65 61 72 63 68 45 50 4b 63 50 63 69         fg_searchEPKcPci
00 5f 5a 4e 39 45 7a 43 66 67 55 74 69 6c 39 63         ._ZN9EzCfgUtil9c
66 67 5f 63 6c 6f 73 65 45 76 00 61 74 6f 69 00         fg_closeEv.atoi.
73 65 6d 67 65 74 00 5f 5f 65 72 72 6e 6f 5f 6c         semget.__errno_l
6f 63 61 74 69 6f 6e 00 73 74 72 65 72 72 6f 72         ocation.strerror
00 73 65 6d 63 74 6c 00 6d 73 67 67 65 74 00 73         .semctl.msgget.s
74 72 63 70 79 00 67 65 74 70 69 64 00 6d 73 67         trcpy.getpid.msg
73 6e 64 00 6d 73 67 72 63 76 00 5f 5a 4e 31 31         snd.msgrcv._ZN11
45 7a 44 65 62 75 67 55 74 69 6c 35 74 72 61 63         EzDebugUtil5trac
65 45 69 50 4b 63 7a 00 5f 5a 4e 39 45 7a 43 66         eEiPKcz._ZN9EzCf
67 55 74 69 6c 44 31 45 76 00 5f 55 6e 77 69 6e         gUtilD1Ev._Unwin
64 5f 52 65 73 75 6d 65 00 5f 5f 67 78 78 5f 70         d_Resume.__gxx_p
65 72 73 6f 6e 61 6c 69 74 79 5f 76 30 00 5f 5a         ersonality_v0._Z
31 34 4c 6f 63 61 74 65 4d 65 6d 6f 72 79 49 64         14LocateMemoryId
50 31 31 45 7a 44 65 62 75 67 55 74 69 6c 50 4b         P11EzDebugUtilPK
63 00 5f 5a 31 35 43 72 65 61 74 65 43 68 61 6e         c._Z15CreateChan
6e 65 6c 49 64 50 31 31 45 7a 44 65 62 75 67 55         nelIdP11EzDebugU
74 69 6c 50 4b 63 53 32 5f 00 5f 5a 31 35 4c 6f         tilPKcS2_._Z15Lo
63 61 74 65 43 68 61 6e 6e 65 6c 49 64 50 31 31         cateChannelIdP11
45 7a 44 65 62 75 67 55 74 69 6c 50 4b 63 00 5f         EzDebugUtilPKc._
5a 31 38 43 72 65 61 74 65 54 61 73 6b 4d 65 6d         Z18CreateTaskMem
6f 72 79 49 64 50 31 31 45 7a 44 65 62 75 67 55         oryIdP11EzDebugU
74 69 6c 50 4b 63 00 5f 5a 31 38 4c 6f 63 61 74         tilPKc._Z18Locat
65 54 61 73 6b 4d 65 6d 6f 72 79 49 64 50 31 31         eTaskMemoryIdP11
45 7a 44 65 62 75 67 55 74 69 6c 50 4b 63 00 5f         EzDebugUtilPKc._
5a 31 34 57 72 69 74 65 43 68 61 6e 6e 65 6c 49         Z14WriteChannelI
64 50 31 31 45 7a 44 65 62 75 67 55 74 69 6c 69         dP11EzDebugUtili
50 4b 63 53 32 5f 50 63 69 00 6d 65 6d 63 70 79         PKcS2_Pci.memcpy
00 5f 5a 4e 53 74 38 69 6f 73 5f 62 61 73 65 34         ._ZNSt8ios_base4
49 6e 69 74 43 31 45 76 00 5f 5a 4e 53 74 38 69         InitC1Ev._ZNSt8i
6f 73 5f 62 61 73 65 34 49 6e 69 74 44 31 45 76         os_base4InitD1Ev
00 5f 5f 63 78 61 5f 61 74 65 78 69 74 00 6c 69         .__cxa_atexit.li
62 73 74 64 63 2b 2b 2e 73 6f 2e 36 00 6c 69 62         bstdc++.so.6.lib
6d 2e 73 6f 2e 36 00 6c 69 62 67 63 63 5f 73 2e         m.so.6.libgcc_s.
73 6f 2e 31 00 6c 69 62 63 2e 73 6f 2e 36 00 5f         so.1.libc.so.6._
65 64 61 74 61 00 5f 5f 62 73 73 5f 73 74 61 72         edata.__bss_star
74 00 5f 65 6e 64 00 6c 69 62 65 7a 63 68 61 6e         t._end.libezchan
6e 65 6c 74 6f 6f 6c 73 2e 73 6f 2e 31 2e 30 2e         neltools.so.1.0.
30 00 47 43 43 5f 33 2e 30 00 43 58 58 41 42 49         0.GCC_3.0.CXXABI
5f 31 2e 33 00 47 4c 49 42 43 58 58 5f 33 2e 34         _1.3.GLIBCXX_3.4
00 47 4c 49 42 43 5f 32 2e 31 34 00 47 4c 49 42         .GLIBC_2.14.GLIB
43 5f 32 2e 32 2e 35 00 00 00 00 00 02 00 00 00         C_2.2.5.........
00 00 02 00 03 00 02 00 02 00 02 00 03 00 00 00         ................
00 00 00 00 02 00 02 00 00 00 02 00 02 00 02 00         ................
02 00 00 00 02 00 02 00 00 00 02 00 00 00 02 00         ................
00 00 04 00 05 00 06 00 00 00 01 00 01 00 01 00         ................
01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00         ................
01 00 00 00 00 00 00 00 01 00 01 00 1f 03 00 00         ................
10 00 00 00 20 00 00 00 50 26 79 0b 00 00 05 00         .... ...P&y.....
6a 03 00 00 00 00 00 00 01 00 02 00 06 03 00 00         j...............
10 00 00 00 30 00 00 00 d3 af 6b 05 00 00 04 00         ....0.....k.....
72 03 00 00 10 00 00 00 74 29 92 08 00 00 03 00         r.......t)......
7d 03 00 00 00 00 00 00 01 00 02 00 2d 03 00 00         }...........-...
10 00 00 00 00 00 00 00 94 91 96 06 00 00 06 00         ................
89 03 00 00 10 00 00 00 75 1a 69 09 00 00 02 00         ........u.i.....
94 03 00 00 00 00 00 00 a8 3d 20 00 00 00 00 00         .........= .....
08 00 00 00 00 00 00 00 30 11 00 00 00 00 00 00         ........0.......
b0 3d 20 00 00 00 00 00 08 00 00 00 00 00 00 00         .= .............
0e 31 00 00 00 00 00 00 b8 3d 20 00 00 00 00 00         .1.......= .....
08 00 00 00 00 00 00 00 f0 10 00 00 00 00 00 00         ................
c8 3d 20 00 00 00 00 00 08 00 00 00 00 00 00 00         .= .............
Wan Kenobi
  • 43
  • 6
  • What is the code of your server ? – Cyphall Oct 13 '18 at 08:04
  • It's a third party server only thing I can do is check the tcpdump – Wan Kenobi Oct 13 '18 at 08:06
  • So what makes you believe that the server actually received a longer packet? Perhaps the server received only what you sent, then sent a longer response anyway. – torek Oct 13 '18 at 08:29
  • I have the contact person from the company running the server who is checking the dump logs from his end. It's an ISO8583 server so the message he's getting is longer that what is supposed to accept. – Wan Kenobi Oct 13 '18 at 08:33
  • I think Steffen Ullrich is correct: you sent precisely what you sent; they sent back 10976 bytes as a result of what you sent. Your code is not sending what they expect—they expect a two byte length prefix before the data—and then *their* code breaks as a result. – torek Oct 13 '18 at 09:05

1 Answers1

2

I very much doubt that the problem is only your program. A quick check with netcat as the server which your unmodified program connects to shows:

$ nc -l 7046  | hd
00000000  33 39 30 38 30 30 38 30  33 38 30 30 30 30 30 30  |3908008038000000|
00000010  30 30 30 30 30 30 30 34  30 30 30 30 30 30 30 30  |0000000400000000|
00000020  30 30 30 30 30 30 30 30  30 30 30 37 30 39 32 32  |0000000000070922|

In other words - it was only received what you expected to send.

The dump from the server is interesting though:

30 38 30 30 38 30 33 38 30 30 30 30 30 30 30 30         0800803800000000

It is missing the 39 you've send at the beginning. This makes me believe that the server is interpreting this as the length of the data you send and according to the information I've found in Wireshark: ISO 8583-1 this is actually the case when using TCP as transmission protocol.

Only, it looks like the server is not using ASCII 39 as the length as you assumed but instead the binary representation 0x3339, i.e. 13113 decimal which nicely matches your statement of "...but the server is receiver over 13K bytes" . And the server might then blindly take this is the length of the message without checking the actual length - which is pretty dangerous as can be seen in the Heartbleed attack. And like in Heartbleed you actually have an unitialized buffer which as can be seen in your question currently contains parts of an ELF binary but might also contain some sensitive data.

Anyway, your code should probably send the message length in binary as expected by the server. This might look like this:

import struct
...
msg = b'080080380000000000000400000000000000000007092250121018001'
s.send(struct.pack('>H',len(msg)) + msg)
Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172
  • You my friend are a super hero. That worked like a charm. Thanks man, is there an equivalent of this in C#? – Wan Kenobi Oct 13 '18 at 09:33
  • @WanKenobi: see [Convert a ushort value into two byte values in C#](https://stackoverflow.com/questions/18587611/convert-a-ushort-value-into-two-byte-values-in-c-sharp). But watch out for the order of bytes, it looks like your server needs big endian while the examples there show little endian - i.e. you probably need to switch what gets assigned to which byte. – Steffen Ullrich Oct 13 '18 at 09:43