Tuesday, August 8, 2017

'm back...Snowden had litle level of access to information. couldn't plug in nothing, bring nothing inside...couldn't keystroke nothing...my wild guess...he sent a link trought the internal chatroom...OR

how to add http headers to a packet sniffed using scapy

....

f I understand correctly, the problem you're having is that you want to update an existing HTTP request with a new header. What you want is to update a string in place, which Python can't do directly (strings are immutable).
So what you should do is take the HTTP header:
old_hdr = pkt[Raw] or old_hdr = pkt[TCP].payload
and manipulate it like a string:
new_hdr = 'New Header: value'
hdr = old_hdr.split('\r\n') # This is a crappy hack. Parsing HTTP headers
hdr.insert(new_hdr, 2)      # is a [solved problem][1].
send_hdr = '\r\n'.join(hdr)
pkt[TCP].payload = send_hdr
If you find checksums are not updating, delete them before sending the packet:
del pkt[TCP].chksum
and Scapy will put them back for you, with the right values.
Edit: I just noticed that my link is fail. Here is how to parse HTTP headers.

THE GUARDIAN TOP SECRET