Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def fingerprint(self, data, flow_key, mode):
flow_key += mode
offset = 0
data_offset = None
if flow_key not in self.h2_decoder:
self.h2_decoder[flow_key] = Decoder()
self.h2_decoder[flow_key].max_allowed_table_size = 65536
if flow_key in self.data_cache and self.data_cache[flow_key][2]:
if self.data_cache[flow_key][0] + len(data) >= self.data_cache[flow_key][1]:
data_offset = self.data_cache[flow_key][1] - self.data_cache[flow_key][0]
self.data_cache[flow_key] = [0,0,False]
else:
self.data_cache[flow_key][0] += len(data)
data_offset = None
offset_ = self.check_magic(data)
offset += offset_
http2 = self.parse_iterate(data, offset, flow_key)
if data_offset and http2 != None:
#!/usr/bin/python
import hpack
if __name__ == '__main__':
data = ''
with open('./fragment2.pcap', 'rb') as f:
data = f.read()
idx = data.find("\x00\x02\x06\x2a") + 4
data = data[idx:]
for i in xrange(len(data)):
for j in xrange(i, len(data)):
try:
d = hpack.Decoder()
print("DECODED : %s" % d.decode(data[i:j]))
except Exception as e:
print(e)
def fingerprint(self, data, flow_key, mode):
flow_key += mode
offset = 0
data_offset = None
if flow_key not in self.h2_decoder:
self.h2_decoder[flow_key] = Decoder()
self.h2_decoder[flow_key].max_allowed_table_size = 65536
if flow_key in self.data_cache and self.data_cache[flow_key][2]:
if self.data_cache[flow_key][0] + len(data) >= self.data_cache[flow_key][1]:
data_offset = self.data_cache[flow_key][1] - self.data_cache[flow_key][0]
self.data_cache[flow_key] = [0,0,False]
else:
self.data_cache[flow_key][0] += len(data)
data_offset = None
offset_ = self.check_magic(data)
offset += offset_
http2 = self.parse_iterate(data, offset, flow_key)
if data_offset and http2 != None: