Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Error only when using Radar #74

Closed
seajaysec opened this issue Aug 1, 2018 · 5 comments
Closed

API Error only when using Radar #74

seajaysec opened this issue Aug 1, 2018 · 5 comments

Comments

@seajaysec
Copy link

seajaysec commented Aug 1, 2018

I receive the following success message after performing shodan init {MY_API_KEY}:

Successfully initialized

And can run all commands I've tested without issue, save for shodan radar, which returns the following error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/shodan/cli/worldmap.py", line 205, in fetch_data
    for banner in self.api.stream.banners():
  File "/usr/local/lib/python3.7/site-packages/shodan/stream.py", line 99, in banners
    stream = self._create_stream('/shodan/banners', timeout=timeout)
  File "/usr/local/lib/python3.7/site-packages/shodan/stream.py", line 50, in _create_stream
    raise APIError(data['error'])
shodan.exception.APIError: Access denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/shodan", line 11, in <module>
    load_entry_point('shodan==1.8.1', 'console_scripts', 'shodan')()
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/shodan/__main__.py", line 1331, in radar
    launch_map(api)
  File "/usr/local/lib/python3.7/site-packages/shodan/cli/worldmap.py", line 242, in launch_map
    return curses.wrapper(app.run)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/local/lib/python3.7/site-packages/shodan/cli/worldmap.py", line 222, in run
    refresh = self.fetch_data(now)
  File "/usr/local/lib/python3.7/site-packages/shodan/cli/worldmap.py", line 212, in fetch_data
    except StandardError:
NameError: name 'StandardError' is not defined

I'm running macOS 10.13.6 and Python 3.7.

Also tried to install with Python 2.7 on a raspberry pi with a fully updated Raspbian release, and received this error:

Traceback (most recent call last):
  File "/usr/local/bin/shodan", line 11, in <module>
    load_entry_point('shodan==1.8.1', 'console_scripts', 'shodan')()
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "build/bdist.linux-armv7l/egg/shodan/__main__.py", line 1331, in radar
  File "build/bdist.linux-armv7l/egg/shodan/cli/worldmap.py", line 242, in launch_map
  File "/usr/lib/python2.7/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "build/bdist.linux-armv7l/egg/shodan/cli/worldmap.py", line 222, in run
  File "build/bdist.linux-armv7l/egg/shodan/cli/worldmap.py", line 205, in fetch_data
  File "build/bdist.linux-armv7l/egg/shodan/stream.py", line 99, in banners
  File "build/bdist.linux-armv7l/egg/shodan/stream.py", line 50, in _create_stream
shodan.exception.APIError: Access denied

Regenerating my API key did not help, nor did running the init command with sudo.

@achillean
Copy link
Owner

It looks like you don't have an upgraded API key which is required to connect to the Streaming API of Shodan. You need to have at least one of our API subscription plans (https://developer.shodan.io/pricing).

@seajaysec
Copy link
Author

Ah, yeah I'm only on the developer API plan.

Thanks, wasn't going to be able to make that leap from the error message.

@achillean
Copy link
Owner

Updated the code so it now shows an "Error: Access denied" error without the stack trace if you try to use it with a free API key. And also added some handling for when the window size is too small to render the map.

@cedws
Copy link

cedws commented May 12, 2019

Just came across this - any chance it could be changed to Error: Please upgrade your API plan to ... as it is for other subcommands? Access denied isn't really specific enough.

@cedws
Copy link

cedws commented May 12, 2019

Ah, it looks like this message comes directly from the backend. I guess that needs to be changed, or we could interpret the status code we get back from the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants