Tags: udp scapy
Rating: 3.0
Simplest way forward seemed to parse all packets and store the data transmission for each flag letter in a list and then OR all the values, which would return the first non-zero value. One thing that didn't fit nicely was that decoding the binary '\x00' resulted in the same value which messed up the OR logic (i.e. '\x00' OR 'k' returned '\x00') so I added extra logic to instead store 0 in the list whenever it was observed.
```
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 3 20:26:21 2023
"""
from scapy.all import *
flag=""
ans=[]
# Initialise the answer list with 60 empty lists for each letter in the flag
for i in range(60):
ans.append([])
open_pcap = rdpcap('swaal.pcap')
count = 0
for packet in open_pcap:
if packet['Raw'].load == b'\x00':
ans[count%60].append(0)
else:
ans[count%60].append(packet['Raw'].load.decode())
count += 1
for i in range(60):
flag += reduce(lambda x,y: x or y, ans[i])
print(flag)
```