Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iface.scan() not detecting cipher types #62

Open
hersh-nv opened this issue Apr 2, 2020 · 2 comments
Open

iface.scan() not detecting cipher types #62

hersh-nv opened this issue Apr 2, 2020 · 2 comments

Comments

@hersh-nv
Copy link

hersh-nv commented Apr 2, 2020

when using iface.scan() to scan for available networks, the cipher field in the returned network profiles is always 0, corresponding with const.CIPHER_TYPE_NONE. this is incorrect, as in my case all available networks actually used cipher type CCMP.

>>> import pywifi
>>> iface = pywifi.PyWiFi().interfaces()[0]
>>> iface.scan()
>>> time.sleep(10)
>>> profiles = iface.scan_results()
>>> [profile.cipher for profile in profiles]
[0, 0, 0, 0, 0, 0, 0]

this means that when adding a key to a profile prior to connecting to it, i also needed to amend the cipher field. e.g. if i wanted to connect to profiles[0] above, i would have to:

>>> from pywifi import const
>>> profiles[0].cipher = const.CIPHER_TYPE_CCMP
>>> profiles[0].key = "networkpasswordhere"
>>> profile = iface.add_network_profile(profiles[0])
>>> iface.connect(profile)

without setting the cipher type, the profile would not add to the interface. (i believe this may be the cause of issue #45.)

the issue here is that the scan should be able to return the cipher type of each profile; the user shouldn't have to manually determine the cipher type through other means and enter it into the profile. for instance in windows 10, using the netsh command to scan for available networks returns the cipher type under the attribute 'Encryption'.

>netsh wlan show networks interface="Wi-Fi"

Interface name : Wi-Fi
There are 5 networks currently available

SSID 1 : ExampleSSID
    Network type             : Infrastructure
    Authentication           : WPA2-Personal
    Encryption               : CCMP

...

issue found in Windows 10 and Linux (Ubuntu 19.10), and occurs regardless of whether interface is connected to an AP or in disconnected status when using iface.scan().

@abrararies
Copy link

Facing same issue

@Lgum
Copy link

Lgum commented Jan 11, 2021

The issue seems to be a mixup in the returned values in '_wifiutil_win.py'. The returned 'akm' value is actually the Ciphertype and the 'auth_alg'-value includes the authentification algorithm and the key management. ( see: https://docs.microsoft.com/en-us/windows/win32/nativewifi/dot11-auth-algorithm and https://docs.microsoft.com/en-us/windows/win32/nativewifi/dot11-cipher-algorithm ).

In my case, the returned values are correct (auth-algorithm = 7 => DOT11_AUTH_ALGO_RSNA_PSK and akm = 4 =>DOT11_CIPHER_ALGO_CCMP) but the assignment is wrong.

A quick fix is to just take the akm-value returned from pywifi and use an enum to determine the cipher type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants