Skip to content

Instantly share code, notes, and snippets.

@anoduck
Last active August 14, 2024 06:46
Show Gist options
  • Save anoduck/56b550bb5a22f73df046aafa5886e292 to your computer and use it in GitHub Desktop.
Save anoduck/56b550bb5a22f73df046aafa5886e292 to your computer and use it in GitHub Desktop.
Ivre Setup for Kali / Debian
#!/usr/bin/env bash
# contrived from https://doc.ivre.rocks/en/latest/install/fast-install-and-first-run.html
# Ensure user has suid permissions
if [ "$EUID" -ne 0 ]
then echo "You must run this with root permissions."
exit
fi
# Install Dependencies
apt -y --no-install-recommends install python3-pymongo python3-cryptography python3-tindydb python3-bottle python3-openssl apache2 libapache2-mod-wsgi-py3 dokuwiki
# Acquire where to clone ivre
echo "Where would you like to clone the ivre repository to?"
echo "Please use the full path including the folder name for ivre"
echo "Ex. git clone https://github.com/ivre/ivre %YOUR_FOLDER_HERE"
read -rsp "Full path to repo : " REPODIR
# Clone Ivre
git clone https://github.com/ivre/ivre "$REPODIR" && cd "$_" || exit
# Build and install ivre
BUILD_OUT=$(python3 -m build)
echo "$BUILD_OUT" | awk '! /\*/ && !/setuptools/{print $5}'
cd dist || exit
python3 -m installer "$WHEEL"
# Regardless of whether you install ivre via the apt package manager OR
# you go with the above option and build ivre by hand, you will need to still
# do the following.
# To avoid openssl errors, upgrade pyopenssl
python3 -m pip --upgrade pyopenssl
# Change dir
cd /var/www/html || exit
# Create ivre dir if it does not exist
if ! [[ -d "/var/www/html/ivre" ]]; then
mkdir -p ivre && cd "$_" || return
fi
if [[ ! -d "/usr/local/share/ivre" ]]; then
PREFIX="/usr/share/ivre"
else
PREFIX="/usr/local/share/ivre"
fi
# Link static to PWD
ln -sf $PREFIX/web/static/* .
# Link pages to PWD
cd /var/lib/dokuwiki/data/pages || exit
ln -sf $PREFIX/dokuwiki/doc .
cd /var/lib/dokuwiki/data/media || exit
ln -sf $PREFIX/dokuwiki/media/logo.png .
ln -sf $PREFIX/dokuwiki/media/doc .
cd /usr/share/dokuwiki || exit
patch -p0 < $PREFIX/patches/dokuwiki/backlinks-20200729.patch
cd /etc/apache2/mods-enabled || exit
for m in rewrite.load wsgi.conf wsgi.load ; do
[ -L $m ] || ln -s ../mods-available/$m ;
done
cd ../
cat << EOF >> conf-available/ivre.conf
Alias /cgi "$PREFIX/web/wsgi/app.wsgi"
<Location /cgi>
SetHandler wsgi-script
Options +ExecCGI
Require all granted
</Location>
EOF
# Enable ivre configuration file
a2enconf ivre
# Opion: Rather than follow ivre's documentation; perform best admin practices
# Thus, disable dokuwiki if enabled, and create virtual site specifically
# for ivre, rather than modifying files that belong to other packages. This
# approach is much safer, because it would avoid package conflicts, and it would
# prevent the creation of symbolic links that are multiple layers deep.
# Ex. apache.conf --sym link 1--> dokuwiki --sym link 2--> dokuwiki
if [[ -f "/etc/apache2/conf-enabled/dokuwiki" ]]; then
a2disconf dokuwiki
fi
# Copy apache configuration file from dokuwiki for use with ivre.
cp "/etc/dokuwiki/apache.conf" "/etc/apache2/conf-available/ivre-dokuwiki.conf"
a2enconf ivre-dokuwiki
cat << EOF >> /etc/apache2/sites-available/ivre-site.conf
<VirtualHost *:80>
DocumentRoot /var/www/html/ivre
<Directory "/var/www/html/ivre">
Options None FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ErrorLog /var/log/apache2/ivre_error.log
CustomLog /var/log/apache2/ivre_access.log combined
</VirtualHost>
EOF
a2ensite ivre-site
mkdir -p /var/www/.ivre
chown -R www-data:www-data /var/www/.ivre
chmod -R 755 /var/www/.ivre
sed -i 's/^\(\s*\)#Rewrite/\1Rewrite/' /etc/apache2/sites-available/ivre-site.conf
echo 'WEB_GET_NOTEPAD_PAGES = "localdokuwiki"' >> /etc/ivre.conf
service apache2 start ## or start
# Database init
yes | ivre ipinfo --init
yes | ivre scancli --init
yes | ivre view --init
yes | ivre flowcli --init
yes | sudo ivre runscansagentdb --init
ivre ipdata --download
@anoduck
Copy link
Author

anoduck commented Aug 7, 2024

If you have any difficulties, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment