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

CoreWLAN returning None for SSID/BSSID with PyObjC #19

Open
angiangvnc opened this issue Mar 31, 2024 · 18 comments
Open

CoreWLAN returning None for SSID/BSSID with PyObjC #19

angiangvnc opened this issue Mar 31, 2024 · 18 comments

Comments

@angiangvnc
Copy link

angiangvnc commented Mar 31, 2024

When the script scans for networks, the BSSID results show as None.

This means that when I select a network to crack, zizzania crashes with the error TypeError: expected str, bytes or os.PathLike object, not NoneType.

I am using macOS 14.4.1, please help.

@phenotypic
Copy link
Owner

Hi there, please can you confirm you receive the following messages when you run the script:

Obtaining authorisation for location services (required for WiFi scanning)...

Received authorisation, continuing...

The first time you run the script, Python will request Location Services authorisation which you must accept for the script to function properly.

You can see if the permission has been granted by going to System Settings > Privacy & Security > Location Services and checking next to Python.

@donCappo
Copy link

donCappo commented Apr 1, 2024

I'm not the original poster, but I got the same issue. I can confirm, that python has the Location services enabled.
I don't get name nor bssid in the output scan. I'm also at macos 14.4.1

+--------+------+-------+------+---------+---------------+
| Number | Name | BSSID | RSSI | Channel | Security |
+--------+------+-------+------+---------+---------------+
| 1 | None | None | -74 | 9 | Open |
| 2 | None | None | -47 | 6 | WPA2 Personal |
| 3 | None | None | -76 | 108 | WPA2 Personal |
| 4 | None | None | -94 | 108 | WPA2 Personal |
| 5 | None | None | -94 | 108 | WPA2 Personal |
| 6 | None | None | -93 | 108 | WPA2 Personal |
| 7 | None | None | -87 | 1 | WPA2 Personal |
+--------+------+-------+------+---------+---------------+

@angiangvnc
Copy link
Author

Screenshot 2024-04-02 at 08 54 58 Plz help me not run code error bug

@phenotypic
Copy link
Owner

In the latest version of the script, I manually load the frameworks using objc rather than importing CoreWLAN and CoreLocation directly.

This seems to have resolved the issue on the other MacBook I have used for testing. @donCappo and @angiangvnc please confirm this has resolved the issue for you too.

@angiangvnc
Copy link
Author

Code run not BSSID, continues run code

@phenotypic
Copy link
Owner

phenotypic commented Apr 3, 2024

Please confirm that this is with the latest version of the script? You will need to re-clone the repository.

As mentioned, this update fixes the issue on the MacBook I am using for testing.

@basma-b
Copy link

basma-b commented Apr 3, 2024

@phenotypic I have the same issue
because BSSID is NONE

@phenotypic
Copy link
Owner

@basma-b please can you confirm this issue is with the latest version of the script (that was release a couple of hours ago)?

If so, please list your macOS and Python versions.

@angiangvnc
Copy link
Author

Yes, i run last version update today, but error BSSID none

@angiangvnc
Copy link
Author

Screenshot 2024-04-03 at 21 15 20

@AsTonyshment
Copy link

I encountered the same issue with not being able to access SSID/BSSID information. Then I found a discussion related to this on the Apple Developer Forums: CoreWLAN returning null SSID with PyObjC on MacOS 14.4 with Location Services enabled. Here is a quote from the original post:

I tested with the Python 3.8.18, 3.9.18, 3.10.13, and 3.11.8 downloaded with Brew as well as Python 3.9.6 distributed by Apple with the command line developer tools.
I have noticed that even without the proper permissions Python 3.9 distributed by Apple can access the SSID. Enabling the permissions it can also access location and BSSID. This applies to MacOS 14.1, 14.2 and MacOS 14.4 and matches the behavior in MacOS 13.
As for the Python versions distributed by Brew, I am getting inconsistent results. Testing MacOS 14.1 and 14.2, I was able to access location with all Python versions, however I was never able to get SSID or BSSID. Testing MacOS 14.4 I was able to get SSID and BSSID with some versions after granting permissions but not others. In my testing 3.8 and 3.9 worked and 3.10 and 3.11 did not, but this might not be consistent as it was previously not working.
In MacOS 13.6 I was able to get location, SSID, and BSSID with Python 3.8, 3.9, 3.10, and 3.11 from Brew and Python 3.9 from Apple.

So it appears to be an issue caused by the Python version in conjunction with Apple's complex and often frustrating permission management system. After some troubleshooting, I downloaded and switched to Python 3.9.13 (installed at /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9) and that finally resolved the issue. It’s probably best to avoid using the Python installed via Homebrew for this purpose.

Hope my reply helps!

@phenotypic
Copy link
Owner

phenotypic commented Apr 4, 2024

Hi @AsTonyshment, thank you for the message. You are right, the issue does not seem to occur when using the system-native version of Python.

However, it's unclear whether the core problem stems from the Python version, PyObjC library, CoreWLAN framework, macOS version, or some combination of these factors.

This is a difficult issue to solve as it seems to be inconsistent. For example, I am using Python 3.12.2 installed via Homebrew and I do not experience the bug, so I am unable to troubleshoot directly. Other people highlight this inconsistency in the issue you linked. This may have something to do with recent CoreWLAN privilege changes.

As a note, a similar issue was opened in the PyObjC library in 2022, but was resolved by granting Python location services permissions. Of course, WiFiCrackPy requests these permissions so it is unclear why the problem persists.

Ideally, the script should function seamlessly with any Python version, irrespective of whether it's system-native or installed via Homebrew. Ideally, we should try to identify the core problem so that we can flag it with the PyObjC library or the CoreWLAN framework. Any help would be greatly appreciated!

