I would like to know if anyone has any idea of how to access live wi-fi raw data from my computer (in monitor and promicuous mode). I would like to develop a code to get the MAC address of every device around me, including cellphones that are not connected to any network (I know every smartphone sends wi-fi signal when they're on). Since I've discovered that the latest versions of MacBooks can use the wi-fi board in monitor and promicuous mode, I'm trying to access it's raw data. I don't even know if it's possible with Mathematica (but if it is, it would be perfect to handle the data the way I want).

If you know whether and how it could be done, please help me. If it can't be done in Mathematica, could you indicate a programming language that allows to access this kind of data?

I'm asking this here because i've done some tests in Wireshark and was able to get the MAC address of my own iPhone when I turned the wi-fi on. The problem is that I can only capture a lot of data and analyse it AFTERWARDS. I would like to analyse the wi-fi data as soon as it's been captured.

I've searched about it on internet and even how to do that with arduino, but without any luck.

Thanks for your help in advance!


Thanks to rm -rf I'm able to get information from my wifi and display in Mathematica. The next step is sniff all wifi devices (more precisely smartphones) that are on. The important part is that they must not be necessarily connected to any network!

I found the command "airport sniff [channel]" that can be used from Terminal. It creates a temporary .cap file in the /tmp folder, but i'm not able to read it. I'm not quite sure if it's the right path.

I would be glad if someone could help me a little bit further here =]

  • 1
    $\begingroup$ Cool first question! Welcome to SE! $\endgroup$
    – Murta
    Jun 7 '14 at 17:48
  • 3
    $\begingroup$ I think you got very lucky that somebody here knew how to retrieve network information, since it wasn't really a Mathematica solution but more like an OS X solution. Your follow-up is probably better suited on a site about networks. $\endgroup$
    – C. E.
    Jun 7 '14 at 20:30
  • $\begingroup$ I too see this as a borderline off-topic question and am considering joining the close votes. If we allow this, any question that could be answered using a program that outputs to stdout, with no relation to Mathematica whatsoever, would be on-topic. The question is interesting, though. $\endgroup$ Jun 8 '14 at 9:35
  • $\begingroup$ This question appears to be off-topic because it is mostly unrelated to Mathematica. $\endgroup$ Jun 8 '14 at 9:37

The airport utility on your mac (which is not very widely known) gives you programmatic access to all your wireless information. I wrote a fun answer on Ask Different using this command line utility.

To get the information about wireless devices around you, use the -s flag. Here's a simple function to automate it:

getSSID[] := With[{data = Import["!/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s", "Table"]},
  TableForm[Rest@data, TableHeadings -> {Range@Length@Rest@data, First@data}]


enter image description here

You might need to cleanup the data a bit when there are networks with spaces in their names (you get an entry for each word, so the BSSID is not necessarily the second column).

  • 1
    $\begingroup$ That's a veeeery nice first step! After that I found this link (osxdaily.com/2007/01/18/…) to use the Airport command more easily (So I had to update the path in your code too!). The last site that I visited just showed me the command "airport sniff CHANNEL". I think I have all the pieces now to do my project! Thank you very much! $\endgroup$
    – DMurta
    Jun 7 '14 at 17:10
  • $\begingroup$ are you not sure that there's nothing missing here? I don't know exacly why, but it doesn't work =( $\endgroup$
    – DMurta
    Jun 7 '14 at 19:26
  • $\begingroup$ Until now I was able to see that the "airport sniff [channel]" command creates a .cap file in the /tmp folder, but i'm unable to read it $\endgroup$
    – DMurta
    Jun 7 '14 at 19:45
  • $\begingroup$ This will solve the space issue: lines = Import[ "!/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s", "Lines"]; headings = StringSplit@First@lines; data = Rest@lines; splitLine[str_] := StringCases[str, a___ ~~ b : RegularExpression[ "[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}"] ~~ c___ :> Sequence @@ ({StringTrim@a, b}~Join~StringSplit@c)] TableForm[splitLine /@ data, TableHeadings -> {Range@Length@data, headings}] $\endgroup$
    – C. E.
    Jun 7 '14 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.