TLS ClientHello, with abilities to handle extensions. The Random structure follows the RFC 5246: while it is 32-byte long, many implementations use the first 4 bytes as a gmt_unix_time, and then the remaining 28 byts should be completely random. This was designed in order to (s
| 251 | ############################################################################### |
| 252 | |
| 253 | class TLSClientHello(_TLSHandshake): |
| 254 | """ |
| 255 | TLS ClientHello, with abilities to handle extensions. |
| 256 | |
| 257 | The Random structure follows the RFC 5246: while it is 32-byte long, |
| 258 | many implementations use the first 4 bytes as a gmt_unix_time, and then |
| 259 | the remaining 28 byts should be completely random. This was designed in |
| 260 | order to (sort of) mitigate broken RNGs. If you prefer to show the full |
| 261 | 32 random bytes without any GMT time, just comment in/out the lines below. |
| 262 | """ |
| 263 | name = "TLS Handshake - Client Hello" |
| 264 | fields_desc = [ByteEnumField("msgtype", 1, _tls_handshake_type), |
| 265 | ThreeBytesField("msglen", None), |
| 266 | _TLSClientVersionField("version", None, _tls_version), |
| 267 | |
| 268 | # _TLSRandomBytesField("random_bytes", None, 32), |
| 269 | _GMTUnixTimeField("gmt_unix_time", None), |
| 270 | _TLSRandomBytesField("random_bytes", None, 28), |
| 271 | |
| 272 | FieldLenField("sidlen", None, fmt="B", length_of="sid"), |
| 273 | _SessionIDField("sid", "", |
| 274 | length_from=lambda pkt: pkt.sidlen), |
| 275 | |
| 276 | FieldLenField("cipherslen", None, fmt="!H", |
| 277 | length_of="ciphers"), |
| 278 | _CipherSuitesField("ciphers", None, |
| 279 | _tls_cipher_suites, itemfmt="!H", |
| 280 | length_from=lambda pkt: pkt.cipherslen), |
| 281 | |
| 282 | FieldLenField("complen", None, fmt="B", length_of="comp"), |
| 283 | _CompressionMethodsField("comp", [0], |
| 284 | _tls_compression_algs, |
| 285 | itemfmt="B", |
| 286 | length_from=lambda pkt: pkt.complen), # noqa: E501 |
| 287 | |
| 288 | _ExtensionsLenField("extlen", None, length_of="ext"), |
| 289 | _ExtensionsField("ext", None, |
| 290 | length_from=lambda pkt: (pkt.msglen - |
| 291 | (pkt.sidlen or 0) - # noqa: E501 |
| 292 | (pkt.cipherslen or 0) - # noqa: E501 |
| 293 | (pkt.complen or 0) - # noqa: E501 |
| 294 | 40))] |
| 295 | |
| 296 | def post_build(self, p, pay): |
| 297 | if self.random_bytes is None: |
| 298 | p = p[:10] + randstring(28) + p[10 + 28:] |
| 299 | |
| 300 | # if no ciphersuites were provided, we add a few usual, supported |
| 301 | # ciphersuites along with the appropriate extensions |
| 302 | if self.ciphers is None: |
| 303 | cipherstart = 39 + (self.sidlen or 0) |
| 304 | s = b"001ac02bc023c02fc027009e0067009c003cc009c0130033002f000a" |
| 305 | p = p[:cipherstart] + hex_bytes(s) + p[cipherstart + 2:] |
| 306 | if self.ext is None: |
| 307 | ext_len = b'\x00\x2c' |
| 308 | ext_reneg = b'\xff\x01\x00\x01\x00' |
| 309 | ext_sn = b'\x00\x00\x00\x0f\x00\r\x00\x00\nsecdev.org' |
| 310 | ext_sigalg = b'\x00\r\x00\x08\x00\x06\x04\x03\x04\x01\x02\x01' |
no test coverage detected
searching dependent graphs…