Building OSINT Phone Numbers With Python

A few days ago, I wrote an article about the Findigo tool, which you can see here. This tool is one that we have created. In this article, I will teach you how to create and build a phone number OSINT program using the Python programming language. If you haven't learned programming and haven't used Python before, I suggest you learn it first before continuing to read this article. So, what is OSINT on phone numbers?

OSINT Phone Numbers

OSINT stands for open source intelligence, which in the context of telephone numbers refers to the use of open resources to gather information about a specific phone number. OSINT on telephone numbers involves using publicly available online data to identify the owner of the phone number, geographical location, and other relevant information. Typically, OSINT on telephone numbers involves searching through search engines, social media platforms, telephone directories, or other public databases to gather information that may be associated with the desired phone number. Information that can be found through OSINT on telephone numbers includes the owner's name, address, social media profiles, related businesses, and so on.

Python Library

let's use one of the Python libraries called phonenumbers. The phonenumbers library in Python is a library or module used to manipulate, validate, and format telephone numbers. This library provides various functions for working with telephone numbers, including checking the validity of a number, obtaining information about country codes, formatting telephone numbers into different formats, and much more. The phonenumbers library is based on the Google libphonenumber library, which was originally developed to validate international phone numbers and provide country code data. This library is highly useful in applications that require phone number manipulation, such as mobile apps, telecommunications systems, and customer services.

How To Install It

I'm using the windows OS for this article, but the process is the same, don't worry about it. To install it, you need to open the terminal on your device and enter the command below:

pip install phonenumbers

You will see like this :

Coding

Now, let's start the coding. Open your IDE, such as Visual Studio Code, Notepad++, or any other IDE of your choice. In this article, I'll be using Visual Studio Code as the IDE and running the code in CMD afterward. The code will automatically generate comments for each line of code, which will help in understanding how the code works. Here is the source code that you can simply copy and paste into your IDE. This code is intended to show the ISP (Internet Service Provider) of a phone number :

# Import modules
import argparse, phonenumbers
from phonenumbers import carrier

# Adding an argument for the phone number
parser = argparse.ArgumentParser()
parser.add_argument('-n', '--number', type=str, help='set the phone number')
args = parser.parse_args()

# Main function
def main():

    # Check if the user adds the argument in the terminal
    if args.number:
        target_number = phonenumbers.parse(args.number)  # Parsing the given phone number
        isp = carrier.name_for_number(target_number, 'en')  # Getting the ISP (Internet Service Provider) name

        # Displaying the ISP (Internet Service Provider)
        print("=====[OUTPUT]=====")
        print(f"ISP : {isp}") 

# Run the code in terminal
if __name__ == "__main__":
    main()

You need to run the code like this :

Don't forget to enter and the result indicates that the number on the specified target shows an output result of the MTN ISP. In linux enviroment you need to running like this into your terminal :

python main.py -n (phonenumber)

Next, we will determine the country location of the given phone number. The code for it is as follows :

# Import modules
import argparse, phonenumbers
from phonenumbers import geocoder

# Adding an argument for the phone number
parser = argparse.ArgumentParser()
parser.add_argument('-n', '--number', type=str, help='set the phone number')
args = parser.parse_args()

# Main function
def main():

    # Check if the user adds the argument in the terminal
    if args.number:
        target_number = phonenumbers.parse(args.number)  # Parsing the given phone number
        location = geocoder.description_for_number(target_number, 'en')  # Getting the location

        # Displaying the location
        print("=====[OUTPUT]=====")
        print(f"Location : {location}") 

# Run the code in terminal
if __name__ == "__main__":
    main()

Output :

Lastly, we will determine the time zone of the associated number. The code for it is :

# Import modules
import argparse, phonenumbers
from phonenumbers import timezone

# Adding an argument for the phone number
parser = argparse.ArgumentParser()
parser.add_argument('-n', '--number', type=str, help='set the phone number')
args = parser.parse_args()

# Main function
def main():

    # Check if the user adds the argument in the terminal
    if args.number:
        target_number = phonenumbers.parse(args.number)  # Parsing the given phone number
        time_zone = timezone.time_zones_for_number(target_number)  # Getting the time zone

        # Displaying the time zone
        print("=====[OUTPUT]=====")
        print(f"Time zone : {time_zone}") 

# Run the code in terminal
if __name__ == "__main__":
    main()

Output :

Closing

That's what I provided to you on how to perform OSINT on telephone numbers. There are many more functions available in the library. You can visit it directly here. Hopefully, it will be useful for you!