From 2cabd72b820ef1fccf881f7a70bb131128c52f06 Mon Sep 17 00:00:00 2001 From: Jan Rude Date: Fri, 3 Mar 2017 12:38:48 +0100 Subject: [PATCH 1/4] Update install.sh --- install.sh | 89 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 28 deletions(-) diff --git a/install.sh b/install.sh index c21f41f..d374175 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Installation file for HackPi +# Installer for HackPi # # Usage: # chmod +x install.sh @@ -8,21 +8,25 @@ # KERNEL_VERSION=$(uname -r) +MODULE_INSTALLED=false # Update Packages and ensure dependencies are installed sudo apt-get update 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/lgandx/Responder ~/Responder printf "\nInstalling..." -printf "\nBackup files? [y/n]" +printf "\nBackup files? [y/n] " read backup -if [[ $backup == y* ]]; +if [[ $backup == y* ]] ; 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 /etc/modules ~/HackPi/backup/modules.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 fi -# Server configuration -printf "\nConfigure backdoor usage? [y/n]" -read server - -if [[ $server == y* ]]; +# Check if kernel module is there, otherwise download kernel and patch +if [[ $KERNEL_VERSION == "4.4.38+" || $KERNEL_VERSION == "4.4.48+" ]] ; 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 + sudo cp -f ~/HackPi/dwc2/dwc2."$KERNEL_VERSION".ko /lib/modules/"$KERNEL_VERSION"/kernel/drivers/usb/dwc2/dwc2.ko + $MODULE_INSTALLED=true +else + 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: " - read port - if [ $port != "1337" ]; +if [ "$MODULE_INSTALLED" = true ] ; +then + # 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 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' ~/poisontap/pi_poisontap.js sudo sed -i -e 's/1337/'$port'/g' ~/poisontap/backdoor.html 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 -# 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." From b74cb653ff24052d5518e39704e1df1e663c1cf7 Mon Sep 17 00:00:00 2001 From: Jan Rude Date: Fri, 3 Mar 2017 13:18:05 +0100 Subject: [PATCH 2/4] Update install.sh modular kernel module check --- install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index d374175..dbb6bd9 100755 --- a/install.sh +++ b/install.sh @@ -36,7 +36,7 @@ then fi # Check if kernel module is there, otherwise download kernel and patch -if [[ $KERNEL_VERSION == "4.4.38+" || $KERNEL_VERSION == "4.4.48+" ]] ; +if [ -f ~/HackPi/dwc2/dwc2."$KERNEL_VERSION".ko ] ; then sudo cp -f ~/HackPi/dwc2/dwc2."$KERNEL_VERSION".ko /lib/modules/"$KERNEL_VERSION"/kernel/drivers/usb/dwc2/dwc2.ko $MODULE_INSTALLED=true @@ -56,6 +56,7 @@ else 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 + sudo cp -f drivers/usb/dwc2/dwc2."$KERNEL_VERSION".ko ~/HackPi/dwc2/ $MODULE_INSTALLED=true fi fi From 73feb3eb8c90e896b5aa9174aa7ef15ebf4b1ccd Mon Sep 17 00:00:00 2001 From: Jan Rude Date: Fri, 3 Mar 2017 14:47:12 +0100 Subject: [PATCH 3/4] Update rc.local --- rc.local | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc.local b/rc.local index a4bbc38..898b9e4 100644 --- a/rc.local +++ b/rc.local @@ -49,6 +49,6 @@ ifconfig br0 up systemctl enable getty@ttyGS0.service # Start Responder -/usr/bin/screen -dmS responder bash -c 'cd /home/pi/Responder/; python Responder.py -I br0 -f -w -r -d -F' +/usr/bin/screen -dmS responder bash -c 'cd /home/pi/Responder/; python Responder.py -I br0 -wF' exit 0 From 73dbeb9e45d768bbde4e61d9590a87af839169f7 Mon Sep 17 00:00:00 2001 From: Jan Rude Date: Fri, 3 Mar 2017 14:55:54 +0100 Subject: [PATCH 4/4] Update install.sh --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index dbb6bd9..71aab36 100755 --- a/install.sh +++ b/install.sh @@ -68,7 +68,7 @@ then read server if [[ $server == y* ]] ; then - printf "\nIP address of server which is running the backend_server.js: " + printf "IP 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 @@ -92,7 +92,7 @@ then 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." + printf "\nDone.\nYou can now reboot the device.\n" else printf "Installation aborted.\n" [ -v PS1 ] && return || exit