This commit is contained in:
Greg DiCristofaro 2021-09-27 18:32:33 -04:00
parent 800ce196a8
commit 552668ca8b
5 changed files with 130 additions and 162 deletions

View File

@ -1,13 +1,12 @@
#!/bin/bash
# Unzips an autopsy platform zip to specified directory and does setup
# called like: install_autopsy.sh [-z zip_path] [-i install_directory]
usage() {
echo "Usage: install_autopsy.sh [-z zip_path] [-i install_directory] [-v asc_file]" 1>&2;
echo "If specifying a .asc verification file (with -v flag), the program will attempt to create a temp folder in the working directory and verify the signature with gpg." 1>&2;
echo "Usage: install_autopsy.sh [-z zip_path] [-i install_directory] [-j java_home] [-v asc_file]" 1>&2
echo "If specifying a .asc verification file (with -v flag), the program will attempt to create a temp folder in the working directory and verify the signature with gpg." 1>&2
}
while getopts "z:i:v:" o; do
while getopts "z:i:j:v:" o; do
case "${o}" in
z)
AUTOPSY_ZIP_PATH=${OPTARG}
@ -15,7 +14,11 @@ while getopts "z:i:v:" o; do
i)
INSTALL_DIR=${OPTARG}
;;
v) ASC_FILE=${OPTARG}
v)
ASC_FILE=${OPTARG}
;;
j)
JAVA_PATH=${OPTARG}
;;
*)
usage
@ -29,53 +32,47 @@ if [[ -z "$AUTOPSY_ZIP_PATH" ]] || [[ -z "$INSTALL_DIR" ]]; then
exit 1
fi
if [[ -n "$ASC_FILE" ]]
then
if [[ -n "$ASC_FILE" ]]; then
VERIFY_DIR=$(pwd)/temp
KEY_DIR=$VERIFY_DIR/private
mkdir -p $VERIFY_DIR && \
sudo wget -O $VERIFY_DIR/carrier.asc https://sleuthkit.org/carrier.asc && \
mkdir -p $KEY_DIR && \
sudo chmod 600 $KEY_DIR && \
sudo gpg --homedir "$KEY_DIR" --import $VERIFY_DIR/carrier.asc && \
sudo gpgv --homedir "$KEY_DIR" --keyring "$KEY_DIR/pubring.kbx" $ASC_FILE $AUTOPSY_ZIP_PATH && \
mkdir -p $VERIFY_DIR &&
sudo wget -O $VERIFY_DIR/carrier.asc https://sleuthkit.org/carrier.asc &&
mkdir -p $KEY_DIR &&
sudo chmod 600 $KEY_DIR &&
sudo gpg --homedir "$KEY_DIR" --import $VERIFY_DIR/carrier.asc &&
sudo gpgv --homedir "$KEY_DIR" --keyring "$KEY_DIR/pubring.kbx" $ASC_FILE $AUTOPSY_ZIP_PATH &&
sudo rm -r $VERIFY_DIR
if [[ $? -ne 0 ]]
then
echo "Unable to successfully verify $AUTOPSY_ZIP_PATH with $ASC_FILE" >> /dev/stderr
if [[ $? -ne 0 ]]; then
echo "Unable to successfully verify $AUTOPSY_ZIP_PATH with $ASC_FILE" >>/dev/stderr
exit 1
fi
fi
ZIP_FILE_NAME=$(basename -- "$AUTOPSY_ZIP_PATH")
ZIP_NAME="${ZIP_FILE_NAME%.*}"
AUTOPSY_EXTRACTED_PATH=$INSTALL_DIR/$ZIP_NAME
if [[ -d $AUTOPSY_EXTRACTED_PATH || -f $AUTOPSY_EXTRACTED_PATH ]]
then
echo "A file or directory already exists at $AUTOPSY_EXTRACTED_PATH" >> /dev/stderr
if [[ -d $AUTOPSY_EXTRACTED_PATH || -f $AUTOPSY_EXTRACTED_PATH ]]; then
echo "A file or directory already exists at $AUTOPSY_EXTRACTED_PATH" >>/dev/stderr
exit 1
fi
echo "Extracting $AUTOPSY_ZIP_PATH to $AUTOPSY_EXTRACTED_PATH..."
mkdir -p $AUTOPSY_EXTRACTED_PATH && \
unzip $AUTOPSY_ZIP_PATH -d $INSTALL_DIR
if [[ $? -ne 0 ]]
then
echo "Unable to successfully extract $AUTOPSY_ZIP_PATH to $INSTALL_DIR" >> /dev/stderr
mkdir -p $AUTOPSY_EXTRACTED_PATH &&
unzip $AUTOPSY_ZIP_PATH -d $INSTALL_DIR
if [[ $? -ne 0 ]]; then
echo "Unable to successfully extract $AUTOPSY_ZIP_PATH to $INSTALL_DIR" >>/dev/stderr
exit 1
fi
echo "Setting up autopsy at $AUTOPSY_EXTRACTED_PATH..."
pushd $AUTOPSY_EXTRACTED_PATH && \
chown -R $(whoami) . && \
chmod u+x ./unix_setup.sh && \
./unix_setup.sh && \
popd
if [[ $? -ne 0 ]]
then
echo "Unable to setup permissions for autopsy binaries" >> /dev/stderr
pushd $AUTOPSY_EXTRACTED_PATH &&
chown -R $(whoami) . &&
chmod u+x ./unix_setup.sh &&
./unix_setup.sh -j $JAVA_PATH &&
popd
if [[ $? -ne 0 ]]; then
echo "Unable to setup permissions for autopsy binaries" >>/dev/stderr
exit 1
else
echo "Autopsy setup done."

