-
Notifications
You must be signed in to change notification settings - Fork 21
/
Start-Packet-Capture.sh
59 lines (54 loc) · 1.57 KB
/
Start-Packet-Capture.sh
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
#!/bin/bash
# Author: Roberto Rodriguez (@Cyb3rWard0g)
# License: GPL-3.0
usage(){
echo " "
echo "Usage: $0 [option...]" >&2
echo
echo " -r Resource Group Name"
echo " -s Storage Account Name"
echo " -c Computer Names (e.g VM01,VM02)"
echo
echo "Examples:"
echo " $0 -r resourcegroup01 -s storageaccount01 -c VM01,VM02"
echo " "
exit 1
}
# ************ Command Options **********************
while getopts r:s:c:h option
do
case "${option}"
in
r) RESOURCE_GROUP=$OPTARG;;
s) STORAGE_ACCOUNT=$OPTARG;;
c) COMPUTER_NAMES=$OPTARG;;
h) usage;;
esac
done
if ((OPTIND == 1))
then
echo "No options specified"
usage
fi
if [ -z "$RESOURCE_GROUP" ] || [ -z "$STORAGE_ACCOUNT" ] || [ -z "$COMPUTER_NAMES" ]; then
echo "[!] Make sure you provide values for the Resource group (-r), Storage Account (-s) and Computer Names (-c) parameters."
usage
else
IFS=', ' read -r -a COMPUTER_ARRAY <<< "$COMPUTER_NAMES"
for COMPUTER in "${COMPUTER_ARRAY[@]}"; do
sleep 5
echo "[+] Starting ${COMPUTER}_PCAP session.."
az network watcher packet-capture create --resource-group ${RESOURCE_GROUP} --vm ${COMPUTER} --name "${COMPUTER}_PCAP" --storage-account ${STORAGE_ACCOUNT} --filters "
[
{
\"localIPAddress\":\"10.0.0.0-10.0.1.9\",
\"remoteIPAddress\":\"10.0.0.0-10.0.1.9\"
},
{
\"localIPAddress\":\"10.0.0.0-10.0.1.9\",
\"remoteIPAddress\":\"192.168.0.0-192.168.0.10\"
}
]
"
done
fi