Sunteți pe pagina 1din 5

Preparação

A linguagem GO e o compilador GCC são pré-requisitos para a instalação do Gophish.


yum install golang

Download manual do arquivo de instalação do GO na pasta Downloads


wget https://dl.google.com/go/go1.11.linux-amd64.tar.gz

Extraia o arquivo
tar -xvf go1.11.linux-amd64.tar.gz

Mova a pasta GO
mv go /usr/local

Crie o diretório de trabalho


mkdir /usr/Projects

Incluir variáveis de ambiente


vi etc/profile.d/setup-go.sh

Conteúdo do arquivo:

export GOROOT=/usr/local/go
export GOPATH=/usr/Projects
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Atribuir permissão ao arquivo


chmod 700 setup-go.sh

Na pasta: /etc/profile.d/

Executar
. ./setup-go.sh

Verificar a variável de ambiente:


env | grep GO
go env

Verificar a versão instalada


go version

Download do gophish na pasta de Downloads


wget https://github.com/gophish/gophish/releases/download/0.7.1/gophish-
v0.7.1-linux-64bit.zip

Extrair o arquivo na pasta de Projetos


unzip /home/admin/Downloads/gophish-v0.7.1-linux-64bit.zip -d "/usr/Projects"

-------------------------------------------------------------------------------
Instalar Mysql
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
yum install mysql-server
systemctl start mysqld
mysql_secure_installation

Criando o BD

mysql -u root -p
onde a senha é 3elospwd00

create database gophish;


grant all on gophish.* to 'gophishuser' identified by 'gophish';

Em vi /etc/my.cnf
[mysqld]

sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_
CREATE_USER,NO_ENGINE_SUBSTITUTION

-------------------------------------------------------------------------------
Instalando o OpenSSL
yum group install 'Development Tools'
yum install perl-core zlib-devel -y

Em cd /usr/local/src/
wget https://www.openssl.org/source/openssl-1.1.1.tar.gz
tar -xvf openssl-1.1.1.tar.gz

cd openssl-1.1.1
openssl version -a

Em cd /usr/local/src/openssl-1.1.1

./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib


make
make test
make install

Em cd /etc/ld.so.conf.d/
vi openssl-1.1.1.conf

Copie e cole no arquivo a linha:


/usr/local/ssl/lib

sudo ldconfig -v

mv /bin/openssl /bin/openssl.BEKUP

vi /etc/profile.d/openssl.sh

Copie e cole as linhas:

#Set OPENSSL_PATH
OPENSSL_PATH="/usr/local/ssl/bin"
export OPENSSL_PATH
PATH=$PATH:$OPENSSL_PATH
export PATH

chmod +x /etc/profile.d/openssl.sh

source /etc/profile.d/openssl.sh
echo $PATH

which openssl

openssl version -a
-----------------------------------------------------------------------------

Na pasta onde está o binário do gophish, execute (usr/Projects)


openssl req -newkey rsa:2048 -nodes -keyout gophish.key -x509 -days 365 -out
gophish.crt
------------------------------------------------------------------------------

Preencha os campos requeridos

sudo vi config.json

altere o nome do certificado e chave, no exemplo acima


gophish.key
gophish.crt

Altere o nome banco: mysql

Altere o caminho do banco: gophishuser:gophish@(127.0.0.1:3306)/gophish?


charset=utf8&parseTime=True&loc=UTC

Execute:
openssl x509 -noout -in gophish.crt -fingerprint -sha1
openssl x509 -noout -in gophish.crt -fingerprint -sha256

Tornar o binário executável

sudo root
cd /usr/Projects
chmod 762 gophish
./gophish

https://localhost:3333

------------------------------------------------------------------------------

Tornando o gophish como serviço a ser inicializado automaticamente

vi /lib/systemd/system/gophish.service

[Unit]
Description=Gophish service
After=network-online.target

[Service]
Environment="GOPHISH_BIN_PATH=/usr/Projects/"
Environment="GOPHISH_LOG_PATH=/var/log/gophish/"
ExecStart=/bin/bash /usr/Projects/gophish.sh
RestartSec=1
Restart=on-failure

[Install]
WantedBy=multi-user.target

vi /usr/Projects/gophish.sh

#!/bin/bash

GOPHISH_LOG_FILE=gophish.log
GOPHISH_ERR_FILE=gophish.err

check_bin_path() {
if [[ -z "$GOPHISH_BIN_PATH" ]]; then
exit 1
fi
}

check_log_path() {
if [[ -z "$GOPHISH_LOG_PATH" ]]; then
exit 2
fi
}

create_new_log_err() {
GOPHISH_STAMP=`date +%Y%m%d%H%M%S-%N`
if [[ -e $GOPHISH_LOG_PATH$GOPHISH_LOG_FILE ]]; then
mv $GOPHISH_LOG_PATH$GOPHISH_LOG_FILE $GOPHISH_LOG_PATH$GOPHISH_LOG_FILE-
$GOPHISH_STAMP
fi

if [[ -e $GOPHISH_LOG_PATH$GOPHISH_ERR_FILE ]]; then


mv $GOPHISH_LOG_PATH$GOPHISH_ERR_FILE $GOPHISH_LOG_PATH$GOPHISH_ERR_FILE-
$GOPHISH_STAMP
fi

touch $GOPHISH_LOG_PATH$GOPHISH_LOG_FILE
touch $GOPHISH_LOG_PATH$GOPHISH_ERR_FILE
}

launch_gophish() {
cd $GOPHISH_BIN_PATH
./gophish >> $GOPHISH_LOG_PATH$GOPHISH_LOG_FILE 2>>
$GOPHISH_LOG_PATH$GOPHISH_ERR_FILE
}

check_bin_path
check_log_path
create_new_log_err
launch_gophish

vi /etc/init.d/gophish

#!/bin/bash
# /etc/init.d/gophish
# initialization file for stop/start of gophish application server
#
# chkconfig: - 64 36
# description: stops/starts gophish application server
# processname:gophish
# config:/opt/goapps/usr/Projects/config.json

# define script variables

processName=Gophish
process=gophish
appDirectory=/opt/goapps/usr/Projects
logfile=/var/log/gophish/gophish.log
errfile=/var/log/gophish/gophish.error

start() {
echo 'Starting '${processName}'...'
cd ${appDirectory}
nohup ./$process >>$logfile 2>>$errfile &
sleep 1
}

stop() {
echo 'StoppingStopping '${processName}'...'
pid=$(/usr/sbin/pidof ${process})
kill ${pid}
sleep 1
}

status() {
pid=$(/usr/sbin/pidof ${process})
if [[ "$pid" != "" ]]; then
echo ${processName}' is running...'
else
echo ${processName}' is not running...'
fi
}

case $1 in
start|stop|status) "$1" ;;
esac

------------------------------------------------------------------------------

Configurando o sendmail para enviar email através do gmail


https://www.digitalocean.com/community/questions/how-to-configure-sendmail-to-send-
mail-using-an-external-gmail-smtp-server
https://aacable.wordpress.com/2015/08/07/centos-sending-email-using-sendmail-relay-
via-gmail/
http://powdahound.com/2009/06/using-gmail-as-sendmails-relay/

S-ar putea să vă placă și