AbuseIPdbSCAN
Python Scanner for passing IP addresses and utilizing AbuseIPdb API to find bad IPs
Install / Use
/learn @mikebanks/AbuseIPdbSCANREADME
AbuseIPDB Scanner
Query AbuseIPDB for IPs, CIDR blocks, files of IPs, or full country allocations, and export results as CSV, TSV, JSON, or JSONL. Designed for quick lookups, bulk workflows, and downstream automation/AI ingestion.
Current version: 2.2.1 Release notes: https://github.com/mikebanks/AbuseIPdbSCAN/releases/tag/v2.2.1
Features
- Single IP and CIDR block lookups (AbuseIPDB v2)
- File parsing for IPv4 lists (deduplicated)
- Country-wide scanning via allocation lists (NirSoft)
- Multiple output formats: CSV, TSV, JSON, JSONL
- Optional category name translation for reports
Quickstart
git clone https://github.com/mikebanks/AbuseIPdbSCAN.git
cd AbuseIPdbSCAN
python3 -m pip install -r requirements.txt
Configure your AbuseIPDB API key (see Configuration). Then run, for example:
python3 AbuseIPDB.py -i 1.1.1.1 -j result.json
Requirements
- Python 3.10+ (enforced at runtime; tested with 3.13)
- Dependencies in
requirements.txt
Install with pip:
python3 -m pip install -r requirements.txt
Or with Pipenv:
pipenv install
pipenv run python AbuseIPDB.py -v
Installation
Install the CLI as a package (pure Python, no compiled extensions):
# From a clone
python3 -m pip install .
# Or directly from GitHub (latest tagged)
python3 -m pip install \
"git+https://github.com/mikebanks/AbuseIPdbSCAN.git@v2.2.1"
This installs a console script abuseipdb-scan on your PATH:
abuseipdb-scan -v
abuseipdb-scan -i 8.8.8.8 -j out.json
Configuration
You need an AbuseIPDB API key. See the official docs: https://docs.abuseipdb.com/
The tool reads API_KEY from environment variables or a local .env file:
- Option A (environment):
export API_KEY=your_key_here - Option B (dotenv file): create a
.envin the repo root with:
API_KEY=your_key_here
You can interactively create .env using: python3 AbuseIPDB.py --init.
Usage
General form (write results to a file when using a format flag):
python3 AbuseIPDB.py [INPUT] [OPTIONS]
Inputs (choose one):
-i, --ip <IP>: Lookup a single IP address-b, --block <CIDR>: Lookup a CIDR block (AbuseIPDB accepts /24 or smaller)-f, --file <path>: Parse a file and lookup all IPv4 addresses found-cc, --countrycode <cc>: Scan all /24 subnets for a country code (NirSoft list)
Options:
-d, --days <int>: Max age of reports to include (default: 30)-x, --translate: Translate numeric categories to names when present-v, --version: Show version and exit--init: Interactively create.envwithAPI_KEY--limit <int>: Limit number of /24 subnets processed during--countrycode--sleep <float>: Seconds to sleep between API calls (helpful for rate limits)
Output formats (provide a filename to write results):
-j, --json <file>: JSON array (recommended for sharing)-l, --jsonl <file>: JSON Lines, one object per line (recommended for AI/ETL)-c, --csv <file>: Comma-separated values-t, --tsv <file>: Tab-separated values
Note: If no output flag is provided, results print to stdout as pretty JSON. Prefer --json/--jsonl when writing to files.
Examples
Single IP (pretty JSON saved to a file):
python3 AbuseIPDB.py -i 8.8.8.8 -j out.json
CIDR block (/24 or smaller):
python3 AbuseIPDB.py -b 1.1.1.0/24 -l out.jsonl
Parse a file of IPs and translate categories to names:
python3 AbuseIPDB.py -f example_list.txt -x -j out.json
Scan all /24s in a country (heavy; mind rate limits):
python3 AbuseIPDB.py -cc nz --limit 50 --sleep 0.5 -l nz.jsonl
Sample outputs are in reports/:
reports/example_list.jsonreports/example_list.jsonlreports/example_list.csvreports/example_list.tsv
You can also run a quickstart script with common invocations:
bash examples/quickstart.sh
Outputs are written to examples/out/.
Output Schema (overview)
Returned objects mirror AbuseIPDB v2 responses with a few conveniences. Typical top-level fields include:
ipAddress,ipVersion,isPublic,isWhitelistedcountryCode,countryName,domain,isp,usageTypeabuseConfidenceScore,totalReports,numDistinctUsers,lastReportedAtreports: list of report objects withcategories,comment,reportedAt,reporterCountryCode,reporterCountryName,reporterId
When --translate is used on IP lookups, reports[*].categories will contain category names instead of integers.
Example (truncated):
{
"ipAddress": "8.8.8.8",
"abuseConfidenceScore": 0,
"totalReports": 15,
"reports": [
{ "categories": [15], "comment": "…", "reportedAt": "2020-04-02T01:32:48+01:00" }
]
}
Notes for Automation and AI
- Prefer
--jsonlfor large/batch jobs; it’s line-delimited and stream-friendly. - Keys are stable and predictable; JSON output uses sorted keys for consistency.
- Use
--translateto convert numeric categories to readable labels before ingestion. - For reproducibility, pin
requirements.txtand record CLI invocations alongside outputs.
Troubleshooting
- Private IPs: Private addresses/blocks are skipped with a message.
- Large blocks: AbuseIPDB requires /24 or smaller; larger blocks will be rejected.
- HTTP 429/5xx: The tool includes basic retries with exponential backoff and timeouts on network calls. If issues persist, try again later.
- Country scans: This uses NirSoft allocation data. Invalid codes return 404; see https://www.nirsoft.net/countryip/ for available codes. Country scans can be slow and may hit rate limits.
- Use
--limitto cap subnets and--sleepto throttle requests.
- Use
Contributing
Read AGENTS.md for repository-specific setup steps, coding standards, and pull request expectations.
Implementation Notes
- Network calls use timeouts and limited retries with exponential backoff.
- All output writers normalize inputs to lists of objects; single lookups are wrapped automatically.
- Private IPs/blocks are skipped rather than returned as strings, with messages sent to stderr.
- Category labels cover AbuseIPDB categories 0–23.
Security and Privacy
- Keep your
API_KEYsecret. Do not commit.envfiles. - Outputs may contain reporter metadata and comments. Handle and share responsibly.
Acknowledgements
- AbuseIPDB: https://www.abuseipdb.com/
- NirSoft Country IP Lists: https://www.nirsoft.net/countryip/
License
No license file is present in this repository. If you plan to use or distribute this project, please open an issue to clarify licensing.
Related Skills
node-connect
348.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
348.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
348.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
