0

I want to sniff the chart of cryptocurrencies and found this code in Python. This code takes the network io and saves it in binary escape format. How can I convert it to json or string?

import socket
import json

HOST = socket.gethostbyname(socket.gethostname())

s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP)
s.bind((HOST,1))
s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)

s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
data = s.recvfrom(65565)
print(data[0])

The output data is similar this:

b'E\x02\x004H#@\x00\x80\x06\x00\x00\x94\xfb\x96hP^_\xf4\r=\xee\x98\xcf\x1d\x08n\x1b\x82\x903\x80R\xfa\x00\xdb\xdc\x00\x00\x02\x04\x05\xb4\x01\x03\x03\x00\x01\x01\x04\x02'

mkrieger1
  • 19,194
  • 5
  • 54
  • 65

0 Answers0