Skip to content

Commit f3014c6

Browse files
committed
Add snipe hunting script. Bash >= 4.0.
1 parent 81ceaa4 commit f3014c6

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

snipe-hunt.sh

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
3+
NAME="glusterfs"
4+
CASE="-defaults"
5+
declare -A CONF
6+
CONF=( ["case sensitive"]="auto" ["preserve case"]="yes" ["short preserve case"]="yes" )
7+
PROT="NT1"
8+
9+
if [[ $# > 0 ]]; then
10+
case $1 in
11+
yescase)
12+
CASE="-$1"
13+
CONF["case sensitive"]="yes"
14+
shift
15+
;;
16+
nocase)
17+
CASE="-$1"
18+
CONF["case sensitive"]="no"
19+
shift
20+
;;
21+
largedir)
22+
CASE="-$1"
23+
CONF["case sensitive"]="yes"
24+
CONF["preserve case"]="no"
25+
CONF["short preserve case"]="no"
26+
shift
27+
;;
28+
esac
29+
fi
30+
31+
if [[ $# > 0 ]]; then
32+
case $1 in
33+
SMB3)
34+
PROT="$1"
35+
shift
36+
;;
37+
SMB2)
38+
PROT="$1"
39+
shift
40+
;;
41+
esac
42+
fi
43+
44+
if [[ $# > 0 ]]; then
45+
NAME="$1"
46+
shift
47+
fi
48+
49+
for OPT in "${!CONF[@]}"; do
50+
sed -i "s/\\(:${OPT}: \\).*/\\1'${CONF[${OPT}]}'/" vagrant.yaml
51+
done
52+
53+
RUN_NAME="${NAME}-${PROT}${CASE}"
54+
55+
vagrant provision || exit 1
56+
57+
rm -f scripts/${RUN_NAME}.pcap
58+
rm -f scripts/${RUN_NAME}_logs.tgz
59+
60+
tcpdump -w scripts/${RUN_NAME}.pcap -i virbr0 -s 0 tcp &
61+
PID=$!
62+
63+
smbclient -m ${PROT} -U vagrant%vagrant -L ganesh || true
64+
smbclient -m ${PROT} -U vagrant%vagrant //ganesh/share1 -c "put scripts/foo foo; rm foo; q;" && SAVE=true || SAVE=false
65+
66+
kill -INT $PID
67+
68+
if [ $SAVE == true ]; then
69+
vagrant ssh ganesh -c "sudo tar -czvf ${RUN_NAME}_logs.tgz /var/log/samba /var/log/glusterfs"
70+
vagrant ssh-config >scripts/ssh_config
71+
scp -F scripts/ssh_config vagrant@ganesh:${RUN_NAME}_logs.tgz scripts/
72+
fi

0 commit comments

Comments
 (0)