def __init__(self, **kwargs): Protocol.__init__(self, **kwargs) self.payload = None self.fields = [ VersionField("version"), RandomField("random"), VectorUInt8Field("session_id"), VectorUInt8Field("cookie"), CipherSuitesField("cipher_suites"), CompressionMethodsField("compression_methods"), ExtensionsField("extensions"), ]
def hook_alpn(record, protocols=None): tmp = ApplicationLayerProtocolNegotiation() for protocol in protocols: v = VectorUInt8Field(None) v.value = protocol tmp.protocol_name_list.append(v) record.payload.extensions.append(Extension() + tmp) return record
def decode_payload(self, data=None, payload_auto_decode=True): if data is None: data = self.payload if data is None: return False self.payload = [] while len(data) > 0: obj = VectorUInt8Field(None) data = obj.dissect(data) self.payload.append(obj)
def assemble(self): protocols = [] if isinstance(self.payload, (list, tuple)): protocols = self.payload data = b"" for protocol in protocols: if isinstance(protocol, VectorUInt8Field): data += protocol.assemble() else: obj = VectorUInt8Field(None) obj.value = protocol data += obj.assemble() return data
def __init__(self, **kwargs): Protocol.__init__(self, **kwargs) self.payload = None self.fields = [VersionField("version"), VectorUInt8Field("cookie")]