schollz / find3-cli-scanner

The command-line scanner that supports Bluetooth and WiFi
https://www.internalpositioning.com/doc/tracking_your_computer.md
149 stars 55 forks source link

Cannot run passive mode on OSX #31

Open pliablepixels opened 5 years ago

pliablepixels commented 5 years ago

OSX Version: Mojave 10.14.2 find-3-scanner version: (probably a bug)

usr/local/bin/find3-cli-scanner -v
find3-cli-scanner version

Hi, thank you for this library.

It looks like find3-cli-scanner needs iwconfig that is not present on OSX computers. Is there a work around? The install section describes how to install it on OSX, so I am assuming I can run it natively as well, without a docker image. The only other issue I found related to OSX is a closed issue that is actually running a docker linux image, so my apologies if I missed any other reference.

It doesn't look like iwconfig is available in brew either.

sudo /usr/local/bin/find3-cli-scanner -i en0 -device mycomputer -family myfamily -server https://cloud.internalpositioning.com -scantime 40 -forever -passive
Password:
2019-01-25 08:50:45 [INFO] main.go func1:209 scanning with en0 
2019-01-25 08:50:45 [INFO] main.go func1:218 scanning for 40 seconds 
2019-01-25 08:50:45 [INFO] main.go func1:222 working in passive mode 
2019-01-25 08:50:46 [ERROR] utils.go RunCommand:27 exec: "iwconfig": executable file not found in $PATH 

It seems iwconfig is only needed to switch the card to monitor mode (find3-cli-scanner invokes iwconfig en0 mode monitor), but I haven't found out how to switch the card to monitor mode and keep it that way and exit. Tools like airport and tcpdump (ref) only seem to switch on monitor mode for the duration of their own scans. I also tried running wireless diagnostics sniff (ref) whilst trying to run this cli program.

So is there a command equivalent I can use on OSX? In that case, I can just write a wrapper iwconfig script)

jekkos commented 5 years ago

You could try to use my python script for the scanning, it just expects to find an interface in monitor mode, so that part should be managed by the system itself

https://github.com/jekkos/find3-openwrt-scanner

schollz commented 5 years ago

@pliablepixels

You don't need to use the find3-cli-scanner to switch the card. You can do it manually first and then run using the flag --no-modify which will prevent the code from trying to use iwconfig.

Unfortunately I'm not an OS X person so I don't know how to make the switch manually.

pliablepixels commented 5 years ago

@schollz thanks. In that case, I'm not sure what I am doing wrong:

  1. Terminal 1, I have tcpdump -Ini en0 running. This puts my card into monitor mode.

  2. Terminal 2: Validate that I am actually in monitor mode:

    $ airport -I
     agrCtlRSSI: -36
     agrExtRSSI: 0
    agrCtlNoise: -98
    agrExtNoise: 0
          state: running
        op mode: station monitor <==== // THIS
     lastTxRate: 73
        maxRate: 72
    lastAssocStatus: 0
    802.11 auth: open
      link auth: wpa2-psk
          BSSID:xxxx
           SSID: xxx
            MCS: 7
        channel: 6

Terminal 1: tcpdump shows its detecting my phones in the vicinity (I grepped for mac)

Terminal 3: I ran:

sudo /usr/local/bin/find3-cli-scanner -i en0 -f test_family -d my_mac -server https://cloud.internalpositioning.com -scantime 40  -passive -no-modify 

Note that "my_mac" and "test_family" are actual names I am using.

This is the output:

2019-01-26 19:59:29 [INFO] main.go func1:209 scanning with en0 
2019-01-26 19:59:29 [INFO] main.go func1:218 scanning for 40 seconds 
2019-01-26 19:59:29 [INFO] main.go func1:222 working in passive mode 
2019-01-26 20:00:09 [INFO] reverse.go ReverseScan:134 collected 0 packets 
2019-01-26 20:00:09 [ERROR] main.go main:237 no packets found 

Should not the cli find the phones like tcpdump is?

schollz commented 5 years ago

@pliablepixels Can you run with the -debug flag and post output?

pliablepixels commented 5 years ago

Here goes:

sudo /usr/local/bin/find3-cli-scanner -i en0 -f test_family -d my_mac -server https://cloud.internalpositioning.com -scantime 40  -passive -no-modify -debug

2019-01-27 12:57:07 [INFO] main.go func1:209 scanning with en0 
2019-01-27 12:57:07 [INFO] main.go func1:218 scanning for 40 seconds 
2019-01-27 12:57:07 [INFO] main.go func1:222 working in passive mode 
2019-01-27 12:57:07 [DEBUG] reverse.go ReverseScan:28 reverse scanning for 40s 
2019-01-27 12:57:07 [DEBUG] reverse.go func1:39 waiting for 40s 
2019-01-27 12:57:47 [DEBUG] reverse.go func1:41 timed out 
2019-01-27 12:57:47 [DEBUG] reverse.go ReverseScan:102 got done signal 
2019-01-27 12:57:47 [DEBUG] reverse.go ReverseScan:104 <nil> 
2019-01-27 12:57:47 [INFO] reverse.go ReverseScan:134 collected 0 packets 
2019-01-27 12:57:47 [ERROR] main.go main:237 no packets found