Another TCP Resequencer fix

This commit is contained in:
Neale Pickett 2009-06-03 11:14:54 -06:00
parent 61da8aeb8b
commit d8f1c6f989
2 changed files with 17 additions and 3 deletions

View File

@ -213,9 +213,15 @@ def pp(value, bits=16):
##
## Codecs
##
import codecs
from __init__ import BitVector
import string
b64alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
def from_b64(s, alphabet, codec='base64'):
tr = string.maketrans(alphabet, b64alpha)
t = s.translate(tr)
return t.decode(codec)
class Esab64Codec(codecs.Codec):
"""Little-endian version of base64."""

10
ip.py
View File

@ -276,7 +276,8 @@ class TCP_Resequence:
del pending[key]
if frame.flags & (FIN | RST):
seq += 1
self.closed[idx] = True
if frame.flags & (FIN | ACK) == FIN | ACK:
self.closed[xdi] = True
if self.closed == [True, True]:
self.handle = self.handle_drop
if seq != pkt.ack:
@ -288,8 +289,15 @@ class TCP_Resequence:
def handle_drop(self, pkt):
"""Warn about any unhandled packets"""
if pkt.flags & SYN:
# Re-using ports!
self.__init__()
return self.handle(pkt)
if pkt.payload:
warnings.warn('Spurious frame after shutdown: %r %d' % (pkt, pkt.flags))
hexdump(pkt.payload)
merf
class Dispatch: