This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_ddosguardian_service.sh
86 lines (52 loc) · 1.79 KB
/
setup_ddosguardian_service.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
if [ -d "/etc/ddos-guardian" ]; then
echo "Directory /etc/ddos-guardian already exists."
exit 1
fi
mkdir /etc/ddos-guardian
cd /etc/ddos-guardian
git clone https://github.com/xlelord9292/ddos-guardian .
if ! command -v node &> /dev/null; then
curl -sL https://deb.nodesource.com/setup_14.x | bash -
apt install -y nodejs
fi
npm install
apt update
apt upgrade -y
cat <<EOF > /etc/systemd/system/guardian.service
[Unit]
Description=DDoS Guardian Service
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/etc/ddos-guardian
ExecStart=/usr/bin/node /etc/ddos-guardian/attacks.js
Restart=always
StandardOutput=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable guardian
systemctl start guardian
iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 3 -j ACCEPT
iptables -A INPUT -p udp -m limit --limit 1/s --limit-burst 3 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s --limit-burst 3 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -j DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -m conntrack --ctstate INVALID -j DROP
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
iptables -A INPUT -p icmp -m limit --limit 1/s -j ACCEPT
iptables -A INPUT -j LOG --log-prefix "Dropped: "
iptables -A INPUT -j DROP
iptables-save > /etc/iptables/rules.v4
cd /etc/nginx/conf.d/
git clone https://github.com/xlelord9292/ddos-guardian-layer-7
sudo apt-get install libnginx-mod-http-lua
echo "DDoS Guardian setup complete."