-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdsniffd
More file actions
executable file
·103 lines (89 loc) · 1.67 KB
/
dsniffd
File metadata and controls
executable file
·103 lines (89 loc) · 1.67 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env sh
#set -x
set -e
export LANG="C"
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
con=${CONNECTION:-`nmcli -g uuid,state connection | awk -F ':' '$2=="activated" {print $1; exit}'`}
if=`nmcli -t connection show $con | sed -n -E "/^GENERAL\.DEVICES:/s///p"`
TEMP=$(getopt -o 'hi:' --long 'help,interface:' -n "$0" -- "$@")
if [ $? -ne 0 ]; then
usage
echo 'Terminating...' >&2
exit 1
fi
# Note the quotes around "$TEMP": they are essential!
eval set -- "$TEMP"
unset TEMP
while true; do
case "$1" in
'-h'|'--help')
echo 'Option -h, --help'
shift 1
usage
exit
;;
'-i'|'--interface')
echo "Option -i, --interface; argument '$2'"
if="$2"
shift 2
continue
;;
'--')
shift
break
;;
*)
echo 'Internal error!' >&2
exit 1
;;
esac
done
echo 'Remaining arguments:'
for arg; do
echo "--> '$arg'"
done
if [ ! "$if" ]; then
echo "Konnte Interface nicht ermitteln :-(" 1>&2
exit 1
else
echo "Interface ($if) ermittelt :-)"
fi
dir="/var/tmp/`basename "$0"`.$if"
mkdir -p $dir && cd $dir
pwd
dsniff_pid="dsniff.pid"
db="dsniff.$if.db"
log="`basename "$0"`.log"
# check write permissions amongst other things
touch $dir $dsniff_pid $db $log
usage () {
cat <<! 1>&2
Usage: $0 -i <interface> <start|stop|status> ;-)
!
exit 1
}
startup () {
daemonize -e $log -o /var/tmp/dsniffd.out.txt -c $dir -l $dsniff_pid -p $dsniff_pid -u root /usr/sbin/dsniff -i $if # -w $db
}
cleanup () {
pkill -F $dsniff_pid
#db5.3_dump "$db" >>/var/tmp/dsniffd.out.txt && rm -r -- "$dir"
}
status () {
tail $log
}
case "$1" in
start)
shift
startup "$@"
;;
stop)
cleanup
;;
status)
status
;;
*)
usage
;;
esac