Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #!/bin/bash
  2. #define variables
  3.  
  4. echo "$(tput setaf 3)  _       ___ _______    ____  _                              __   "
  5. echo " | |     / (_) ____(_)  / __ \\(_)___  ___  ____ _____  ____  / /__ "
  6. echo " | | /| / / / /_  / /  / /_/ / / __ \/ _ \/ __ '/ __ \/ __ \/ / _ \\"
  7. echo " | |/ |/ / / __/ / /  / ____/ / / / /  __/ /_/ / /_/ / /_/ / /  __/"
  8. echo " |__/|__/_/_/   /_/  /_/   /_/_/ /_/\___/\__,_/ .___/ .___/_/\___/ "
  9. echo " $(tput sgr0) OWN the Network                            $(tput setaf 3)/_/   /_/$(tput sgr0)       v2.2"
  10. echo ""
  11.  
  12. echo -n "Pineapple Netmask [255.255.255.0]: "
  13. read pineapplenetmask
  14. if [[ $pineapplenetmask == '' ]]; then
  15. pineapplenetmask=255.255.255.0 #Default netmask for /24 network
  16. fi
  17.  
  18. echo -n "Pineapple Network [172.16.42.0/24]: "
  19. read pineapplenet
  20. if [[ $pineapplenet == '' ]]; then
  21. pineapplenet=172.16.42.0/24 # Pineapple network. Default is 172.16.42.0/24
  22. fi
  23.  
  24. echo -n "Interface between PC and Pineapple [eth0]: "
  25. read pineapplelan
  26. if [[ $pineapplelan == '' ]]; then
  27. pineapplelan=eth0 # Interface of ethernet cable directly connected to Pineapple
  28. fi
  29.  
  30. echo -n "Interface between PC and Internet [wlan0]: "
  31. read pineapplewan
  32. if [[ $pineapplewan == '' ]]; then
  33. pineapplewan=wlan0 #i.e. wlan0 for wifi, ppp0 for 3g modem/dialup, eth0 for lan
  34. fi
  35.  
  36. temppineapplegw=`netstat -nr | awk 'BEGIN {while ($3!="0.0.0.0") getline; print $2}'` #Usually correct by default
  37. echo -n "Internet Gateway [$temppineapplegw]: "
  38. read pineapplegw
  39. if [[ $pineapplegw == '' ]]; then
  40. pineapplegw=`netstat -nr | awk 'BEGIN {while ($3!="0.0.0.0") getline; print $2}'` #Usually correct by default
  41. fi
  42.  
  43. echo -n "IP Address of Host PC [172.16.42.42]: "
  44. read pineapplehostip
  45. if [[ $pineapplehostip == '' ]]; then
  46. pineapplehostip=172.16.42.42 #IP Address of host computer
  47. fi
  48.  
  49. echo -n "IP Address of Pineapple [172.16.42.1]: "
  50. read pineappleip
  51. if [[ $pineappleip == '' ]]; then
  52. pineappleip=172.16.42.1 #Thanks Douglas Adams
  53. fi
  54.  
  55. #Display settings
  56. #echo Pineapple connected to: $pineapplelan
  57. #echo Internet connection from: $pineapplewan
  58. #echo Internet connection gateway: $pineapplegw
  59. #echo Host Computer IP: $pineapplehostip
  60. #echo Pineapple IP: $pineappleip
  61. #echo Network: $pineapplenet
  62. #echo Netmask: $pineapplenetmask
  63.  
  64. echo ""
  65. echo "$(tput setaf 6)     _ .   $(tput sgr0)        $(tput setaf 7)___$(tput sgr0)          $(tput setaf 3)\||/$(tput sgr0)   Internet: $pineapplegw - $pineapplewan"
  66. echo "$(tput setaf 6)   (  _ )_ $(tput sgr0) $(tput setaf 2)<-->$(tput sgr0)  $(tput setaf 7)[___]$(tput sgr0)  $(tput setaf 2)<-->$(tput sgr0)  $(tput setaf 3),<><>,$(tput sgr0)  Computer: $pineapplehostip"
  67. echo "$(tput setaf 6) (_  _(_ ,)$(tput sgr0)       $(tput setaf 7)\___\\$(tput sgr0)        $(tput setaf 3)'<><>'$(tput sgr0) Pineapple: $pineapplenet - $pineapplelan"
  68.  
  69.  
  70. #Bring up Ethernet Interface directly connected to Pineapple
  71. ifconfig $pineapplelan $pineapplehostip netmask $pineapplenetmask up
  72.  
  73. # Enable IP Forwarding
  74. echo '1' > /proc/sys/net/ipv4/ip_forward
  75. #echo -n "IP Forwarding enabled. /proc/sys/net/ipv4/ip_forward set to "
  76. #cat /proc/sys/net/ipv4/ip_forward
  77.  
  78. #clear chains and rules
  79. iptables -X
  80. iptables -F
  81. #echo iptables chains and rules cleared
  82.  
  83. #setup IP forwarding
  84. iptables -A FORWARD -i $pineapplewan -o $pineapplelan -s $pineapplenet -m state --state NEW -j ACCEPT
  85. iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
  86. iptables -A POSTROUTING -t nat -j MASQUERADE
  87. #echo IP Forwarding Enabled
  88.  
  89. #remove default route
  90. route del default
  91. #echo Default route removed
  92.  
  93. #add default gateway
  94. route add default gw $pineapplegw $pineapplewan
  95. #echo Pineapple Default Gateway Configured
  96.  
  97. #instructions
  98. #echo All set. Now on the Pineapple issue: route add default gw $pineapplehostip br-lan
  99.  
  100. #ping -c1 $pineappleip
  101. #if [ $? -eq 0 ]; then
  102. #echo "ICS configuration successful."
  103. #echo "Issuing on Pineapple: route add default gw $pineapplehostip br-lan"
  104. #echo "  ssh root@$pineappleip 'route add default gw '$pineapplehostip' br-lan'"
  105. #echo "Enter Pineapple password if prompted"
  106. #ssh root@$pineappleip 'route add default gw '$pineapplehostip' br-lan'
  107. #fi
  108.  
  109. echo ""
  110. echo "Browse to http://$pineappleip:1471"
  111. echo ""