rattfieldnz/shodan

A laravel package to check URLs with Shodan API.


README

PHP Version PHP Version License: MIT Latest Version on Packagist Total Downloads Build Status StyleCI Scrutinizer Code Quality codecov

A laravel package to check URLs with Shodan API.

Installation

Install via composer

composer require rattfieldnz/shodan

Register Service Provider

Note! This and next step are optional if you use laravel>=5.5 with package auto discovery feature.

Add service provider to config/app.php in providers section.

RattfieldNz\Shodan\ShodanServiceProvider::class,

Register Facade

Register package facade in config/app.php in aliases section

RattfieldNz\Shodan\Facades\ShodanFacade::class,

Publish Configuration File

php artisan vendor:publish --provider="RattfieldNz\Shodan\ShodanServiceProvider" --tag="shodan"

Set your Shodan API key

In your .env, add:

SHODAN_API_KEY=YOUR-ACTUAL-API-KEY
SHODAN_REQUEST_TIMEOUT=10

Usage

Using Blade Syntax

@if(isset(Shodan::setUrl('https://github.com')->check()->getResults()))
    // Iterate over associative array results.
    // getResults(true) returns results as JSON-encoded string.
@else
    <p>No results were found</p>
@endif

getResults(true) returns results as JSON-encoded string.

Using Facades

Shodan::setUrl('https://github.com');
Shodan::check();
Shodan::getResults();

Or:

Shodan::setUrl('https://github.com')->check()->getResults();

Example with input and output (associative array)

View EXAMPLE_INPUT_OUTPUT_ASSOCIATIVEARRAY.md.

Example with input and output (JSON)

View EXAMPLE_INPUT_OUTPUT_JSON.md.

Testing

From inside the root folder of this package:

$ chmod u+x run_phpunit && ./run_phpunit YOUR_SHODAN_API_KEY

Replace YOUR_SHODAN_API_KEY with your actual key. Get one by visiting https://developer.shodan.io/api.

Security

If you discover any security related issues, please email emailme@robertattfield.com instead of using the issue tracker.

Credits

This package is bootstrapped with the help of melihovv/laravel-package-generator.