Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Working proof of concept for Windows support from issue #2 #3

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions wireless/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import sys

import Wireless


def get_win_profiles():
output = Wireless.cmd("netsh wlan show profiles")
# Example Vista output for "netsh wlan show profiles"
"""

Profiles on interface Wireless Network Connection:

Group Policy Profiles (read only)
---------------------------------
<None>

User Profiles
-------------
All User Profile : cashvault
All User Profile : IBM-guest
All User Profile : Guakamole

"""
names = []
for line in output.splitlines():
if "All User Profile" in line:
names.append(line.split(":")[-1].strip())
return names


def get_win_profile_ssid(profile):
output = Wireless.cmd("netsh wlan show profile \"%s\"" % profile)
# Example Vista output for "netsh wlan show profile <name>"
"""
...
Connectivity settings
---------------------
Number of SSIDs : 1
SSID name : "cashvault"
Network type : Infrastructure
Radio type : [ Any Radio Type ]
Vendor extension : Not present
...
"""
for line in output.splitlines():
if "SSID name" in line:
return line.split(":")[-1].strip(' "')


def win_connect(ssid):
print("[*] Get WiFi profiles")
profiles = get_win_profiles()
print("[*] Scanning profiles for given SSID")
for prof in profiles:
if get_win_profile_ssid(prof) == ssid:
print(Wireless.cmd("netsh wlan connect name=\"%s\"" % prof))
return


if sys.argv[1:]:
win_connect(sys.argv[1])