Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendPacket.py cannot send the correct icmp package #4

Open
MidCheck opened this issue Mar 15, 2021 · 0 comments
Open

sendPacket.py cannot send the correct icmp package #4

MidCheck opened this issue Mar 15, 2021 · 0 comments

Comments

@MidCheck
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant