#!/bin/sh # One-line install script for ecomscan (installs to ~/bin) # # $ curl https://ecomscan.com | sh # replaced \e with \033 for bash3 compat WHITE="\033[1;37;40m" RED="\033[1;31;40m" GREEN="\033[1;32;40m" END="\033[0m" arch="" case $(uname -m) in i386|i686) arch="386" ;; x86_64|amd64) arch="amd64" ;; arm64|aarch64) arch="arm64" ;; *) echo "Unsupported architecture" && exit 1;; esac os="" case $(uname -s) in Darwin) os="darwin" ;; Linux) os="linux" ;; *) echo "Unsupported OS" && exit 1 ;; esac URL="https://ecomscan.com/downloads/${os}-${arch}/ecomscan" DIR="$HOME/bin" findWritableDir() { local dirs="$1" local found="" for dir in $dirs; do mkdir -p "$dir" 2>/dev/null if [ $? -eq 0 ] && [ -w "$dir" ]; then found="$dir" break fi done if [ -n "$found" ]; then echo "$found" return 0 else return 1 fi } dirsToCheck="$HOME/bin /mnt/shared/$LOGNAME/sansec /tmp/sansec" DIR=$(findWritableDir "$dirsToCheck") if [ $? -ne 0 ]; then printf "${RED}Could not find a writeable location! Install ecomscan manually.${END}\n" printf "See https://sansec.io/kb/about-ecomscan/usage\n\n" exit 1 fi ECOM="$DIR/ecomscan" printf "\n${WHITE}Welcome to eComscan, the advanced eCommerce security scanner${END}\n\n" # Download the binary printf "Downloading ecomscan to $ECOM ...\n" curl -SfL -# "$URL" -o "$ECOM" || { echo "Failed to download ecomscan."; exit 1; } # Set permissions printf "Setting up permissions ...\n" chmod 755 "$ECOM" || { echo "Failed to set up permissions for ecomscan."; exit 1; } printf "Running ecomscan in interactive mode ...\n" exec "$ECOM" interactive