How can i turn on wifi connection using python?
If you want to set up a Hotspot, you need to enable monitor mode of the WiFi driver.
If you're on linux you can do,
ifconfig
and iwconfig
to find the name of WiFi driver/device
and then use one of the air suite package to turn on the monitor mode on that particular driver
airmon-ng start <driver name>
All these commands can be run using the python subprocess module, which allows you to interact with the linux/windows command line to process output and work out accordingly
import subprocess
p = subprocess.Popen(["echo", "hello world"], stdout=subprocess.PIPE)
print(p.communicate())
>>>('hello world', None)
Connection to wi-fi using python
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.
Related Topics
How to Detect Whether a Python Variable Is a Function
How to Get List of Methods in a Python Class
Is Python Interpreted, or Compiled, or Both
Parse a .Py File, Read the Ast, Modify It, Then Write Back the Modified Source Code
Simple Way to Encode a String According to a Password
Why Is Plotting with Matplotlib So Slow
How to Open a File for Both Reading and Writing
How to Create a Namespace Package in Python
How to Access the Query String in Flask Routes
Threading in a Pyqt Application: Use Qt Threads or Python Threads
How to Convert a Pandas Series or Index to a Numpy Array
How to Validate a Url with a Regular Expression in Python
Too Many Values to Unpack', Iterating Over a Dict. Key=>String, Value=>List
How to Reliably Open a File in the Same Directory as the Currently Running Script