braineo / airport-bssid

command line tool to connect to specific bssid for macOS
GNU General Public License v3.0
59 stars 9 forks source link

All the returned BSSIDs are null #1

Open sushihangover opened 5 years ago

sushihangover commented 5 years ago

All the returned BSSIDs are null, thus it can not connect to one when supplied (via airport scan)

./.build/x86_64-apple-macosx/debug/bssid scan

ssid: AndroidRepeater, bssid: , channel: 2, dBm -24
ssid: XFINITY, bssid: , channel: 149, dBm -86
ssid: xfinitywifi, bssid: , channel: 149, dBm -86
ssid: iPhone, bssid: , channel: 11, dBm -87
ssid: CableWiFi, bssid: , channel: 149, dBm -87
braineo commented 5 years ago

Are you using 10.15 beta?

I found a post about CoreWLAN that in 10.15 the BSSID returns nil somehow.

https://forums.developer.apple.com/thread/119490

braineo commented 4 years ago

@sushihangover I updated the README about this. I did some research on this, seemed from 10.15 apple becomes more strict on privacy so BSSID become not something you can ask for free :(

bmansvk commented 4 years ago

I am little bit confused if there is workaround for this. I am running Catalina, successfully build project and signed locally as stated in the README: codesign --force --sign - --entitlements bssid.entitlements --timestamp=none ./.build/x86_64-apple-macosx/debug/bssid

it doesn't work. All channels shows empty BSSID.

Is there some workaround for this? It is not clear for me from these comments above.

braineo commented 4 years ago

@bmansvk As mentioned in README, even signing the app does not work.

A work around for 10.15 is scan and connect via channel number

bssid connect --ssid <ssid> --channel <channelNumber>
bmansvk commented 4 years ago

Yes I tried this.

  1. Scanned for channel number

    No SSID specified, scanning all
    ssid: Anicka, bssid: , channel: 10, dBm 0
    ssid: sedros.sx, bssid: , channel: 11, dBm -56
    ssid: public.sedros.sx, bssid: , channel: 11, dBm -58
    ssid: sedros.sx, bssid: , channel: 1, dBm -67
    ssid: sedros.sx, bssid: , channel: 44, dBm -70
    ssid: public.sedros.sx, bssid: , channel: 1, dBm -70
    ssid: public.sedros.sx, bssid: , channel: 44, dBm -71
  2. And tried to connect (also tried to remove saved SSID from network settings before connect):

    % ./.build/x86_64-apple-macosx/debug/bssid connect --ssid public.sedros.sx --channel 44
    Input WiFi password

Mac successfully connects to specified SSID but not channel 44, only 11 (which connect there by default, chan 11 has better signal than 44). There are same SSIDs on channel 44 with different BSSIDs (multiple APs on channel 44 with same SSID)

It seems that still doesn't work for me. I thought this is because missing BSSID in "scan command".

@bmansvk As mentioned in README, even signing the app does not work.

A work around for 10.15 is scan and connect via channel number

bssid connect --ssid <ssid> --channel <channelNumber>
braineo commented 4 years ago

@bmansvk

Thanks for reporting. I sometimes can reproduce the problem but not every time. Looks like macOS has some other logic to select Wifi even for specified network (ssid and channel in this case). I'll need some further investigation.

nagualcode commented 4 years ago

Same here on 10.15.5

mtrpires commented 4 years ago

it's be a dirty hack, but you could use airport -s and scrape bssids from there in 10.15:

Screen Shot 2020-09-10 at 20 16 44
braineo commented 3 years ago

Hi guys, thanks for the comment,

@bmansvk

after I tested this API in some of my friends' places, office... I can only say the behavior is unpredictable.

try interface.associate(to: network, password: password)

When loop to this line, the network for sure is the correct one, but sometime the OS decides to connect to one with strongest signal

Aklaran commented 3 years ago

Is the app sandboxed? I got my networks to return their bssids by enabling the Outgoing Connections (Client) capability in the App Sandbox section.

braineo commented 3 years ago

@Aklaran Is it a different app or this one? I tried to test it and it returns illegal instruction after enabling sandbox

Aklaran commented 3 years ago

@braineo This is just in a minimal test app that I spun up, I haven't tried it in this one

braineo commented 3 years ago

@Aklaran Thanks! Seems command line application is not treated equally with an App, I would need to have a pseudo to hold this command line.

Rukongai commented 3 years ago

@braineo

As a python script kiddie I don't know much of anything - but would this help with pulling BSID on 10.15+ ?

It's saying to enable CoreLocations prior to checking networks

https://developer.apple.com/forums/thread/131636

braineo commented 3 years ago

@braineo

As a python script kiddie I don't know much of anything - but would this help with pulling BSID on 10.15+ ?

It's saying to enable CoreLocations prior to checking networks

https://developer.apple.com/forums/thread/131636

I've tried this one in another branch, although I made it asking you permissions for location, it still does not work.

The explanation of inheriting sand box from parent Application seems promising, going to try it later

vkedwardli commented 3 years ago
try interface.associate(to: network, password: password)

When loop to this line, the network for sure is the correct one, but sometime the OS decides to connect to one with strongest signal

I'm having the exact problem

thewade commented 1 year ago

This might be fixed in MacOS 13. In Python I am able to get the BSSID using CoreWLAN after granting location services permissions to Python itself. This same approach was not working for Python in earlier version of MacOS.

See this thread for more details: https://github.com/ronaldoussoren/pyobjc/issues/484

Been playing with the Swift code, but I am having trouble getting generate the request for permissions.

edrozenberg commented 8 months ago

Same here, scan shows all blank info (even scanning with sudo), and connecting via ssid + channel always shows Cannot find specified access point. Unfortunately this utility and other methods like Apple's airport utility all fail to let the user do the most basic Fn thing, to be able to connect to a specific BSSID, something which is important in many scenarios such as having to use networks set up by complete morons with multiple AP's with identical names serving different blocks of unbridged IP's. It's Apple's fault, they assume we're all morons who don't need to do things we clearly need to do, because they know better. I'm going to need to start traveling with a Linux machine in addition to or instead of the Mac laptop so I can actually do things without Apple telling me I'm an idiot for needing to do it.