Nakiami / mellivora

Mellivora is a CTF engine written in PHP
GNU General Public License v3.0
441 stars 171 forks source link

Install Mellivora on Arch Linux #83

Closed g4rcez closed 7 years ago

g4rcez commented 7 years ago

I triying install the Mellivora in ArchLinux, but the application stop on call localhost. Please, help me to configure the CTF Platform

nix-xin commented 7 years ago

Hi Allen, please send examples of the error you're seeing. I might be able to help.

R/ Luciano

On Mar 16, 2017, at 3:12 PM, Allan Garcez notifications@github.com wrote:

right I triying install the Mellivora in ArchLinux, but the application stop on call localhost. Please, help me to configure the CTF Platform

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

g4rcez commented 7 years ago

I don't have images of errors. But Apache don't redirect to Mellivora Platform.

noraj commented 7 years ago

Here is what I did on archlinux and it's not working either (see https://github.com/Nakiami/mellivora/issues/82):

Update your system:

# pacman -Syu

Install php and extensions:

# pacman -S php php-pear php-fpm

Install Composer:

$ curl -sS https://getcomposer.org/installer | php
# mv composer.phar /usr/local/bin/composer

Go in the main web folder:

$ cd /srv/http

Install git and clone the repo:

# pacman -S git
# git clone https://github.com/Nakiami/mellivora.git

Give permissions to the http user:

# chown -R http:http mellivora
$ cd mellivora

Fetch required dependencies using Composer:

$ sudo -u http composer install

Copy configurations files:

$ sudo -u http cp /srv/http/mellivora/include/config/config.inc.php.example /srv/http/mellivora/include/config/config.inc.php
$ sudo -u http cp /srv/http/mellivora/include/config/db.inc.php.example /srv/http/mellivora/include/config/db.inc.php

Edit the configuration file:

$ sudo -u http vim /srv/http/mellivora/include/config/config.inc.php

Edit date.timezone in php.ini:

# vim /etc/php/php.ini

Install nginx:

# pacman -S nginx
# mkdir /etc/nginx/servers-available /etc/nginx/servers-enabled /etc/nginx/ssl

