Skip to content

Instantly share code, notes, and snippets.

@MoralCode
Created January 24, 2021 22:56
Show Gist options
  • Select an option

  • Save MoralCode/0e6d3515cc6546ada033a504d95c79f7 to your computer and use it in GitHub Desktop.

Select an option

Save MoralCode/0e6d3515cc6546ada033a504d95c79f7 to your computer and use it in GitHub Desktop.
#!/bin/sh
# This script extracts the embedded tarball from the linux anyconnect install script downloaded from vpn.rit.edu
# While it uses the same mechanism to extract the file as the original install script, everything else has been removed.
#
# Usage: ./rit-vpn-extract.sh "path/to/anyconnect/installer/script"
# If the anyconnect script is in the same folder, just include the name of the file as the argument to this script
#
# Author: Adrian Edwards
MARKER=$((`grep -an "[B]EGIN\ ARCHIVE" "${1}" | cut -d ":" -f 1` + 1))
MARKER_END=$((`grep -an "[E]ND\ ARCHIVE" "${1}" | cut -d ":" -f 1` - 1))
TARNAME=`date +%N`
TARFILE=./vpninst${TARNAME}.tgz
echo "Extracting installation files to ${TARFILE}..."
# "head --bytes=-1" used to remove '\n' prior to MARKER_END
head -n ${MARKER_END} "${1}" | tail -n +${MARKER} | head --bytes=-1 > ${TARFILE} || exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment