pull/6/head
Cédric Bonhomme 2017-08-30 08:01:08 +02:00
parent 0aaeb86232
commit 3a72694a69
No known key found for this signature in database
GPG Key ID: A1CB94DE57B7A70D
3 changed files with 39 additions and 36 deletions

2
README.rst Normal file → Executable file
View File

@ -39,7 +39,7 @@ If you do not want a development environment with synced folders:
$ git clone https://github.com/MISP/misp-vagrant.git $ git clone https://github.com/MISP/misp-vagrant.git
$ cd misp-vagrant/ $ cd misp-vagrant/
$ MISP_ENV='demo' $ export MISP_ENV='demo'
$ vagrant up $ vagrant up
Modules activated by default in the VM: Modules activated by default in the VM:

9
Vagrantfile vendored Normal file → Executable file
View File

@ -46,8 +46,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# the path on the guest to mount the folder. And the optional third # the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options. # argument is a set of non-required options.
disabled = true disabled = true
if MISP_ENV == "dev" vm_name = "MISP - Ubuntu 17.04"
if "#{MISP_ENV}" == "dev"
disabled = false disabled = false
vm_name.concat(" - DEV")
end end
config.vm.synced_folder "..", "/var/www/MISP", config.vm.synced_folder "..", "/var/www/MISP",
owner: "www-data", group: "www-data", disabled: disabled owner: "www-data", group: "www-data", disabled: disabled
@ -61,8 +64,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# vb.gui = true # vb.gui = true
# #
# # Use VBoxManage to customize the VM. For example to change memory: # # Use VBoxManage to customize the VM. For example to change memory:
vb.customize ["modifyvm", :id, "--memory", "4096"] vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--name", "MISP - Ubuntu 17.04 - DEV"] vb.customize ["modifyvm", :id, "--name", vm_name]
end end
# #
# View the documentation for the provider you're using for more # View the documentation for the provider you're using for more

64
bootstrap.sh Normal file → Executable file
View File

