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

python3, script works only if there is a port open apparently? #10

Closed 01010101001 closed 5 years ago

01010101001 commented 5 years ago

when I scan an IP that has open ports, the script works perfectly fine. when scanning an IP which returns nothing, I get 2 exceptions - is this expected??

root@scan-test:~# ./masscan.py scanning $IP [2018-11-13 20:13:27,364] [DEBUG] [masscan.py 10 line] Scan parameters: "masscan -oX - $IP -p 1-65535 --rate=8000" Traceback (most recent call last): File "/root/masscan/masscan.py", line 371, in analyse_masscan_xml_scan dom = ET.fromstring(self._masscan_last_output) File "/usr/lib/python3.5/xml/etree/ElementTree.py", line 1345, in XML return parser.close() xml.etree.ElementTree.ParseError: no element found: line 1, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "./masscan.py", line 17, in mas.scan(target, ports='1-65535', arguments='--rate=8000') File "/root/masscan/masscan.py", line 317, in scan masscan_warn_keep_trace=masscan_warn_keep_trace File "/root/masscan/masscan.py", line 374, in analyse_masscan_xml_scan raise NetworkConnectionError("network is unreachable.") masscan.masscan.NetworkConnectionError: network is unreachable.

how can I handle this? catching any exception will just end in "AssertionError: Do a scan before trying to get result !". This is on python 3.5.3.

thanks in advance

MyKings commented 5 years ago

@01010101001 This error is caused by not returning the correct scan result. Please confirm that you can access the target network to be scanned. You can use the ping command to test.