tlsfuzzer / tlsfuzzer

SSL and TLS protocol test suite and fuzzer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get ClientHello message in HEX form before sending?

r4t31 opened this issue · comments

commented

Feature request

Does tlsfuzzer have some method to get a message in HEX form before sending and modify it (in HEX form) and send via tlsfuzzer after that?

There isn't a ready to use way to display the message before sending, but it shouldn't be too hard to add something like that.
fuzz_message() here:

def fuzz_message(generator, substitutions=None, xors=None):

can modify any byte of the message before it's sent, so instead of calling substitute_and_xor() on data, you could do print(data.hex()) to get the hex-encoded message.

Sending hex-encoded message is supported, see RawMessageGenerator() for that. You'll need to convert the hex-encoded bytes to bytes() or bytearray() first, with something like bytes.fromhex('deadbeef').

(If you want compatibility with very old pythons, you may want to use the a2b_hex() and b2a_hex() functions from tlslite-ng instead: https://github.com/tlsfuzzer/tlslite-ng/blob/4b5efc2285f114b437f6f1678617af3ca0e0fbc5/tlslite/utils/compat.py#L52 )

commented

Unfortunately, if we will take data from this place - it will be not full.
I can get data modifying method send() from tlslite\bufferedsocket.py
But when I try to modify hex data and send it like that my TLS message is sending incorrectly...

class BufferedSocket(object):
    def send(self, data):
          data = my_mod_data
          if self.buffer_writes:
          self._write_queue.append(data)
          return len(data)
          return self.socket.send(data)

what do you mean by not full? it is the complete message; it does not include the record layer but that's by design, how messages are fragmented is separate from their contents