No exception handling when there's no open port
Chan9390 opened this issue · 6 comments
Hey @MyKings,
This is a great python wrapper for masscan. But I found an issue when using this.
When I scan a host without any open port I get an exception. It would be better to handle it rather than raising an exception.
Code:
import masscan
mas = masscan.PortScanner()
mas.scan('127.0.0.1', ports='1-65535')
Exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/masscan/masscan.py", line 312, in scan
masscan_warn_keep_trace=masscan_warn_keep_trace
File "/usr/local/lib/python2.7/dist-packages/masscan/masscan.py", line 369, in analyse_masscan_xml_scan
raise PortScannerError(masscan_err)
masscan.masscan.PortScannerError: u'\nStarting masscan 1.0.6 (http://bit.ly/14GZzcT) at 2018-05-27 13:57:06 GMT\n -- forced options: -sS -Pn -n --randomize-hosts -v --send-eth\nInitiating SYN Stealth Scan\nScanning 1 hosts [65535 ports/host]\nrate: 0.00-kpps, 0.00% done, 0:00:00 remaining, found=0 \rrate: 9.99-kpps, 10.76% done, 0:00:49 remaining, found=0 \rrate: 9.98-kpps, 22.69% done, 0:00:20 remaining, found=0 \rrate: 9.98-kpps, 34.41% done, 0:00:11 remaining, found=0 \rrate: 9.94-kpps, 45.85% done, 0:00:07 remaining, found=0 \rrate: 9.97-kpps, 56.86% done, 0:00:04 remaining, found=0 \rrate: 9.97-kpps, 68.61% done, 0:00:02 remaining, found=0 \rrate: 9.95-kpps, 80.49% done, 0:00:01 remaining, found=0 \rrate: 9.94-kpps, 91.36% done, 0:00:00 remaining, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 0-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 10-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 10-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 9-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 9-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 9-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 9-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 8-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 8-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 8-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 8-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 7-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 7-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 7-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 7-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 6-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 6-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 6-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 6-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 5-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 5-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 5-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 5-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 4-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 4-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 4-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 4-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 3-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 3-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 3-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 3-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 2-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 2-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 2-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 2-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 1-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 1-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 1-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 1-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 0-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 0-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 0-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting 0-secs, found=0 \rrate: 0.00-kpps, 100.00% done, waiting -1-secs, found=0 \r \r'
(Note: My system doesn't have any open port)
Waiting for your response :)
ok, I will solve this problem at the next milestone :)
Waiting for your update
Hey @MyKings , the issue here is that ports are not open. Its not host not found.
Well, it doesn't really matter if the host is not alive or the port is not open.
I have reservations about throwing NetworkConnectionError
.
But I plan not to make any changes recently, so reopen this issue.
Seems solved. If all host down (via ping) or all host/port not found, will throw the NetworkConnectionError
Exception, just need to try/catch it now.
I have made changes to my tool's workflow. Closing the issue.