Skip to content

Commit fa24358

Browse files
author
adam
committed
Attempting to fix behavior of default nextoffset selection when using ignore_handshake flag.
1 parent bd0ce50 commit fa24358

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

lib/dshell.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,18 @@ def TCP(self, addr, tcp, ts, **kwargs):
730730

731731
# all other states, or always if ignoring handshake
732732
if self.ignore_handshake or self.find(addr, state='established'):
733+
# When ignoring handshakes, we can be tolerant of unknown nextoffsets and set them by inference
734+
if self.ignore_handshake:
735+
if not conn:
736+
conn = self.track(addr, ts=ts, state='init', **kwargs)
737+
if addr == conn.addr:
738+
# Direction for this packet is CS
739+
if conn.nextoffset['cs'] == None:
740+
conn.nextoffset['cs'] = tcp.seq + 1
741+
else:
742+
# Direction for this packet is SC
743+
if conn.nextoffset['sc'] == None:
744+
conn.nextoffset['sc'] = tcp.seq + 1
733745
self.track(addr, str(tcp.data), ts,
734746
state='established', offset=tcp.seq, **kwargs)
735747

@@ -875,7 +887,7 @@ class Connection(Packet):
875887
def __init__(self, decoder, addr, ts=None, **kwargs):
876888
self.state = None
877889
# the offset we expect for the next blob in this direction
878-
self.nextoffset = {'cs': 0, 'sc': 0}
890+
self.nextoffset = {'cs': None, 'sc': None}
879891
# init IP-level data
880892
Packet.__init__(self, decoder, addr, ts=ts, **kwargs)
881893
self.clientip, self.clientport, self.serverip, self.serverport = (

0 commit comments

Comments
 (0)