Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Version 3.2
- # This is a script for the pineapple mark 4 firmware 2.7.1 up, Newer firmware may break this script, Read through to add or comment out what you don't want.
- # Run: chmod +x pineapple-mk4-setup-script.sh; ./pineapple-mk4-setup-script.sh
- # It is assumed a USB drive with swap partition is unplugged and waiting to be inserted: http://forums.hak5.org/index.php?showtopic=25882&hl=swap&st=0
- red='\e[0;31m'
- lightRed='\e[1;31m'
- green='\e[0;32m'
- yellow='\e[0;33m'
- cyan='\e[0;36m'
- textReset='\e[m'
- bold='\033[1m'
- boldEnd='\033[0m'
- uWhite='\e[4;37m'
- appleSuccess=true
- changeTimeZone=true
- autoStartKarma=true
- DNSSpoofLogsToUSB=true
- changeSSID=true
- changePineapplePort=true
- stealthAutoStart=true
- updateFSTabForSwap=true
- useUSB=true # Please use one;-)
- cleanUpUSB=true
- logsToUSB=false
- isThereInternet=true # Required for installing packages!!!
- # All get installed to /usb/
- installSSLStrip=true # Requires Internet
- installTCPDump=true # Requires Internet
- installNMap=true # Requires Internet
- installReaver=true #Requires Internet
- installMDK3=true #Requires Internet
- changeRootPassword=true
- newrootpassword='pineapplesareyummy'
- newSSID='AndroidAP'
- newPineapplePort=1471 # make sure it's above 1024
- newTimeZone='PST8PDT' # PST8PDT America/Vancouver visit http://wiki.openwrt.org/doc/uci/system#time.zones for a list of time zones
- newTimeZoneLocation='America/Vancouver' # Please be careful, do not put in the whole value IE "PST8PDT,M3.2.0,M11.1.0" just use the PST8PDT
- # If you mess this up you may need to use serial connection to fix!!!
- echo
- echo -e $uWhite$bold'Pineapple Mark 4 setup script created by'$cyan' petertfm'$textReset
- echo
- echo
- # Enable Apple Success to disable portal page popup when dnsspoofing with no internet:
- if [ $appleSuccess = true ]; then
- if [ -d /www/ ]; then
- if [ ! -d /www/library/ ]; then
- mkdir /www/library
- if [ ! -d /www/library/test/ ]; then
- mkdir /www/library/test
- fi
- fi
- if [ ! -f /www/library/test/success.html ]; then
- echo -e '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
- <HTML>
- <HEAD>
- <TITLE>Success</TITLE>
- </HEAD>
- <BODY>
- Success
- </BODY>
- </HTML>' > /www/library/test/success.html
- fi
- echo -e '/www/library/test/success.html Created: Tricks apple products to beleve there is internet when running dnsspoof.'
- else
- echo -e $lightRed'/www/ folder not found, most likely script needs to be updated, firmware may have changed'
- fi
- echo -e $textReset
- fi
- # Change Timezone:
- if [ $changeTimeZone = true ]; then
- if [ -f /etc/config/system ]; then
- echo -e 'Changing TimeZone: '$yellow$newTimeZone$textReset' Location: '$yellow$newTimeZoneLocation
- sed -i "s/option timezone.*/option timezone '"$newTimeZone"'/g" /etc/config/system
- if [ -f /etc/rc.d/S98sysntpd ]; then
- /etc/rc.d/S98sysntpd restart
- else
- echo -e $lightRed'/etc/rc.d/S98sysntpd file not found, most likely script needs to be updated, firmware may have changed'
- fi
- else
- echo -e $lightRed'/etc/config/system file not found, most likely script needs to be updated, firmware may have changed'
- fi
- echo -e $textReset
- fi
- # AutoStart Karma
- if [ $autoStartKarma = true ]; then
- if [ -f /pineapple/karma/autoKarmaStart.php ]; then
- php /pineapple/karma/autoKarmaStart.php > /dev/null
- echo 'Karma AutoStart Enabled'
- else
- echo -e $lightRed'/pineapple/karma/autoKarmaStart.php file not found, most likely script needs to be updated, firmware may have changed'
- fi
- echo -e $textReset
- fi
- # DNSSpoof Logs to USB:
- if [ $DNSSpoofLogsToUSB = true ]; then
- if [ -f /pineapple/dnsspoof/dnsspoof.sh ]; then
- echo -e '#!/bin/sh
- if [ ! -d /usb/logs ]; then
- mkdir /usb/logs
- fi
- if [ ! -d /usb/logs/DNSSpoof ]; then
- mkdir /usb/logs/DNSSpoof
- fi
- if [ -b /dev/sda1 ]; then
- MYPATH="/usb/logs/DNSSpoof/DNSSpoof-"
- dnsspoofFile="null"
- x=1
- while :
- do
- dnsspoofFile=${MYPATH}${x}.log
- if [ ! -f $dnsspoofFile ]; then
- break
- fi
- x=$(( $x + 1 ))
- done
- if [ -f /usb/logs/DNSSpoof/DNSSpoof.log ]; then
- md5=`md5sum /usb/logs/DNSSpoof/DNSSpoof.log`
- if [ ${md5:0:32} != "9a13ce17b26d5d2e2e153584c2d7c8e8" ]; then
- cp /usb/logs/DNSSpoof/DNSSpoof.log ${dnsspoofFile}
- fi
- fi
- sed -i "s/$cmd = \\"cat logs\\/dnsspoof.log\\";.*/$cmd = \\"cat \\/usb\\/logs\\/DNSSpoof\\/DNSSpoof.log\\";/g" /pineapple/pages/logs.php
- dnsspoof -i br-lan -f /pineapple/config/spoofhost > /dev/null 2> /usb/logs/DNSSpoof/DNSSpoof.log
- else
- sed -i "s/$cmd = \\"cat \\/usb\\/logs\\/DNSSpoof\\/DNSSpoof.log\\";.*/$cmd = \\"cat logs\\/dnsspoof.log\\";/g" /pineapple/pages/logs.php
- dnsspoof -i br-lan -f /pineapple/config/spoofhost > /dev/null 2> /pineapple/logs/dnsspoof.log
- fi' > /pineapple/dnsspoof/dnsspoof.sh
- echo 'Installed DNSSpoof logs to usb by petertfm'
- else
- echo -e $lightRed'/pineapple/dnsspoof/dnsspoof.sh file not found, most likely script needs to be updated, firmware may have changed'
- fi
- echo -e $textReset
- fi
- # Changing SSID:
- if [ $changeSSID = true ]; then
- echo -e 'Changing SSID: '$yellow$newSSID
- sed -i 's/option ssid.*/option ssid '$newSSID'/g' /etc/config/wireless
- echo -e $textReset
- fi
- # Changing Pineapple UI Port:
- if [ $changePineapplePort = true ]; then
- echo -e 'Changing Pineapple UI Port: '$yellow$newPineapplePort
- currentPort=`cat /etc/config/uhttpd | grep -i listen_http | grep -v listen_https | tail -n 1`
- currentPortPos=`expr index "$currentPort" :`
- port=${currentPort:$currentPortPos}
- sed -i 's/'$port'/'$newPineapplePort'/g' /etc/config/uhttpd
- echo -e $textReset
- fi
- # Enable Stealth:
- if [ $stealthAutoStart = true ]; then
- if [ -f /etc/rc.local ]; then
- sed -i '/icmp_echo_ignore_all/d' /etc/rc.local
- sed -i '/exit 0/d' /etc/rc.local
- echo -e 'echo -e 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all # Autostart Stealth mode
- exit 0' >> /etc/rc.local
- echo 'Stealth AutoStart Enabled'
- else
- echo -e $lightRed'/etc/rc.local file not found, most likely script needs to be updated, firmware may have changed'
- fi
- echo -e $textReset
- fi
- # Updating FStab(USB):
- if [ $updateFSTabForSwap = true ]; then
- if [ -f /etc/config/fstab ]; then
- echo 'Updateing fstab for use with swap partition'
- echo -e 'config global automount
- option from_fstab 1
- option anon_mount 1
- config global autoswap
- option from_fstab 1
- option anon_swap 1
- config mount
- option target /usb
- option device /dev/sda1
- option fstype ext4
- option options rw,sync
- option enabled 1
- option enabled_fsck 0
- config swap
- option device /dev/sda2
- option enabled 1' > /etc/config/fstab
- else
- echo -e $lightRed'/etc/config/fstab file not found, most likely script needs to be updated, firmware may have changed'
- echo -e $red'This script is outdated, Exiting...'
- exit 1
- fi
- echo -e $textReset
- fi
- #
- ##
- ###
- ####
- ##### The rest of this script is mostly USB related with an exception to changing the root password
- if [ $useUSB = true ]; then
- echo
- read -p 'Please Insert USB Drive then press ENTER!!!' nullVar
- echo 'Sleeping 15 seconds, USB drive initializing.'
- sleep 15
- echo -e $textReset
- if [ -b /dev/sda1 ]; then # The dev name of what gets mounted to /usb/
- # Make swap:
- if [ $updateFSTabForSwap = true ]; then
- if [ -b /dev/sda2 ]; then
- echo 'mkswap /dev/sda2, Swap may already have been made previously'
- mkswap /dev/sda2
- else
- echo -e $lightRed'/dev/sda2 not found for swap!'
- fi
- echo -e $textReset
- fi
- # Starting fresh with pineapple created files/folders on USB, From a previous install/firmware.
- if [ $cleanUpUSB = true ]; then
- echo 'Removing folders on USB, In prep for fresh settings'
- echo -e $yellow'(NOTE) Keep /usb/etc/ and /usb/usr/ to save previously installed OPKG packages'$textReset
- if [ -d /usb/data/ ]; then
- echo -n -e "Remove /usb/data/ "$cyan"(y)/n? "$textReset
- read dataYesNo
- if [[ "$dataYesNo" == '' ]]; then
- dataYesNo='y'
- fi
- if [ $dataYesNo == 'y' ]; then
- echo 'Removing: /usb/data/ TCPDump module is known to use this folder'
- rm -r /usb/data/
- fi
- fi
- if [ -d /usb/get/ ]; then
- echo -n -e "Remove /usb/get/ "$cyan"(y)/n? "$textReset
- read getYesNo
- if [[ "$getYesNo" == '' ]]; then
- getYesNo='y'
- fi
- if [ $getYesNo == 'y' ]; then
- echo 'Removing: /usb/get/ get module is known to use this folder'
- rm -r /usb/get/
- fi
- fi
- if [ -d /usb/logs/ ]; then
- echo -n -e "Remove /usb/logs/ "$cyan"(y)/n? "$textReset
- read logsYesNo
- if [[ "$logsYesNo" == '' ]]; then
- logsYesNo='y'
- fi
- if [ $logsYesNo == 'y' ]; then
- echo 'Removing: /usb/logs/'
- rm -r /usb/logs/
- fi
- fi
- if [ -d /usb/modules/ ]; then
- echo -n -e "Remove /usb/modules/ "$cyan"(y)/n? "$textReset
- read modulesYesNo
- if [[ "$modulesYesNo" == '' ]]; then
- modulesYesNo='y'
- fi
- if [ $modulesYesNo == 'y' ]; then
- echo 'Removing: /usb/modules/'
- rm -r /usb/modules/
- fi
- fi
- if [ -d /usb/infusions/ ]; then
- echo -n -e "Remove /usb/infusions/ "$cyan"(y)/n? "$textReset
- read infusionsYesNo
- if [[ "$infusionsYesNo" == '' ]]; then
- infusionsYesNo='y'
- fi
- if [ $infusionsYesNo == 'y' ]; then
- echo 'Removing: /usb/infusions/'
- rm -r /usb/infusions/
- fi
- fi
- if [ -d /usb/etc/ ]; then
- echo -n -e "Remove /usb/etc/ "$cyan"(y)/n? "$textReset
- read etcYesNo
- if [[ "$etcYesNo" == '' ]]; then
- etcYesNo='y'
- fi
- if [ $etcYesNo == 'y' ]; then
- echo 'Removing: /usb/etc/'
- rm -r /usb/etc/
- fi
- fi
- if [ -d /usb/usr/ ]; then
- echo -n -e "Remove /usb/usr/ "$cyan"(y)/n? "$textReset
- read usrYesNo
- if [[ "$usrYesNo" == '' ]]; then
- usrYesNo='y'
- fi
- if [ $usrYesNo == 'y' ]; then
- echo 'Removing: /usb/usr/'
- rm -r /usb/usr/
- fi
- fi
- if [ -d /usb/var/ ]; then
- echo -n -e "Remove /usb/var/ "$cyan"(y)/n? "$textReset
- read varYesNo
- if [[ "$varYesNo" == '' ]]; then
- varYesNo='y'
- fi
- if [ $varYesNo == 'y' ]; then
- echo 'Removing: /usb/var/'
- rm -r /usb/var/
- fi
- fi
- echo -e $textReset
- fi
- # /logs/ folder to USB:
- if [ $logsToUSB = true ]; then
- if [ -d /pineapple/logs/ ]; then
- # Moving logs folder to USB is experimental, After this change the usb drive must remain inserted at all times
- echo 'Moving /pineapple/logs/ folder to /usb/logs/, and sym linking back to /pineapple/logs'
- echo -e $yellow$bold'WARNING!!! from this point on the usb drive must be inserted at all times!'$boldEnd
- mv /pineapple/logs/ /usb/
- ln -s /usb/logs/ /pineapple/logs
- echo 'To revert back: rm /pineapple/logs; mv /usb/logs/ /pineapple/'
- else
- echo -e $lightRed'/pineapple/logs folder not found, most likely script needs to be updated, firmware may have changed'
- fi
- echo -e $textReset
- fi
- # OPKG Update:
- if [ $isThereInternet = true ]; then
- opkg update
- echo
- echo -e $textReset
- # Install SSLStrip:
- if [ $installSSLStrip = true ]; then
- # This will take a couple minutes to complete
- echo 'Installing SSLStrip, This will take a moment to complete...'
- opkg --dest usb install sslstrip
- touch /usb/usr/lib/python2.7/site-packages/zope/__init__.py
- echo
- echo
- echo -e $textReset
- fi
- # Install TCPDump:
- if [ $installTCPDump = true ]; then
- echo 'Installing TCPDump'
- opkg --dest usb install tcpdump
- echo
- echo
- echo -e $textReset
- fi
- # Install NMap:
- if [ $installNMap = true ]; then
- echo 'Installing NMap'
- opkg --dest usb install nmap
- echo
- echo
- echo -e $textReset
- fi
- # Install Reaver:
- if [ $installReaver = true ]; then
- echo 'Installing Reaver'
- opkg --dest usb install reaver
- echo
- echo
- echo -e $textReset
- fi
- # Install MDK3:
- if [ $installMDK3 = true ]; then
- echo 'Installing MDK3'
- opkg --dest usb install mdk3
- echo
- echo
- echo -e $textReset
- fi
- # Needed extras for packages installed to /usb/
- if [ -d /usb/etc/ ]; then
- echo 'Sym linking /usb/etc/* with /etc/'
- ls /usb/etc/
- ln -s /usb/etc/* /etc/
- echo
- fi
- if [ -d /usb/usr/sbin/ ]; then
- echo 'Sym linking /usb/usr/sbin/* with /usr/sbin/'
- ls /usb/usr/sbin/
- ln -s /usb/usr/sbin/* /usr/sbin/
- echo
- fi
- if [ -d /usb/usr/share/ ]; then
- echo 'Sym linking /usb/usr/share/* with /usr/share/'
- ls /usb/usr/share/
- ln -s /usb/usr/share/* /usr/share/
- echo
- fi
- if [ -d /usb/usr/lib/ ]; then
- echo 'Sym linking /usb/usr/lib/*.* with /usr/lib/'
- ls /usb/usr/lib/
- ln -s /usb/usr/lib/*.* /usr/lib/
- echo
- fi
- if [ -d /usb/usr/include/ ]; then
- if [ ! -d /usr/include/ ]; then
- echo 'Making directory /usr/include'
- mkdir /usr/include
- fi
- echo 'Sym linking /usb/usr/include/* with /usr/include/'
- ls /usb/usr/include/
- ln -s /usb/usr/include/* /usr/include/
- fi
- echo
- echo
- fi # End of Internet Functions
- fi
- fi
- #####
- ####
- ###
- ##
- # End of USB Functions
- # Change root password:
- if [ $changeRootPassword = true ]; then
- echo -n -e "Change root password to:"$yellow$newrootpassword$cyan" (y)/n? "$textReset
- read newPasswordYesNo
- if [[ "$newPasswordYesNo" == '' ]]; then
- newPasswordYesNo='y'
- fi
- if [ $newPasswordYesNo == 'y' ]; then
- echo -e $newrootpassword'\n'$newrootpassword | passwd
- echo -e 'New password for root: '$yellow$newrootpassword
- echo -e $textReset'Warning if root password is lost serial connection is required!!!'
- fi
- echo
- echo -e $textReset
- fi
- # Restart Pineapple UI Port:
- if [ $changePineapplePort = true ]; then
- echo -e $textReset'Rebooting uhttpd server...'
- /etc/init.d/uhttpd restart
- echo -e $textReset
- fi
- echo
- echo
- echo -e $cyan'Issue reboot to finish'$textReset
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement