DragonFlyBSD Kernel Audit
DF-0743 / live_run.sh
← back to finding ↓ download raw
#!/bin/sh
# live_run.sh — DF-0743 live discriminator (root).
#
# Sets up a single gre0 (GRE mode), starts tcpdump on gre0 capturing the
# decapsulated inner packets, injects packets A and B, then reports how many
# inner packets tcpdump captured — broken down by inner ip_id.
#
#   buggy  : only id 0xAAAA captured (packet B dropped by the misparse)
#   fixed  : both 0xAAAA and 0xBBBB captured
#
# Usage:  ./live_run.sh
set -e
cd "$(dirname "$0")"

# clean slate
ifconfig gre0 destroy 2>/dev/null || true
ifconfig gre1 destroy 2>/dev/null || true
ifconfig gre create            # gre0
ifconfig gre0 tunnel 127.0.0.1 127.0.0.1
ifconfig gre0 up               # default GRE mode (link0)

# capture decapsulated inner packets on gre0
rm -f /tmp/gre0.pcap
tcpdump -i gre0 -w /tmp/gre0.pcap -s 96 -n 2>/tmp/tcpdump.err &
TCPD_PID=$!
sleep 1

./live_trigger

sleep 1
kill $TCPD_PID 2>/dev/null || true
wait $TCPD_PID 2>/dev/null || true

echo "=== tcpdump capture (decapsulated inner packets on gre0) ==="
tcpdump -nn -r /tmp/gre0.pcap 2>/dev/null
echo "=== inner id 0xAAAA (packet A) count ==="
tcpdump -nn -r /tmp/gre0.pcap 2>/dev/null | grep -ci "id 43690" || true
echo "=== inner id 0xBBBB (packet B) count ==="
tcpdump -nn -r /tmp/gre0.pcap 2>/dev/null | grep -ci "id 48059" || true
echo "=== tcpdump stderr ==="
cat /tmp/tcpdump.err 2>/dev/null || true