├── LICENSE ├── README.md └── wi-fi-based-device-locator.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 emedina 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WiF-based Device Locator 2 | 3 | 4 | ,██ ██▄ 5 | 6 | ███ ███ 7 | 8 | W i F i b a s e d -- l o c a t i o n ███▌ ▐██ 9 | 10 | ███████████ ██████ ┌████████ ██████████ ███ ███ ▐████████ 11 | 12 | ████ ████ ███⌂ ▄███ ███ ██▌ ███▀ ███ ███ ███ ▀▀▀ ███▌ 13 | 14 | ███▌ ███▌ ███ ███ ███▌ ███▀ ██▌ ███ ▄████████▌ 15 | 16 | ███▌ ███▌ ███▌ ███, ▄███ ████, ██▌ ███ ███ ███ ▐███ ,███▌ 17 | 18 | ██████▌ █████ █████ ▀██████▀ ▀█████████ ███ ▐██▌ █████▀└███▌ 19 | powered by: l o c a t i o n s e r v i c e s 20 | 21 | ________________________________________________________________________________ 22 | 23 | ## Introduction 24 | 25 | This script uses the Mozilla Location Services API to determine the location of a device based on the Wi-Fi access points in its vicinity. The script has a menu-driven interface that allows users to input the information of multiple Wi-Fi access points and obtain their location information. Accuracy of the output relays in the amount of users offer as input for the script to call the Mozilla API, results are printed as coordinates to use as input in any map services out there. 26 | 27 | ## Installation & Usage 28 | 29 | 30 | - Clone repository: 31 | 32 | git clone https:github.com/e-m3din4/wifi-based-device-locator 33 | 34 | - Install library: 35 | 36 | pip3 install requests 37 | 38 | - Run the script: 39 | 40 | python3 wifi-based=device-locator.py 41 | 42 | - Follow the on-screen instructions to enter the details of the Wi-Fi access points. 43 | 44 | ------------------------------- 45 | 1. Get location information 46 | 2. Quit 47 | ------------------------------- 48 | 49 | Enter your choice [1-2]: 1 50 | 51 | - Enter the MAC address of the Wi-Fi access point, addtional data will increase accuracy in the results (optional: signal strenght, channel, addtional access points) 52 | 53 | 54 | ------------------------------- 55 | 1. Get location information 56 | 2. Quit 57 | ------------------------------- 58 | Enter your choice [1-2]: 1 59 | Enter the MAC address of the Wi-Fi access point: 60 | Enter the signal strength of the Wi-Fi access point (in dBm) [optional]: 61 | Enter the channel of the Wi-Fi access point [optional]: 62 | Add another Wi-Fi access point? (y/n): 63 | WiFi Access Point: 64 | { 65 | macAddress : 01:a1:02:b2:03:c3 66 | signalStrenght : -45 dbm 67 | channel : 8 68 | Latitude : 10,XXXXXX 69 | Longitude : 10,XXXXXX 70 | Location Accuracy : 86% 71 | } 72 | 73 | - The script will then make a POST request to the API endpoint and return the location information if the request was successful. 74 | 75 | 76 | - If the request was not successful, the script will return None. The script provides the option to obtain the location information for multiple Wi-Fi access points or quit the program. 77 | 78 | ## Limitations 79 | 80 | This script is limited by the accuracy and availability of Wi-Fi access points in the vicinity of the device. The accuracy of the location information also depends on the number of Wi-Fi access points provided and the quality of their signals. Location of specific wifi-devices such as mobile phones, tablets, etc, it is required it has been, at least once, working as wifi AP, as a tether for certain area and has been captured for it to appears in the database. 81 | 82 | ### Only for research and educational purposes, respect people privacy. 83 | ### Author: Edgar Medina 84 | 85 | -------------------------------------------------------------------------------- /wi-fi-based-device-locator.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | def get_location(wifi_access_points): 4 | # Define the API endpoint 5 | endpoint = "https://location.services.mozilla.com/v1/geolocate" 6 | 7 | # Define the request payload with the Wi-Fi access points 8 | payload = { 9 | "wifiAccessPoints": wifi_access_points 10 | } 11 | 12 | # Make a POST request to the API endpoint 13 | response = requests.post(endpoint, json=payload) 14 | 15 | # Check the status code of the response 16 | if response.status_code == 200: 17 | # If the request was successful, return the location information 18 | return response.json() 19 | else: 20 | # If the request was not successful, return None 21 | return None 22 | 23 | def display_menu(): 24 | print(" ") 25 | print(" ,██ ██▄ ") 26 | print(" ") 27 | print(" ███ ███ ") 28 | print(" ") 29 | print(" W i F i b a s e d -- l o c a t i o n ███▌ ▐███ ") 30 | print(" ") 31 | print(" ███████████ ██████ ┌████████ ██████████ ███ ███ ███ ▐████████ ") 32 | print(" ") 33 | print(" ████ ████ ███⌂ ▄███ ███ ██▌ ███▀ ███ ███ ███▀ ▀▀▀ ███▌ ") 34 | print(" ") 35 | print(" ███▌ ███▌ ███ ███ ███▌ ███▀ ▄██▌ ███ ▄████████▌ ") 36 | print(" ") 37 | print(" ███▌ ███▌ ███▌ ███, ▄███ ████, ██▌ ███ ███ ███ ▐███ ,███▌ ") 38 | print(" ") 39 | print(" ██████▌ █████ █████ ▀██████▀ ▀█████████ ███ ███ ▐██▌ █████▀└███▌ ") 40 | print(" powered by: l o c a t i o n s e r v i c e s ") 41 | print(" ") 42 | print(" _____________________________________________________________________________ ") 43 | print(" 1. Get location information ") 44 | print(" _____________________ ________________________ ") 45 | print(" 2.Quit ") 46 | print(" ----------------------------------------------------------------------------- ") 47 | print(" ") 48 | choice = input("Enter your choice [1-2]: ") 49 | return int(choice) 50 | 51 | def get_wifi_access_points(): 52 | wifi_access_points = [] 53 | more = True 54 | while more: 55 | mac_address = input("Enter the MAC address of the Wi-Fi access point: ") 56 | signal_strength = int(input("Enter the signal strength of the Wi-Fi access point (in dBm) [optional]: ") or -120) 57 | channel = int(input("Enter the channel of the Wi-Fi access point [optional]: ") or 1) 58 | wifi_access_point = { 59 | "macAddress": mac_address, 60 | "signalStrength": signal_strength, 61 | "channel": channel 62 | } 63 | wifi_access_points.append(wifi_access_point) 64 | more = input("Add another Wi-Fi access point? (y/n): ") == "y" 65 | return wifi_access_points 66 | 67 | # Main loop 68 | choice = 0 69 | while choice != 2: 70 | choice = display_menu() 71 | if choice == 1: 72 | wifi_access_points = get_wifi_access_points() 73 | location = get_location(wifi_access_points) 74 | if location: 75 | print("Latitude:", location["location"]["lat"]) 76 | print("Longitude:", location["location"]["lng"]) 77 | print("Accuracy:", location["accuracy"]) 78 | else: 79 | print("Location could not be determined.") 80 | elif choice == 2: 81 | print("Exiting program.") 82 | else: 83 | print("Invalid choice.") 84 | --------------------------------------------------------------------------------