0

I want to be able to display hex data from a StreamSocket in scapy. This is my current scapy code

from scapy.all import socket, StreamSocket, Raw
import data_packets, returned_data

data    = data_packets.client_to_server_init()

mysocket = socket.socket()
mysocket.connect((args.IP_Address, args.dPort))

myStream = StreamSocket(mysocket)

result=myStream.sr1(Raw(data))

result.show()

The result is similar to that shown below

###[ Raw ]###
load      = '\x00\x00\x02\x99R\x92\x05R\xec\x02R\xe9\x02R...

Basically I want everything to be in hex whereas currently the returned data is coming back as a mix of hex and ASCII characters as you can see from the output above (Notice the capital R's that are mixed in between, those are \x52 being converted to ASCII)

NOTE: I've tried creating my own show() function but it hasn't changed anything. That code is below

def my_show(packet):


    for f in packet.fields_desc:

        fvalue = packet.getfieldval(f.name)
        reprval = f.i2repr(packet,fvalue)
        return "%s" % (reprval)   
agood25
  • 40
  • 4

1 Answers1

0

You could try taking a page from Python: print a string as hex bytes?

and use encode('hex') on your outpt as part of my_show:

return ':'.join(x.encode('hex') for x in fvalue)
Community
  • 1
  • 1
Paul Rubel
  • 26,632
  • 7
  • 60
  • 80