Skip to content

Instantly share code, notes, and snippets.

@jamieparfet
Created June 23, 2019 09:41
Show Gist options
  • Save jamieparfet/994e9cae784aa68409d4f384f8f9f73c to your computer and use it in GitHub Desktop.
Save jamieparfet/994e9cae784aa68409d4f384f8f9f73c to your computer and use it in GitHub Desktop.
#!/bin/bash
# Set Firefox's plugins dir
firefox_flash_install_dir="/usr/lib/mozilla/plugins"
# Setup Arch
case $(uname -m) in
x86_64) arch=x86_64 ;;
i?86) arch=i386 ;;
esac
# Check the latest version of Flash from Adobe's website
flash_version=$(wget -qO- https://fpdownload.macromedia.com/pub/flashplayer/masterversion/masterversion.xml | grep -m1 "NPAPI_linux version" | cut -d \" -f 2 | tr , .)
flash_debug_version=$(echo $flash_version | cut -d \. -f 1)
# Error out if $flash_version is not set
if [ -z "$flash_version" ]; then
printf "[-] ERROR: Could not identify the latest version of Flash. Perhaps the link does not work. Exiting.\n" >&2
exit 1
fi
# Create Firefox plugins directory if it does not exist
if [ ! -e "$firefox_flash_install_dir" ]; then
sudo mkdir -p "$firefox_flash_install_dir"
fi
# Exit on first error
set -e
# Change to temp directory
cd /tmp
# If argument #1 is "debug", install debug version
if [ "$1" = "debug" ]; then
printf "[+] Installing Flash Player (debugger)\n"
# Download the debug tarball
wget "https://fpdownload.macromedia.com/pub/flashplayer/updaters/${flash_debug_version}/flash_player_npapi_linux_debug.${arch}.tar.gz"
# Extract the contents of the tarball to the necessary directories
tar -xof flash_player_npapi_linux_debug.${arch}.tar.gz -C $firefox_flash_install_dir libflashplayer.so
tar --wildcards -xof flash_player_npapi_linux_debug.${arch}.tar.gz -C /usr usr/*
# Create config file in home directory
cat <<EOF > ~/mm.cfg
ErrorReportingEnable=1
TraceOutputFileEnable=1
MaxWarnings=50
AS3Trace=1
EOF
# Print success message and remove tarball
printf "[+] Flash Player debugger ($flash_debug_version) installed into $firefox_flash_install_dir/\n"
printf "[+] Contents of usr/* copied to /usr folder\n"
printf "[+] File created: ~/mm.cfg\n"
printf "[+] Flash log location: ~/.macromedia/Flash_Player/Logs/flashlog.txt\n\n"
rm flash_player_npapi_linux*.tar.gz
# If no arguments are passed, install standard Flash player
elif [ $# -eq 0 ]; then
printf "[+] Installing Flash Player (standard)\n\n"
# Download Flash tarball
wget "https://fpdownload.adobe.com/pub/flashplayer/pdc/${flash_version}/flash_player_npapi_linux.${arch}.tar.gz"
# Extract Flash player to Firefox plugins directory
tar -xof flash_player_npapi_linux.${arch}.tar.gz -C $firefox_flash_install_dir libflashplayer.so
# Print success message and remove tarball
printf "[+] Flash Player ($flash_version) installed into $firefox_flash_install_dir/\n\n"
rm flash_player_npapi_linux*.tar.gz
# Otherwise, print error and exit
else
printf "Error, probably due to an unrecognized argument.\n"
printf "If you are trying to install the debugger, try running:\n"
printf "$0 debug\n"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment