Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions scripts/install_didier_stevens_pdf_tools.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
#!/bin/bash -e
#!/usr/bin/env bash
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail

# Get Didier Stevens's pdf-parser.py and pdfid.py from github, place them in tools/ dir, and make executable

SCRIPT_PATH=$(dirname -- "$(readlink -f -- "$0";)";)
. "$SCRIPT_PATH/lib/project_paths.sh"
SCRIPT_PATH="$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")"
. "${SCRIPT_PATH}/lib/project_paths.sh"

TOOL_EXECUTABLES=(pdfid.py pdf-parser.py xorsearch.py)
DIDIER_STEVENS_RAW_GITHUB_URL='https://raw.githubusercontent.com/DidierStevens/DidierStevensSuite/master/'
DIDIER_STEVENS_RAW_GITHUB_URL="https://raw.githubusercontent.com/DidierStevens/DidierStevensSuite/master/"

mkdir -p "$PDFALYZER_TOOLS_DIR"
pushd "$PDFALYZER_TOOLS_DIR"
mkdir -p -v "${PDFALYZER_TOOLS_DIR}"
pushd "${PDFALYZER_TOOLS_DIR}" || exit 1

for tool_executable in "${TOOL_EXECUTABLES[@]}"; do
wget $DIDIER_STEVENS_RAW_GITHUB_URL/$tool_executable
chmod 744 "$PDFALYZER_TOOLS_DIR/$tool_executable"
wget --secure-protocol=auto --https-only --continue --verbose -N --tries=10 --check-certificate "${DIDIER_STEVENS_RAW_GITHUB_URL}/${tool_executable}"
chmod 744 "${PDFALYZER_TOOLS_DIR}/${tool_executable}"
done

echo -e "\n\n\nDidier Stevens recommends always using the -O option with pdf-parser.py. This can be accomplished by setting the PDFPARSER_OPTIONS environment variable:\n"
echo -e " PDFPARSER_OPTIONS=-O\n\nYou are encouraged to add that to your environment via your .bash_profile or similar.\nThis has NOT been done automatically."
popd
printf "\n\n\nDidier Stevens recommends always using the -O option with pdf-parser.py. This can be accomplished by setting the PDFPARSER_OPTIONS environment variable:\n\n"
printf " PDFPARSER_OPTIONS=-O\n\nYou are encouraged to add that to your environment via your .bash_profile or similar.\nThis has NOT been done automatically.\n"
popd || exit 1

11 changes: 5 additions & 6 deletions scripts/install_t1utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
# Requires autoconf and automake on macOS.

if cat /etc/*release | grep ^NAME | egrep 'CentOS|Red|Fedora'; then
echo "Installing t1utils with yum..."
echo "Info: Installing t1utils with yum..."
sudo yum install -y t1utils
exit 0
elif cat /etc/*release | grep ^NAME | egrep 'Ubuntu|Debian|Mint|Knoppix'; then
echo "Installing t1utils with apt-get..."
echo "Info: Installing t1utils with apt-get..."
sudo apt-get install -y t1utils
exit 0
elif ! echo `uname -a` | grep Darwin 2>&1 >/dev/null; then
echo "OS NOT DETECTED, couldn't install t1utils"
echo "Warning: OS NOT DETECTED, couldn't install t1utils"
exit 1;
fi

echo "macOS detected, building t1utils from source..."
echo "Info: macOS detected, building t1utils from source..."


for required_build_tool in automake autoconf make; do
Expand All @@ -26,9 +26,8 @@ done

SCRIPT_PATH=$(dirname -- "$(readlink -f -- "$0";)";)
source "$SCRIPT_PATH/lib/project_paths.sh"
TMP_DIR="$PDFALYZER_PROJECT_PATH/tmp"
TMP_DIR="$(mktemp -d -p "${PDFALYZER_PROJECT_PATH}" -t "tmp.XXXXXXXXXX")"

mkdir -p "$TMP_DIR"
pushd "$TMP_DIR" >/dev/null
git clone https://github.com/kohler/t1utils.git

Expand Down