View File

@ -18,17 +18,6 @@ then
exit 1
fi
# put this in bash_profile
# https://stackoverflow.com/questions/22502759/mac-os-x-10-9-setting-permanent-environment-variables
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) && \
echo "Java home is now: $JAVA_HOME" && \
echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)' | tee ~/.bash_profile ~/.bashrc
if [[ $? -ne 0 ]]
then
echo "Unable to properly set up JAVA_HOME." >> /dev/stderr
exit 1
fi
OPEN_JDK_LN=/usr/local/opt/openjdk && \
rm $ && \
ln -s $JAVA_HOME $OPEN_JDK_LN

View File

@ -2,12 +2,10 @@
# this script is designed to install necessary dependencies on debian
# this script requires elevated privileges
echo "Turning on all repositories for apt..."
sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
if [[ $? -ne 0 ]]
then
echo "Failed to turn on all repositories" >> /dev/stderr
if [[ $? -ne 0 ]]; then
echo "Failed to turn on all repositories" >>/dev/stderr
exit 1
fi
@ -19,23 +17,20 @@ echo "Installing all apt dependencies..."
# sudo apt -y install autopoint libsqlite3-dev libcppunit-dev
# TODO multi user dependencies?
sudo apt update && \
sudo apt -y install build-essential autoconf libtool git-core automake git zip wget ant \
# &&
# sudo apt -y build-dep imagemagick libmagickcore-dev libde265 libheif && \
# sudo apt -y install
imagemagick libde265-dev libheif-dev \
libpq-dev \
testdisk libafflib-dev libewf-dev libvhdi-dev libvmdk-dev \
libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x \
gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
sudo apt update &&
sudo apt -y build-dep imagemagick libmagickcore-dev &&
sudo apt -y install build-essential autoconf libtool git-core automake git zip wget ant \
libde265-dev libheif-dev \
libpq-dev \
testdisk libafflib-dev libewf-dev libvhdi-dev libvmdk-dev \
libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x \
gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
# if [[ $? -ne 0 ]]
# then
# echo "Failed to install necessary dependencies" >> /dev/stderr
# exit 1
# fi
if [[ $? -ne 0 ]]; then
echo "Failed to install necessary dependencies" >>/dev/stderr
exit 1
fi
# echo "Cloning source for libde265 and libheif..."
# pushd /usr/src/ && \
@ -77,40 +72,37 @@ gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.
# exit 1
# fi
# echo "Installing ImageMagick..."
# pushd /usr/src/ && \
# sudo wget https://www.imagemagick.org/download/ImageMagick.tar.gz && \
# sudo tar xf ImageMagick.tar.gz && \
# pushd ImageMagick-7* && \
# sudo ./configure --with-heic=yes && \
# sudo make && \
# sudo make install && \
# popd && \
# popd
# if [[ $? -ne 0 ]]
# then
# popd && popd
# echo "Failed to install ImageMagick" >> /dev/stderr
# exit 1
# fi
echo "Installing ImageMagick..."
pushd /usr/src/ &&
sudo wget https://www.imagemagick.org/download/ImageMagick.tar.gz &&
sudo tar xf ImageMagick.tar.gz &&
pushd ImageMagick-7* &&
sudo ./configure --with-heic=yes &&
sudo make &&
sudo make install &&
popd &&
popd
if [[ $? -ne 0 ]]; then
popd && popd
echo "Failed to install ImageMagick" >>/dev/stderr
exit 1
fi
# sudo ldconfig
# if [[ $? -ne 0 ]]
# then
# echo "ldconfig call failed" >> /dev/stderr
# exit 1
# fi
sudo ldconfig
if [[ $? -ne 0 ]]; then
echo "ldconfig call failed" >>/dev/stderr
exit 1
fi
echo "Installing bellsoft Java 8..."
pushd /usr/src/ && \
wget -q -O - https://download.bell-sw.com/pki/GPG-KEY-bellsoft | sudo apt-key add - && \
echo "deb [arch=amd64] https://apt.bell-sw.com/ stable main" | sudo tee /etc/apt/sources.list.d/bellsoft.list && \
sudo apt update && \
sudo apt -y install bellsoft-java8-full && \
popd
if [[ $? -ne 0 ]]
then
echo "Failed to install bellsoft java 8" >> /dev/stderr
pushd /usr/src/ &&
wget -q -O - https://download.bell-sw.com/pki/GPG-KEY-bellsoft | sudo apt-key add - &&
echo "deb [arch=amd64] https://apt.bell-sw.com/ stable main" | sudo tee /etc/apt/sources.list.d/bellsoft.list &&
sudo apt update &&
sudo apt -y install bellsoft-java8-full &&
popd
if [[ $? -ne 0 ]]; then
echo "Failed to install bellsoft java 8" >>/dev/stderr
exit 1
fi

