image.png

In this case, the attached .pcap file contains data showing that the TCP window size has been manually adjusted for each request.

image.png

We can use pyshark to write a program that manually extracts the window size from each request and reconstruct it to ASCII.

from scapy.all import *
import string

# Define the range of printable ASCII characters
ascii_range = range(32, 127)

# Initialize an empty string to store the reconstructed message
reconstructed_message = ""

# Load the pcapng file
packets = rdpcap("exfil.pcapng")

# Iterate through each packet
for packet in packets:
    # Check if the packet has a TCP layer
    if packet.haslayer(TCP):
        # Extract the TCP window size
        window_size = packet[TCP].window
        
        # Check if the window size falls within the ASCII printable range
        if window_size in ascii_range:
            # Convert the window size to the corresponding ASCII character
            reconstructed_message += chr(window_size)

# Print the reconstructed message
print("Reconstructed Message:", reconstructed_message)