MACTracker – A simple device tracking application

MACTracker Introduction:



Hello all, this is my new blog post on a simple application that I developed a while ago. I am writing the blog post about the application MACTracker, what it does and its utility in the real world. The idea behind the application was mainly of my colleague and friend. His idea helped me in developing the application.

MACTracker Idea:

The idea behind the application MACTracker is to track all devices connected over the network. MACTracker get the name of the device and the mac address or the physical address of the device. For developing this MACTracker application I have used a tool named nmap which would gather up all the details of the devices over the network, Java to manipulate the nmap output and get the filtered data, the power of shell scripts to bind in the process of nmap and java compilation along with an inbuilt utility provided by Linux and Unix shell known as crontab that helped me in simulating the application to execute over a certain interval of time.


  1. Installing NMAP in the system. To install nmap in the system follow the required link.
  2. Installing Java in the system.
  3. Idea of shell scripting.
  4. Manipulating cronjob either using system crontab or Jenkins , any other continuous integration tools that can carry out cron jobs.

 Installation of nmap:

Nmap has supported Mac OS X since 2001, and our support has only improved over time. While Mac users can compile Nmap themselves, we also offer an executable installer. Nmap makes use of Jhbuild and gtk-mac-bundler which are used to build other projects for Mac OS X, such as OpenSSL, libapr, libsvn… Nmap is also available through systems such as MacPorts and Fink which package Unix software for Mac OS X.

Executable Installer:

The easiest way to install Nmap and Zenmap on Mac OS X is to use our installer. The Mac OS X section of the Nmap download page provides a file named,nmap-<version>.dmg where is<version> the version number of the most recent release. The .dmg file is known as a “disk image”. Installation instructions follow:

  1. Download the ffile.nmap-<version>.dmgDouble-click the icon to open it. (Depending on how you downloaded the file, it may be opened automatically.)
  2. The contents of the disk image will be displayed. One of the files will be a Mac meta-package file named nmap-<version>.mpkg. Open it to start the installer.On OS X 10.8 and later, you may see a dialog like Figure 2.2.

    Figure 2.2. Apple Gatekeeper block screen

    Apple Gatekeeper block screen

    If this happens, it is necessary to right-click or control-click on the .mpkg and select “Open”, as shown in Figure 2.3.

    Figure 2.3. Apple Gatekeeper Open menu

    Apple Gatekeeper Open menu

    A dialog similar to the first will appear, this time having an “Open” button (shown in Figure 2.4). Click the button to continue.

    Figure 2.4. Apple Gatekeeper Open screen

    Apple Gatekeeper Open screen
  3. Follow the instructions in the installer. You will be asked for your password since Nmap installs in a system directory.
  4. Once the installer is finished, eject the disk image by control-clicking on its icon and selecting “Eject”. The disk image may now be placed in the trash.

See the instructions in the section called “Executing Nmap on Mac OS X” for help on running Nmap and Zenmap after they are installed.

The programs installed by the installer will run on Intel Mac OS X 10.5 (Leopard) or later. Users of earlier versions will have to compile from source or use a third-party package. Instructions for PowerPC (PPC) Mac systems (which Apple ceased selling in 2006) are available on our wiki.

Application implementation structure and its description:

To understand the implementation and the strategy please follow my git page where I have described the working and the procedure for MACTracker


A simple MACTracker application that would help a user keep track of the devices connected to a network. It uses the capabilities of a tool called andNMAP very simple logic to deduce the MAC address and the device connected to the network.


  1. NMAP installed on the machine.
  2. JAVA installed in the machine.


NMAP (Network Mapper) is a command that can help users discover hosts and services on a computer network. I have used asNMAP a service in my application to identify devices that are connected to the network. To install withinNMAP your system I would suggest my viewers to install ZENMAP which is just a GUI wrapper over the NMAP command. It would help harness the capabilities of NMAP over a lightweight GUI. To get ZENMAP installed in your system just follow the link. Since I am using a mac environment to set up my application I just downloaded the required version of Zenmap, extracted it and placed it in my application directory. But before installing the application NMAP into your mac please check that your machine has the permission to install applications outside your app store. To do that just visit System Preferences -> Security -> Click on "Anywhere" To check whether NMAP has properly been installed in your machine just run the command nmap --version.
In this application, I have taken a dump of NMAP output in an XML format using the parameter -oX. The NMAP command looks like this nmap -sP -n -oX - <ip_address>/24 | tee nmap.xml. You can use the parameter -oN to output the desired result in a text format as well.


The MAC_IDENTIFIER the directory has a java logic written that would extract the MAC Address and the device name connected over the network. A BufferedReader the object would contain the required nmap dump which can be iterated to get the corresponding mac address of the device connected over the network and the device name as well.


The TRACKER_EXECUTE the directory has two shell scripts. would run the nmap command and dump the entire log into a file called nmap. The JAVA logic written utilises this dump to iterate the MAC address and the device name. Then comes the logic for, it simply traverses to the MAC_IDENTIFIER directory, compiles and executes the java class. In the corresponding shell script I have used the IP address of my network. Please make sure to enter the IP address of your respective network.

Now comes, the interesting part of setting a cron job to automate the entire process.


Under the root directory, I have another shell executed that basically runs my two processes of dumping the nmap log and iterating the java logic thereafter.

Setting the cron job

UNIX and LINUX by default provide a default service called crontab that helps in executing services periodically. I have a cron job set that would run this task_runner logic every after 30 minutes. Here is the logic for it.
*/30 * * * *
/Users/soumyajit/Documents/git_repos/target_mac/ >

N.B: I have configured the cron so that I get the redirected output of the terminal into a log file called task_runner.log.

Setting up CRONTAB

Crontab utility is a program that would run applications or scripts within a system at a certain interval of time. It basically has 4 modes of working which includes:

  1. crontab -e: Suggests editing the current crontab in the system.
  2. crontab -l: Displaying the current version of the crontab.
  3. crontab -u: Specifying the name of the user whose crontab is to be tweaked.
  4. crontab -r: Removes the current crontab for the user.


Thank you all, that’s all for today. Hope to come up with something new for MACTracker very soon !!?

Learn Visual Artificial Intelligence Implementation in Existing Automation Framework using Applitools. Click on link 


Soumyajit Basu

Soumyajit is 5+ years experienced Software professional with his prime focus on automation technologies based on quality development and takes interest in the CI/CD processes. He provides help in developing the QA process in an organization with his skills in automation for the web platform. His focus is on improving the delivery process for an ongoing project and connects the dot to help out with a successful deployment. He has experience in working on analytics, e-commerce, and the ad-tech domain.

Besides being a professional he takes an immense interest in learning new skills and technologies. He is a research guide author/writer at Dzone and Web Code Geeks. He also maintains a blog platform of his own where he likes to keep up his technology junks.