Decode HTTP package contents in python as shown in wirehark

Ok, so basically I want to intercept some packets that I know contain some JSON data. But HTTP packets are not readable by humans, so in order for my problem, I need to make the whole packet (and not just the header, which is already plain text) readable by humans. I have no experience with the network at all.

import pcap
from impacket import ImpactDecoder, ImpactPacket

def print_packet(pktlen, data, timestamp):
    if not data:
        return

    decoder = ImpactDecoder.EthDecoder()
    ether = decoder.decode(data)
    iphdr = ether.child()
    tcphdr = iphdr.child()

    if iphdr.get_ip_src() == '*******':
        print tcphdr

p = pcap.pcapObject()
dev = 'wlan0'
p.open_live(dev, 1600, 0, 100)

try:
    p.setfilter('tcp', 0, 0)
    while 1:
        p.loop(1, print_packet)
except KeyboardInterrupt:
    print 'shutting down'

I found tools like libpcap-python, scapy, Impacket pcapy and so on. They all seem good, but I can't figure out how to decode packets with them correctly.

Wireshark " : text/html", , , , ​​ python, ,.

+3
1

HTTP JSON . Wireshark , HTTP, , " TCP-", , .

+1

Source: https://habr.com/ru/post/1793284/


All Articles