-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
94 lines (77 loc) Β· 2.56 KB
/
install.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
#!/bin/bash
# Honeypot Security Tool Installation Script
echo "π Starting Honeypot Installation..."
# Ensure the script is run as root
if [ "$(id -u)" -ne 0 ]; then
echo "β This script must be run as root! Use: sudo ./install.sh"
exit 1
fi
# Update system packages
echo "π Updating system packages..."
apt update && apt upgrade -y
# Install required dependencies
echo "π¦ Installing dependencies..."
apt install -y python3 python3-pip python3-venv ufw logrotate iptables fail2ban
# Create a dedicated user for the honeypot
if id "honeypot" &>/dev/null; then
echo "π€ Honeypot user already exists."
else
echo "π€ Creating honeypot user..."
useradd -r -s /usr/sbin/nologin honeypot
fi
# Set up the honeypot directory
echo "π Setting up directories..."
mkdir -p /honeypot/logs /honeypot/config /honeypot/analytics
chown -R honeypot:honeypot /honeypot
chmod -R 750 /honeypot
# Check if honeypot.py exists before copying
if [ ! -f honeypot/src/honeypot.py ]; then
echo "β Error: honeypot.py not found! Make sure it's in the correct directory."
exit 1
fi
# Copy honeypot files to the system
echo "π₯ Copying honeypot files..."
cp -r honeypot/src/*.py /honeypot/
cp -r config/ /honeypot/
cp config/honeypot.service /etc/systemd/system/
# Set correct permissions
echo "π Setting permissions..."
chown -R honeypot:honeypot /honeypot
chmod -R 750 /honeypot
# Install Python dependencies
echo "π Installing Python dependencies..."
python3 -m venv /honeypot/venv
source /honeypot/venv/bin/activate
if [ -f /honeypot/config/requirements.txt ]; then
pip install -r /honeypot/config/requirements.txt
else
echo "β Error: requirements.txt not found!"
deactivate
exit 1
fi
deactivate
# Enable and start honeypot service
echo "π οΈ Enabling and starting honeypot service..."
systemctl daemon-reload
if [ -f /etc/systemd/system/honeypot.service ]; then
systemctl enable honeypot.service
systemctl start honeypot.service
else
echo "β Error: honeypot.service file not found!"
exit 1
fi
# Configure firewall (optional)
echo "π₯ Configuring UFW Firewall..."
ufw allow 22/tcp # SSH
ufw allow 80/tcp # Web dashboard (if applicable)
ufw allow 443/tcp # HTTPS (if applicable)
ufw enable
# Set up log rotation
if [ -f config/logrotate.conf ]; then
echo "π Configuring log rotation..."
cp config/logrotate.conf /etc/logrotate.d/honeypot
else
echo "β οΈ Warning: logrotate.conf file not found! Skipping log rotation setup."
fi
echo "β
Installation complete! Check service status:"
systemctl status honeypot.service