Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ##
- ## MADE CHANGES BELOW !!
- ## Author: brtw2003/bl0wf1sh '10
- ## Complete documentation: http://dradisframework.org
- ##
- DRADIS_PORT="3004"
- DRADIS_IP="localhost"
- BASE_DIR="CHANGE_ME"
- #where your dradis 2.5.0 should be installed
- BANNER="banner.png"
- #add your own custom logo to the front login page - must be a png and not too large!
- DRADIS_ENV="mycompany"
- #this will be used for your default dradis environment, including database instance
- SVN_USE="no"
- #if you say yes, dradis svn release will be downloaded and used
- #use it only if you are quite familar with dradis!
- TEMPLATE="generic"
- # import a default templates - based on the dradis export package feature
- # -templates must be placed into directory: _TEMPLATES
- # -use the export package feature within dradis to create the dradis-export.zip file
- # -file name must be like: {template}_xxxxxxx.tmpl.zip
- # -example: pentest_template_V1.1.tmpl.zip
- # Currently 3 templates can be specified
- # mobile (default for MC assessment)
- # wlan (default for WLAN pentest)
- # generic (default for the usual pentest)
- #
- TMPL_GENERIC="generic_pentest_1.0.tmpl"
- TMPL_MCD="mobile_computing_1.0.tmpl"
- TMPL_WLAN="wlan_1.0.tmpl"
- #templates must be placed in the BASE_DIR/_TEMPLATES folder
- ############ END OF MANUAL CHANGES ########
- ######################################
- RELEASE="1.1"
- UPDATE="10/02/2010 (brtw2003)"
- DRADIS_DB="${DRADIS_ENV}.sqlite3"
- DRADIS_RELEASE="2.5.0"
- TERMINAL="/usr/bin/xterm -bg white -fg black"
- ####
- ### functions
- ####
- #setup new dradis (installation + initialization)
- dradis_new () {
- if [ ${BASE_DIR} == "CHANGE_ME" ]; then
- printf "\n\n###ERROR### SORRY, you didn't change the BASE_DIR paramater !\n"
- printf "###ERROR## Okay, fix it - edit BASE_DIR paramater in this script!\n\n"
- printf "###INFO## will start nano for you to edit file!\n\n"
- sleep 5
- nano startDradis
- printf "\n###INFO## CHANGE directory NOW TO: $BASE_DIR & run startDradis again !!\n\n"
- exit 0
- fi
- if [ ${SVN_USE} == "yes" ]; then
- printf "\n###INFO## You choose the svn release, will prepare ...inlcuding svn download of latest version\n"
- printf "###INFO## base dir we will use: ${BASE_DIR}\n\n"
- printf "\n...okay, let's go...\n"
- if [ ! -d ${BASE_DIR} ]; then
- mkdir -p ${BASE_DIR}
- fi
- if [ ! -d ${BASE_DIR}/server ]; then
- cd ${BASE_DIR} && `which svn` co https://dradis.svn.sourceforge.net/svnroot/dradis/server/trunk server && \
- `which svn` co https://dradis.svn.sourceforge.net/svnroot/dradis/server/trunk client
- else
- cd ${BASE_DIR}/server && printf "\nDradis Server Release (svn update, just a second..): \t" && `which svn` update
- cd ${BASE_DIR}/client && printf "\nDradis Client Release (svn update, just a second..): \t" && `which svn` update
- fi
- if [ ! -d ${BASE_DIR}/_TEMPLATES ]; then
- mkdir ${BASE_DIR}/_DB-BACKUP ${BASE_DIR}/_LOGS ${BASE_DIR}/_TEMPLATES
- cp -p `pwd`/_TEMPLATES/* ${BASE_DIR}/_TEMPLATES/
- fi
- fi
- if [[ $EUID -ne 0 ]]; then
- printf "\n###ERROR## SORRY, script needs to be run as root!\n"
- exit 0
- fi
- if [ ! -f "${BASE_DIR}/.installed" ]; then
- read -p "Installation folder: $BASE_DIR - is this correct? (y/n) : " -e optFolder
- if [ $optFolder == "n" ]; then
- printf "\n\n###ERROR## Okay, fix it - edit BASE_DIR paramater in this script!\n\n\n"
- printf "###INFO## will start nano for your to edit file!\n\n"
- sleep 5
- nano startDradis
- printf "\n###INFO## CHANGE directory NOW TO: $BASE_DIR & run startDradis again !!\n\n"
- exit 0
- fi
- printf "\n###INFO## Using latest dradis release (2.5.0)\n"
- printf "###INFO## Will unpack original dradis source 2.5.0..\n"
- printf "###INFO## Dradis will be installed to: ${BASE_DIR}\n"
- printf "###INFO## Custom stuff can be found in: ${BASE_DIR}/_TEMPLATES\n"
- if [ ! -f ./_TEMPLATES/dradis-v2.5.0.tar.gz ]; then
- printf "\n###ERROR## Sorry, installer source not found!\n\n"
- exit 0
- else
- mkdir -p ${BASE_DIR}
- cp `pwd`/startDradis ${BASE_DIR}/
- cp `pwd`/_TEMPLATES/dradis-v2.5.0.tar.gz ${BASE_DIR}/ && \
- mkdir -p ${BASE_DIR}/_TEMPLATES ${BASE_DIR}/_LOGS ${BASE_DIR}/_DB-BACKUP && \
- cp `pwd`/_TEMPLATES/* ${BASE_DIR}/_TEMPLATES/ && \
- cd ${BASE_DIR} && tar xf dradis-v2.5.0.tar.gz && rm dradis-v2.5.0.tar.gz && \
- mv dradis-2.5/* . && rm -rf dradis-2.5
- fi
- if [ -f "$BASE_DIR/_TEMPLATES/${BANNER}" ]; then
- printf "\n###INFO## Found custom banner, will copy it to the right folder...\n"
- cp $BASE_DIR/_TEMPLATES/${BANNER} $BASE_DIR/server/public/images/banner.png
- fi
- # remove production env variable in environment.rb
- sed -i "s/^ENV/#ENV/g" ${BASE_DIR}/server/config/environment.rb && \
- sed -i "s/^RAILS_ENV/#RAILS_ENV/g" ${BASE_DIR}/server/config/environment.rb
- touch ${BASE_DIR}/.installed
- read -p "Initial dradis shared login password? : " -e optPWD
- if [ -n "$optPWD" ]; then
- DRADIS_PWD="${optPWD}"
- else
- DRADIS_PWD="topSecure"
- fi
- #create now custom ssl certificate
- dradis_ssl
- if [ -n "${DRADIS_ENV}" ]; then
- cd ${BASE_DIR}/server/config
- if [ ! -f environments/${DRADIS_ENV}.rb ]; then
- DRADIS_DB="${DRADIS_ENV}.sqlite3"
- cp environments/production.rb environments/${DRADIS_ENV}.rb
- if [ -z "$(cat database.yml |grep '${DRADIS_ENV}:')" ]; then
- printf "\n\n${DRADIS_ENV}:\n adapter: sqlite3\n database: db/${DRADIS_DB}\n timeout: 5000\n\n" >>database.yml
- fi
- fi
- else
- DRADIS_DB=production.sqlite3
- fi
- if [ ! -f "$BASE_DIR/server/db/migrate/007_create_custom_environment.rb" ]; then
- cp $BASE_DIR/_TEMPLATES/007_create_custom_environment.rb $BASE_DIR/server/db/migrate/
- fi
- #initialize dradis environment
- cd ${BASE_DIR}/server
- export RAILS_ENV=$DRADIS_ENV; rake dradis:reset >/dev/null
- sleep 3
- db_date=$(date '+%F %H:%M:%S')
- sqlite3 -line ${BASE_DIR}/server/db/${DRADIS_DB} "update configurations set value='${DRADIS_PWD}' where name='password'"
- #let's call the import template function
- dradis_import
- printf "\n\n###INFO## Okay, done..\n"
- printf "###INFO## We have do run verify.sh - to check prerequisites!\n"
- printf "###INFO## Dradis 2.5 needs some new gem packages, which are not installed in BT4 finale!\n\n"
- cd ${BASE_DIR}
- sh verify.sh
- printf "\n###INFO## CHANGE directory NOW TO: $BASE_DIR & run startDradis again !!\n\n"
- exit 0
- else
- printf "\n###INFO## ..dradis release 2.5.0 is already installed!!\n"
- if [ ! -f "$BASE_DIR/.verifycalled" ]; then
- printf "###WARNING## You still have not executed verify.sh !!\n\n"
- read -p "Should we really proceed? (y/n)" -e optVerify
- fi
- if [ $optVerify == "n" ]; then
- printf "\n###INFO## GOOD CHOICE, will run now verify.sh !!\n\n"
- cd ${BASE_DIR}
- sh verify.sh
- printf "\n###INFO## CHANGE directory NOW TO: $BASE_DIR & run startDradis again !!\n\n"
- exit 0
- fi
- clear
- printf "\n\n###INFO## ..use a different menu option! Dradis $DRADIS_RELEASE installation looks good!\n\n"
- cd ${BASE_DIR}
- exit 0
- fi
- }
- #general import functions for our custom templates
- dradis_import () {
- ###import project templates
- if [ ${TEMPLATE} == "generic" ]; then
- printf "\n###INFO## You choose to import the 'Generic Pentest Template Package'...give me a second\n\n"
- if [ -f "${BASE_DIR}/_TEMPLATES/${TMPL_GENERIC}" ]; then
- cd ${BASE_DIR}/server
- FILE="[$BASE_DIR/_TEMPLATES/$TMPL_GENERIC]"
- rake 'upload:project:template'$FILE'' >/dev/null
- else
- printf "\n###ERROR## Sorry, template file doesn't exist: $TMPL_GENERIC \n"
- fi
- fi
- if [ ${TEMPLATE} == "mobile" ]; then
- printf "\n###INFO## You choose to import the 'Generic Mobile Template Package'...give me a second\n\n"
- if [ -f "${BASE_DIR}/_TEMPLATES/${TMPL_MCD}" ]; then
- cd ${BASE_DIR}/server
- FILE="[$BASE_DIR/_TEMPLATES/$TMPL_MCD]"
- rake 'upload:project:template'$FILE'' >/dev/null
- else
- printf "\n###ERROR## Sorry, template file doesn't exist: $TMPL_MCD \n"
- fi
- fi
- if [ ${TEMPLATE} == "wlan" ]; then
- printf "\n###INFO## You choose to import the 'Generic Wireless LAN Template Package'...give me a second\n\n"
- if [ -f "${BASE_DIR}/_TEMPLATES/${TMPL_WLAN}" ]; then
- cd ${BASE_DIR}/server
- FILE="[$BASE_DIR/_TEMPLATES/$TMPL_WLAN]"
- rake 'upload:project:template'$FILE'' >/dev/null
- else
- printf "\n###ERROR## Sorry, template file doesn't exist: $TMPL_WLAN \n"
- fi
- fi
- }
- #call firefox
- dradis_browser () {
- if [ -f "$(which firefox)" ]; then
- $(which firefox) -no-remote https://${DRADIS_IP}:${DRADIS_PORT}/login&
- printf "\n\n\n*****************************************************************************\n"
- printf "\nPlease, use default Dradis shared PWD:\t\t$DRADIS_PWD"
- printf "\nDradis server Log File can be found here: $BASE_DIR/_LOGS/$DRADIS_ENV.log\n"
- if [ "$ENCRYPT" == "YES" ]; then
- printf "\nDon't forget your encrypted GPG password for your backup: $GPG_PWD\n"
- fi
- printf "*****************************************************************************\n\n"
- else
- printf "\n\n\n*****************************************************************************\n"
- printf "\nPlease, use default Dradis shared PWD:\t\t$DRADIS_PWD"
- printf "\n\n..Didn't find Firefox...\n"
- printf "\nSTART NOW YOUR WEB BROWSER and login to: https://$DRADIS_IP:$DRADIS_PORT/login"
- printf "\nDradis server Log File can be found here: ${BASE_DIR}/_LOGS/$DRADIS_ENV.log\n"
- if [ "$ENCRYPT" == "YES" ]; then
- printf "\nDon't forget your encrypted GPG password for your backup: $GPG_PWD\n"
- fi
- printf "*****************************************************************************\n\n"
- fi
- }
- #use dradis with backup feature
- dradis_backup () {
- if [ ${BASE_DIR} == "CHANGE_ME" ]; then
- printf "\n\n###ERROR### SORRY, you didn't change the BASE_DIR paramater !\n"
- printf "###ERROR## Okay, fix it - edit BASE_DIR paramater in this script!\n\n"
- printf "###INFO## will start nano for your to edit file!\n\n"
- sleep 5
- nano startDradis
- printf "\n###INFO## CHANGE directory NOW TO: $BASE_DIR & run startDradis again !!\n\n"
- exit 0
- fi
- if [ ! -f "$BASE_DIR/.verifycalled" ]; then
- printf "###WARNING## You still have not executed verify.sh !!\n\n"
- read -p "Should we really proceed? (y/n)" -e optVerify
- fi
- if [ "$optVerify" == "n" ]; then
- printf "\n###INFO## GOOD CHOICE, run now verify.sh !!\n\n"
- cd ${BASE_DIR}
- sh verify.sh
- printf "\n###INFO## CHANGE directory NOW TO: $BASE_DIR & run startDradis again !!\n\n"
- exit 0
- fi
- ##look for required env settings...
- if [ ! "$(pidof -s xinit)" ]; then
- printf "\n###ERROR## SORRY, X11 is not running and we do use xterm to start dradis!\n"
- printf "###ERROR## also to start firefox for you..\n"
- exit 0
- elif [ "${DRADIS_IP}" == "localhost" ]; then
- if [ ! $(ifconfig -a | awk '/^[lL][a-zA-Z0-9,_:.]/{n=$1}($1=="UP"){u[n]=n}END{for(n in u){print u[n]}}') ]; then
- printf "\n\t###ERROR## SORRY, seems your dont have a loopback device?\n"
- printf "we do need it, because dradis server is usually running on localhost!\n"
- printf "Fix your networking first!\n"
- exit 0
- fi
- fi
- if [ ! -n "$(env |grep "^DISPLAY" |cut -d"=" -f2)" ]; then
- printf "\n###ERROR## SORRY, can't find a proper DISPLAY variable!Are you running X??\n"
- printf "\n###ERROR### ..let's see if we can fix it...\n"
- #look if we can setup display var ....for the real lazy onces :-)
- user_id=$(ps -ef |grep xinit |grep -v grep |cut -d" " -f1)
- if [ -d "/home/${user_id}" ]; then
- if [ -f "/home/${user_id}/.Xauthority" ]; then
- export XAUTHORITY=/home/${user_id}/.Xauthority
- export DISPLAY=:0.0
- fi
- fi
- if [ ! -n "$(env |grep "^DISPLAY" |cut -d"=" -f2)" ]; then
- printf "\n###INFO### PROBLEM fixed :-)\n"
- else
- printf "\n###ERROR### Can't do magic, please fix DISPLAY and xauthority issue!\n"
- exit 0
- fi
- fi
- # remove production env variable in environment.rb - done during install, but safer to do it again !
- sed -i "s/^ENV/#ENV/g" ${BASE_DIR}/server/config/environment.rb && \
- sed -i "s/^RAILS_ENV/#RAILS_ENV/g" ${BASE_DIR}/server/config/environment.rb
- printf "\n\n###INFO## Okay, let's do the backup...\n"
- BACKUP="YES"
- read -p "Should we encrypt the backup data? (y/n): " -e optEncrypt
- if [ $optEncrypt == "y" ]; then
- read -p "GPG password to encrypt file (REMEMBER IT!!!): " -e optGPG
- ENCRYPT="YES"
- if [ -n "$optGPG" ]; then
- GPG_PWD="$optGPG"
- else
- printf "\n\n###ERROR### SORRY, string can not be empty!! Try it again\n"
- read -p "GPG password to encrypt file (REMEMBER IT!!!): " -e optGPG
- GPG_PWD="$optGPG"
- fi
- fi
- read -p "Initial dradis shared login password? : " -e optPWD
- if [ -n "$optPWD" ]; then
- DRADIS_PWD="${optPWD}"
- else
- DRADIS_PWD="topSecure"
- fi
- printf "\n\n###INFO## looking for running dradis instance..\n"
- pgrep -f 'ruby ./script/server' >/dev/null
- if [[ $? -eq 0 ]]; then
- printf "\n\n###WARNING## dradis server active..I KILL IT NOW!\n\n"
- kill -9 `pgrep -f 'ruby ./script/server'` >/dev/null
- fi
- if [ -n "${DRADIS_ENV}" ]; then
- cd ${BASE_DIR}/server/config
- if [ ! -f environments/${DRADIS_ENV}.rb ]; then
- DRADIS_DB="${DRADIS_ENV}.sqlite3"
- cp environments/production.rb environments/${DRADIS_ENV}.rb
- if [ -z "$(cat database.yml |grep '${DRADIS_ENV}:')" ]; then
- printf "\n\n${DRADIS_ENV}:\n adapter: sqlite3\n database: db/${DRADIS_DB}\n timeout: 5000\n\n" >>database.yml
- fi
- fi
- else
- DRADIS_DB=production.sqlite3
- fi
- if [ ! -f "$BASE_DIR/server/db/$DRADIS_DB" ]; then
- printf "\n###INFO### your production database doesn't exist, therefore nothing to backup!\n"
- printf "###INFO### will initalize now your new environment...\n"
- if [ ! -f "$BASE_DIR/server/db/migrate/007_create_custom_environment.rb" ]; then
- cp $BASE_DIR/_TEMPLATES/007_create_custom_environment.rb $BASE_DIR/server/db/migrate/
- fi
- cd ${BASE_DIR}/server
- export RAILS_ENV=${DRADIS_ENV};rake db:migrate >/dev/null
- else
- # do a backup of old dradis sqlite database
- printf "\n###INFO## backup previous Dradis Framework database & settings....\n"
- cd ${BASE_DIR}/server/db
- cp ${DRADIS_DB} ${BASE_DIR}/_DB-BACKUP/${DRADIS_DB}.`date +%F` && \
- gzip ${BASE_DIR}/_DB-BACKUP/${DRADIS_DB}.`date +%F`
- printf "###INFO## Backup is located in: \t${BASE_DIR}/_DB-BACKUP\n"
- printf "###INFO## backup previous project....\n"
- cd ${BASE_DIR}/server
- export RAILS_ENV=${DRADIS_ENV};rake dradis:backup >/dev/null
- sleep 4
- printf "###INFO## clear old environment..\n"
- cd ${BASE_DIR}/server
- export RAILS_ENV=${DRADIS_ENV};rake dradis:reset >/dev/null
- mv ${BASE_DIR}/server/backups/dradis_*.zip ${BASE_DIR}/_DB-BACKUP/
- fi
- if [ "${ENCRYPT}" == "YES" ]; then
- if [ -f "$(which gpg)" ]; then
- if [ -f "${BASE_DIR}/_DB-BACKUP/${DRADIS_DB}.`date +%F`.gz" ]; then
- printf "\n\n###INFO## encrypting db backup file...\n"
- $(which gpg) -q --passphrase "$GPG_PWD" --yes --batch --no-tty -c ${BASE_DIR}/_DB-BACKUP/${DRADIS_DB}.`date +%F`.gz >/dev/null
- sleep 3
- rm -f ${BASE_DIR}/_DB-BACKUP/${DRADIS_DB}.`date +%F`.gz
- else
- printf "\n\n###ERROR## sorry, there is no backup file to encrypt!\n"
- fi
- else
- printf "\n\n###ERROR## sorry, gpg not found, will not encrypt your database backup file!\n"
- printf "###INFO## install it, under debian run: apt-get install gpg\n"
- fi
- fi
- db_date=$(date '+%F %H:%M:%S')
- sqlite3 -line ${BASE_DIR}/server/db/${DRADIS_DB} "update configurations set value='${DRADIS_PWD}' where name='password'"
- #let's call the import template function
- dradis_import
- ##finally we start the server and client if needed
- cd ${BASE_DIR}/server
- ${TERMINAL} -T "DRADIS SERVER" -geometry 70x25+0+0 -e ruby ./script/server -e ${DRADIS_ENV} -p ${DRADIS_PORT} -b ${DRADIS_IP}&
- if [ "${CLIENT}" == "YES" ]; then
- sleep 3
- cd ${BASE_DIR}/client
- ${TERMINAL} -T "DRADIS CLIENT" -geometry 70x25+0+350 -e ruby dradis.rb -g&
- fi
- #create a sym link in our log dir to the server log...
- if [ ! -f "$BASE_DIR/_LOGS/$DRADIS_ENV.log" ]; then
- cd $BASE_DIR/_LOGS/
- ln -s $BASE_DIR/server/log/${DRADIS_ENV}.log
- fi
- sleep 4
- #finally start firefox
- dradis_browser
- exit 0
- }
- #quick dradis initialization without backup
- dradis_quick () {
- if [ ${BASE_DIR} == "CHANGE_ME" ]; then
- printf "\n\n###ERROR### SORRY, you didn't change the BASE_DIR paramater !\n"
- printf "###ERROR## Okay, fix it - edit BASE_DIR paramater in this script!\n\n"
- printf "###INFO## will start nano for your to edit file!\n\n"
- sleep 5
- nano startDradis
- printf "\n###INFO## CHANGE directory NOW TO: $BASE_DIR & run startDradis again !!\n\n"
- exit 0
- fi
- if [ ! -f "$BASE_DIR/.verifycalled" ]; then
- printf "###WARNING## You still have not executed verify.sh !!\n\n"
- read -p "Should we really proceed? (y/n)" -e optVerify
- fi
- if [ "$optVerify" == "n" ]; then
- printf "\n###INFO## GOOD CHOICE, run now verify.sh !!\n\n"
- cd ${BASE_DIR}
- sh verify.sh
- printf "\n###INFO## CHANGE directory NOW TO: $BASE_DIR & run startDradis again !!\n\n"
- exit 0
- fi
- ##look for required env settings...
- if [ ! "$(pidof -s xinit)" ]; then
- printf "\n###ERROR## SORRY, X11 is not running and we do use xterm to start dradis!\n"
- printf "###ERROR## also to start firefox for you..\n"
- exit 0
- elif [ "${DRADIS_IP}" == "localhost" ]; then
- if [ ! $(ifconfig -a | awk '/^[lL][a-zA-Z0-9,_:.]/{n=$1}($1=="UP"){u[n]=n}END{for(n in u){print u[n]}}') ]; then
- printf "\n\t###ERROR## SORRY, seems your dont have a loopback device?\n"
- printf "we do need it, because dradis server is usually running on localhost!\n"
- printf "Fix your networking first!\n"
- exit 0
- fi
- fi
- if [ ! -n "$(env |grep "^DISPLAY" |cut -d"=" -f2)" ]; then
- printf "\n###ERROR## SORRY, can't find a proper DISPLAY variable!Are you running X??\n"
- printf "\n###ERROR### ..let's see if we can fix it...\n"
- #look if we can setup display var ....for the real lazy onces :-)
- user_id=$(ps -ef |grep xinit |grep -v grep |cut -d" " -f1)
- if [ -d "/home/${user_id}" ]; then
- if [ -f "/home/${user_id}/.Xauthority" ]; then
- export XAUTHORITY=/home/${user_id}/.Xauthority
- export DISPLAY=:0.0
- fi
- fi
- if [ ! -n "$(env |grep "^DISPLAY" |cut -d"=" -f2)" ]; then
- printf "\n###INFO### PROBLEM fixed :-)\n"
- else
- printf "\n###ERROR### Can't do magic, please fix DISPLAY and xauthority issue!\n"
- exit 0
- fi
- fi
- if [ -f "$BASE_DIR/_TEMPLATES/${BANNER}" ]; then
- printf "\n###INFO## Found custom banner, will copy it to the right folder...\n"
- cp $BASE_DIR/_TEMPLATES/${BANNER} $BASE_DIR/server/public/images/banner.png
- fi
- # remove production env variable in environment.rb - done during install, but safer to do it again !
- sed -i "s/^ENV/#ENV/g" ${BASE_DIR}/server/config/environment.rb && \
- sed -i "s/^RAILS_ENV/#RAILS_ENV/g" ${BASE_DIR}/server/config/environment.rb
- read -p "Initial dradis shared login password? : " -e optPWD
- if [ -n "$optPWD" ]; then
- DRADIS_PWD="${optPWD}"
- else
- DRADIS_PWD="topSecure"
- fi
- pgrep -f 'ruby ./script/server' >/dev/null
- if [[ $? -eq 0 ]]; then
- printf "\n\n###WARNING## dradis server active..I KILL IT NOW!\n\n"
- kill -9 `pgrep -f 'ruby ./script/server'` >/dev/null
- fi
- if [ -n "${DRADIS_ENV}" ]; then
- cd ${BASE_DIR}/server/config
- if [ ! -f environments/${DRADIS_ENV}.rb ]; then
- DRADIS_DB="${DRADIS_ENV}.sqlite3"
- cp environments/production.rb environments/${DRADIS_ENV}.rb
- if [ -z "$(cat database.yml |grep '${DRADIS_ENV}:')" ]; then
- printf "\n\n${DRADIS_ENV}:\n adapter: sqlite3\n database: db/${DRADIS_DB}\n timeout: 5000\n\n" >>database.yml
- fi
- fi
- else
- DRADIS_DB=production.sqlite3
- fi
- if [ ! -f "$BASE_DIR/server/db/migrate/007_create_custom_environment.rb" ]; then
- cp $BASE_DIR/_TEMPLATES/007_create_custom_environment.rb $BASE_DIR/server/db/migrate/
- fi
- printf "###INFO## clear previous environment..\n"
- cd ${BASE_DIR}/server
- export RAILS_ENV=${DRADIS_ENV};rake dradis:reset >/dev/null
- db_date=$(date '+%F %H:%M:%S')
- sqlite3 -line ${BASE_DIR}/server/db/${DRADIS_DB} "update configurations set value='${DRADIS_PWD}' where name='password'"
- read -p "Would you like to import a predefined template? (y/n)" -e askTMPL
- if [ $askTMPL == "y" ]; then
- read -p "Choose template (generic, mobile or wlan): " -e askTYPE
- if [ $askTYPE == "generic" ]; then
- TEMPLATE="generic"
- elif [ $askTYPE == "mobile" ]; then
- TEMPLATE="mobile"
- elif [ $askTYPE == "wlan" ]; then
- TEMPLATE="wlan"
- fi
- #let's call the import template function
- printf "\n###INFO## ...will import your requested template...\n"
- dradis_import
- fi
- ##finally we start the server and client if needed
- cd ${BASE_DIR}/server
- ${TERMINAL} -T "DRADIS SERVER" -geometry 70x25+0+0 -e ruby ./script/server -e ${DRADIS_ENV} -p ${DRADIS_PORT} -b ${DRADIS_IP}&
- #create a sym link in our log dir to the server log...
- if [ ! -f "$BASE_DIR/_LOGS/$DRADIS_ENV.log" ]; then
- cd $BASE_DIR/_LOGS/
- ln -s $BASE_DIR/server/log/${DRADIS_ENV}.log
- fi
- sleep 4
- #finally start firefox
- dradis_browser
- exit 0
- }
- dradis_ssl () {
- read -p "Create a new SSL Certificate (y/n)? : " -e optSSL
- if [ $optSSL == "y" ]; then
- ## 1.step creating proper self-signed certs
- if [ -f "${BASE_DIR}/server/config/ssl/server.crt" ]; then
- cd ${BASE_DIR}/server/config/ssl
- printf "\n###INFO### creating new ssl key...\n"
- $(openssl genrsa -des3 -out server.key 1024)
- printf "\n###INFO### create now server request, based on our new key...\n"
- printf "\n###INFO### add all your custom infos...\n"
- $(openssl req -new -key server.key.insecure -out server.csr)
- printf "\n###INFO### create a self-signed certificate..don't wanna sponsor verisign & co..\n"
- $(openssl x509 -req -days 365 -in server.csr -signkey server.key.insecure -out server.crt >/dev/null)
- printf "\n\n###INFO### ..seems we are done :-)\n"
- else
- printf "\n\n###ERROR## SORRY, don't see any existing ssl certificate in ${BASE_DIR}/server/config/ssl/\n\n"
- fi
- fi
- clear
- }
- dradis_word () {
- clear
- XML_PARSER="$BASE_DIR/_TEMPLATES/dradis_xml_parser.pl"
- XML_FILE="$BASE_DIR/_TEMPLATES/word_custom_template.xml"
- if [ ! -f "$XML_FILE" ]; then
- printf "\n\n###ERROR## Sorry, there is no default template: $XML_FILE!\n"
- printf "###ERROR## We need an initial dradis XML template - so I will stop now!\n\n\n"
- exit 0
- fi
- #we do need some specific perl modules..
- perl -e 'use XML::Simple;' 2>/dev/null
- if [ `echo $?` != "0" ]; then
- printf "\n###ERROR## Please, install missing Perl module:\n\n"
- read -p "Install XML::Simple Perl module? (y/n)" -e optPerl
- if [ $optPerl == "y" ]; then
- perl -MCPAN -e 'install XML::Simple'
- fi
- sleep 2
- clear
- fi
- #dump current dradis XML meta tags
- $XML_PARSER -f $XML_FILE
- read -p "Should we place your 'word_custom_template.xml' to the right dradis location? (y/n)" -e optXML
- if [ $optXML == "y" ]; then
- #finally copy template to the right place
- cd $BASE_DIR/_TEMPLATES
- if [ -f "$XML_FILE" ]; then
- if [ -d $BASE_DIR/server/vendor/plugins/word_export ]; then
- printf "\n\n###INFO## Copy your template to: $BASE_DIR/server/vendor/plugins/word_export/template.xml\n\n"
- cp $XML_FILE $BASE_DIR/server/vendor/plugins/word_export/template.xml
- sleep 2
- else
- printf "\n\n###ERROR## Sorry, missing word_export plugin - will not copy it!\n";
- sleep 4
- fi
- fi
- fi
- clear
- }
- dradis_start () {
- printf "\n###INFO## Starting dradis $DRADIS_RELEASE....\n"
- cd $BASE_DIR/server
- if [ ! "$(pidof -s xinit)" ]; then
- printf "\n###ERROR## SORRY, X11 is not running and we do use xterm to start dradis!\n"
- printf "###ERROR## also to start firefox for you..\n"
- exit 0
- elif [ "${DRADIS_IP}" == "localhost" ]; then
- if [ ! $(ifconfig -a | awk '/^[lL][a-zA-Z0-9,_:.]/{n=$1}($1=="UP"){u[n]=n}END{for(n in u){print u[n]}}') ]; then
- printf "\n\t###ERROR## SORRY, seems your dont have a loopback device?\n"
- printf "we do need it, because dradis server is usually running on localhost!\n"
- printf "Fix your networking first!\n"
- exit 0
- fi
- fi
- if [ ! -n "$(env |grep "^DISPLAY" |cut -d"=" -f2)" ]; then
- printf "\n###ERROR## SORRY, can't find a proper DISPLAY variable!Are you running X??\n"
- printf "\n###ERROR### ..let's see if we can fix it...\n"
- #look if we can setup display var ....for the real lazy onces :-)
- user_id=$(ps -ef |grep xinit |grep -v grep |cut -d" " -f1)
- if [ -d "/home/${user_id}" ]; then
- if [ -f "/home/${user_id}/.Xauthority" ]; then
- export XAUTHORITY=/home/${user_id}/.Xauthority
- export DISPLAY=:0.0
- fi
- fi
- if [ ! -n "$(env |grep "^DISPLAY" |cut -d"=" -f2)" ]; then
- printf "\n###INFO### PROBLEM fixed :-)\n"
- else
- printf "\n###ERROR### Can't do magic, please fix DISPLAY and xauthority issue!\n"
- exit 0
- fi
- fi
- ##finally we start the server and client if needed
- cd ${BASE_DIR}/server
- ${TERMINAL} -T "DRADIS SERVER" -geometry 70x25+0+0 -e ruby ./script/server -e ${DRADIS_ENV} -p ${DRADIS_PORT} -b ${DRADIS_IP}&
- #create a sym link in our log dir to the server log...
- if [ ! -f "$BASE_DIR/_LOGS/$DRADIS_ENV.log" ]; then
- cd $BASE_DIR/_LOGS/
- ln -s $BASE_DIR/server/log/${DRADIS_ENV}.log
- fi
- sleep 4
- #call firefox
- dradis_browser
- exit 0
- }
- dradis_pwd () {
- clear
- GETIT=`sqlite3 -line -noheader $BASE_DIR/server/db/$DRADIS_DB "select * from configurations where name='password'" |grep value |cut -d"=" -f2`
- printf "\n\nYour current shared Password:\t$GETIT\n\n"
- sleep 3
- clear
- }
- ####
- ## begin menu & loop forever...
- ####
- clear
- echo
- echo -e '\E[37;44m'"\t\033[1mProfessional Pentest documentation matters!\033[0m"
- echo -e '\E[37;44m'"\t\t\033[1mVersion: $RELEASE, Last update: $UPDATE\033[0m"
- if [ $BASE_DIR != "CHANGE_ME" ]; then
- if ([ ! -f $BASE_DIR/.installed ] || [ ! -d $BASE_DIR/server ]); then
- printf "\n\n!!! Seems you didn't install properly dradis 2.5, please start with option 1 !!!\n"
- printf " Install it now and than you'll see all other options you can choose ;-)\n\n"
- while :
- do
- cat << !
- ---------------------- DRADIS FRAMEWORK MENU --------------------------
- | powered by Advanced Services |
- | |
- | 1. Start new dradis $DRADIS_RELEASE custom installation |
- | 2. Quit |
- | |
- -------------------------------------------------------------------------
- !
- echo
- echo
- echo -n " Select an option from the menu: "
- read choice
- case $choice in
- 1) dradis_new ;;
- 2) exit ;;
- *) echo ""$choice" is not valid! "; sleep 2 ;;
- esac
- done
- else
- while :
- do
- cat << !
- ----------------- MOTOROLA - DRADIS FRAMEWORK MENU --------------------
- | powered by Advanced Services |
- | |
- | |
- | 1. Only start Dradis $DRADIS_RELEASE server |
- | |
- | 2. Quick dradis $DRADIS_RELEASE initalization (no Backup) |
- | (wipe exisiting data - quick usage for engagements) |
- | |
- | 3. Use existing dradis environment (with Backup) |
- | |
- | 4. Create a custom dradis SSL certificate |
- | |
- | 5. Dump custom Word template (properties & usage) |
- | |
- | 6. New dradis $DRADIS_RELEASE custom installation |
- | (overwrites existing installation - change BASE_DIR variable!) |
- | |
- | 7. Show me the current shared password |
- | |
- | 8. Quit |
- | |
- -------------------------------------------------------------------------
- !
- echo
- echo
- echo -n " Select an option from the menu: "
- read choice
- case $choice in
- 1) dradis_start ;;
- 2) dradis_quick ;;
- 3) dradis_backup ;;
- 4) dradis_ssl ;;
- 5) dradis_word ;;
- 6) dradis_new ;;
- 7) dradis_pwd ;;
- 8) exit ;;
- *) echo ""$choice" is not valid! "; sleep 2 ;;
- esac
- done
- fi
- else
- printf "\n\n###ERROR## Sorry, you have to adjust BASE_DIR variable! Will call nano for you\n"
- sleep 4
- nano startDradis
- printf "\n\n###INFO## Restart 'startDradis' script again!\n"
- exit 0
- fi
- #EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement