-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·118 lines (103 loc) · 3.37 KB
/
install.sh
File metadata and controls
executable file
·118 lines (103 loc) · 3.37 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
# Simple Firewall Installation Script
echo "🛡️ Installing Simple DDoS/DoS Protection Firewall"
echo "=================================================="
# Check if running as root for system-wide installation
if [[ $EUID -eq 0 ]]; then
echo "⚠️ Running as root - installing system-wide"
INSTALL_PREFIX="/usr/local/bin"
else
echo "Installing for current user"
INSTALL_PREFIX="$HOME/.local/bin"
mkdir -p "$INSTALL_PREFIX"
fi
# Check Python version
echo "Checking Python version..."
if command -v python3 &> /dev/null; then
PYTHON_VERSION=$(python3 --version 2>&1 | cut -d' ' -f2 | cut -d'.' -f1,2)
echo "✅ Python 3 found: $(python3 --version)"
else
echo "❌ Python 3 not found. Please install Python 3.6 or later."
exit 1
fi
# Check if pip is available
echo "Checking pip..."
if command -v pip3 &> /dev/null; then
echo "✅ pip3 found"
elif command -v pip &> /dev/null; then
echo "✅ pip found"
else
echo "❌ pip not found. Please install pip."
exit 1
fi
# Install Python packages
echo "Installing Python packages..."
if command -v pip3 &> /dev/null; then
pip3 install --user scapy psutil colorama netifaces
else
pip install --user scapy psutil colorama netifaces
fi
if [ $? -eq 0 ]; then
echo "✅ Python packages installed successfully"
else
echo "❌ Failed to install Python packages"
exit 1
fi
# Check for iptables
echo "Checking iptables..."
if command -v iptables &> /dev/null; then
echo "✅ iptables found"
else
echo "❌ iptables not found. Please install iptables:"
echo " Ubuntu/Debian: sudo apt-get install iptables"
echo " CentOS/RHEL: sudo yum install iptables"
exit 1
fi
# Make scripts executable
echo "Setting up scripts..."
chmod +x run.py simple_firewall.py test_attacks.py
# Create a system-wide command (optional)
if [[ $EUID -eq 0 ]]; then
echo "Creating system-wide commands..."
# Create firewall command
cat > "$INSTALL_PREFIX/simple-firewall" << 'EOF'
#!/bin/bash
cd "$(dirname "$(readlink -f "$0")")/../share/simple-firewall" || cd "/opt/simple-firewall" || cd "$(pwd)"
exec python3 run.py "$@"
EOF
chmod +x "$INSTALL_PREFIX/simple-firewall"
# Create installation directory
mkdir -p /opt/simple-firewall
cp -r . /opt/simple-firewall/
echo "✅ System-wide installation complete"
echo " Run: sudo simple-firewall --start"
else
# Create user command
mkdir -p "$HOME/.local/share/simple-firewall"
cp -r . "$HOME/.local/share/simple-firewall/"
cat > "$INSTALL_PREFIX/simple-firewall" << 'EOF'
#!/bin/bash
cd "$HOME/.local/share/simple-firewall"
exec python3 run.py "$@"
EOF
chmod +x "$INSTALL_PREFIX/simple-firewall"
echo "✅ User installation complete"
echo " Add $HOME/.local/bin to your PATH if needed"
echo " Run: sudo simple-firewall --start"
fi
echo ""
echo "🎉 Installation Complete!"
echo "========================="
echo ""
echo "Usage:"
echo " sudo python3 run.py --start # Start firewall"
echo " python3 run.py --stats # Show statistics"
echo " python3 run.py --test 127.0.0.1 # Test firewall"
echo ""
echo "Configuration:"
echo " Edit firewall_config.json to customize thresholds"
echo ""
echo "Documentation:"
echo " See README.md for detailed usage instructions"
echo ""
echo "⚠️ Remember: This firewall requires root privileges to modify iptables!"