From 00cd426d3b2e9261b0a9e5eb548371770b824b4b Mon Sep 17 00:00:00 2001 From: Re4son Date: Sat, 23 Feb 2019 23:38:35 +1100 Subject: [PATCH] Install experimental arm64 & arm32 powershell for Empire Let's download and install the experimental arm packages manually before installing Empire. We also have to set the following environmental variable POWERSHELL_TELEMETRY_OPTOUT=1 in "/etc/profile.d/powershell.sh" & "/etc/bash.bashrc" to opt out of Microsofts telemetry program (DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY has been retired by MS) --- nethunter-fs/stages/stage3 | 39 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/nethunter-fs/stages/stage3 b/nethunter-fs/stages/stage3 index ca95e840d..3c05e4588 100644 --- a/nethunter-fs/stages/stage3 +++ b/nethunter-fs/stages/stage3 @@ -43,11 +43,46 @@ dpkg-divert --remove --rename /usr/sbin/invoke-rc.d EOF # End of third-stage script +# Let's do a little bit of magic from outside the chroot if [ "$build_size" = full ]; then # We should run git clone outside chroot because it has issues with machine-code translation git clone https://github.com/Proxmark/proxmark3.git "$rootfs/opt/proxmark3" git clone https://github.com/adaptivethreat/Empire.git "$rootfs/opt/Empire" + # powershell for arm64 is not yet available in Microsofts repos so let's install it manually + if [ $build_arch == "arm64" ]; then + mkdir -p $rootfs/opt/microsoft/powershell + wget -P $rootfs/opt/microsoft/powershell https://github.com/PowerShell/PowerShell/releases/download/v6.2.0-preview.4/powershell-6.2.0-preview.4-linux-arm64.tar.gz + tar -xzf $rootfs/opt/microsoft/powershell/powershell-6.2.0-preview.4-linux-arm64.tar.gz -C $rootfs/opt/microsoft/powershell + rm $rootfs/opt/microsoft/powershell/powershell-6.2.0-preview.4-linux-arm64.tar.gz + fi + if [ $build_arch == "armhf" ]; then + mkdir -p $rootfs/opt/microsoft/powershell + wget -P $rootfs/opt/microsoft/powershell https://github.com/PowerShell/PowerShell/releases/download/v6.2.0-preview.4/powershell-6.2.0-preview.4-linux-arm32.tar.gz + tar -xzf $rootfs/opt/microsoft/powershell/powershell-6.2.0-preview.4-linux-arm32.tar.gz -C $rootfs/opt/microsoft/powershell + rm $rootfs/opt/microsoft/powershell/powershell-6.2.0-preview.4-linux-arm32.tar.gz + fi + # Microsoft no longer supports deletion of the file DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY to disable telemetry + # We have to set this environment variable instead + cat << EOF > "$rootfs/etc/profile.d/powershell.sh" +# Microsoft no longer supports deletion of the file DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY to disable telemetry +# We have to set this environment variable instead + +export POWERSHELL_TELEMETRY_OPTOUT=1 +EOF + + cat << EOF >> "$rootfs/etc/bash.bashrc" +# Microsoft no longer supports deletion of the file DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY to disable telemetry +# We have to set this environment variable instead + +export POWERSHELL_TELEMETRY_OPTOUT=1 +EOF + + # The installation of Empire will still throw a few errors in relation to not being able to install powershell and that it cannot disable telemetry but that is not + # to worry about anymore as we have taken care of it ourselves now + +# End of doing a little magic from outside the chroot + cat << EOF >> "$rootfs/third-stage" # Enable PHP in Apache @@ -66,9 +101,9 @@ fi if cd /opt/Empire/setup; then # Lets patch install.sh to build xar for our target architecture if [ $build_arch == "arm64" ]; then - sed "install.sh" -i -e "s/(cd xar-1.5.2 \&\& \./configure)/(cd xar-1.5.2 \&\& \./configure --build=armv8l-unkown-linux-gnu)/" + sed "install.sh" -i -e "s/(cd xar-1.5.2 \&\& \.\/configure)/(cd xar-1.5.2 \&\& \.\/configure --build=armv8l-unkown-linux-gnu)/" elif [ $build_arch == "armhf" ]; then - sed "install.sh" -i -e "s/(cd xar-1.5.2 \&\& \./configure)/(cd xar-1.5.2 \&\& \./configure --build=armv7l-unkown-linux-gnu)/" + sed "install.sh" -i -e "s/(cd xar-1.5.2 \&\& \.\/configure)/(cd xar-1.5.2 \&\& \.\/configure --build=armv7l-unkown-linux-gnu)/" fi chmod +x install.sh printf "\n" | ./install.sh