phenotypic / WiFiCrackPy

Automated Wi-Fi cracker for macOS
MIT License
150 stars 17 forks source link

CoreWLAN returning None for SSID/BSSID with PyObjC #19

Open angiangvnc opened 7 months ago

angiangvnc commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago
Screenshot 2024-04-02 at 08 54 58

Plz help me not run code error bug

phenotypic commented 7 months ago

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 commented 7 months ago

Code run not BSSID, continues run code

phenotypic commented 7 months ago

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 commented 7 months ago

@phenotypic I have the same issue because BSSID is NONE

phenotypic commented 7 months ago

@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 commented 7 months ago

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

angiangvnc commented 7 months ago
Screenshot 2024-04-03 at 21 15 20
AsTonyshment commented 7 months ago

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 commented 7 months ago

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!

koolaidxk1d commented 7 months ago

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 commented 5 months ago

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 commented 5 months ago

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

1mehdifaraji commented 3 months ago

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

lex554 commented 1 month ago

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 commented 2 weeks ago

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?