6 Simple OSINT Python Scripts to Add to Your Toolkit.

I've put together 6 easy python scripts to add to your OSINT toolkit.

6 Simple OSINT Python Scripts to Add to Your Toolkit.
Photo by Artem Sapegin / Unsplash

I've put together 6 easy python scripts to add to your OSINT toolkit. These are basic scripts you can use to make quick searches or to help you set up new OSINT accounts quickly. Feel free to use and customize these as you need.

You can find them on my GitHub: https://github.com/grose1/osint

1. A fast and simple IP Geolocation Lookup

Quickly retrieve location information for an IP address

import requests

def geolocate_ip_address(ip_address):
    url = f'https://ipapi.co/{ip_address}/json/'
    response = requests.get(url)
    data = response.json()
    return data

# Usage:
ip_address = '8.8.8.8'
location_data = geolocate_ip_address(ip_address)
print('IP:', location_data['ip'])
print('City:', location_data['city'])
print('Region:', location_data['region'])
print('Country:', location_data['country_name'])

2. Quickly search usernames with Google API

Using Googles custom search api you can quickly search for usernames

import requests

# Simple Function to search for usernames on Google
# https://developers.google.com/custom-search/v1/introduction
# https://programmablesearchengine.google.com/controlpanel/all
def search_google(query):
    api_key = 'API KEY'  # Replace with your Google Custom Search JSON API key
    search_engine_id = 'ID'  # Replace with your Google Custom Search Engine ID
    base_url = 'https://www.googleapis.com/customsearch/v1'

    params = {
        'key': api_key,
        'cx': search_engine_id,
        'q': query
    }

    try:
        response = requests.get(base_url, params=params)
        data = response.json()

        if 'items' in data:
            print('Search Results for', query + ':')
            for item in data['items']:
                print('Title:', item['title'])
                print('Link:', item['link'])
                print('---')
        else:
            print('No search results found for', query)

    except requests.exceptions.RequestException as e:
        print('Error occurred:', str(e))

# Example usage
username = 'site:example.com "username"'  # Replace with the username you want to search

# Search for the username on Google
search_google(username)

3. Quickly Search for Hashtags with Google API

Using Googles custom search api you can quickly search for Hashtags

import requests

# https://developers.google.com/custom-search/v1/introduction
# https://programmablesearchengine.google.com/controlpanel/all
# Function to search for hashtags using the Google Custom Search API
def search_hashtags_on_custom_search_api(hashtag, api_key, cx, num_results=10):
    url = 'https://www.googleapis.com/customsearch/v1'

    # Prepare the query parameters
    params = {
        'key': api_key,
        'cx': cx,
        'q': f'site:twitter.com #{hashtag}',
        'num': num_results
    }

    try:
        # Send the GET request to the Custom Search API
        response = requests.get(url, params=params)
        response_json = response.json()

        # Process and display the search results
        if 'items' in response_json:
            for i, item in enumerate(response_json['items'], start=1):
                print(f"Result #{i}: {item['link']}")
        else:
            print('No search results found.')
    except requests.RequestException as e:
        print('Error occurred:', str(e))

# Example usage
target_hashtag = '#examplehashtag'  # Replace with the hashtag you want to search for
api_key = 'api key'  # Replace with your Google Custom Search API key
cx = 'ID'  # Replace with your Custom Search Engine ID

# Search for the hashtag using the Custom Search API
search_hashtags_on_custom_search_api(target_hashtag, api_key, cx)

4. Create Random Usernames for OSINT Accounts

A quick and simple python script to create random usernames to use for throwaway OSINT accounts. You can customize the adjective and nouns section to make work for your needs

import random
import string

# Function to generate a random username
def generate_username():
    adjectives = ['happy', 'sunny', 'daring', 'brave', 'curious', 'clever', 'vivid', 'cool', 'silly', 'witty']
    nouns = ['unicorn', 'wizard', 'adventure', 'hero', 'dreamer', 'jester', 'artist', 'rebel', 'champion', 'voyager']
    numbers = random.randint(10, 99)
    username = random.choice(adjectives) + random.choice(nouns) + str(numbers)
    return username

# Example usage
username = generate_username()
print('Generated Username:', username)

5 Create Random User Profile Descriptions for OSINT Accounts

You can use this easy python script to create random user profiles for your OSINT accounts. You can edit each category to suit your needs.

import random

# Lists of possible profile details
interests = ['Travel', 'Photography', 'Food', 'Music', 'Fitness', 'Art', 'Fashion', 'Sports']
locations = ['New York', 'London', 'Paris', 'Tokyo', 'Sydney', 'Berlin', 'Los Angeles', 'Dubai']
occupations = ['Software Engineer', 'Designer', 'Writer', 'Teacher', 'Marketing Specialist', 'Chef', 'Athlete']
quotes = [
    "Carpe Diem! Seize the day.",
    "Life is what happens when you're busy making other plans.",
    "In a world where you can be anything, be kind.",
    "Adventure awaits just outside your comfort zone.",
    "Follow your dreams and never look back.",
    "Believe you can and you're halfway there."
]

# Random name generator
def generate_random_name():
    first_names = ['John', 'Emily', 'Michael', 'Sophia', 'Daniel', 'Olivia', 'David', 'Emma']
    last_names = ['Smith', 'Johnson', 'Brown', 'Taylor', 'Lee', 'Walker', 'Clark', 'Anderson']
    return f"{random.choice(first_names)} {random.choice(last_names)}"

# Function to generate a random user profile description
def generate_profile_description():
    name = generate_random_name()
    age = random.randint(20, 50)
    interest = random.choice(interests)
    location = random.choice(locations)
    occupation = random.choice(occupations)
    quote = random.choice(quotes)
    
    profile_description = f"Hi, I'm {name}! {age} years old. I'm passionate about {interest}. Based in {location}. {occupation} by profession. {quote}"
    
    return profile_description

# Example usage
profile_description = generate_profile_description()
print('Generated Profile Description:')
print(profile_description)

6 Random Password Generator

A simple random password generator to use for your OSINT accounts.

import random
import string

# Function to generate a random password
def generate_password(length=12):
    characters = string.ascii_letters + string.digits + string.punctuation
    password = ''.join(random.choice(characters) for _ in range(length))
    return password

# Example usage
password_length = 8  # Replace with your desired password length

# Generate a random password
password = generate_password(password_length)
print('Generated Password:', password)