Update install.sh

This commit is contained in:
Jan Rude
2017-03-03 12:38:48 +01:00
committed by GitHub
parent 787d8748d0
commit 2cabd72b82

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# #
# Installation file for HackPi # Installer for HackPi
# #
# Usage: # Usage:
# chmod +x install.sh # chmod +x install.sh
@@ -8,21 +8,25 @@
# #
KERNEL_VERSION=$(uname -r) KERNEL_VERSION=$(uname -r)
MODULE_INSTALLED=false
# Update Packages and ensure dependencies are installed # Update Packages and ensure dependencies are installed
sudo apt-get update sudo apt-get update
sudo apt-get upgrade -y sudo apt-get upgrade -y
sudo apt-get install -y install isc-dhcp-server dsniff screen nodejs bridge-utils sudo apt-get install -y isc-dhcp-server dsniff screen nodejs bridge-utils
sudo git clone https://github.com/samyk/poisontap ~/poisontap sudo git clone https://github.com/samyk/poisontap ~/poisontap
sudo git clone https://github.com/lgandx/Responder ~/Responder sudo git clone https://github.com/lgandx/Responder ~/Responder
printf "\nInstalling..." printf "\nInstalling..."
printf "\nBackup files? [y/n]" printf "\nBackup files? [y/n] "
read backup read backup
if [[ $backup == y* ]]; if [[ $backup == y* ]] ;
then then
sudo mkdir ~/HackPi/backup if [ ! -d ~/HackPi/backup ] ;
then
sudo mkdir ~/HackPi/backup
fi
sudo cp /boot/config.txt ~/HackPi/backup/config.txt.bak sudo cp /boot/config.txt ~/HackPi/backup/config.txt.bak
sudo cp /etc/modules ~/HackPi/backup/modules.bak sudo cp /etc/modules ~/HackPi/backup/modules.bak
sudo cp /etc/rc.local ~/HackPi/backup/rc.local.bak sudo cp /etc/rc.local ~/HackPi/backup/rc.local.bak
@@ -31,36 +35,65 @@ then
sudo cp /lib/modules/"$KERNEL_VERSION"/kernel/drivers/usb/dwc2/dwc2.ko ~/HackPi/backup/dwc2.ko.bak sudo cp /lib/modules/"$KERNEL_VERSION"/kernel/drivers/usb/dwc2/dwc2.ko ~/HackPi/backup/dwc2.ko.bak
fi fi
# Server configuration # Check if kernel module is there, otherwise download kernel and patch
printf "\nConfigure backdoor usage? [y/n]" if [[ $KERNEL_VERSION == "4.4.38+" || $KERNEL_VERSION == "4.4.48+" ]] ;
read server
if [[ $server == y* ]];
then then
printf "\nIP address of server which is running the backend_server.js: " sudo cp -f ~/HackPi/dwc2/dwc2."$KERNEL_VERSION".ko /lib/modules/"$KERNEL_VERSION"/kernel/drivers/usb/dwc2/dwc2.ko
read ip $MODULE_INSTALLED=true
sudo sed -i -e 's/YOUR.DOMAIN/'$ip'/g' ~/poisontap/target_backdoor.js else
sudo sed -i -e 's/YOUR.DOMAIN/'$ip'/g' ~/poisontap/backdoor.html printf "\nModule for kernel $KERNEL_VERSION not found.\nPatching is possible, but requires downloading the kernel."
printf "\nProceed? [y/n] "
read proceed
if [[ $proceed == y* ]];
then
sudo apt-get install -y bc
sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source
sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update
rpi-source
printf "\nPatching kernel module...\n"
cd ~/linux/drivers/usb/dwc2
patch -i ~/HackPi/dwc2/gadget.patch
cd ~/linux
make M=drivers/usb/dwc2 CONFIG_USB_DWC2=m
sudo cp -f drivers/usb/dwc2/dwc2."$KERNEL_VERSION".ko /lib/modules/"$KERNEL_VERSION"/kernel/drivers/usb/dwc2/dwc2.ko
$MODULE_INSTALLED=true
fi
fi
printf "\nAnd the port: " if [ "$MODULE_INSTALLED" = true ] ;
read port then
if [ $port != "1337" ]; # Server configuration
printf "\nConfigure backdoor usage? [y/n] "
read server
if [[ $server == y* ]] ;
then
printf "\nIP address of server which is running the backend_server.js: "
read ip
sudo sed -i -e 's/YOUR.DOMAIN/'$ip'/g' ~/poisontap/target_backdoor.js
sudo sed -i -e 's/YOUR.DOMAIN/'$ip'/g' ~/poisontap/backdoor.html
printf "And the port: "
read port
if [ $port != "1337" ] ;
then then
sudo sed -i -e 's/1337/'$port'/g' ~/HackPi/interfaces sudo sed -i -e 's/1337/'$port'/g' ~/HackPi/interfaces
sudo sed -i -e 's/1337/'$port'/g' ~/HackPi/rc.local sudo sed -i -e 's/1337/'$port'/g' ~/HackPi/rc.local
sudo sed -i -e 's/1337/'$port'/g' ~/poisontap/pi_poisontap.js sudo sed -i -e 's/1337/'$port'/g' ~/poisontap/pi_poisontap.js
sudo sed -i -e 's/1337/'$port'/g' ~/poisontap/backdoor.html sudo sed -i -e 's/1337/'$port'/g' ~/poisontap/backdoor.html
fi fi
fi
# Install files
sudo cp -f ~/HackPi/config.txt /boot/
sudo cp -f ~/HackPi/modules /etc/
sudo cp -f ~/HackPi/rc.local /etc/
sudo chmod +x /etc/rc.local
sudo cp -f ~/HackPi/isc-dhcp-server /etc/default/
sudo cp -f ~/HackPi/dhcpd.conf /etc/dhcp/
sudo cp -f ~/HackPi/interfaces /etc/network/
printf "\nDone.\nYou can now reboot the device."
else
printf "Installation aborted.\n"
[ -v PS1 ] && return || exit
fi fi
# Install files
sudo cp -f ~/HackPi/config.txt /boot/
sudo cp -f ~/HackPi/modules /etc/
sudo cp -f ~/HackPi/rc.local /etc/
sudo chmod +x /etc/rc.local
sudo cp -f ~/HackPi/isc-dhcp-server /etc/default/
sudo cp -f ~/HackPi/dhcpd.conf /etc/dhcp/
sudo cp -f ~/HackPi/interfaces /etc/network/
sudo cp -f ~/HackPi/dwc2/dwc2."$KERNEL_VERSION".ko /lib/modules/"$KERNEL_VERSION"/kernel/drivers/usb/dwc2/dwc2.ko
printf "\nDone.\nYou can now reboot the device."