achillean / shodan-python Goto Github PK
View Code? Open in Web Editor NEWThe official Python library for Shodan
Home Page: https://developer.shodan.io
License: Other
The official Python library for Shodan
Home Page: https://developer.shodan.io
License: Other
The shodan init step only creates a local file to store the API key at the moment, it doesn't actually validate the key to make sure it will work with the API. Add another step during the initialization phase to ensure the key will actually work before returning a success message.
1.7.4 is 744ca96 and 1.7.5 is only on pypi and not here :/
shodan myip
currently returns only the IPv4 address of the host. Also returning the IPv6 address(es) would be a nice feature, too.
Provide a command to save the images contained in the banners into a separate file/ directory. The proposed command is:
shodan convert shodan-data.json.gz images
ls shodan-data-images/
1.1.1.1-3389.jpg
...
Fixed it, nvm
Hi,
I can't parse the file I just downloaded via my browser (used 1 credit for it) via the following command:
shodan parse --fields ip_str,port,org --separator , shodan-export.json.gz
tor , shodan-export.json.gz
Traceback (most recent call last):
File "/usr/local/bin/shodan", line 1223, in
main()
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/bin/shodan", line 516, in parse
for banner in helpers.iterate_files(filenames):
File "/usr/local/lib/python3.4/dist-packages/shodan/helpers.py", line 107, in iterate_files
for line in fin:
File "/usr/lib/python3.4/gzip.py", line 594, in readline
c = self.read(readsize)
File "/usr/lib/python3.4/gzip.py", line 365, in read
if not self._read(readsize):
File "/usr/lib/python3.4/gzip.py", line 453, in _read
uncompress = self.decompress.decompress(buf)
zlib.error: Error -3 while decompressing data: invalid distance too far back
Thanks
On release 1.7.2 the command-line interface to Shodan is unable to connect to the firehose.
Using the Host option works as expected. However, when I try to use Search to narrow down on a specific set of fields, all I get is an empty (blank) page with no data. At the bottom left corner, the page shows "lines 1-1/1 (END)".
Like this:
In place of
# Add the field information to the row
row += tmp + separator
use
# Add the field information to the row
row += tmp
row += separator
shodan has a dependency on simplejson, but setup.py imports shodan to grab the version and that fails if simplejson is missing.
pip install https://github.com/achillean/shodan-python/archive/master.zip
Downloading/unpacking https://github.com/achillean/shodan-python/archive/master.zip
Downloading master.zip (unknown size): 7.1kB downloaded
Running setup.py egg_info for package from https://github.com/achillean/shodan-python/archive/master.zip
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/var/folders/t1/2_lj1kls35ldty1jb2bs0znr0000gn/T/pip-7_kNm9-build/setup.py", line 5, in <module>
from shodan import __version__ as version
File "shodan/__init__.py", line 1, in <module>
from .api import WebAPI
File "shodan/api.py", line 2, in <module>
from simplejson import dumps, loads
ImportError: No module named simplejson
Add a simple man-page for the "shodan" command-line interface that provides general guidelines/ principles on how to use the CLI. Also include examples for common use-cases.
Suggested by Nux: https://twitter.com/ItsNux
$ shodan scan submit 217.113.224.201
Starting Shodan scan at 2016-09-01 16:09 - 65534 scan credits left
No open ports found or the host has been recently crawled and cant get scanned again so soon.
I tried many different IPs and none of them returned any different messages, yet my scan credits get deducted. Why?
Error:Please upgrade your API plan to use filters or paging
Do i need to pay for some plans?
shodan search port:80 country:"MX"
Error: Invalid API key
When you do shodan --help the results are:
Commands:
count Returns the number of results for a search
download Download search results and save them in a...
init Initialize the Shodan command-line
myip Print your external IP address
parse Extract information out of compressed JSON...
scan Returns the number of results for a search
search Search the Shodan database
The Scan info should be Scan a network using Shodan.
github.com/achillean/shodan-python/blob/8258321b8e7d6f9b320dd30c05931c0e4c32d4ab/bin/shodan#L234
Getting JSON errors with both search and host functions, generally if I rerun the query it will work.
No problems accessing results via shodan web interface or via direct API call.
File "C:\Python27\lib\site-packages\shodan\client.py", line 198, in host
return self._request('/shodan/host/%s' % ','.join(ips), params)
File "C:\Python27\lib\site-packages\shodan\client.py", line 158, in _request
raise APIError('Unable to parse JSON response')
shodan.exception.APIError: Unable to parse JSON response
Running under debugger the response object shows:
'
<title>502 Bad Gateway</title>Me and at least one other person are having trouble using this api recently. I use it in a tool here: https://github.com/DanMcInerney/device-pharmer
I am getting shodan results exactly as the docs for this API suggest to do it, namely:
api = shodan.Shodan(API_KEY)
results = api.search(search, page=1)
Yet even when I use my own paid-for API key, I'm getting "Unable to connect to Shodan" errors. Any idea what's going wrong?
Hey, I installed the shodan python module earlier today and tried running a few queries. Here's what happens:
>>> from shodan import WebAPI >>> api = WebAPI("xxx") >>> api.exploits.search('cve-2011-1255') Traceback (most recent call last): File "", line 1, in File "build/bdist.macosx-10.8-intel/egg/shodan/api.py", line 58, in search File "build/bdist.macosx-10.8-intel/egg/shodan/api.py", line 159, in _request File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 126, in urlopen return _opener.open(url, data, timeout) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 400, in open response = meth(req, response) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 513, in http_response 'http', request, response, code, msg, hdrs) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 438, in error return self._call_chain(*args) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 372, in _call_chain result = func(*args) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 521, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 502: Bad Gateway
Provide a new parameter in the CLI to store the data from the firehose in specified file size chunks. For example, the following command stores information in the firehose-data directory and once a file size gets above 100MB it creates a new data file in the directory:
shodan stream --datadir firehose-data/ --chunk=100M
I use the command "shodan init [mykey]", and the response is "Error: Invalid API key".
My friend use the same command, he can use without any problems.
I installed shodan by "pip install shodan" in MacOS.
Strangely, the search only works with apache
api = shodan.Shodan(SHODAN_API_KEY)
# Wrap the request in a try/ except block to catch errors
# Search Shodan
results = api.search('apache')
whatever else I search it outputs this error:
results = api.search('test')
Traceback (most recent call last):
File "C:\Users\Daniel\Anaconda3\lib\site-packages\shodan-1.5.6-py3.5.egg\shodan\client.py", line 175, in _request
File "C:\Users\Daniel\Anaconda3\lib\site-packages\requests\models.py", line 826, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\Daniel\Anaconda3\lib\site-packages\simplejson-3.10.0-py3.5-win-amd64.egg\simplejson\__init__.py", line 516, in loads
return _default_decoder.decode(s)
File "C:\Users\Daniel\Anaconda3\lib\site-packages\simplejson-3.10.0-py3.5-win-amd64.egg\simplejson\decoder.py", line 374, in decode
obj, end = self.raw_decode(s)
File "C:\Users\Daniel\Anaconda3\lib\site-packages\simplejson-3.10.0-py3.5-win-amd64.egg\simplejson\decoder.py", line 404, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "sh.py", line 13, in <module>
results = api.search('test')
File "C:\Users\Daniel\Anaconda3\lib\site-packages\shodan-1.5.6-py3.5.egg\shodan\client.py", line 332, in search
File "C:\Users\Daniel\Anaconda3\lib\site-packages\shodan-1.5.6-py3.5.egg\shodan\client.py", line 177, in _request
shodan.exception.APIError: Unable to parse JSON response
Am I missing something?
Hi, there.
I run the sample code in your python docs pages.
However, it returned an error.
Error: Unable to parse JSON response
Most of time the api will return errors although sometimes it can successfully execute. And I really don't know why.
My os is Win10 and I also tried it at Win7. Doesn't work too.
While shodan/api.py
contains the correct imports, shodan/cli/worldmap.py
always tries to import the python2-only module.
In some cases the Shodan CLI will report an accurate count of what it knows regarding Open ports. But then what it lists below in the Ports section doesn't match up with the count.
Example 1:
Number of open ports: 8
Ports:
2082
2083
|-- SSL Versions: TLSv1, TLSv1.1, TLSv1.2
2086
2087
|-- SSL Versions: TLSv1, TLSv1.1, TLSv1.2
8080
8880
Missing: 443 and 8443. The UI shows all 8.
Example 2:
Number of open ports: 9
Vulnerabilities: CVE-2015-0204 CVE-2015-4000
Ports:
22 OpenSSH (5.3)
53
53
80 Apache httpd (2.2.15)
465
|-- SSL Versions: TLSv1, TLSv1.1, TLSv1.2
|-- Diffie-Hellman Parameters:
Bits: 2048
Generator: 2
587
|-- SSL Versions: TLSv1, TLSv1.1
636
|-- SSL Versions: SSLv3, TLSv1, TLSv1.1, TLSv1.2
|-- Diffie-Hellman Parameters:
Bits: 2048
Generator: 2
993
|-- SSL Versions: SSLv3, TLSv1, TLSv1.1, TLSv1.2
|-- Diffie-Hellman Parameters:
Bits: 1024
Generator: 2
Fingerprint: RFC2409/Oakley Group 2
Missing: 8443. The UI shows all 9.
In the implementation of the basic search example, using shodan.Shodan(SHODAN_API_KEY) throws an error.
I think it should be shodan.WebAPI(SHODAN_API_KEY)
It doesn't make sense that a user would ever want to download 0 results, therefore treat it the same as a user that wants to download all results (i.e. "-1").
By default, the Streaming API sends heartbeat messages every few seconds to ensure the connection remains open and doesn't timeout. However, the shodan scan command relies on the lack of data going through as an indicator that a scan has finished. As a result, an on-demand scan via the CLI doesn't finish at the moment.
Can we have python 3 support
[~/repos/shodan]$ python --version
Python 2.6.6
[~/repos/shodan]$ shodan count linux
10786267
[~/repos/shodan]$ shodan host 8.8.8.8
8.8.8.8
Traceback (most recent call last):
File "/usr/bin/shodan", line 4, in <module>
__import__('pkg_resources').run_script('shodan==1.3.8', 'shodan')
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 742, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 1674, in run_script
exec(script_code, namespace, namespace)
File "/usr/lib/python2.6/site-packages/shodan-1.3.8-py2.6.egg/EGG-INFO/scripts/shodan", line 1134, in <module>
File "/usr/lib/python2.6/site-packages/click-6.2-py2.6.egg/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/click-6.2-py2.6.egg/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/lib/python2.6/site-packages/click-6.2-py2.6.egg/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python2.6/site-packages/click-6.2-py2.6.egg/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python2.6/site-packages/click-6.2-py2.6.egg/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/shodan-1.3.8-py2.6.egg/EGG-INFO/scripts/shodan", line 488, in host
ValueError: zero length field name in format
[~/repos/shodan]$ shodan alert
Usage: shodan alert [OPTIONS] COMMAND [ARGS]...
Options:
-h, --help Show this message and exit.
Commands:
clear Remove all alerts
list List all the active alerts
remove Remove the specified alert
[~/repos/shodan]$ shodan alert list
Traceback (most recent call last):
File "/usr/bin/shodan", line 4, in <module>
__import__('pkg_resources').run_script('shodan==1.3.8', 'shodan')
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 742, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 1674, in run_script
exec(script_code, namespace, namespace)
File "/usr/lib/python2.6/site-packages/shodan-1.3.8-py2.6.egg/EGG-INFO/scripts/shodan", line 1134, in <module>
File "/usr/lib/python2.6/site-packages/click-6.2-py2.6.egg/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/click-6.2-py2.6.egg/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/lib/python2.6/site-packages/click-6.2-py2.6.egg/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python2.6/site-packages/click-6.2-py2.6.egg/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python2.6/site-packages/click-6.2-py2.6.egg/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python2.6/site-packages/click-6.2-py2.6.egg/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/lib64/python2.6/contextlib.py", line 34, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib/python2.6/site-packages/click-6.2-py2.6.egg/click/core.py", line 86, in augment_usage_errors
yield
File "/usr/lib/python2.6/site-packages/click-6.2-py2.6.egg/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/shodan-1.3.8-py2.6.egg/EGG-INFO/scripts/shodan", line 351, in alert_list
ValueError: zero length field name in format
#!/usr/bin/env python
# Initialize Shodan
import shodan
api = shodan.Shodan("API_KEY")
# Create a new alert
alert = api.create_alert('desktops', CRAZY/24')
try:
# Subscribe to data for the created alert
for banner in api.stream.alert(alert['id']):
print banner
except:
# Cleanup if any error occurs
api.delete_alert(alert['id'])
There is no way to control timeout with the Shodan module. Maybe a timeout variable could be exposed to allow control for these scenarios?
root@kali:~# ./collecting_info_using_facets.py apache
Traceback (most recent call last):
File "./collecting_info_using_facets.py", line 3, in
import shodan
ImportError: No module named shodan
It would be nice to be presented with a clean list of just the ports Shodan has found without the TLS/SSL and banner information on by default.
Proposed:
Ports:
22 tcp
53 tcp
53 udp
80 tcp
465 tcp
587 tcp
636 tcp
993 tcp
(plus please see my previous post on adding the TCP/UDP flag)
Ports:
22 tcp OpenSSH (5.3)
53 tcp
53 udp
80 tcp Apache httpd (2.2.15)
465 tcp
|-- SSL Versions: TLSv1, TLSv1.1, TLSv1.2
|-- Diffie-Hellman Parameters:
Bits: 2048
Generator: 2
587 tcp
|-- SSL Versions: TLSv1, TLSv1.1
636 tcp
|-- SSL Versions: SSLv3, TLSv1, TLSv1.1, TLSv1.2
|-- Diffie-Hellman Parameters:
Bits: 2048
Generator: 2
993 tcp
|-- SSL Versions: SSLv3, TLSv1, TLSv1.1, TLSv1.2
|-- Diffie-Hellman Parameters:
Bits: 1024
Generator: 2
Fingerprint: RFC2409/Oakley Group 2
It would be helpful if to the right of the ports listed, Shodan would display if the port is being identified as TCP or UDP. In most cases, assuming that it's TCP isn't wrong. However, in a few cases I've seen 53 listed and thought it was likely UDP only to check the UI and find out that it's actually TCP.
Example:
Ports:
22 OpenSSH (5.3)
53
53
Mockup:
Ports:
22 TCP OpenSSH (5.3)
53 TCP
53 UDP
Just bought a shodan member on Black Friday.So I want to use python3 to prepare a small script about shodan,however,I can't find the search equipment about shodan api.so,I want get the shodan search api address.example:api.search("") https://api.shodan.io/query={}&key={}
can you help me?
In shodan/wps.py, the GoogleLocation will not work anymore.
https://code.google.com/p/gears/wiki/GeolocationAPI:
Since Google Gears has been shut down since March 2011, the time has come to also say goodbye to the Geolocation API that powered Google Gears. The Google Gears Geolocation API will stop responding to requests on November 17, 2012.
According to StackOverflow you should look into Google location API. Example:
https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_API_KEY
{
"homeMobileCountryCode": 310,
"homeMobileNetworkCode": 260,
"radioType": "gsm",
"carrier": "T-Mobile",
"cellTowers": [
{
"cellId": 39627456,
"locationAreaCode": 40495,
"mobileCountryCode": 310,
"mobileNetworkCode": 260,
"age": 0,
"signalStrength": -95
}
],
"wifiAccessPoints": [
{
"macAddress": "01:23:45:67:89:AB",
"signalStrength": 8,
"age": 0,
"signalToNoiseRatio": -65,
"channel": 8
}
]
}
shodan myip
/usr/local/lib/python2.7/dist-packages/requests-2.6.0-py2.7.egg/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
did i missed something or this is a known issue.
Python queries with utf-8 encoding returns 0 results. But those same strings used on the shodan website work. For example, I tried searching this (it means welcome in Chinese): 220-欢迎
More than 600 results according to shodanhq.com
But 0 results when using the Python api.
Hello. I try to use shodan python an always have the same error: Error: Unable to parse JSON response.
I have a Freelancer developer account and have credits remaining (more than 8000).
I try the Basic Shodan Search (https://github.com/achillean/shodan-python/blob/master/docs/examples/basic-search.rst):
import shodan
import sys
API_KEY = "YOUR_API_KEY"
if len(sys.argv) == 1:
print 'Usage: %s ' % sys.argv[0]
sys.exit(1)
try:
# Setup the api
api = shodan.Shodan(API_KEY)
# Perform the search
query = ' '.join(sys.argv[1:])
result = api.search(query)
# Loop through the matches and print each IP
for service in result['matches']:
print service['ip_str']
except Exception, e:
print 'Error: %s' % e
sys.exit(1)
Reading large files can take a lot of time/ memory. Try out a variety of other JSON libraries with C bindings and see whether we could move the project to use those.
shodan init
places the api key in a world-readable text file under ~/.shodan/
.
I believe this file should be created w/ 600 permissions.
Hi
I installed shodan-python with python 3
The program crash on the initialization on init key
Traceback (most recent call last):
File "/usr/local/bin/shodan", line 30, in
import shodan
File "/usr/local/lib/python3.5/dist-packages/shodan/init.py", line 2, in
from shodan.client import Shodan
File "/usr/local/lib/python3.5/dist-packages/shodan/client.py", line 16, in
from .helpers import api_request
File "/usr/local/lib/python3.5/dist-packages/shodan/helpers.py", line 155
(1<<50L, 'PB'),
^
SyntaxError: invalid syntax
This happen because in python 3 long integer are now parts of int and the L is not need anymore:
https://docs.python.org/3/whatsnew/3.0.html
I removed the L from
abbrevs = (
(1<<50L, 'PB'),
(1<<40L, 'TB'),
(1<<30L, 'GB'),
(1<<20L, 'MB'),
(1<<10L, 'kB'),
(1, 'bytes')
)
and works in python 3
But you also have a problem with python 2 because the division round the result
If you try with this:
humanize_bytes(102412341111,1)
You will obtain 1.0 and not 1.3 as expected
The problem is in
bytes / factor
you need to define factor as long to force python 2 to use long and have correct results
bytes / long(factor)
This is a proposal function that works correctly with python 2 and 3
def humanize_bytes(bytes, precision=1):
"""Return a humanized string representation of a number of bytes.
>>> humanize_bytes(1)
'1 byte'
>>> humanize_bytes(1024)
'1.0 kB'
>>> humanize_bytes(1024*123)
'123.0 kB'
>>> humanize_bytes(1024*12342)
'12.1 MB'
>>> humanize_bytes(1024*12342,2)
'12.05 MB'
>>> humanize_bytes(1024*1234,2)
'1.21 MB'
>>> humanize_bytes(1024*1234*1111,2)
'1.31 GB'
>>> humanize_bytes(1024*1234*1111,1)
'1.3 GB'
"""
abbrevs = (
(1<<50, 'PB'),
(1<<40, 'TB'),
(1<<30, 'GB'),
(1<<20, 'MB'),
(1<<10, 'kB'),
(1, 'bytes')
)
if bytes == 1:
return '1 byte'
for factor, suffix in abbrevs:
if bytes >= factor:
break
return '%.*f %s' % (precision, bytes / float(factor), suffix)
Also I would like to propose this new functions that does not need the shift and works directly with division and not need break (based on diveintopython3)
Please note that in this one the minimum results are reported in kb
for example 10 B are reported as 0.010 kb
def humanize_bytes(bytes, precision=1):
"""Return a humanized string representation of a number of bytes.
>>> humanize_bytes(1)
'1 byte'
>>> humanize_bytes(1024)
'1.0 kB'
>>> humanize_bytes(1024*123)
'123.0 kB'
>>> humanize_bytes(1024*12342)
'12.1 MB'
>>> humanize_bytes(1024*12342,2)
'12.05 MB'
>>> humanize_bytes(1024*1234,2)
'1.21 MB'
>>> humanize_bytes(1024*1234*1111,2)
'1.31 GB'
>>> humanize_bytes(1024*1234*1111,1)
'1.3 GB'
"""
if bytes == 1:
return '1 byte'
if bytes < 1024:
return '%.*f %s' % (precision, bytes, "bytes")
suffixes = ['KB', 'MB', 'GB', 'TB', 'PB']
multiple = 1024.0 #.0 force float on python 2
for suffix in suffixes:
bytes /= multiple
if bytes < multiple:
return '%.*f %s' % (precision, bytes, suffix)
hi everybody, I'm trying to execute a python file with the next code in windows.
try:
import shodan
except:
print "shodan doesn't import"
SHODAN_API_KEY = "3JpvEP8hK266ZAPoc5FT2plFpON4hylA"
api = shodan.Shodan(SHODAN_API_KEY)
try:
# Search Shodan
results = api.search('apache')
# Show the results
print 'Results found: %s' % results['total']
for result in results['matches']:
print 'IP: %s' % result['ip_str']
print result['data']
print ''
except shodan.APIError, e:
print 'Error: %s' % e
get this error:
shodan doesn't import
Traceback (most recent call last):
File "C:\Users\Usuario.Usuario-PC\Desktop\shodan.py", line 8, in <module>
api = shodan.Shodan(SHODAN_API_KEY)
NameError: name 'shodan' is not defined
Also I tried to execute it on ubuntu and i get the same error:
import shodan
SHODAN_API_KEY = "3JpvEP8hK266ZAPoc5FT2plFpON4hylA"
api = shodan.Shodan(SHODAN_API_KEY)
try:
# Search Shodan
results = api.search('apache')
# Show the results
print 'Results found: %s' % results['total']
for result in results['matches']:
print 'IP: %s' % result['ip_str']
print result['data']
print ''
except shodan.APIError, e:
print 'Error: %s' % e
Traceback (most recent call last):
File "shodan.py", line 1, in <module>
import shodan
File "/home/user/shodan.py", line 4, in <module>
api = shodan.Shodan(SHODAN_API_KEY)
AttributeError: 'module' objet has no attribute 'Shodan'
What's up ?
I did install shodan from pip
(pip install shodan or easy_install shodan)
Add 2 new options to the shodan host command:
-O/ --filename: Save the results into the specified file
-S/ --save: Save the results into a filename with the name of the IP
The api is quite slow...
The uri should be updated to api.shodan.io
, as http://www.shodanhq.com/api/
is outdated and needs to be redirected.
The requests
library is also quicker than urlib
, so maybe this could be updated as well.
Both these issues I saw in api.py
It would be nice if search results have an optional property of a CVE number where the result is affected by. I know there is a filter available for that (example: vuln:cve-2014-0160) but in the output the results contain no clue of that CVE number.
Also: is there any list available of currently supported CVE numbers detected by Shodan?
Tried launching "shodan --help" and received below error:
root@b0x:~/Desktop/Research/shodan-python# shodan --help
Traceback (most recent call last):
File "/usr/local/bin/shodan", line 4, in
import('pkg_resources').run_script('shodan==1.6.5', 'shodan')
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 739, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 1486, in run_script
raise ResolutionError("No script named %r" % script_name)
pkg_resources.ResolutionError: No script named 'shodan'
The .json() is in some cases not callable, when removing the () it will work..
See: http://love-python.blogspot.nl/2013/03/dict-object-is-not-callable-on-json.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.