From bd9d621e4a443293b176e729a111b49bda0a34fc Mon Sep 17 00:00:00 2001 From: norly Date: Mon, 21 Jan 2019 02:54:16 +0100 Subject: First version --- .gitignore | 1 + amiga-uae-virus-scan.sh | 252 ++++++++++++++++++++++++++++++++++++++++++++++++ installer_urls | 6 ++ sha256sums | 12 +++ 4 files changed, 271 insertions(+) create mode 100644 .gitignore create mode 100755 amiga-uae-virus-scan.sh create mode 100644 installer_urls create mode 100644 sha256sums diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..150a127 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +installers diff --git a/amiga-uae-virus-scan.sh b/amiga-uae-virus-scan.sh new file mode 100755 index 0000000..c63bbb7 --- /dev/null +++ b/amiga-uae-virus-scan.sh @@ -0,0 +1,252 @@ +#!/bin/bash + +# Ensure we have something to scan +if [ $# -lt 1 ] +then + echo "Usage: $0 floppy-to-test.adf" + echo "Usage: $0 directory-to-scan" + exit 1 +fi + + +# Ensure we have all native tools +if [ -z "$(which curl)" -o \ + -z "$(which lha)" -o \ + -z "$(which fs-uae)" -o \ + -z "$(which sha256sum)" ] +then + echo -e "\033[1m\033[31mERROR:\033[0m" + echo "This script requires the following programs to be in $PATH:" + echo " curl" + echo " lha" + echo " fs-uae" + echo " sha256sum" + exit 1 +fi + + +# Directories +CWD="$PWD" +INSTALLERS="$CWD/installers" +DHDIR=dh0 + + +# Alias for curl +CURL="curl --progress-bar --location -o" + + + + +# Provide a way to bail. +# This does NOT clean up a running emulation session. +function int_func() +{ + tset + echo "$0: Interrupt." + exit 1 +} +trap int_func INT + + +function colorprint() +{ + echo -en "\033[1m\033[3$1m" + shift + echo "$@" + echo -en "\033[0m" +} +trap int_func INT + + + +# Download any packages we don't have yet +function download_installers() +{ + colorprint 3 "Downloading missing components..." + + mkdir -p "$INSTALLERS" + + for n in $(cat installer_urls) + do + LHANAME=${n##*/} + TXTNAME=${LHANAME%.lha}.readme + + if [ ! -e "$INSTALLERS/$LHANAME" ] + then + echo -e "\033[1m\033[34mDownloading\033[0m $LHANAME ..." + $CURL "$INSTALLERS/$LHANAME" "$n" + fi + + if [ ! -e "$INSTALLERS/$TXTNAME" ] + then + echo -e "\033[1m\033[34mDownloading\033[0m $TXTNAME ..." + $CURL "$INSTALLERS/$TXTNAME" "${n%.lha}.readme" + fi + done + + colorprint 2 "...done" + echo +} + + + +# Checksum all files we get from Aminet +function verify_installers() +{ + colorprint 3 "Checking integrity..." + + if ! sha256sum --strict --quiet --check sha256sums + then + echo + echo -e "\033[1m\033[31mERROR:\033[0m" + echo "Integrity check failed." + echo "Try removing the broken file and re-downloading it." + echo "If you just downloaded these files, then maybe Aminet is currently having problems serving those files?" + echo + exit 1 + fi + + colorprint 2 "...done" + echo +} + + + +# This prepares a folder to be a virtual partition, +# with an Amiga system ready to run and scan a directory. +function populate_dh0() +{ + mkdir -p "$TD/$DHDIR" + + + # Programs + mkdir -p "$TD/$DHDIR/C" + lha xqiw="$TD/$DHDIR/C" "$INSTALLERS"/CheckX.lha CheckX/CheckX + lha xqiw="$TD/$DHDIR/C" "$INSTALLERS"/UAEquit.lha UAEquit + + + # Libraries + mkdir -p "$TD/$DHDIR/Libs" + + mkdir -p "$TD/$DHDIR/Libs/xad" + lha xqiw="$TD/$DHDIR/Libs" "$INSTALLERS"/xadmaster000.lha xad/Libs/xadmaster.library + lha xqiw="$TD/$DHDIR/Libs/xad" "$INSTALLERS"/xadmaster000.lha xad/Libs/xad/* + + mkdir -p "$TD/$DHDIR/Libs/xfd" + lha xqiw="$TD/$DHDIR/Libs" "$INSTALLERS"/xfdmaster.lha xfd_User/Libs/xfdmaster.library + lha xqiw="$TD/$DHDIR/Libs/xfd" "$INSTALLERS"/xfdmaster.lha xfd_User/Libs/xfd/* + + lha xqiw="$TD/$DHDIR/Libs" "$INSTALLERS"/xvslibrary.lha xvs/libs/xvs.library + + + # Startup-sequence, config, registration keys + mkdir -p "$TD/$DHDIR/S" + lha xqiw="$TD/$DHDIR/S" "$INSTALLERS"/xadmaster-key.lha xadmaster.key + + cat > "$TD/$DHDIR/S/startup-sequence" <<-EOF + CheckX ALL FROM SYS:scandir LOG SYS:checkx-scandir.log + UAEquit + EOF +} + + + +function write_uae_config() +{ + # Write main UAE config + cat > "$TD/amiga-virus-scan.fs-uae" <<-EOF + [fs-uae] + amiga_model = A4000 + automatic_input_grab = 0 + end_config = 1 + expect_version = 2.8.0 + floppies_dir = ./ + #floppy_drive_1 = ./df1.adf + fullscreen = 0 + hard_drive_0 = ./$DHDIR + initial_input_grab = 0 + jit_compiler = 1 + joystick_port_0 = Mouse + joystick_port_0_mode = mouse + joystick_port_1 = none + joystick_port_1_mode = nothing + joystick_port_2 = none + joystick_port_2_mode = none + joystick_port_3 = none + joystick_port_3_mode = none + keep_aspect = 1 + maximized = 0 + save_disk = 0 + uae_sound_output = none + video_sync = 1 + window_hidden = 1 + zoom = full + EOF + + + # Prevent FS-UAE from printing audio errors + cat > "$TD"/.alsoftrc <<-EOF + [general] + drivers = null + EOF +} + + + + +# +# +# Main script +# + +colorprint 7 " *******************************************" +colorprint 7 " Amiga virus scanner wrapper starting up" +colorprint 7 " *******************************************" +echo + + +# Get external Amiga software +download_installers +verify_installers + + +# Prepare emulation environment +colorprint 3 "Preparing emulation environment..." + +TD="$(mktemp --directory)" +populate_dh0 +write_uae_config + +# Copy files to scan +colorprint 7 "Scan target: $1 (will be copied to emulation first)" + +cp -r "$1" "$TD/$DHDIR/scandir" +chmod -R u+rwX "$TD/$DHDIR/scandir" + +colorprint 2 "...done" +echo + + +# Run emulator +colorprint 3 "Running emulator..." +cd "$TD" +export HOME="$TD" +fs-uae amiga-virus-scan.fs-uae > /dev/null + +colorprint 2 "...done" +echo + + +# Print results +echo +echo +colorprint 2 "Scan results:" +echo +cat ./dh0/checkx-scandir.log + + +# Clean up +cd .. +rm -rf "$TD" + +echo diff --git a/installer_urls b/installer_urls new file mode 100644 index 0000000..c276afd --- /dev/null +++ b/installer_urls @@ -0,0 +1,6 @@ +http://aminet.net/util/arc/CheckX.lha +http://aminet.net/misc/emu/UAEquit.lha +http://aminet.net/util/arc/xadmaster000.lha +http://aminet.net/util/arc/xadmaster-key.lha +http://aminet.net/util/pack/xfdmaster.lha +http://aminet.net/util/virus/xvslibrary.lha diff --git a/sha256sums b/sha256sums new file mode 100644 index 0000000..ad10400 --- /dev/null +++ b/sha256sums @@ -0,0 +1,12 @@ +5b09b4c0c4514cf59cfc8fea1ce9703db62517a09ab678083fa109ffaf1eb79a *installers/CheckX.lha +eba8885379830501d930ea5de1a7df6c6e81e882e9fbf646db0131d67336b0da *installers/CheckX.readme +7c325086d73996dec7828b1aff75779a425a22cf0b69129da8766e691cae5af6 *installers/UAEquit.lha +b148133d547c04c97a70491ae3bb4250e8220ee14ca5e6fe5ad36673805369cb *installers/UAEquit.readme +045ccc5f163d44b42fcc0a6950c0269895e268c2ec437b4a01c07a10df81e7ee *installers/xadmaster000.lha +27aa8bfb89b8685405c5fa239153a10509c0f9252e4e307be4b80d7e8ad2af22 *installers/xadmaster000.readme +837aab7e6bb13ce6be4424fe5a116ee9615a758ea490d5f6761ce0a4824b5f32 *installers/xadmaster-key.lha +bdb1cf276bdf0dd90bce89bab516d62faf12efe081c49f110c92929d7a295fda *installers/xadmaster-key.readme +4147a2b29a7d007ab5b5a5f855c2a8095c6a9d9cadcb4f238d86cd8ca1424d62 *installers/xfdmaster.lha +3e504ab996a57479fb44ee73bddb3067e9a43fc6eda9f41c047b15654ef2e314 *installers/xfdmaster.readme +ae984ddbd99c3bda8958e66a7219337e2dd7c015baf1b73c7165bbd2ddfd0eb6 *installers/xvslibrary.lha +8a81d11b6e7114c52b0292d2d5082910cb3f9bdb3c731665a774f348f31adb95 *installers/xvslibrary.readme -- cgit v1.2.3