3

Imagine, you have Windows 7, file "passwords.txt", which contains 2000 passwords for Wifi "MyHomeWifi", but only one of them is correct. And you have python. And, of course, the question is how to connect to this wifi. I only know, that to connect to wifi you can use in command line:

netsh wlan connect _Wifi_name_

Flexo
  • 87,323
  • 22
  • 191
  • 272
PepeHands
  • 1,368
  • 5
  • 20
  • 36

1 Answers1

9
from subprocess import check_output
output = check_output('netsh wlan connect _Wifi_name_', shell=True)

print output

The rest is up to you. Consider merging in the following (you gotta do some work yourself man..):

with open('mypasswords.txt') as fh:
    for line in fh:
        ...

Pragmatically "writing" passwords as input via python instead of passing it as a parameter:

from subprocess import Popen, STDOUT, PIPE
from time import sleep

handle = Popen('netsh wlan connect _Wifi_name_', shell=True, stdout=PIPE, stderr=STDOUT, stdin=PIPE)

sleep(5) # wait for the password prompt to occur (if there is one, i'm on Linux and sudo will always ask me for a password so i'm just assuming windows isn't retarded).
handle.stdint.write('mySecretP@ssW0rd\n')
while handle.poll() == None:
    print handle.stdout.readline().strip()

A more controlled version of it.

Torxed
  • 22,866
  • 14
  • 82
  • 131