shodan-python icon indicating copy to clipboard operation
shodan-python copied to clipboard

Shodan radar exception on windows machines with curses missing.

Open L1-0 opened this issue 1 year ago • 1 comments

Hi!

I'm getting the following error when trying to execute shodan radar on a windows machine after installing the latest shodan package via pip:

PS C:\Windows\system32> shodan radar
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Scripts\shodan.exe\__main__.py", line 7, in <module>
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\shodan\__main__.py", line 932, in radar
    from shodan.cli.worldmap import launch_map
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\shodan\cli\worldmap.py", line 15, in <module>
    import curses
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\curses\__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses' 

After executing pip install windows-curses, the error goes away. Thus i would propose a check for windows systems for this module as a solution or handle the exception and show this as a solution.

PS C:\Windows\system32> shodan version
1.30.1

Greetings

L1-0 avatar Dec 06 '23 12:12 L1-0

@achillean Per the official Python documentation:

"The Windows version of Python doesn’t include the curses module. A ported version called UniCurses is available."

Do we want to file a PR to update requirements.txt to import curses for windows based on platform? - i.e: https://stackoverflow.com/questions/29222269/is-there-a-way-to-have-a-conditional-requirements-txt-file-for-my-python-applica

rmhowe425 avatar Feb 08 '24 23:02 rmhowe425