Skip to content

sendPacket.py cannot send the correct icmp package #4

Description

@MidCheck

issue

The checksum is not calculated before sendto, and the activation package is discarded when used across network segments in docker.

patch

import array
packet = header + data
words = array.array('h', pakcet)
pkt_checksum = 0
for word in words:
    pkt_checksum += (word & 0xffff)
pkt_checksum = (pkt_checksum >> 16) + (pkt_checksum & 0xffff)
pkt_checksum += (pkt_checksum >> 16)
pkt_checksum = (~pkt_checksum) & 0xffff

header = struct.pack("bbHHh", ICMP_ECHO_REQUEST, 0, pkt_checksum, pkt_id, 1)

Insert these codes into line 54 of sendPacket.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions