networking - String to binary python -


This is probably a dummy question for most of you, but I am facing this problem;

I am capturing a mac address on the network, I can change this mac address to "\ x00 \ x21 \ x23 \ x24 \ x25" like this:

  ... b = p .sprintf ("% Dot11.addr2%") Print "Sending to this MAC address", B #Here looks like MAC address 00: 00: 00: 00: 00 : 00: 00 dstmac = str ('\\ x' + B.replace (':', '\\ x')) Now, the MAC address looks like this: "\ x00 \ x00 \ x00 \ x00 \ x00 \ X00 "sendp (DST = DSTMAC, Blobblabella) ...   

When this script sends Mac on the wire, then this 00 00 00 00 sent Instead be encoded in hex real \ x (and all serial numbers) sent.

Usually, you can use it like this and it's fine: "sendp (dst =" \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 ", blablablabla)

I think I am

thanks!

\ x for signaling string literals decode string instead of hex.

  & gt; Gt; & gt; '123456789c'.decode (' hex ')' \ x124Vx \ x9a \ xbc '   

Comments