@phenotypic phenotypic changed the title Error run CoreWLAN returning None for SSID/BSSID with PyObjC Apr 4, 2024
@koolaidxk1d
Copy link

Getting this issue on the latest script version.

OS: Ventura 13.3
Machine: MBP M2
Python Version: 3.9.6 (non-brew)

Obtaining authorisation for location services (required for WiFi scanning)...

Received authorisation, continuing...

Scanning for networks...

+--------+----------------------+-------+------+---------+--------------------+
| Number |         Name         | BSSID | RSSI | Channel |      Security      |
+--------+----------------------+-------+------+---------+--------------------+
|   1    |       *CENSORED*        |  None | -36  |   149   | WPA2/WPA3 Personal |
|   2    |       *CENSORED*       |  None | -88  |    6    |   WPA2 Personal    |
|   3    |      *CENSORED*      |  None | -77  |    6    |   WPA2 Personal    |
|   4    |   *CENSORED*    |  None | -85  |    44   |  WPA2 Enterprise   |
|   5    |   *CENSORED*   |  None | -91  |    1    |   WPA2 Personal    |
|   6    |  *CENSORED*   |  None | -83  |    36   |   WPA2 Personal    |
|   7    |  *CENSORED*  |  None | -73  |    1    |   WPA2 Personal    |
|   8    |  *CENSORED*  |  None | -85  |    44   |   WPA2 Personal    |
|   9    |      *CENSORED*       |  None | -76  |    1    |   WPA2 Personal    |
|   10   |   *CENSORED*   |  None | -83  |    6    |   WPA2 Personal    |
|   11   |        *CENSORED*         |  None | -73  |    4    |   WPA2 Personal    |
|   12   | *CENSORED* |  None | -91  |    11   |   WPA2 Personal    |
|   13   |        *CENSORED*         |  None | -80  |    6    |        WEP         |
|   14   |      *CENSORED*      |  None | -78  |    6    |        Open        |
|   15   |     *CENSORED*     |  None | -80  |    6    |   WPA2 Personal    |
+--------+----------------------+-------+------+---------+--------------------+

Select a network to crack: 3

Initiating zizzania to capture handshake...

Traceback (most recent call last):
  File "/Users/*CENSORED*/Downloads/wifi-cracking-macos/WiFiCrackPy/WiFiCrackPy.py", line 142, in <module>
    scan_networks()
  File "/Users/*CENSORED*/Downloads/wifi-cracking-macos/WiFiCrackPy/WiFiCrackPy.py", line 83, in scan_networks
    capture_network(networks[x]['bssid'], networks[x]['channel'])
  File "/Users/*CENSORED*/Downloads/wifi-cracking-macos/WiFiCrackPy/WiFiCrackPy.py", line 104, in capture_network
    subprocess.run(['sudo', zizzania_path, '-i', iface, '-b', bssid, '-w', 'capture.pcap', '-q'] + ['-n'] * args.d)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1754, in _execute_child
    self.pid = _posixsubprocess.fork_exec(
TypeError: expected str, bytes or os.PathLike object, not NoneType

@jeevanpillay
Copy link

jeevanpillay commented May 21, 2024

So it appears to be an issue caused by the Python version in conjunction with Apple's complex and often frustrating permission management system. After some troubleshooting, I downloaded and switched to Python 3.9.13 (installed at /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9) and that finally resolved the issue. It’s probably best to avoid using the Python installed via Homebrew for this purpose.

I managed to fix my issues based on this comment.

There are multiple ways that Python can be installed.

  1. MacOS Python default in /usr/bin/python3
  2. Homebrew install using brew install python3
  3. Download from python.org & installed in /Library/Frameworks/Python.framework/Versions/3.12/Resources/Python.app/Contents/MacOS/Python

Setups

  1. brew list and search for python3@<version>.
  2. then run brew uninstall python3@<version> & brew cleanup python3@<version>
  3. then download python arm64 from python.org and install. (note, don't forget the certificates, it's part of the .pkg, run after install)
  4. now, check that python3 is pointing to the latest downloaded version
  5. enable location services for python3 (note, there may be two versions of python3 in location services, enable both, afaik one is native macos python3 & the other is your downloaded)

this worked for me! hopefully it helps you too for now before we figure out a native solution for all brew/native/python.org versions.

note from @phenotypic

Ideally, the script should function seamlessly with any Python version, irrespective of whether it's system-native or installed via Homebrew. Ideally, we should try to identify the core problem so that we can flag it with the PyObjC library or the CoreWLAN framework. Any help would be greatly appreciated!

gotchas -> sorry brewed up python :(

@katomm
Copy link

katomm commented May 26, 2024

Cumbersome, but I can confirm this works. Thank you @jeevanpillay

@1mehdifaraji
Copy link

I did fix the issue of TypeError: expected str, bytes or os.PathLike object, not NoneType by installing python version 3.9.13.

@lex554
Copy link

lex554 commented Oct 3, 2024

I'm havin issues getting for way handshake with zizzania using Mac,anyone have any ideas on good tools that are compatible with Mac

@hungvminh
Copy link

hungvminh commented Oct 26, 2024

So it appears to be an issue caused by the Python version in conjunction with Apple's complex and often frustrating permission management system. After some troubleshooting, I downloaded and switched to Python 3.9.13 (installed at /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9) and that finally resolved the issue. It’s probably best to avoid using the Python installed via Homebrew for this purpose.

Hope my reply helps!

I've got the same problem, after updating to Somona 14.7 from Ventura (big mistake!). Do you test on it?

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