jeffersongoncalves / laravel-ip-reputation
Check IP address reputation (VirusTotal) from Laravel, with free-tier rate limits and quota tracking built in
Package info
github.com/jeffersongoncalves/laravel-ip-reputation
pkg:composer/jeffersongoncalves/laravel-ip-reputation
Requires
- php: ^8.2
- illuminate/contracts: ^12.0|^13.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.24
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^3.0|^4.0
- pestphp/pest-plugin-laravel: ^3.0|^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-01 03:48:04 UTC
README
Laravel IP Reputation
Check the health of an IP address from Laravel against VirusTotal, AbuseIPDB, GreyNoise, AlienVault OTX, Shodan InternetDB, IPQualityScore and CrowdSec, all answering with the same Reputation object. Each driver respects its free-tier limits on its own (e.g. VirusTotal: 4 lookups/min, 500/day, 15.5K/month), results are cached so repeat checks cost nothing, and private addresses are refused before a lookup is spent.
Installation
composer require jeffersongoncalves/laravel-ip-reputation
Pick a default driver and add its key:
IP_REPUTATION_DRIVER=virustotal VIRUSTOTAL_API_KEY=your-key
Drivers
| Driver | Key (.env) |
Free tier (default limits) |
malicious / suspicious |
score |
|---|---|---|---|---|
virustotal |
VIRUSTOTAL_API_KEY |
4/min, 500/day, 15.5K/month | antivirus engines flagging it | community reputation, negative = bad |
abuseipdb |
ABUSEIPDB_API_KEY |
1,000 checks/day (+1,000 reports/day) | 1 from threshold (75) / 1 below it |
abuseConfidenceScore 0–100 |
greynoise |
GREYNOISE_API_KEY |
not published: set yours | classification malicious / suspicious; benign and known business services = harmless |
— |
otx |
OTX_API_KEY |
not published: set yours | threat pulses listing it (0 when OTX allowlists the IP) | OTX reputation |
shodan |
none (InternetDB, non-commercial) | not published | 1 with a tag in malicious_tags / one per known CVE |
— |
ipqualityscore |
IPQUALITYSCORE_API_KEY |
1,000 lookups (per_month) |
1 from threshold (90) / 1 from suspicious_threshold (75) |
fraud_score 0–100 |
crowdsec |
CROWDSEC_CTI_API_KEY |
not published: set yours | CTI reputation malicious / suspicious; safe, known = harmless |
scores.overall.total 0–5 |
tags carries what each provider adds: Tor/VPN/proxy flags, GreyNoise and CrowdSec behaviors, AbuseIPDB usage type and report count, Shodan's open ports and CVEs. An IP a provider has never seen (a 404) is a clean result, not an error.
Where a provider doesn't publish its free limits the defaults are null: a 429 still stops the calls until its Retry-After, and you can set your plan's numbers under drivers.<name>.limits.
Check one IP against another driver than the default:
IpReputation::check('1.2.3.4', driver: 'abuseipdb');
Reporting to AbuseIPDB
use JeffersonGoncalves\IpReputation\Drivers\AbuseIpDbDriver; $abuseipdb = IpReputation::driver('abuseipdb'); $abuseipdb->report('1.2.3.4', [AbuseIpDbDriver::WEB_APP_ATTACK, AbuseIpDbDriver::BAD_WEB_BOT], 'GET /.env'); // returns the IP's new abuse confidence score
Reports spend report_limits, not the check quota. AbuseIPDB takes the same IP once per 15 minutes; a refused report throws QuotaExceeded. The comment is public: never put personal data in it.
Publish the config (optional):
php artisan vendor:publish --tag="laravel-ip-reputation-config"
Usage
use JeffersonGoncalves\IpReputation\Facades\IpReputation; $reputation = IpReputation::check('1.2.3.4'); $reputation->verdict(); // 'malicious' | 'suspicious' | 'clean' $reputation->isMalicious(); // at least one engine says malicious $reputation->isMalicious(3); // at least three do $reputation->malicious; // engines flagging it malicious $reputation->suspicious; $reputation->harmless; $reputation->undetected; $reputation->score; // VirusTotal community reputation (negative = bad) $reputation->country; // 'BR' $reputation->asn; // 64500 $reputation->asOwner; // 'ACME' $reputation->network; // '1.2.3.0/24' $reputation->analyzedAt; // last VirusTotal analysis $reputation->checkedAt; // when we asked $reputation->toArray();
| Method | What it does |
|---|---|
check($ip, fresh: false) |
Cached result when it's younger than cache_ttl, otherwise one API call. fresh: true skips the cache. |
cached($ip) |
The cached result or null. Never calls the API. |
available() |
Whether one more lookup fits in the quota right now. |
driver()->quota()->remaining() |
['per_minute' => 3, 'per_day' => 497, 'per_month' => 15497] |
isPublic($ip) |
false for private, loopback, reserved and invalid addresses. |
check() throws:
InvalidArgumentExceptionfor a non-public or invalid address (no lookup spent).JeffersonGoncalves\IpReputation\Exceptions\QuotaExceededwhen a window is full. It carrieswindow(per_minute,per_day,per_month) andretryAfterin seconds, so a queued job canrelease($e->retryAfter).Illuminate\Http\Client\RequestExceptionfor other API errors.
Network (BGP and registry)
network() tells where an IP sits on the internet, from RIPEstat (free, no key), cached for a week:
$network = IpReputation::network('72.60.149.85'); $network->prefix; // '72.60.149.0/24' announced BGP prefix $network->asn; // 47583 $network->asName; // 'AS-HOSTINGER Hostinger Operations UAB' $network->registryCountry; // 'LT' country the block is registered to $network->registryBlock; // '72.60.0.0/16'
registryCountry is what country blocklists go by, not where the server stands: the IP above is a São Paulo VPS, yet geo-IP by registry reads Lithuania. It throws InvalidArgumentException for a non-public address and RequestException when RIPEstat fails.
Command
php artisan ip-reputation:check 1.2.3.4 php artisan ip-reputation:check 1.2.3.4 --fresh
Prints the verdict, every field and the quota left.
Quota
Counters are kept in the cache in calendar windows: the current minute, the UTC day (VirusTotal resets its daily quota at 00:00 UTC) and the UTC month. A call that would cross any limit is refused before it reaches the API and doesn't count. Each driver has its own counters. A 429 marks the window the provider most likely means as spent (the minute for VirusTotal, the day for AbuseIPDB) and throws QuotaExceeded with the provider's Retry-After when it sends one.
With a premium key, raise or remove the limits (null = unlimited):
'limits' => [ 'per_minute' => null, 'per_day' => null, 'per_month' => null, ],
Several servers sharing one key? Point IP_REPUTATION_CACHE_STORE at a shared store (redis, database) so they share the counters too.
Config
| Key | Env | Default |
|---|---|---|
driver |
IP_REPUTATION_DRIVER |
virustotal |
cache_ttl |
IP_REPUTATION_CACHE_TTL |
86400 (one day) |
cache_store |
IP_REPUTATION_CACHE_STORE |
default store |
drivers.<name>.api_key |
see Drivers | — |
drivers.<name>.timeout |
<NAME>_TIMEOUT |
10 |
drivers.<name>.limits |
— | the free tier, see Drivers |
drivers.abuseipdb.threshold / max_age_days / report_limits |
— | 75 / 90 / 1000 a day |
drivers.ipqualityscore.threshold / suspicious_threshold / strictness |
— | 90 / 75 / 0 |
drivers.shodan.malicious_tags |
— | compromised, malware, c2 |
Custom drivers
Implement JeffersonGoncalves\IpReputation\Contracts\Driver (or extend Drivers\HttpDriver for the quota, 429 and 404 handling) and register it:
IpReputation::extend('mine', fn ($app) => new MyDriver(...)); IpReputation::check('1.2.3.4', driver: 'mine');
Testing
composer test
Changelog
See CHANGELOG.
License
The MIT License (MIT). See License File.