View File

@ -4,7 +4,7 @@
# called like: build_tsk.sh -r <repo path to be created or existing> -b <tsk branch to checkout>
usage() {
echo "Usage: build_tsk.sh [-r repo_path] [-b tsk_branch]" 1>&2;
echo "Usage: install_tsk_from_src [-r repo_path] [-b tsk_branch]" 1>&2
}
while getopts "r:b:" o; do
@ -27,44 +27,40 @@ if [[ -z "${SLEUTHKIT_SRC_DIR}" ]] || [[ -z "${TSK_BRANCH}" ]]; then
exit 1
fi
if [[ ! -d $SLEUTHKIT_SRC_DIR ]]
then
if [[ ! -d $SLEUTHKIT_SRC_DIR ]]; then
TSK_REPO_PATH=$(dirname "$SLEUTHKIT_SRC_DIR")
echo "Cloning Sleuthkit to $TSK_REPO_PATH..."
mkdir -p $TSK_REPO_PATH && \
pushd $TSK_REPO_PATH && \
git clone https://github.com/sleuthkit/sleuthkit.git && \
mkdir -p $TSK_REPO_PATH &&
pushd $TSK_REPO_PATH &&
git clone https://github.com/sleuthkit/sleuthkit.git &&
popd
if [[ ! -d $SLEUTHKIT_SRC_DIR ]]
then
echo "Unable to successfully clone Sleuthkit" >> /dev/stderr
if [[ ! -d $SLEUTHKIT_SRC_DIR ]]; then
echo "Unable to successfully clone Sleuthkit" >>/dev/stderr
exit 1
fi
fi
echo "Getting latest of Sleuthkit branch: $TSK_BRANCH..."
pushd $SLEUTHKIT_SRC_DIR && \
git reset --hard && \
git checkout $TSK_BRANCH && \
git pull && \
popd
if [[ $? -ne 0 ]]
then
echo "Unable to reset Sleuthkit repo and pull latest on $TSK_BRANCH" >> /dev/stderr
pushd $SLEUTHKIT_SRC_DIR &&
git reset --hard &&
git checkout $TSK_BRANCH &&
git pull &&
popd
if [[ $? -ne 0 ]]; then
echo "Unable to reset Sleuthkit repo and pull latest on $TSK_BRANCH" >>/dev/stderr
exit 1
fi
echo "Installing Sleuthkit..."
pushd $SLEUTHKIT_SRC_DIR && \
# export CPPFLAGS="-I/usr/local/opt/libpq/include" && \
./bootstrap && \
./configure && \
make && \
sudo make install && \
popd
if [[ $? -ne 0 ]]
then
echo "Unable to build Sleuthkit." >> /dev/stderr
pushd $SLEUTHKIT_SRC_DIR &&
# export CPPFLAGS="-I/usr/local/opt/libpq/include" && \
./bootstrap &&
./configure &&
make &&
sudo make install &&
popd
if [[ $? -ne 0 ]]; then
echo "Unable to build Sleuthkit." >>/dev/stderr
exit 1
fi

View File

@ -25,13 +25,6 @@ while getopts "j:" o; do
done
if [[ -z "${SLEUTHKIT_SRC_DIR}" ]] || [[ -z "${TSK_BRANCH}" ]]; then
usage
exit 1
fi
# In the beginning...
echo "---------------------------------------------"
echo "Checking prerequisites and preparing Autopsy:"
@ -54,7 +47,8 @@ fi
echo -n "Checking for Java..."
if [ -n "$JAVA_PATH"]; then
if [ -x "$JAVA_PATH/bin/java" ]; then
# TODO
sed -Ei '/^#?\s*jdkhome=/d' etc/autopsy.conf
echo "jdkhome=$JAVA_PATH" >> etc/autopsy.conf
else
echo "ERROR: Java was not found in $JAVA_PATH."
exit 1