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

No exception handling when there's no open port #6

Closed
Chan9390 opened this issue May 27, 2018 · 6 comments
Closed

No exception handling when there's no open port #6

Chan9390 opened this issue May 27, 2018 · 6 comments

Comments

@Chan9390
Copy link

Chan9390 commented May 27, 2018

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 :)

@MyKings
Copy link
Owner

MyKings commented May 28, 2018

ok, I will solve this problem at the next milestone :)

@Chan9390
Copy link
Author

Waiting for your update

@Chan9390
Copy link
Author

Hey @MyKings , the issue here is that ports are not open. Its not host not found.

@MyKings
Copy link
Owner

MyKings commented May 29, 2018

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.

@MyKings MyKings reopened this May 29, 2018
@myme5261314
Copy link

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.

@Chan9390
Copy link
Author

I have made changes to my tool's workflow. Closing the issue.

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