How to get ClientHello message in HEX form before sending?
r4t31 opened this issue · comments
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:
tlsfuzzer/tlsfuzzer/messages.py
Line 1666 in 309fe03
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 )
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