-
Notifications
You must be signed in to change notification settings - Fork 3
/
set_up.sh
104 lines (90 loc) · 3.82 KB
/
set_up.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
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
103
104
#!/bin/bash
source ./config.sh
GREEN='\033[0;32m' # Green Color
YELLOW='\033[0;33m'
RED='\033[0;31m' # RED Color
NC='\033[0m' # No Color
USER_CHOICE="$1"
print_help(){
#
# Help message
#
echo -e "${GREEN}Usage: set_up.sh [target]"
echo " Target can be one of the following:"
echo " suricata, ntp, attacker, victim, memcached"
echo ""
echo " Be aware that set up of ntp must be run after attacker has been"
echo " set up at least once!"
echo -e " IP addresses are specified in config.sh file${NC}"
}
case "$USER_CHOICE" in
"victim")
ssh -l "$VICTIM_USR" "$VICTIM_IP" \
VICTIM_SURICATA_GW_IP="$VICTIM_SURICATA_GW_IP" VICTIM_INTERFACE_NAME="$VICTIM_INTERFACE_NAME" \
/bin/bash <"victim/set_ip_route.sh"
scp -r victim/slowread_file.txt "$VICTIM_USR@$VICTIM_IP:$VICTIM_HOME_PATH"
;;
"suricata")
# TODO suricata-update maybe?
# set routes on Suricata
ssh -l "$SURICATA_USR" "$SURICATA_IP" \
"[ -d /etc/suricata/my-rules ] || mkdir /etc/suricata/my-rules"
scp rules/*.rules "$SURICATA_USR@$SURICATA_IP:/etc/suricata/my-rules"
scp suricata/suricata.yaml suricata/threshold.config "$SURICATA_USR@$SURICATA_IP:/etc/suricata/"
scp suricata/default_startup.config "$SURICATA_USR@$SURICATA_IP:/etc/default/suricata"
ssh -l "$SURICATA_USR" "$SURICATA_IP" \
VICTIM_NETWORK="$VICTIM_NETWORK" VICTIM_SURICATA_GW_IP="$VICTIM_SURICATA_GW_IP" \
SURICATA_INTERFACE_NAME_VICTIM_NETWORK="$SURICATA_INTERFACE_NAME_VICTIM_NETWORK" \
HOST_PC_VICTIM_NETWORK_GW="$HOST_PC_VICTIM_NETWORK_GW" \
/bin/bash <"suricata/set_ip_route.sh"
;;
"host-pc")
#
# Set host-pc so Victim si able to communicate with outside world
#
echo -e "${YELLOW}This command must be run as root!${NC}"
sudo HOST_PC_VICTIM_LANIF="$HOST_PC_VICTIM_LANIF" HOST_PC_WANIF="$HOST_PC_WANIF" \
/bin/bash "host-pc/allow_masquerading.sh"
;;
"attacker")
#
# Copy ddos scripts to the attacker machine
scp -r ddos_scripts/ "$ATTACKER_USR@$ATTACKER_IP:/root/"
ssh -l "$ATTACKER_USR" "$ATTACKER_IP" \
VICTIM_NETWORK="$VICTIM_NETWORK" \
SURICATA_IP="$SURICATA_IP" \
/bin/bash <"attacker/set_up_attacker.sh"
;;
"ntp")
echo -e "${YELLOW}This must be run after attacker has been set up!${NC}"
scp amp_server/ntp.conf "$AMP_SERVER_USR@$AMP_SERVER_IP:/etc"
ssh -l "$AMP_SERVER_USR" "$AMP_SERVER_IP" \
VICTIM_NETWORK="$VICTIM_NETWORK" \
SURICATA_IP="$SURICATA_IP" \
/bin/bash <"amp_server/set_ntp_server.sh"
# Add 600 entries to the ntp server
# https://samsclass.info/124/proj14/p6x-NTP-DrDOS.htm
echo -e "${YELLOW}This can take a while...${NC}"
ssh -l "$ATTACKER_USR" "$ATTACKER_IP" \
"pushd /root/ddos_scripts/ntpdos; /bin/bash 600ntp.sh >/var/log/600ntp.sh 2>/var/log/600ntp.err; popd"
;;
"memcached")
scp amp_server/memcached.conf "$AMP_SERVER_USR@$AMP_SERVER_IP:/etc"
ssh -l "$AMP_SERVER_USR" "$AMP_SERVER_IP" \
VICTIM_NETWORK="$VICTIM_NETWORK"\
SURICATA_IP="$SURICATA_IP" \
/bin/bash <"amp_server/set_memcached_server.sh"
;;
"dns")
scp amp_server/named.conf.default-zones amp_server/named.conf.options amp_server/mydb.root \
"$AMP_SERVER_USR@$AMP_SERVER_IP:/etc/bind/"
ssh -l "$AMP_SERVER_USR" "$AMP_SERVER_IP" \
VICTIM_NETWORK="$VICTIM_NETWORK"\
SURICATA_IP="$SURICATA_IP" \
/bin/bash <"amp_server/set_dns_server.sh"
;;
*)
echo -e "${RED}Wrong argument: '$1'!${NC}"
print_help
exit 1
esac