@ -1,8 +1,11 @@
#! /usr/bin/env bash #! /usr/bin/env bash
MISP_ENV=$1 MISP_ENV=$1
if [ "$MISP_ENV" != "dev" ]; then
echo $MISP_ENV echo "Deployment of a MISP demo environment..."
else
echo "Deployment of a MISP development environment..."
fi
# Database configuration # Database configuration
DBHOST='localhost' DBHOST='localhost'
@ -34,20 +37,16 @@ GPG_KEY_LENGTH='2048'
GPG_PASSPHRASE='' GPG_PASSPHRASE=''
echo "--- Installing MISP... ---"
echo "--- Updating packages list ---"
echo "\n--- Installing MISP... ---\n"
echo "\n--- Updating packages list ---\n"
sudo apt-get -qq update sudo apt-get -qq update
echo "\n--- Install base packages ---\n" echo "--- Install base packages ---"
sudo apt-get -y install curl net-tools gcc git gnupg-agent make python openssl redis-server sudo vim zip > /dev/null 2>&1 sudo apt-get -y install curl net-tools gcc git gnupg-agent make python openssl redis-server sudo vim zip > /dev/null 2>&1
echo "\n--- Installing and configuring Postfix ---\n" echo "--- Installing and configuring Postfix ---"
# # Postfix Configuration: Satellite system # # Postfix Configuration: Satellite system
# # change the relay server later with: # # change the relay server later with:
# sudo postconf -e 'relayhost = example.com' # sudo postconf -e 'relayhost = example.com'
@ -57,7 +56,7 @@ echo "postfix postfix/main_mailer_type string 'Satellite system'" | debconf-set-
sudo apt-get install -y postfix > /dev/null 2>&1 sudo apt-get install -y postfix > /dev/null 2>&1
echo "\n--- Installing MariaDB specific packages and settings ---\n" echo "--- Installing MariaDB specific packages and settings ---"
sudo apt-get install -y mariadb-client mariadb-server > /dev/null 2>&1 sudo apt-get install -y mariadb-client mariadb-server > /dev/null 2>&1
# Secure the MariaDB installation (especially by setting a strong root password) # Secure the MariaDB installation (especially by setting a strong root password)
sleep 7 # give some time to the DB to launch... sleep 7 # give some time to the DB to launch...
@ -86,7 +85,7 @@ EOF
sudo apt-get purge -y expect > /dev/null 2>&1 sudo apt-get purge -y expect > /dev/null 2>&1
echo "\n--- Installing Apache2 ---\n" echo "--- Installing Apache2 ---"
sudo apt-get install -y apache2 apache2-doc apache2-utils > /dev/null 2>&1 sudo apt-get install -y apache2 apache2-doc apache2-utils > /dev/null 2>&1
sudo a2dismod status > /dev/null 2>&1 sudo a2dismod status > /dev/null 2>&1
sudo a2enmod ssl > /dev/null 2>&1 sudo a2enmod ssl > /dev/null 2>&1
@ -95,17 +94,18 @@ sudo a2dissite 000-default > /dev/null 2>&1
sudo a2ensite default-ssl > /dev/null 2>&1 sudo a2ensite default-ssl > /dev/null 2>&1
echo "\n--- Installing PHP-specific packages ---\n" echo "--- Installing PHP-specific packages ---"
sudo apt-get install -y libapache2-mod-php php php-cli php-crypt-gpg php-dev php-json php-mysql php-opcache php-readline php-redis php-xml > /dev/null 2>&1 sudo apt-get install -y libapache2-mod-php php php-cli php-crypt-gpg php-dev php-json php-mysql php-opcache php-readline php-redis php-xml > /dev/null 2>&1
echo "\n--- Restarting Apache ---\n" echo "--- Restarting Apache ---"
sudo systemctl restart apache2 > /dev/null 2>&1 sudo systemctl restart apache2 > /dev/null 2>&1
echo "\n--- Retrieving MISP ---\n" echo "--- Retrieving MISP ---"
if [ "$MISP_ENV" != "dev" ]; then if [ "$MISP_ENV" != "dev" ]; then
mkdir $PATH_TO_MISP mkdir $PATH_TO_MISP
sudo chown www-data:www-data $PATH_TO_MISP
sudo -u www-data git clone https://github.com/MISP/MISP.git $PATH_TO_MISP sudo -u www-data git clone https://github.com/MISP/MISP.git $PATH_TO_MISP
fi fi
sudo chown www-data:www-data $PATH_TO_MISP sudo chown www-data:www-data $PATH_TO_MISP
@ -118,7 +118,7 @@ sudo -u www-data git config core.filemode false
# chmod -R 700 $PATH_TO_MISP # chmod -R 700 $PATH_TO_MISP
echo "\n--- Installing Mitre's STIX ---\n" echo "--- Installing Mitre's STIX ---"
sudo apt-get install -y python-dev python-pip libxml2-dev libxslt1-dev zlib1g-dev python-setuptools > /dev/null 2>&1 sudo apt-get install -y python-dev python-pip libxml2-dev libxslt1-dev zlib1g-dev python-setuptools > /dev/null 2>&1
cd $PATH_TO_MISP/app/files/scripts cd $PATH_TO_MISP/app/files/scripts
sudo -u www-data git clone https://github.com/CybOXProject/python-cybox.git sudo -u www-data git clone https://github.com/CybOXProject/python-cybox.git
@ -137,7 +137,7 @@ sudo -u www-data git checkout v1.0.2
sudo python setup.py install > /dev/null 2>&1 sudo python setup.py install > /dev/null 2>&1
echo "\n--- Retrieving CakePHP... ---\n" echo "--- Retrieving CakePHP... ---"
# CakePHP is included as a submodule of MISP, execute the following commands to let git fetch it: # CakePHP is included as a submodule of MISP, execute the following commands to let git fetch it:
cd $PATH_TO_MISP cd $PATH_TO_MISP
sudo -u www-data git submodule init sudo -u www-data git submodule init
@ -153,7 +153,7 @@ sudo phpenmod redis
sudo -u www-data cp -fa $PATH_TO_MISP/INSTALL/setup/config.php $PATH_TO_MISP/app/Plugin/CakeResque/Config/config.php sudo -u www-data cp -fa $PATH_TO_MISP/INSTALL/setup/config.php $PATH_TO_MISP/app/Plugin/CakeResque/Config/config.php
echo "\n--- Setting the permissions... ---\n" echo "--- Setting the permissions... ---"
sudo chown -R www-data:www-data $PATH_TO_MISP sudo chown -R www-data:www-data $PATH_TO_MISP
sudo chmod -R 750 $PATH_TO_MISP sudo chmod -R 750 $PATH_TO_MISP
sudo chmod -R g+ws $PATH_TO_MISP/app/tmp sudo chmod -R g+ws $PATH_TO_MISP/app/tmp
@ -161,7 +161,7 @@ sudo chmod -R g+ws $PATH_TO_MISP/app/files
sudo chmod -R g+ws $PATH_TO_MISP/app/files/scripts/tmp sudo chmod -R g+ws $PATH_TO_MISP/app/files/scripts/tmp
echo "\n--- Creating a database user... ---\n" echo "--- Creating a database user... ---"
sudo mysql -u $DBUSER_ADMIN -p$DBPASSWORD_ADMIN -e "create database $DBNAME;" sudo mysql -u $DBUSER_ADMIN -p$DBPASSWORD_ADMIN -e "create database $DBNAME;"
sudo mysql -u $DBUSER_ADMIN -p$DBPASSWORD_ADMIN -e "grant usage on *.* to $DBNAME@localhost identified by '$DBPASSWORD_MISP';" sudo mysql -u $DBUSER_ADMIN -p$DBPASSWORD_ADMIN -e "grant usage on *.* to $DBNAME@localhost identified by '$DBPASSWORD_MISP';"
sudo mysql -u $DBUSER_ADMIN -p$DBPASSWORD_ADMIN -e "grant all privileges on $DBNAME.* to '$DBUSER_MISP'@'localhost';" sudo mysql -u $DBUSER_ADMIN -p$DBPASSWORD_ADMIN -e "grant all privileges on $DBNAME.* to '$DBUSER_MISP'@'localhost';"
@ -170,14 +170,14 @@ sudo mysql -u $DBUSER_ADMIN -p$DBPASSWORD_ADMIN -e "flush privileges;"
sudo -u www-data mysql -u $DBUSER_MISP -p$DBPASSWORD_MISP $DBNAME < /var/www/MISP/INSTALL/MYSQL.sql sudo -u www-data mysql -u $DBUSER_MISP -p$DBPASSWORD_MISP $DBNAME < /var/www/MISP/INSTALL/MYSQL.sql
echo "\n--- Configuring Apache... ---\n" echo "--- Configuring Apache... ---"
# !!! apache.24.misp.ssl seems to be missing # !!! apache.24.misp.ssl seems to be missing
#cp $PATH_TO_MISP/INSTALL/apache.24.misp.ssl /etc/apache2/sites-available/misp-ssl.conf #cp $PATH_TO_MISP/INSTALL/apache.24.misp.ssl /etc/apache2/sites-available/misp-ssl.conf
# If a valid SSL certificate is not already created for the server, create a self-signed certificate: # If a valid SSL certificate is not already created for the server, create a self-signed certificate:
sudo openssl req -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=$OPENSSL_C/ST=$OPENSSL_ST/L=$OPENSSL_L/O=<$OPENSSL_O/OU=$OPENSSL_OU/CN=$OPENSSL_CN/emailAddress=$OPENSSL_EMAILADDRESS" -keyout /etc/ssl/private/misp.local.key -out /etc/ssl/private/misp.local.crt > /dev/null sudo openssl req -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=$OPENSSL_C/ST=$OPENSSL_ST/L=$OPENSSL_L/O=<$OPENSSL_O/OU=$OPENSSL_OU/CN=$OPENSSL_CN/emailAddress=$OPENSSL_EMAILADDRESS" -keyout /etc/ssl/private/misp.local.key -out /etc/ssl/private/misp.local.crt > /dev/null
echo "\n--- Add a VirtualHost for MISP ---\n" echo "--- Add a VirtualHost for MISP ---"
sudo cat > /etc/apache2/sites-available/misp-ssl.conf <<EOF sudo cat > /etc/apache2/sites-available/misp-ssl.conf <<EOF
<VirtualHost *:80> <VirtualHost *:80>
ServerAdmin admin@misp.local ServerAdmin admin@misp.local
@ -235,15 +235,15 @@ sudo a2dissite default-ssl
sudo a2ensite misp-ssl sudo a2ensite misp-ssl
echo "\n--- Restarting Apache ---\n" echo "--- Restarting Apache ---"
sudo systemctl restart apache2 > /dev/null 2>&1 sudo systemctl restart apache2 > /dev/null 2>&1
echo "\n--- Configuring log rotation ---\n" echo "--- Configuring log rotation ---"
sudo cp $PATH_TO_MISP/INSTALL/misp.logrotate /etc/logrotate.d/misp sudo cp $PATH_TO_MISP/INSTALL/misp.logrotate /etc/logrotate.d/misp
echo "\n--- MISP configuration ---\n" echo "--- MISP configuration ---"
# There are 4 sample configuration files in /var/www/MISP/app/Config that need to be copied # There are 4 sample configuration files in /var/www/MISP/app/Config that need to be copied
sudo -u www-data cp -a $PATH_TO_MISP/app/Config/bootstrap.default.php /var/www/MISP/app/Config/bootstrap.php sudo -u www-data cp -a $PATH_TO_MISP/app/Config/bootstrap.default.php /var/www/MISP/app/Config/bootstrap.php
sudo -u www-data cp -a $PATH_TO_MISP/app/Config/database.default.php /var/www/MISP/app/Config/database.php sudo -u www-data cp -a $PATH_TO_MISP/app/Config/database.default.php /var/www/MISP/app/Config/database.php
@ -275,7 +275,7 @@ sudo $PATH_TO_MISP/app/Console/cake Baseurl $MISP_BASEURL
sudo $PATH_TO_MISP/app/Console/cake Live $MISP_LIVE sudo $PATH_TO_MISP/app/Console/cake Live $MISP_LIVE
echo "\n--- Generating a GPG encryption key... ---\n" echo "--- Generating a GPG encryption key... ---"
sudo apt-get install -y rng-tools haveged sudo apt-get install -y rng-tools haveged
sudo -u www-data mkdir $PATH_TO_MISP/.gnupg sudo -u www-data mkdir $PATH_TO_MISP/.gnupg
sudo chmod 700 $PATH_TO_MISP/.gnupg sudo chmod 700 $PATH_TO_MISP/.gnupg
@ -299,7 +299,7 @@ rm gen-key-script
sudo -u www-data gpg --homedir $PATH_TO_MISP/.gnupg --batch --gen-key gen-key-scriptgpg --homedir $PATH_TO_MISP/.gnupg --export --armor $EMAIL_ADDRESS > $PATH_TO_MISP/app/webroot/gpg.asc sudo -u www-data gpg --homedir $PATH_TO_MISP/.gnupg --batch --gen-key gen-key-scriptgpg --homedir $PATH_TO_MISP/.gnupg --export --armor $EMAIL_ADDRESS > $PATH_TO_MISP/app/webroot/gpg.asc
echo "\n--- Making the background workers start on boot... ---\n" echo "--- Making the background workers start on boot... ---"
sudo chmod 755 $PATH_TO_MISP/app/Console/worker/start.sh sudo chmod 755 $PATH_TO_MISP/app/Console/worker/start.sh
# With systemd: # With systemd:
# sudo cat > /etc/systemd/system/workers.service <<EOF # sudo cat > /etc/systemd/system/workers.service <<EOF
@ -327,7 +327,7 @@ fi
sudo sed -i -e '$i \sudo -u www-data bash /var/www/MISP/app/Console/worker/start.sh\n' /etc/rc.local sudo sed -i -e '$i \sudo -u www-data bash /var/www/MISP/app/Console/worker/start.sh\n' /etc/rc.local
echo "\n--- Installing MISP modules... ---\n" echo "--- Installing MISP modules... ---"
sudo apt-get install -y python3-dev python3-pip libpq5 libjpeg-dev > /dev/null 2>&1 sudo apt-get install -y python3-dev python3-pip libpq5 libjpeg-dev > /dev/null 2>&1
cd /usr/local/src/ cd /usr/local/src/
sudo git clone https://github.com/MISP/misp-modules.git sudo git clone https://github.com/MISP/misp-modules.git
@ -355,21 +355,21 @@ sudo sed -i -e '$i \sudo -u www-data misp-modules -l 0.0.0.0 -s &\n' /etc/rc.loc
echo "\n--- Restarting Apache... ---\n" echo "--- Restarting Apache... ---"
sudo systemctl restart apache2 > /dev/null 2>&1 sudo systemctl restart apache2 > /dev/null 2>&1
sleep 5 sleep 5
echo "\n--- Updating the galaxies... ---\n" echo "--- Updating the galaxies... ---"
sudo -E $PATH_TO_MISP/app/Console/cake userInit -q > /dev/null sudo -E $PATH_TO_MISP/app/Console/cake userInit -q > /dev/null
AUTH_KEY=$(mysql -u $DBUSER_MISP -p$DBPASSWORD_MISP misp -e "SELECT authkey FROM users;" | tail -1) AUTH_KEY=$(mysql -u $DBUSER_MISP -p$DBPASSWORD_MISP misp -e "SELECT authkey FROM users;" | tail -1)
curl -k -X POST -H "Authorization: $AUTH_KEY" -H "Accept: application/json" -v http://127.0.0.1/galaxies/update > /dev/null 2>&1 curl -k -X POST -H "Authorization: $AUTH_KEY" -H "Accept: application/json" -v http://127.0.0.1/galaxies/update > /dev/null 2>&1
echo "\n--- Updating the taxonomies... ---\n" echo "--- Updating the taxonomies... ---"
curl -k -X POST -H "Authorization: $AUTH_KEY" -H "Accept: application/json" -v http://127.0.0.1/taxonomies/update > /dev/null 2>&1 curl -k -X POST -H "Authorization: $AUTH_KEY" -H "Accept: application/json" -v http://127.0.0.1/taxonomies/update > /dev/null 2>&1
# echo "\n--- Enabling MISP new pub/sub feature (ZeroMQ)... ---\n" # echo "--- Enabling MISP new pub/sub feature (ZeroMQ)... ---"
# # ZeroMQ depends on the Python client for Redis # # ZeroMQ depends on the Python client for Redis
# pip install redis > /dev/null 2>&1 # pip install redis > /dev/null 2>&1
# ## Install ZeroMQ and prerequisites # ## Install ZeroMQ and prerequisites
@ -397,7 +397,7 @@ curl -k -X POST -H "Authorization: $AUTH_KEY" -H "Accept: application/json" -v h
# pip install pyzmq > /dev/null 2>&1 # pip install pyzmq > /dev/null 2>&1
echo "\e[32mMISP is ready\e[0m" echo "--- MISP is ready ---"
echo "Login and passwords for the MISP image are the following:" echo "Login and passwords for the MISP image are the following:"
echo "Web interface (default network settings): $MISP_BASEURL" echo "Web interface (default network settings): $MISP_BASEURL"
echo "MISP admin: admin@admin.test/admin" echo "MISP admin: admin@admin.test/admin"