-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_prepared_agent.sh
executable file
·97 lines (75 loc) · 2.39 KB
/
create_prepared_agent.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
#!/bin/bash
#export API_KEY=abcdef
#curl --silent --location https://xxxx/ossec_agent/install | sudo bash -
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
set -e
#rpm or deb?
#install latest ossec agent deb/rpm
#apt-get --purge -y remove ossec-hids-agent
export OSSEC_MANAGER_IP="54.244.48.91"
#SNORT=1
check_cmd() {
if command -v $1 >/dev/null 2>&1
then
return 0
else
return 1
fi
}
echo "client $OSSEC_MANAGER_IP" > /client
if check_cmd yum; then
yum install -y inotify-tools aws-cli tcpdump --enablerepo=epel
yum -y install make gcc git flex bison libpcap-devel pcre-devel libdnet-devel.x86_64 zlib-devel libnghttp2-devel --enablerepo=epel
yum install -y https://ossec.wazuh.com/el/7/x86_64/ossec-hids-agent-2.8.3-4.el7.x86_64.rpm
else
apt-get install -yqq expect
URL='https://ossec.wazuh.com/repos/apt/ubuntu/pool/main/o/ossec-hids-agent/ossec-hids-agent_2.8.3-4xenial_amd64.deb'
TMPFILE=`mktemp`
wget "$URL" -qO $TMPFILE
DEBIAN_FRONTEND=noninteractive dpkg -i --force-all $TMPFILE
rm -f $TMPFILE
fi
cd /
wget http://download.redis.io/releases/redis-3.2.8.tar.gz
tar xvfz redis-3.2.8.tar.gz
cd redis-3.2.8
make distclean
make
cd src
cp redis-server redis-cli /usr/local/bin
mv /var/ossec/etc/ossec.conf /var/ossec/etc/ossec.conf.orig
cat >/var/ossec/etc/ossec.conf <<EOL
<ossec_config>
<client>
<server-ip>RPLC_IP</server-ip>
<config-profile>RPLC_PROFILE</config-profile>
</client>
</ossec_config>
EOL
sed -i'' "s/RPLC_IP/$OSSEC_MANAGER_IP/" /var/ossec/etc/ossec.conf
/var/ossec/bin/agent-auth -m "$OSSEC_MANAGER_IP"
/var/ossec/bin/ossec-control restart
cd "$DIR"
if [ -z "$SNORT" ]; then
sed -i'' 's/RPLC_PROFILE/default/' /var/ossec/etc/ossec.conf
crontab -l > /tmp/rootcron.tmp 2>/dev/null
if [[ $(cat /tmp/rootcron.tmp) != *"tcpdmps3"* ]]
then
echo "* * * * * /usr/bin/flock -w 1000 /var/tcpdump.lock $DIR/tcpdmps3.sh" >> /tmp/rootcron.tmp
crontab /tmp/rootcron.tmp
else
:
fi
rm -rf /tmp/rootcron.tmp
else
sed -i'' 's/RPLC_PROFILE/snort/' /var/ossec/etc/ossec.conf
echo "snort" > /snort_installed
./install_snort_server.sh
fi
#this needs to be secured via ssl certificates
#/var/ossec/bin/ossec-agentd -f -d
#get ip address
#register agent and get keys from server
# add server ip to agent
#curl -XPOST https://xxxx/ossec_agent/register/$API_KEY/$(HOSTNAME)
#//http://documentation.wazuh.com/en/latest/ossec_reference.html