5

I am going to make mobile device detector using a single board computer (SBC) running a Linux based OS. The SBC will have a USB/802.11 wireless adaptor. The SBC will be a DHCP server. The mobile device will join the wireless network (adhoc or infrastructure, it doesn't matter) of the SBC. When the mobile device joins the network, the SBC will detect it. It will check the MAC address of the incoming mobile device with a set of accepted addresses. If there is a match, the SBC will execute a command.

I have basic Linux knowledge. I can't write shell scripts but I know C++/Qt. I don't know where to start. Do you know relevant command line utilities or libraries to use in this project?

P.S: Maybe I only need a way to detect when dhcp client list changes. Together with mac address filtering, this may work.

niw3
  • 120
  • 1
  • 8
  • You have to learn a little bit of shell script. If you write a deamon you have to write a start and kill script for the init.d. Well it's not hard but you need to know the basics :-) – rekire Jan 18 '12 at 21:14
  • I can create one from existing start/kill scripts. That's not a problem. – niw3 Jan 18 '12 at 21:18
  • You should give some more details, for example, what kind of software is going to run on that SBC? Doing something like a software AP would require hostapd, which I believe has the MAC-filtering capability built in. – Daniel Kamil Kozar Jan 18 '12 at 22:29
  • I don't know what to use on a software access point. Thanks for the comment, I'll read software ap how-to's first. – niw3 Jan 18 '12 at 22:56

2 Answers2

0

You can use nmap to discover your network. Here you can find some examples.

Then you should parse it's output. E.g.:

while true; do
    nmap -v -sT 192.168.0.0/24 | fgrep "YOUR_SEARCHED_IP" && \
    echo BINGO "YOUR_SEARCHED_IP" IS IN THE 192.168.0.0/24 NETWORK
done  

And nmap has an -sn option to skip the port checks.

Even better you can use ip neighbor show to see your neighborhood networks IP address.

Or you can use a simple ping test, like:

for ip in $(seq 1 254); do 
    ping -c 1 192.168.1.$ip>/dev/null && \
    echo “192.168.1.$ip is UP"
done

And you can combine it with nslookup to see the hostnames.

Zsolt Botykai
  • 50,406
  • 14
  • 85
  • 110
  • Thanks. However, nmap searches for open ports, so the mobile device has to have open ports otherwise it will not be detected. – niw3 Jan 18 '12 at 22:47
  • Well if you do a `nmap -o $IP_RANGE` it reports something like `Nmap scan report on $IP` then on the next line `host is up`. But see my updated answer. – Zsolt Botykai Jan 19 '12 at 07:20
0

nmap tests the IP layer, but wireless devices are not required to use that.

You can also use "Monitor" mode on your wireless interface and/or combined with an appropriate listening program such as e.g. airodump-ng. Note that if the wireless network uses client isolation, you may see much less clients than are in fact participating, and also note that, just like properly-switched Ethernet, you won't necessarily see distant clients located in another segment.

jørgensen
  • 10,149
  • 2
  • 20
  • 27