./BACK_TO_PROJECTS
Genesis Project2025

Python Info-Gathering Tool

The foundation of my offensive security journey. A CLI utility demonstrating core networking concepts: DNS Resolution, IP Geolocation, and API Integration.

Execution Flow

01. Target Input

CLI arguments accept the target domain URL.

USER INPUT● RECEIVED
> python infotool.py google.com
SOCKETRESOLVING
Host: google.com
IP: 142.251.42.46

02. DNS Resolution

Uses Python's native `socket` library to resolve the hostname to its underlying IPv4 address.

03. Geolocation Lookup

Queries the `ipinfo.io` REST API to enrich the IP data with physical location, ISP, and timezone.

JSON RESPONSE200 OK
"city": "Mumbai", "loc": "19.07,72.88"

Core Logic

A minimalist implementation of networking basics. This script was my first exploration into automating data retrieval using Python.

Python
infotool.py
import sys, requests, socket

# 1. Input Validation
if len(sys.argv) != 2:
    print("Usage: python infotool.py <websiteurl>")
    sys.exit(1)

website_url = sys.argv[1]

try:
    # 2. DNS Resolution
    ip_address = socket.gethostbyname(website_url)
    print(f"IP Address: {ip_address}")

    # 3. API Request for Geolocation
    response = requests.get(f"https://ipinfo.io/{ip_address}/json")
    
    if response.status_code == 200:
        data = response.json()
        print(f"City: {data.get('city')}")
        print(f"Region: {data.get('region')}")
        print(f"Coordinates: {data.get('loc')}")
        
except socket.gaierror:
    print("Error: Could not resolve hostname.")

Key Learnings

Networking

Understood the translation of Hostnames to IP addresses via DNS and the structure of IPv4.

REST APIs

Learned how to programmatically fetch data from external services (ipinfo.io) using HTTP GET requests.

Error Handling

Implemented basic exception handling (Try/Except) to manage connection timeouts and invalid domains.

See How I Started