Am trying to get the MAC address of all the available wireless networks around.
Currently am using:
netsh wlan show networks mode=bssid | findstr BSSID
The output I get it (true MAC hidden for privacy):
BSSID 1 : 2c:ab:25:xx:xx:xx BSSID 1 : 00:22:2d:xx:xx:xx BSSID 1 : c4:3d:c7:xx:xx:xx BSSID 1 : 00:27:22:xx:xx:xx BSSID 1 : 84:c9:b2:xx:xx:xx BSSID 1 : 00:25:5e:xx:xx:xx BSSID 1 : 00:06:5a:xx:xx:xx BSSID 2 : 00:06:5a:xx:xx:xx BSSID 1 : 00:06:5a:xx:xx:xx BSSID 2 : 00:06:5a:xx:xx:xx BSSID 1 : 00:06:5a:xx:xx:xx BSSID 2 : 00:06:5a:xx:xx:xx BSSID 1 : 00:06:5a:xx:xx:xx BSSID 2 : 00:06:5a:xx:xx:xx BSSID 3 : 00:25:5e:xx:xx:xx BSSID 4 : 00:25:5e:xx:xx:xx BSSID 5 : 00:25:5e:xx:xx:xx BSSID 1 : 00:27:22:xx:xx:xx BSSID 1 : 00:27:22:xx:xx:xx BSSID 1 : fc:b0:c4:xx:xx:xx BSSID 1 : fc:b0:c4:xx:xx:xx
I need to implement a regex which can output only the MAC address (i.e. last 17 characters of each line)
Need to store the MAC addresses in an array in C++.
My current code is like this for getting the output:
#include <iostream>
#include <string>
#include <stdio.h> // for _popen() and _pclose()
using namespace std;
int main()
{
char buff[512];
buff[0]=0;
string cmd="netsh wlan show networks mode=bssid | findstr BSSID";
FILE *fpipe = _popen(cmd.c_str(),"rt");
if(fpipe==NULL)
cout<<"Failed to open"<<endl;
else
cout<<"Opened pipe successfully";
while(fgets(buff,sizeof(buff),fpipe)!=NULL){
cout<<buff<<endl;
}
_pclose(fpipe);
}
Can someone provide me a code snippet for implementing boost regex to get only the MAC addresses in an array? My intention is to pass these MAC addresses to google geo-locate API and get location.
Any ideas?
Thanks!
I finally managed to get it working. Here is the code snippet I used:
Thanks to all those who helped! & those whose snippets I've used from throughout stackoverflow!