Intro to mobile carrier lookup cell phone triangulation and location tracking

0 / 854
INTRO TO MOBILE CARRIER LOOKUP AND CELL PHONE TRIANGULATION AND LOCATION TRACKING

Mobile phones have become an integral part of our lives. They even have surpassed, PC/laptop usage. This blog will talk about how we can lookup mobile phone carrier/service provider and use cell phone triangulation techniques to track its location.

 

Cell phone triangulation

 

Cell phone triangulation is very much similar to geolocation tracking using GPS. Cell phone triangulation uses the signal and tower info to track down the location, against GPS, which works by lookup of IP/mac address of the device/modem/router. In triangulation, geolocation tracking is achieved by acquiring the below four variables pertaining to the cell phone to be tracked:-

 

 
LAC (Location area code):- area code of the cell tower location, the cell phone is active in (available to only who owns the phone)

 

 

CID (Cell ID):- A unique ID to identify the base station, the phone talks to. LAC and CID can be obtained from an app like netmonitor installed on the designated mobile phone to be tracked.

 

 

MCC (Mobile country code):- A 3 digit decimal number used to identify the carrier/country

 

 
MNC(Mobile network code):- 2 or 3 digit decimal number used to identify the carrier/country
 
 
Once you have the above four variables, you can calculate the approximate geolocation of a given cell phone at any given point of time. 
 
 
This is how, Big G (Google) is calculating your location even when your GPS location tracking is off in your cell phone.
 
 
Out of the above 4 parameters, MCC and MNC can be obtained remotely for any mobile, LAC and CID are known only to the mobile carrier and to the owner of the cell phone, but can be obtained by the police or higher authorities in case if there is some criminal investigation against the owner of the cell phone.
Someone using an IMSI catcher can also get an access to the LAC and CID, but it’s illegal to possess one if you are not authorized to do so.
 
 
 
In this blog, I will show you how to obtain the mobile operator name and the variables, viz. MCC, MNC, LAC & CID and hence location of the cell phone, programmatically.
 
 
There are heaps of third party services available to query mobile operator name, MCC and MNC. I will show you how to obtain these variables using Twilio API and later use them as input to another third party service (unwiredlabs) for triangulation.
 
 
 
You can signup for Twilio/Unwiredlabs using the below links
 
Twilio:- Signup
 
Unwiredlabs:- Signup
 
 
 
You will need nodejs installed on your machine for this. Download and install nodejs from here
 
 
Once node is installed, install twilio using the command npm install twilio, in the directory where your code for the cell phone triangulation resides.
 
After signing up with Twilio, use the below code to get MCC,MNC and mobile operator
 
 

var accountSid = < your account SID > ;
var authToken = < api token > ;
var LookupsClient = require('twilio').LookupsClient;
var client = new LookupsClient(accountSid, authToken);
var phoneNumber = < mobile number to lookup >  
client.phoneNumbers(phoneNumber).get({ 
type: 'carrier'
}, function(error, number) {
if (number) {
console.log("Carrier type = ", number.carrier.type);
console.log("Carrier data for number ", phoneNumber, " is as below : ")
console.log("Carrier name = ", number.carrier.name);
console.log("Carrier network code = ", number.carrier.mobile_network_code);
console.log("Carrier country code = ", number.carrier.mobile_country_code);
console.log("Carrier country code = ", number.country_code);
} else {
console.log("No data received : Check your internet or proxy settings and retry!!")
}
});

 Run the above from command line using node <filename> to fetch all the info.
 
 
 
Signup with unwiredlabs and use the below code for obtaining the cell triangulation data
 
 

var data = {
"token": < your unwired api token > ,
  "radio": "gsm",
  "mcc": < mcc of mobile to track obtained from twilio api lookup > ,
  "mnc": < mnc of mobile to track obtained from twilio api lookup> ,
  "cells": [{    
"lac": < lac of mobile to track - available from cell phone to track > ,
    "cid": < cid of mobile to track - available from cell phone to track >   
}],
  "address": 1
} 
$.ajax({  
url: 'https://ap1.unwiredlabs.com/v2/process.php,  
type: "POST",
  data: data,
  success: function(data, textStatus, jqXHR)   {  
console.log(data);  
},
  error: function(jqXHR, textStatus, errorThrown)   {   // error
console.log("error ", textStatus, "error thrown: ", errorThrown);  
}
});
}

 
The above code will give approximate location of the cell phone you want to track. There is an error of about 1 km though. If you want more accurate location, then it’s advisable to pass the bssid (mac) array of all access points of the wifi that you are connected to.  
 
 
This array can be obtained from your wifi connection data using nodejs module node-wifiscanner
For below code to work, module, node-wifiscanner is to be installed using npm by the command npm install node-wifiscanner
 
var wifiscanner = require('node-wifiscanner'); 
wifiscanner.scan(function(err, data) {
if (err) {
console.log("Error : " + err);
return;
} 
console.log(data); // this will print information about all the nearby WiFis in range along with bssid's 
of the wifi that you are connected to. 
// prepare data to feed to API for finding the location
var wifiArray = new Array(); 
for (index = 0; index < data.length; index++) {
var obj = {
"bssid": data[index].mac,
"channel": data[index].channel.split(",")[0],
"signal": data[index].signal_level
}; 
wifiArray.push(obj);
}
console.log(wifiArray);
}); 
 
Run the above from command line using node <filename> to fetch all the info.
 
 
Note that, the bssid array is optional, but will be helpful if you need more accuracy in location tracking.
Once you obtain the bssid array using the above code snippet, pass it to the unwiredlabs API as below
 
var data = {
"token": < your unwired api token > ,
"radio": "gsm",
"mcc": < mcc of mobile to track obtained from twilio api lookup > ,
"mnc": < mnc of mobile to track obtained from twilio api lookup > ,
"cells": [{    
"lac": < lac of mobile to track - available from cell phone to track > ,
"cid": < cid of mobile to track - available from cell phone to track >   
}],
"wifi": wifiArray, // obtained from wifi-bssid-scanner above
"address": 1
} 
$.ajax({  
url: 'https://ap1.unwiredlabs.com/v2/process.php,  
type: "POST",
data: data,
success: function(data, textStatus, jqXHR)   {  
console.log(data);  
},
error: function(jqXHR, textStatus, errorThrown)   {   // error
console.log("error ", textStatus, "error thrown: ", errorThrown);  
}
});
}
 
 
 
All the above code can be put together where all the node.js scripts can reside on the server and can be called from the client (browser) using socket.io. Stay tuned for more hacks and interesting stuff.

 

Comments

comments


An avid reader, responsible for generating creative content ideas for golibrary.co. His interests include algorithms and programming languages. Blogging is a hobby and passion.
loading...