Pywifi Unable to Pull Authentication Method

The company I work for has an old wifi-scanner application written in VBScript that utilizes a lot of deprecated features that will cause it to stop functioning when we roll out Windows 11 Professional. For this reason, I am rewriting the application in Python. The intention is that once it is functional, I would convert it to an executable using the PyInstaller module.

What I am trying to do is to pull BSSID, SSID, Signal Strength, Authentication Type, Encryption Type, & Location (by user input) and output it into a CSV file. It would be nice to also have Radio Type and Channel, but the pywifi module does not support that. That is not the nature of my problem, however.

My problem lies in the fact that I am unable to pull Authentication Type from pywifi. This was detailed here that shows that the akm module (which documentation says is Authentication Type) actually maps to Encryption Type. It also shows that in order to get Authentication Type, it has to be mapped to windows default get_auth_alg(networks[i].dot11DefaultAuthAlgorithm) function. However, whenever I try to do that through the _wifiutil_win.py, WifiUtil class, I am getting “<function WifiUtil._get.auth_alg at ” as the output. See my code below:

 Import Third-Party Modules Necessary
import comtypes
import csv
import io
import os
import pymsgbox
import pywifi
from pywifi import _wifiutil_win
import re
import time

# Prompts for location from user
choice = pymsgbox.prompt('Please enter the location that is being scanned: n N: Northern Atrium n NE: Northeastern Atrium n E: Eastern Atrium n SE: Southeastern Atrium n S: Southern Atrium n SW: Southwestern Atrium'
               'n W: Western Atrium n NW: Northwestern Atrium n K: Kitchen n I: IT Area n V: Vacations Area n T: Travelstore Area n D: Denise Office n M: Meetings Area n R: Reception', 'Balboa Travel WiFi Scan')

# Populates location field based on user input
match choice:
    case 'N':
        location = "Northern Atrium"
    case 'NE':
        location = "Northeastern Atrium"
    case 'E':
        location = "Eastern Atrium"
    case 'SE':
        location = "Southeastern Atrium"
    case 'S':
        location = "Southern Atrium"
    case 'SW':
        location = "Southwestern Atrium"
    case 'W':
        location = "Western Atrium"
    case 'NW':
        location = "Northwestern Atrium"
    case 'K':
        location = "Kitchen"
    case 'I':
        location = "IT Area"
    case 'V':
        location = "Vacations"
    case 'T':
        location = "Travelstore Area"
    case 'D':
        location = "Denise's Office"
    case 'M':
        location = "Meetings Area"
    case 'R':
        location = "Reception"
                
# Execute Wi-Fi Scan
wifi = pywifi.PyWiFi()
iface = wifi.interfaces()[0]
iface.scan()

timer = 30
while timer > 0:
    pymsgbox.alert('Time Remaining: ' + str(timer) + ' seconds', 'Scan in Progress', timeout=1000)
    timer -= 1

results = iface.scan_results()

# Creates the csv file and populates field names in the first row
FilePath = 'C:/Dell/Wifi-Scan.csv'

file_exists = os.path.isfile(FilePath)
       
with io.open(FilePath, 'a', encoding='utf-8', newline='') as file:
    fieldnames = ['BSSID', 'SSID', 'Signal', 'Authentication Type', 'Encryption', 'Location']
    writer = csv.writer(file)

    # If File already exists, do not write headers.
    if not file_exists:
        writer.writerow(fieldnames)

    #Creates the link between fieldnames and variables
    for network in results:
        bssid = network.bssid[:-1]

        ssid = network.ssid
        if len(ssid) == 0:
            ssid = "No SSID"  # Converts blank value to No SSID

        auth = _wifiutil_win.WifiUtil._get_auth_alg
        cipher = network.akm

        # Converts RSSI to Signal Strength
        strength = int(((network.signal - (-90)) * (100 - 0) / ((-21) - (-90))))

        # Case for matching Authentication Type
        match auth:
            case [0]:
                auth = 'None'
            case [1]:
                auth = 'Open'
            case [2]:
                auth = 'Shared Key'
            case [3]:
                auth = 'WPA'
            case [4]:
                auth = 'WPA-PSK'
            case [5]:
                auth = 'WPA None'
            case [6]:
                auth = 'WPA2'
            case [7]:
                auth = 'WPA2-PSK'
            case [8]:
                auth = 'WPA3'
            case [9]:
                auth = 'WPA3 Enterprise'
            case [10]:
                auth = 'WPA3 SAE'
            case [11]:
                auth = 'WPA3 Enterprise'

        #Case for matching Cipher Type
        match cipher:
            case [0]:
                cipher = 'None'
            case [1]:
                cipher = 'WEP'
            case [2]:
                cipher = 'TKIP'
            case [4]:
                cipher = 'CCMP'
            case [5]:
                cipher = 'WEP'
            case [100]:
                cipher = 'WPA'
            case [101]:
                cipher = 'WEP'

        # Writes the scan results into the fields
        row = [bssid, ssid, strength, auth, cipher, location]
        writer.writerow(row)

pymsgbox.alert('Scan Completed.  File saved to ' + str(FilePath), 'Scan Completed')

Documentation for Pywifi _wifiutil_win.py can be found here

I’ve also tried writing the program using the subprocess.check_output using netsh wlan show networks mode=Bssid, but I am having difficulty enumerating the specific information that I want to extract and input into a csv. Thus why I’m trying to dig into this pywifi issue to fix execution this way.

I’ve tried executing the WifiUtils class directly from pywifi’s _wifiutil_win.py capabilities which only returned “<function WifiUtil._get.auth_alg at ” as output.

I’ve tried calling the network.auth_alg directly in my code and I get an error that there is no auth_alg attribute for the network object.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật