forked from eciavatta/caronte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdump.sh
58 lines (44 loc) · 1.07 KB
/
dump.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
#!/bin/bash
# EDIT with "Port Service"
services=(
"80 a"
)
GREEN=$(tput setaf 10)
END=$(tput sgr0)
function create_subfolders {
# create main folder
mkdir -p /root/pcaps/
cd /root/pcaps/
# create services folders
counter=1
for service_data in "${services[@]}"; do
name="service$((counter++))"
mkdir -p $name
echo "$GREEN[+] $name$END"
done
# grant permissions
chmod 777 -R .
echo "$GREEN[+] Subfolders Done$END"
}
create_subfolders
counter=1
for service_data in "${services[@]}"; do
# parse data
separator=' ' read -ra data <<< "$service_data"
port=${data[0]}
service=${data[1]}
# setup variables
name="service${counter}_${service}"
execute="./start_dump_${counter}.sh"
screen_flags="-S $name -d -m"
pcap_name="service${counter}_$service-%Y-%m-%d_%H.%M.%S.pcap"
dump="sudo tcpdump -G 60 -W 30 -w $pcap_name -s0 -i game tcp and port $port"
cycle_dump="while true; do $dump; sleep 5; done"
# execute
cd "service$((counter++))"
echo "$cycle_dump" > $execute
chmod +x "$execute"
screen $screen_flags $execute
cd ../
echo "$GREEN[+] $name $END"
done