Skip to content

Commit 8ee00bb

Browse files
committed
fix #6
1 parent fc0f30c commit 8ee00bb

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

masscan/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
from .masscan import *
44

55
__author__ = 'MyKings (xsseroot@gmail.com)'
6-
__version__ = '0.1.1'
7-
__last_modification__ = '2017.03.23'
6+
__version__ = '0.1.2'
7+
__last_modification__ = '2018.05.29'
88

masscan/masscan.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
logging.basicConfig(format=FORMAT)
1919
logger.setLevel(logging.DEBUG)
2020

21+
22+
class NetworkConnectionError(Exception):
23+
pass
24+
25+
2126
PORTS = "1,3-4,6-7,9,13,17,19-26,30,32-33,37,42-43,49,53,70,79-85,88-90,99-100,106,109-111,113,119,125,135,139,143-144," \
2227
"146,161,163,179,199,211-212,222,254-256,259,264,280,301,306,311,340,366,389,406-407,416-417,425,427,443-445,458," \
2328
"464-465,481,497,500,512-515,524,541,543-545,548,554-555,563,587,593,616-617,625,631,636,646,648,666-668,683,687," \
@@ -364,6 +369,10 @@ def analyse_masscan_xml_scan(self, masscan_xml_output=None, masscan_err='', mass
364369

365370
try:
366371
dom = ET.fromstring(self._masscan_last_output)
372+
except ET.ParseError:
373+
if "found=0" in masscan_err:
374+
raise NetworkConnectionError("network is unreachable.")
375+
raise ET.ParseError
367376
except Exception:
368377
if len(masscan_err) > 0:
369378
raise PortScannerError(masscan_err)

0 commit comments

Comments
 (0)