-
Notifications
You must be signed in to change notification settings - Fork 1
56 lines (48 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
##
## A startup script for an OpenWRT router monitoring wifi
## traffic and sending it to a remote server
##
## Author: <[email protected]>
if [ $# -ne 1 ] ; then
echo "Usage: startup.sh host-ip"
exit 1
fi
# Setup the 3G dongle drivers
insmod vendor=0x12d1 product=0x1001
insmod usb_wwan
insmod option
# Test that the device and its interfaces exists
ls /dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2
if [ $! -ne 0 ] ; then
echo "Error when loading driver"
fi
# This should initiate the ppp0 interface
# Now we sleep a while to let it activate
sleep 5
# Install tcpdump on ram (-d for destination) since it's too big
# for main memory (!)
opkg update
opkg -d ram install tcpdump
# Create a counter to keep track of (possible) different
# running instances across boots
if [ ! -e /root/n ] ; then
echo "0" > /root/n
fi
# Increment the counter
N=$(($(cat /root/n) + 1))
echo $N > /root/n
# Start tcpdump with flags:
# -i The interface
# -B 100 Buffer size of the OS to limit consumption
# -w Binary output file
# -C Capture size before file-rotation (in kB)
# -n Don't resolve addresses
# -e Include link-level headers
# -q Quiet means reduced output (not really sure what it does)
# -s Package size (we don't care about the actual data)
# -z A script to post-proccess the rotated files (from the w option)
# - sends the file over the network and deletes it
/tmp/usr/sbin/tcpdump \
-i wlan0 -B 100 -w "/tmp/data/${N}_dump" -C 1 -neq -s 0 \
-z /root/postprocess &