hatching/httpreplay

dkpt/pcap.py wants a file object but httprelay requests/sends a path

acalarch opened this issue · 1 comments

This may or may not be an issue depending on the intent of reader.py. But, httpreplay/reader.py passes a file path (variable name fp) to dkpt/pcap.py but dkpt wants a file object. This is causing issues in cuckoo/modules/processing/network.py (Cuckoo Sandbox 2.0-RC1).

READER.PY

    def __init__(self, fp):
        self.tcp = None
        self.udp = None
        self.values = []

        try:
            #SHOULD PASS FILE OBJECT NOT PATH
            self.pcap = dpkt.pcap.Reader(fp)
        except ValueError as e:
            if e.message == "invalid tcpdump header":
                log.critical("Currently we don't support PCAP-NG files")
            self.pcap = None

PCAP.PY INIT

class Reader(object):
    """Simple pypcap-compatible pcap file reader."""
    def __init__(self, fileobj):
        self.name = getattr(fileobj, 'name', '<%s>' % fileobj.__class__.__name__)
        self.__f = fileobj
        blah blah blah.... 

You are using an incorrect version of the httpreplay version ;-) As per requirements.txt, the supported version of httpreplay at the time of 2.0-rc1 was HTTPReplay==0.1.5. There was an API change later on that causes this issue. Note that fp is meant as a file object here, not a filepath ;-)
Perhaps backwards compatibility would be nice, but with upcoming releases this won't be necessary really, so going to close this issue.
Thanks for reporting though, let me know if you run into any other issues or have other requests!