aboutsummaryrefslogtreecommitdiffstats
path: root/tools/wifcap.sh
blob: f0213511e8d9c2d80051be54bb5bb3fdb0a617f7 (plain) (blame)
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
# wifcap - WIFI capture helper
# 2012 laurent@gouloum.fr

script=`basename $0`
if [ $# -lt 3 -o $# -gt 4 ]; then
  echo "usage: $script output-prefix iface channel [libpcap_filter]"
  echo -e "\t\tchannel=x: activate hopping by running airodump-ng w/o channel"
  echo "example: sudo $script nadege-flat wlan0 x"
  exit 1
fi
if [ `id -u` -ne 0 ]; then
  echo "must be root"
  exit 1
fi
prefix=$1
iface=$2
channel=$3
if [ $# -eq 4 ]; then
  filter=$4
else
  filter=""
fi
iface_mon=mon0
date=$(date +%Y%m%d-%H%M%S)
output="${date}_${prefix}"

ifconfig $iface_mon >/dev/null 2>&1
if [ $? -ne 0 ]; then
  airmon-ng start $iface
fi

if [ $channel != "x" ]; then
  channel_cmd="--chan $channel"
  output="$output-c$channel"
else
  channel_cmd=""
fi
output="$output.pcap"
tmux new-session -d -s wifcap "set -x; tcpdump -Z nobody -s0 -w \"$output\" -ni $iface_mon $filter"
tmux new-window -t wifcap "airodump-ng -i $iface_mon $channel_cmd"
tmux attach-session -t wifcap