MyKings / python-masscan

python-masscan is a python library which helps in using masscan port scanner.
https://pypi.org/project/python-masscan/
GNU General Public License v3.0
281 stars 60 forks source link

masscan not running #37

Closed donesmarcos30 closed 2 years ago

donesmarcos30 commented 3 years ago

I'm getting this error when I try to execute masscan:

unknown masscan error occured: str('masscan program was not found in path. PATH is : /usr/local/sbin:/usr/local /bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin')

do you have idea how to fix ?

I'm using last version of masscan, python 3.8 on ubuntu 20.4

thanks

mccoy commented 3 years ago

The default search path for the masscan binary is {cwd}:/usr/bin:/usr/local/bin:/sw/bin:/opt/local/bin. Your copy of masscan is not on that list and for some reason the code wants to parrot your $PATH back to you even though it quite explicitly ignores your $PATH. In the PortScanner init() the additional arg it takes is masscan_search_path, which PortScanner assumes to be an iterable of full paths to the masscan binary. Given your $PATH lets say your copy of masscan was in /snap/bin, if you create your portscanner like so:

x = masscan.PortScanner(masscan_search_path=('/snap/bin/masscan',))

then it should work. Please note the comma at the end of that tuple is required because we are passing in a single-element tuple.

gabrielgt99 commented 2 years ago

I solved this problem by installing Masscan on the OS (Debian GNU/Linux 11).

apt install masscan

If you have another problem with libpcap, install this package.

apt-get install libpcap-dev -y