opexxx

fakeAP3.py

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