Capturing MAC Address of device

Capturing MAC Address of device

by Gavin Botten -
Number of replies: 4

Hi, I'm a site administrator for a LAN based Moodle (ver 2.8.3) site being used in a primary school in Gauteng, South Africa, we are the first Primary school in South Africa to implement E-Learning, and are still working out some issues, what I need to ask is.

Is it possible to capture the MAC Address of the device being used on Moodle? 


The reason I ask this is that I noticed that when I go into a specific users profile, it gives me their last I.P. address used when they logged in to Moodle, now as the LAN Network assigns I.P.'s automatically, I can not track devices on the network using their I.P. Addresses, should the device be stolen, or "lost" for some reason, however if I can associate the MAC Address to a specific user, I can track that on the network, or at least tell which AP it is connected to, and from there it narrows our search down to a 10 or 20 meter radius. 

Also, if a device IS stolen and because we use mostly Android tablets, chances are it will be brought to me to be reset to remove the password and be reconnected to the network, as that is a part of my job as well, if I have the MAC Address of the "stolen" or lost device, it is easy enough to check the devices that match the description of the missing device to see if the MAC Address matches.


If this is not being developed, could you tell me where to find and how I can alter the code which captures the I.P. Addresses. I'm guessing that it would be a simple matter to add in some code to capture the MAC Address as an add on to this code, as it already reads the I.P. Address and it should be a simple matter to add in a line that picks up the MAC Address at the same time.


This little "fix" would save me a hell of a lot of time in the beginning of the year, where I would have to write down the MAC Addresses from each child's device.


I hope you guys can help me with this little problem"


Regards

Gavin

Average of ratings: -
In reply to Gavin Botten

Re: Capturing MAC Address of device

by Ken Task -
Picture of Particularly helpful Moodlers

Me thinks not so 'little' IF one is thinking in terms of using Moodle code for this.   If one has to hack Moodle core code to get desired results, then what happens to the core code hacks when needing to update/upgrade?   Could be lost if one doesn't archive/make notes.   Plus, there's the potential of the hacks not working with newer version of code.

Thus ...

Think it best to use something outside of Moodle PHP code cause it's really the OS and Apache server - which is already recording log information in access logs.  Apache logs, however, don't typically log MAC address.  This is limited to local LAN (which, from what you've described, is what you are seeking).

Please see:

http://stackoverflow.com/questions/1420381/how-can-i-get-the-mac-and-the-ip-address-of-a-connected-client-in-php

for some ideas/ways.

You can still create whatever and use simple URL links to what's generated from a System Admins course that's accessible only by System admin level users in Moodle.   I already do some bash shell scripts that search logs looking for device platforms ... iPhone, iPad, Android, etc. and dumps the raw apache log entries to a text file in an accessible directory of a Moodle - does do a word count on terms to get an overall idea of how many users are hitting the Moodle using iPad, iPhones, or Androids - doesn't ID users of those devices, however.

'spirit of sharing', Ken


Average of ratings: Useful (2)
In reply to Gavin Botten

Re: Capturing MAC Address of device

by Colin Fraser -
Picture of Documentation writers Picture of Testers

I doubt very much this functionality is even usable in Moodle, and I am not sure it is desirable. This is something that can be done at the server level, with something like arp or arp -scan, or sudo nmap -sn [your.network.identifier.range]. Dunno what it is on Window servers.... 

Bottom line is that there appears no easy way to track a MAC address, without there being some linking information. I understand you can, if it is available, use bssid to track the longitude and latitude of a user, or perhaps airodump -ng as a way of identifying networks. I am not suggesting you try any of these things, but if you are determined...  

However, thinking about this, surely there is some command that would allow a network admin to link a MAC address to an assigned ip address. From there, I would think there is to be a way of identifying that assigned ip to a user login. This could be, perhaps, a batch process executed at a successful login that writes to a log the Mac address, the assigned ip, the assigned ip and the user login name. The big flaw in this is that MAC addresses are easily faked. In Linux I understand it is something as simple as Nmac -spoof -mac  or similar anyway, in Windows, find the MAC address in the registry and change it. Of course, most people have never heard of a MAC address, or will relate it to Apple products or similar, (be better if it had an i in front). It is only going to be techheads who will wake up and make changes so it is, I suggest, still a worthwhile project for someone.

EDIT: or what Ken  says...wide eyes       

Average of ratings: Useful (2)
In reply to Colin Fraser

Re: Capturing MAC Address of device

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

As others have pointed out, this is not a job for Moodle. Still, if you want to go ahead, the link Ken gave explains how to do it.

Good that you explained why you want this. Before implementing anything I would carefully list all the possible scenarios and in which cases you want to catch and How. For example:
- to notice that a device is lost
- to detect once such a lost device comes back to your LAN
- to detect when such a device is handed over to you (for reset)
etc.

Further question: How about, if that device never comes back to your LAN but lives in the Internet?

Tracking lost devices is not a new thing. There are so many solutions, some even from the device manufacturer. Since these are mobiles, there are apps for sure. I remember reading a story how a thief web-casted his bedroom back to the owner (without knowing, 'fcourse).
In reply to Gavin Botten

Re: Capturing MAC Address of device

by george macin -

Using WMIC Commands you can find the macaddress...

>wmic nic get macaddress,description
More about....WMIC Commands


George