Ejemplo n.º 1
0
def teardownProtocol(protocol):
    if protocol.type != 'http':
        chop.prnt("Error")
        return

    module_data = protocol.module_data
    data = {'request': protocol.clientData, 'response': protocol.serverData}

    if module_data['base64_encode']:
        if (data['request'] is not None and 'body' in data['request']
                and data['request']['body'] is not None):
            data['request']['body'] = b64encode(data['request']['body'])
            data['request']['body_encoding'] = 'base64'

        if (data['response'] is not None and 'body' in data['response']
                and data['response']['body'] is not None):
            data['response']['body'] = b64encode(data['response']['body'])
            data['response']['body_encoding'] = 'base64'

    chopp = ChopProtocol('http_meta')
    chopp.data = data
    chopp.flowStart = protocol.flowStart
    chopp.setTimeStamp(protocol.timestamp)
    chopp.setAddr(protocol.addr)

    return chopp
Ejemplo n.º 2
0
def teardownProtocol(protocol):
    if protocol.type != 'http':
        chop.prnt("Error")
        return

    module_data = protocol.module_data
    data = {'request': protocol.clientData, 'response': protocol.serverData}

    if module_data['base64_encode']:
        if (data['request'] is not None
                and 'body' in data['request']
                and data['request']['body'] is not None):
                data['request']['body'] = b64encode(data['request']['body'])
                data['request']['body_encoding'] = 'base64'

        if (data['response'] is not None
                and 'body' in data['response']
                and data['response']['body'] is not None):
                data['response']['body'] = b64encode(data['response']['body'])
                data['response']['body_encoding'] = 'base64'

    chopp = ChopProtocol('http_meta')
    chopp.data = data
    chopp.flowStart = protocol.flowStart
    chopp.setTimeStamp(protocol.timestamp)
    chopp.setAddr(protocol.addr)

    return chopp
Ejemplo n.º 3
0
def handlePacket(ip):
    if ip.protocol != 1:
        return None

    #Okay so we have traffic labeled as ICMP
    icmp = ChopProtocol('icmp')
    ip_offset = 4 * ip.ihl
    icmp_raw = ip.raw[ip_offset:] #separate the icmp data
    header = struct.unpack('<BBH', icmp_raw[0:4])

    #Since this doesn't fit a client server model
    #Created a new 'data' field in the ChopProtocol object
    #Note that the _clone method in ChopProtocol uses deepcopy
    #so we should be okay
    icmp.data = icmp_message()
    icmp.data.type = header[0]
    icmp.data.code = header[1]
    icmp.data.checksum = header[2]
    icmp.data.raw = icmp_raw
    
    return icmp
Ejemplo n.º 4
0
def handlePacket(ip):
    if ip.protocol != 1:
        return None

    #Okay so we have traffic labeled as ICMP
    icmp = ChopProtocol('icmp')
    ip_offset = 4 * ip.ihl
    icmp_raw = ip.raw[ip_offset:] #separate the icmp data
    header = struct.unpack('<BBH', icmp_raw[0:4])

    #Since this doesn't fit a client server model
    #Created a new 'data' field in the ChopProtocol object
    #Note that the _clone method in ChopProtocol uses deepcopy
    #so we should be okay
    icmp.data = icmp_message()
    icmp.data.type = header[0]
    icmp.data.code = header[1]
    icmp.data.checksum = header[2]
    icmp.data.raw = icmp_raw
    
    return icmp