summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2019-04-18 01:14:32 +0100
committerPeter Wu <peter@lekensteyn.nl>2019-04-18 01:14:32 +0100
commitde25eb75c8d90282ba90396218210c4601603347 (patch)
treea55b9f9ad693a3687e989408d7ae87cada9e605b
parentbe3733bbecef1663cd5625abea4fe23a1b4e09ac (diff)
downloadwireshark-notes-master.tar.gz
crafted-pkt/tls-handshake-fragments.py: actual fragment TCPHEADmaster
Actually fragment or coalesce TLS records across TCP segments.
-rwxr-xr-xcrafted-pkt/tls-handshake-fragments.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/crafted-pkt/tls-handshake-fragments.py b/crafted-pkt/tls-handshake-fragments.py
index 2883933..ad35dfe 100755
--- a/crafted-pkt/tls-handshake-fragments.py
+++ b/crafted-pkt/tls-handshake-fragments.py
@@ -50,17 +50,21 @@ if args.seed is not None:
hsPerStream = 10
maxRecordSize = len(clientHelloMsg) * 4
-# Fragment handshake message over TLS records,
-# fragment TLS records over TCP segments.
packets = []
for i in range(args.count):
hs = b''.join(CH(hsPerStream * i + j + 1) for j in range(hsPerStream))
seq = 0x1000
+ records = b''
+ # Fragment handshake message over TLS records.
while hs:
# Does not matter that n > maxRecordSize, it is capped anyway.
n = random.randint(1, maxRecordSize)
recordData, hs = hs[:n], hs[n:]
- seg = TLSRecord(recordData)
+ records += TLSRecord(recordData)
+ # Fragment TLS records over TCP segments.
+ while records:
+ n = random.randint(1, maxRecordSize)
+ seg, records = records[:n], records[n:]
pkt = IP()/TCP(flags='A', seq=seq, sport=0xc000 + i, dport=443)/seg
packets.append(pkt)
seq += len(seg)