Mapping Cellular Networks: Using OpenCellID for GSM Data Collection
In the world of cellular network reconnaissance, one of the most valuable assets is information about the physical layout of GSM cell towers. Mapping the locations of cell towers allows attackers to gather critical intelligence on the structure and coverage of a network. This data can be used for a variety of purposes, including planning attacks like IMSI catching, jamming, or intercepting GSM communications. Using open-source tools like OpenCellID or OpenBMap, it’s easier than ever to collect GSM data and build a map of a network’s infrastructure.
In this guide, we’ll walk through how to use OpenCellID and OpenBMap to map out cellular networks, collect data on cell towers, and use that information for further exploitation.
Why Map Cellular Networks?
Mapping out cellular networks is a powerful tactic for attackers because it provides a detailed view of the GSM landscape in a given area. Here’s why that matters:
- Identifying Network Coverage: Knowing where the cell towers are located helps attackers determine weak spots in coverage or potential areas to intercept signals.
- Targeting High-Value Towers: Certain cell towers may serve densely populated or high-value areas (e.g., financial districts, government facilities), making them prime targets for interception.
- Exploiting Roaming Behavior: Mapping towers helps attackers understand how phones roam between different cells, providing opportunities for impersonating or hijacking legitimate towers (e.g., using IMSI catchers).
With a complete network map, attackers can systematically choose which towers or locations to exploit for maximum impact.
Step 1: Using OpenCellID for GSM Data Collection
OpenCellID is the world’s largest collaborative project that collects GPS positions of cell towers based on mobile signals. It provides data on cell tower locations, which can be leveraged to map out a network and gain insights into the geographical layout of GSM infrastructure.
Setting Up OpenCellID
Create an Account: To use OpenCellID’s data or API, you'll need to create an account on their website. Once registered, you can request an API key, which allows access to the cell tower data.
Install Required Tools:
OpenCellID provides APIs to access their database, but you can also use various scripts to automate data collection.
Collecting Cell Tower Data via API
The OpenCellID API allows you to pull detailed information about cell towers, including the cell ID, location (latitude/longitude), and network operator. With this data, you can begin building a map of the cellular network.
import requests
import pandas as pd
# OpenCellID API key
api_key = 'YOUR_API_KEY'
# Define parameters for the API request
params = {
'key': api_key,
'lat': 37.7749, # Latitude of the target location
'lon': -122.4194, # Longitude of the target location
'range': 10000, # Search radius in meters
}
# Fetch cell tower data
response = requests.get('https://api.opencellid.org/cell/get', params=params)
data = response.json()
# Convert data into a DataFrame for easy manipulation
df = pd.DataFrame(data['cells'])
# Save data to CSV for later analysis
df.to_csv('cell_towers.csv', index=False)
This script collects GSM tower data within a 10 km radius of a specified location. Modify the latitude and longitude to match your target area and adjust the range to capture more or fewer towers. The data returned will include information like the cell ID, mobile country code (MCC), mobile network code (MNC), and the tower's location.
Step 2: Visualizing the Cellular Network
Once you have the data on the location of cell towers, you can visualize it on a map. This allows you to analyze the network’s structure and find valuable choke points or areas of interest.
Using Google Maps or OpenStreetMap
You can plot the collected cell tower data on Google Maps or OpenStreetMap to create a visual representation of the network layout.
- Convert Data to KML Format:
Convert your data into KML format, which can be imported into Google Earth or OpenStreetMap for visualization.
from simplekml import Kml
# Initialize KML object
kml = Kml()
# Iterate through DataFrame and add points for each cell tower
for _, row in df.iterrows():
kml.newpoint(name=f"Cell ID: {row['cellid']}", coords=[(row['lon'], row['lat'])])
# Save to KML file
kml.save('cell_towers.kml')
- Visualize on Google Earth:
- Open Google Earth and import the KML file to visualize the network of cell towers.
- You can also import this data into any GIS platform to enhance your analysis, including filtering by operators, cell types, or locations.
Using OpenStreetMap with OpenBMap
Alternatively, you can use OpenBMap, a community-driven service similar to OpenCellID, to collect and visualize mobile network data directly on OpenStreetMap.
- Install the OpenBMap Collector: The OpenBMap mobile app allows you to collect GSM data directly from your smartphone, including cell IDs, signal strength, and GPS location.
- Upload Data to OpenBMap: Once collected, upload the data to OpenBMap’s platform, which will automatically map out the towers and provide a visual layout of the network.
Step 3: Analyzing the Cellular Network Layout
With your network map in place, you can begin analyzing the data to identify weak points or areas of interest for further exploitation. Here are some key elements to consider:
1. Tower Density and Coverage Gaps
- High-Density Areas: Focus on high-density areas where many towers overlap. These locations typically have high traffic, making them ideal targets for setting up IMSI catchers or intercepting communications.
- Coverage Gaps: Identify areas with weak or no coverage. Devices in these zones may be more likely to connect to a rogue BTS (Base Transceiver Station), making interception easier.
2. Operator-Specific Data
You can filter the data by Mobile Network Code (MNC) to map out towers belonging to specific operators. This can be useful if you are targeting a particular network provider or if you want to avoid specific networks.
3. Roaming Patterns
By collecting data over time and in different regions, you can analyze how mobile devices roam between cell towers. This information can be leveraged to predict the best locations for setting up rogue BTS devices, as phones are more likely to switch to stronger signals in weak coverage areas.
Step 4: Exploiting the Collected Data
Once you’ve mapped out the GSM network, it’s time to turn that information into actionable intelligence. Here are a few key ways attackers can leverage cellular network maps:
1. Setting Up IMSI Catchers
With knowledge of the cell tower layout, attackers can strategically place IMSI catchers to spoof a legitimate tower and force nearby phones to connect to it. This allows the attacker to:
- Intercept Calls and SMS: Once connected to the fake BTS, all incoming and outgoing traffic can be intercepted and analyzed.
- Track Devices: Collect IMSI and IMEI numbers to track the location and identity of nearby devices.
2. Jamming Specific Towers
Once you know the exact location of key cell towers, GSM jamming becomes easier. Attackers can target specific towers for disruption, forcing mobile phones to drop from the network or connect to a weaker signal (or a rogue BTS).
- Selective Jamming: Disable service in a particular area while maintaining control over which devices connect to a rogue BTS.
3. Exploiting Roaming Behavior
By mapping out areas where devices frequently roam between towers, attackers can:
- Target Roaming Devices: Set up fake towers in these areas to intercept communications from devices as they switch between legitimate towers.
- Monitor Handovers: Exploit the handover process (when a device switches from one tower to another) to inject or manipulate data.
Step 5: Automating Network Mapping for Continuous Monitoring
Once you have the infrastructure in place to map cellular networks, you can automate the process of continuously collecting and updating your data.
Periodic Data Collection
Use scripts to query OpenCellID’s API regularly and update your network map as new towers are added or existing ones are removed. This ensures you always have the most up-to-date layout of the GSM network.
import time
# Set to run every 24 hours
while True:
response = requests.get('https://api.opencellid.org/cell/get', params=params)
data = response.json()
df = pd.DataFrame(data['cells'])
df.to_csv('cell_towers.csv', index=False)
time.sleep(86400) # Sleep for 24 hours before collecting again
Conclusion
Mapping cellular networks with tools like OpenCellID or OpenBMap allows attackers to gather crucial intelligence on the layout of GSM infrastructure. By collecting data on cell towers and visualizing it on a map, attackers can identify strategic locations for setting up IMSI catchers, jamming towers, and intercepting communications. With this data, it becomes much easier to plan and execute sophisticated attacks on mobile networks, taking full advantage of weaknesses in GSM coverage and
handover behavior.
With the right tools and techniques, cellular networks become an open book—just waiting to be exploited.