Then add include /etc/nginx/servers-enabled/*; at the end of the main http block into /etc/nginx/nginx.conf.

Copy and edit the nginx config file:

# cp /srv/http/mellivora/install/mellivora.nginx.conf /etc/nginx/servers-available/mellivora.conf
# vim /etc/nginx/servers-available/mellivora.conf

Enable the server:

# ln -s /etc/nginx/servers-available/mellivora.conf /etc/nginx/servers-enabled/mellivora.conf

Manage your SSL certificates.

Start nginx and php-fpm:

# systemctl start nginx.service
# systemctl start php-fpm.service

Install a MySQL database:

# pacman -S mariadb

Run the prepare script:

# mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Start MariaDB:

# systemctl start mariadb.service

Run the secure script:

# mysql_secure_installation

Create the Mellivora database and import the provided structure:

$ echo "CREATE DATABASE mellivora CHARACTER SET utf8 COLLATE utf8_general_ci;" | mysql -u root -p
$ mysql mellivora -u root -p < /srv/http/mellivora/install/mellivora.sql
$ mysql mellivora -u root -p < /srv/http/mellivora/install/countries.sql

Create a new MySQL user:

$ echo "GRANT ALL PRIVILEGES ON mellivora.* TO 'YourUserName'@'%' IDENTIFIED BY 'YourPassword';" | mysql -u root -p

Update the database config settings to use the database and user we created above:

$ sudo -u http vim /srv/http/mellivora/include/config/db.inc.php

Here my configuration files:

$ cat /etc/nginx/servers-enabled/mellivora.conf                                                        
server {
    listen 80;
    listen [::]:80;
    listen 443 ssl;

    # ========================================================
    # =========== Modify from here ===========================
    # ========================================================

    root /srv/http/mellivora/htdocs;
    server_name localhost;

    index index.html index.htm index.php;

    access_log /var/log/nginx/localhost_access.log;
    error_log /var/log/nginx/localhost_error.log;

    ssl on;
    ssl_certificate /etc/nginx/ssl/ctf.localhost.crt;
    ssl_certificate_key /etc/nginx/ssl/ctf.localhost.key;

    # ========================================================
    # =========== End of modify ==============================
    # ========================================================

    location / {
        try_files $uri $uri/ @extensionless-php;
    }

    location @extensionless-php {
        rewrite ^(.*)$ $1.php last;
    }

    location ~ \.php(?:$|/) {
        include /etc/nginx/fastcgi_params;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTPS on;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    }
}

$ cat /srv/http/mellivora/include/config/config.inc.php                                                
<?php

// * Database time and PHP time should always be the same.
// * See: http://www.php.net/manual/en/timezones.php for zones
// * If time zones differ, you can use the settings below to rectify
//   the problem, but this is an expensive operation, as the setting
//   is changed each time the page loads. You should probably use the
//   setting "date.timezone" in php.ini.
//const CONFIG_DATE_DEFAULT_TIMEZONE = 'Australia/Sydney';
//date_default_timezone_set(CONFIG_DATE_DEFAULT_TIMEZONE);

// paths below must end in a "/" !
const CONFIG_PATH_BASE = '/srv/http/mellivora/';

// database settings
require('db.inc.php');

// language
const CONFIG_SITE_LANGUAGE = 'en';

// general site settings
const CONFIG_SITE_NAME = 'Mellivora';
const CONFIG_SITE_SLOGAN = 'Mellivora, the CTF engine';
const CONFIG_SITE_DESCRIPTION = 'Description here';
const CONFIG_SITE_URL = 'http://localhost/';
const CONFIG_SITE_URL_STATIC_RESOURCES = 'http://localhost/';
const CONFIG_SITE_ADMIN_RELPATH = 'admin/';
define('CONFIG_SITE_ADMIN_URL', CONFIG_SITE_URL . CONFIG_SITE_ADMIN_RELPATH);

// redirects:
const CONFIG_INDEX_REDIRECT_TO = 'home'; // from index.php
const CONFIG_LOGIN_REDIRECT_TO = 'home'; // after login
const CONFIG_REGISTER_REDIRECT_TO = 'home'; // after successful account registration

// team names longer than 30 chars may break page layout
const CONFIG_MIN_TEAM_NAME_LENGTH = 2;
const CONFIG_MAX_TEAM_NAME_LENGTH = 30;
const CONFIG_ACCOUNTS_SIGNUP_ALLOWED = true;
const CONFIG_ACCOUNTS_DEFAULT_ENABLED = true;

// if set to true, a random password will be generated
// on signup and sent out by email to the user
const CONFIG_ACCOUNTS_EMAIL_PASSWORD_ON_SIGNUP = false;

// is site SSL compatible? if true, ssl will be forced on certain pages
const CONFIG_SSL_COMPAT = true;

// session & cookie expiry time in seconds
// 0 = until browser is closed
const CONFIG_SESSION_TIMEOUT = 0;
const CONFIG_COOKIE_TIMEOUT = 604800;

// logging options
const CONFIG_LOG_VALIDATION_FAILURE_ID = true;

// maximum file upload size
const CONFIG_MAX_FILE_UPLOAD_SIZE = 5242880;
const CONFIG_APPEND_MD5_TO_DOWNLOADS = false;

// email stuff
const CONFIG_EMAIL_USE_SMTP = false;
const CONFIG_EMAIL_FROM_EMAIL = 'you@localhost';
const CONFIG_EMAIL_FROM_NAME = 'Mellivora CTF';
// blank for same as "FROM"
const CONFIG_EMAIL_REPLYTO_EMAIL = '';
const CONFIG_EMAIL_REPLYTO_NAME = '';
// options:
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
const CONFIG_EMAIL_SMTP_DEBUG_LEVEL = 2;
const CONFIG_EMAIL_SMTP_HOST = 'smtp.gmail.com';
const CONFIG_EMAIL_SMTP_PORT = 587;
const CONFIG_EMAIL_SMTP_SECURITY = 'tls';
// require SMTP authentication?
const CONFIG_EMAIL_SMTP_AUTH = true;
const CONFIG_EMAIL_SMTP_USER = 'you@gmail.com';
const CONFIG_EMAIL_SMTP_PASSWORD = '';

// enable re-captcha on signup and various public forms
const CONFIG_RECAPTCHA_ENABLE_PUBLIC = false;
// enabled captcha also on private forms for logged in users
const CONFIG_RECAPTCHA_ENABLE_PRIVATE = false;
// re-captcha keys must be set to function
const CONFIG_RECAPTCHA_PUBLIC_KEY = '';
const CONFIG_RECAPTCHA_PRIVATE_KEY = '';

// only trust x-forwarded-for ip address if you're running
// some sort of reverse proxy, like Cloudflare. when set
// to true, the latest added forwarded-for ip will be used
// for logging and housekeeping
const CONFIG_TRUST_HTTP_X_FORWARDED_FOR_IP = false;

// when this is set to true, an IP address
// will be resolved when it is listed. set
// this to false if DNS resolution is too
// slow when listing a users IPs
const CONFIG_GET_IP_HOST_BY_ADDRESS = true;

// cache times
const CONFIG_CACHE_TIME_SCORES = 0;
const CONFIG_CACHE_TIME_HOME = 0;
const CONFIG_CACHE_TIME_USER = 0;
const CONFIG_CACHE_TIME_CHALLENGE = 0;
const CONFIG_CACHE_TIME_HINTS = 0;
const CONFIG_CACHE_TIME_FILES = 0;
const CONFIG_CACHE_TIME_COUNTRIES = 0;
const CONFIG_CACHE_TIME_DYNAMIC = 0;
const CONFIG_CACHE_TIME_REGISTER = 0;

// user tracking and statistics
const CONFIG_SEGMENT_IO_KEY = '';

// Amazon S3 credentials, for storing files in S3.
// Leave blank to store files locally.
const CONFIG_AWS_S3_KEY_ID = '';
const CONFIG_AWS_S3_SECRET = '';
const CONFIG_AWS_S3_BUCKET = '';

<?php

const DB_ENGINE = 'mysql';
const DB_HOST = 'localhost';
const DB_PORT = 3306;
const DB_NAME = 'mellivora';
const DB_USER = 'noraj';
const DB_PASSWORD = 'hereMyPwd';

All is up and running:

$ sudo systemctl status nginx php-fpm mariadb                                                          
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2017-04-06 00:29:59 CEST; 1min 45s ago
  Process: 23059 ExecStart=/usr/bin/nginx -g pid /run/nginx.pid; error_log stderr; (code=exited, status=
 Main PID: 23061 (nginx)
    Tasks: 2 (limit: 4915)
   Memory: 1.6M
      CPU: 10ms
   CGroup: /system.slice/nginx.service
           ├─23061 nginx: master process /usr/bin/nginx -g pid /run/nginx.pid; error_log stderr;
           └─23062 nginx: worker process

avril 06 00:29:59 rawsec systemd[1]: Starting A high performance web server and a reverse proxy server..
avril 06 00:29:59 rawsec systemd[1]: nginx.service: Failed to read PID from file /run/nginx.pid: Invalid
avril 06 00:29:59 rawsec systemd[1]: Started A high performance web server and a reverse proxy server.

● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2017-04-05 23:43:44 CEST; 48min ago
 Main PID: 2165 (php-fpm)
   Status: "Processes active: 0, idle: 2, Requests: 29, slow: 0, Traffic: 0req/sec"
    Tasks: 3 (limit: 4915)
   Memory: 15.3M
      CPU: 572ms
   CGroup: /system.slice/php-fpm.service
           ├─2165 php-fpm: master process (/etc/php/php-fpm.conf)
           ├─2168 php-fpm: pool www
           └─2169 php-fpm: pool www

avril 05 23:43:44 rawsec systemd[1]: Starting The PHP FastCGI Process Manager...
avril 05 23:43:44 rawsec php-fpm[2165]: [NOTICE] fpm is running, pid 2165
avril 05 23:43:44 rawsec php-fpm[2165]: [NOTICE] ready to handle connections
avril 05 23:43:44 rawsec php-fpm[2165]: [NOTICE] systemd monitor interval set to 10000ms
avril 05 23:43:44 rawsec systemd[1]: Started The PHP FastCGI Process Manager.

● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2017-04-05 23:54:41 CEST; 37min ago
  Process: 2476 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited,
  Process: 2392 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/gal
  Process: 2387 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, 
 Main PID: 2446 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 27 (limit: 4915)
   Memory: 108.8M
      CPU: 2.215s
   CGroup: /system.slice/mariadb.service
           └─2446 /usr/bin/mysqld
Nakiami commented 7 years ago

Do you have any errors in your web server or db log?

noraj commented 7 years ago

Yes I have this error: https://github.com/Nakiami/mellivora/issues/82

noraj commented 7 years ago

@Nakiami have you any idea? I never succeed to make Mellivora works.

Nakiami commented 7 years ago

I made a comment in the thread you linked above. You need to look in your system/application log files to see what error you're getting.