Get data on IP addresses
Project description
Know Your IP
Get comprehensive data on IP addresses. Learn where they are located (lat/long, country, city, time zone), whether they are flagged as malicious (by AbuseIPDB, VirusTotal, IPVoid, etc.), which ports are open and what services are running (via Shodan), and network diagnostics (ping, traceroute).
🚀 What's New in v0.2.0
- Modern Configuration: TOML-based config with Pydantic validation
- VirusTotal API v3: Latest API with enhanced threat intelligence
- Embedded Categories: Self-contained AbuseIPDB category mapping
- Python 3.11+ Features: Match/case syntax, union types, type safety
- Performance Boost: No file I/O for category lookups
- Environment Variables: Configuration via
KNOW_YOUR_IP_*variables
Quick Start
Installation
Requirements: Python 3.11+
pip install know_your_ip
Basic Usage
Command Line
# Analyze single IP
know_your_ip 8.8.8.8
# Analyze from file
know_your_ip --file input.csv --config config.toml
Python Library
from know_your_ip import KnowYourIPConfig, query_ip
# Load configuration
config = KnowYourIPConfig()
config.virustotal.enabled = True
config.virustotal.api_key = "your_api_key"
# Analyze IP
result = query_ip(config, "8.8.8.8")
print(result['virustotal.reputation']) # 530
Configuration
TOML Configuration File
Create know_your_ip.toml:
[maxmind]
enabled = true
db_path = "./db"
[abuseipdb]
enabled = true
api_key = "your_api_key_here"
days = 90
[virustotal]
enabled = true
api_key = "your_api_key_here"
[output]
columns = [
"ip",
"maxmind.country.names.en",
"virustotal.reputation",
"abuseipdb.categories"
]
Environment Variables
export KNOW_YOUR_IP_VIRUSTOTAL_API_KEY="your_key"
export KNOW_YOUR_IP_VIRUSTOTAL_ENABLED=true
export KNOW_YOUR_IP_ABUSEIPDB_API_KEY="your_key"
Programmatic Configuration
from know_your_ip import KnowYourIPConfig
config = KnowYourIPConfig()
config.virustotal.api_key = "your_api_key"
config.abuseipdb.enabled = True
config.abuseipdb.days = 30
Supported Services
| Service | Features | API Required |
|---|---|---|
| MaxMind | Geolocation, ASN, ISP | Free database |
| VirusTotal | Threat reputation, categories | ✅ Free/Paid |
| AbuseIPDB | Abuse reports, categories | ✅ Free/Paid |
| Shodan | Open ports, services | ✅ Paid |
| Censys | Internet scanning data | ✅ Free/Paid |
| IPVoid | Blacklist status | Web scraping |
| GeoNames | Timezone data | ✅ Free |
| Ping/Traceroute | Network diagnostics | System tools |
API Registration Links
- VirusTotal - 500 requests/day, 4/min free
- AbuseIPDB - 1,000 requests/day free
- Shodan - Paid service ($69+/month)
- Censys - 250 requests/month free
- GeoNames - 10,000 requests/day, 1,000/hour free
Advanced Features
Pandas Integration
import pandas as pd
from know_your_ip import load_config, query_ip
# Load IPs from CSV
df = pd.read_csv('ips.csv')
# Load configuration
config = load_config()
# Analyze all IPs
results = df['ip'].apply(lambda ip: pd.Series(query_ip(config, ip)))
results.to_csv('analysis.csv', index=False)
Custom Analysis
from know_your_ip import maxmind_geocode_ip, virustotal_api
# Get only geolocation
location = maxmind_geocode_ip(config, "8.8.8.8")
print(f"Country: {location['maxmind.country.names.en']}")
# Get only threat intelligence
threat_data = virustotal_api(config, "8.8.8.8")
print(f"Malicious detections: {threat_data['virustotal.malicious']}")
Batch Processing
# Process large files with concurrency
know_your_ip --file large_ips.csv --max-conn 10 --config config.toml
# Process specific range
know_your_ip --file ips.csv --from 100 --to 200
API Reference
Core Functions
query_ip(config, ip)- Complete IP analysisload_config(path)- Load configuration from filemaxmind_geocode_ip(config, ip)- Geolocation datavirustotal_api(config, ip)- VirusTotal threat intelabuseipdb_api(config, ip)- Abuse reportsshodan_api(config, ip)- Port/service dataping(config, ip)- Network latencytraceroute(config, ip)- Network path
Configuration Classes
KnowYourIPConfig- Main configurationMaxMindConfig- Geolocation settingsVirusTotalConfig- Threat intel settingsAbuseIPDBConfig- Abuse data settingsOutputConfig- Output column configuration
Command Line Reference
usage: know_your_ip [-h] [-f FILE] [-c CONFIG] [-o OUTPUT] [-n MAX_CONN]
[--from FROM_ROW] [--to TO] [-v] [--no-header]
[ip [ip ...]]
Know Your IP - Comprehensive IP Address Analysis
positional arguments:
ip IP Address(es) to analyze
optional arguments:
-h, --help show this help message and exit
-f FILE, --file FILE List of IP addresses file
-c CONFIG, --config CONFIG
Configuration file (TOML format)
-o OUTPUT, --output OUTPUT
Output CSV file name
-n MAX_CONN, --max-conn MAX_CONN
Max concurrent connections
--from FROM_ROW From row number
--to TO To row number
-v, --verbose Verbose mode
--no-header Output without header
Rate Limits
| Service | Free Tier | Paid Tier |
|---|---|---|
| VirusTotal | 500/day, 4/min | Higher limits |
| AbuseIPDB | 1,000/day | 10,000+/day |
| Censys | 250/month, 1 req/2.5s | Higher limits |
| GeoNames | 10,000/day, 1,000/hour | Commercial plans |
| Shodan | No free API | $69+/month |
Examples
See the examples/ directory for:
- example.py - Basic usage examples
- example.ipynb - Jupyter notebook tutorial
- input.csv - Sample input file
- output.csv - Sample output
System Requirements
Dependencies
- Python 3.11+
- System
traceroutecommand (Linux) ortracert(Windows) - Raw socket access for ping (requires admin/root privileges)
Platform Support
- ✅ Linux
- ✅ macOS
- ✅ Windows
- ✅ Docker/containers
Documentation
For comprehensive documentation, visit: https://themains.github.io/know-your-ip/
Contributing
We welcome contributions! Please see our Contributing Guide and Code of Conduct.
License
Released under the MIT License.
Authors
Security Note: This tool is designed for legitimate security analysis, threat intelligence, and network diagnostics. Please use responsibly and in accordance with applicable laws and service terms of use.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file know_your_ip-0.2.1.tar.gz.
File metadata
- Download URL: know_your_ip-0.2.1.tar.gz
- Upload date:
- Size: 25.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ad4cea763659e9d2d56a243deeebcf73520626baf7c25e5696d8f13c00f2c7d
|
|
| MD5 |
4055330d27436993ee9b345e3f8b65b6
|
|
| BLAKE2b-256 |
0d28d09b68e77d769f5cb445bb897e9e799ec2e079b6dd5cdd43643b9621df12
|
Provenance
The following attestation bundles were made for know_your_ip-0.2.1.tar.gz:
Publisher:
python-publish.yml on themains/know-your-ip
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
know_your_ip-0.2.1.tar.gz -
Subject digest:
2ad4cea763659e9d2d56a243deeebcf73520626baf7c25e5696d8f13c00f2c7d - Sigstore transparency entry: 764245975
- Sigstore integration time:
-
Permalink:
themains/know-your-ip@b89bf01d5a313e3d0e5690d71cbb4e93d1de59bc -
Branch / Tag:
refs/heads/master - Owner: https://github.com/themains
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b89bf01d5a313e3d0e5690d71cbb4e93d1de59bc -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file know_your_ip-0.2.1-py3-none-any.whl.
File metadata
- Download URL: know_your_ip-0.2.1-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72d5a7d21bc0ddf0f409d3bef191e8697138c93fe410da0960529c83ad7e6b84
|
|
| MD5 |
0a98d89fe1529cea6c640c37e820b347
|
|
| BLAKE2b-256 |
030de5141791ccae07b793593746220c43400170af2d7d43aa4f7d6708714f4d
|
Provenance
The following attestation bundles were made for know_your_ip-0.2.1-py3-none-any.whl:
Publisher:
python-publish.yml on themains/know-your-ip
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
know_your_ip-0.2.1-py3-none-any.whl -
Subject digest:
72d5a7d21bc0ddf0f409d3bef191e8697138c93fe410da0960529c83ad7e6b84 - Sigstore transparency entry: 764245979
- Sigstore integration time:
-
Permalink:
themains/know-your-ip@b89bf01d5a313e3d0e5690d71cbb4e93d1de59bc -
Branch / Tag:
refs/heads/master - Owner: https://github.com/themains
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b89bf01d5a313e3d0e5690d71cbb4e93d1de59bc -
Trigger Event:
workflow_dispatch
-
Statement type: