Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/achillean/shodan-perl

Perl library for SHODAN
https://github.com/achillean/shodan-perl

Last synced: 2 months ago
JSON representation

Perl library for SHODAN

Awesome Lists containing this project

README

        

Shodan

Visit the official Shodan API documentation at:

[http://docs.shodanhq.com](http://docs.shodanhq.com)

INSTALLATION

To install this module, run the following commands:

perl Makefile.PL
make
make install

SUPPORT AND DOCUMENTATION

Before you can use the API, you need to have an API key.

Get your API key here: http://www.shodanhq.com/api_doc

Setup the SHODAN WebAPI:

use Shodan::WebAPI;

$api = new Shodan::WebAPI(MY_API_KEY);

Print a list of cisco-ios devices:

$result = $api->search("cisco-ios");
foreach $host ( @{$result->{'matches'}} ) {
print $host{'ip'} . "\n";
}

Get all the information SHODAN has on the IP 217.140.75.46:

$host = $api->host('217.140.75.46');
print $host['ip'];

Search the ExploitDB archive:
$results = $api->exploitdb_search('PHP', { author => 'nuffsaid' });
print 'Total results: ' . $results-{'total'};
my @matches = @{$result->{'matches'}};
for ( my $i = 0; $i < $#matches; $i++ ) {
print "$matches[$i]{id}\n";
}

Download an exploit from ExploitDB:
# $exploit = $matches[0];
$file = $api->exploitdb_download( $exploit{id} );
print "Filename: $file{'filename'}\n";

Make sure to check whether the API results contain the 'error' key, and if so handle the
error appropriately:

if ( $result->{'error'} ) {
print "Error: " . $result->{'error'} . "\n";
# Do other error-handling
}

LICENSE AND COPYRIGHT

Copyright (c) 2010 John Matherly

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise
to promote the sale, use or other dealings in this Software
without prior written authorization.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.