mirror of https://github.com/dirtbags/netarch.git
fixed ip checksum
This commit is contained in:
parent
06a964a3a1
commit
48b398a45f
|
@ -230,9 +230,11 @@ class TCP_Recreate(object):
|
||||||
0, # Header checksum
|
0, # Header checksum
|
||||||
sip,
|
sip,
|
||||||
dip)
|
dip)
|
||||||
shorts = struct.unpack('!hhhhhhhhhh', iphdr)
|
shorts = struct.unpack('!HHHHHHHHHH', iphdr)
|
||||||
shsum = sum(shorts)
|
shsum = sum(shorts)
|
||||||
ipsum = struct.pack('!H', (~shsum & 0xffff))
|
shsum += shsum >> 16 # the carry
|
||||||
|
shsum = ~shsum # one's compliment
|
||||||
|
ipsum = struct.pack('!H', shsum & 0xffff)
|
||||||
iphdr = iphdr[:10] + ipsum + iphdr[12:]
|
iphdr = iphdr[:10] + ipsum + iphdr[12:]
|
||||||
|
|
||||||
tcphdr = struct.pack('!HHLLBBHHH',
|
tcphdr = struct.pack('!HHLLBBHHH',
|
||||||
|
|
Loading…
Reference in New Issue