From c4b74c2e014e0b50a0fe67337bfa95f2e68cc809 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 12 Apr 2016 22:37:14 +0200 Subject: [PATCH] Fixes #1810 --- lib/core/settings.py | 2 +- lib/takeover/icmpsh.py | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/core/settings.py b/lib/core/settings.py index 067fa0568..3dbbbdc46 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -20,7 +20,7 @@ from lib.core.enums import OS from lib.core.revision import getRevisionNumber # sqlmap version (...) -VERSION = "1.0.4.16" +VERSION = "1.0.4.17" REVISION = getRevisionNumber() STABLE = VERSION.count('.') <= 2 VERSION_STRING = "sqlmap/%s#%s" % (VERSION, "stable" if STABLE else "dev") diff --git a/lib/takeover/icmpsh.py b/lib/takeover/icmpsh.py index babfcc1a4..bd4f6a490 100644 --- a/lib/takeover/icmpsh.py +++ b/lib/takeover/icmpsh.py @@ -6,6 +6,8 @@ See the file 'doc/COPYING' for copying permission """ import os +import re +import socket import time from extra.icmpsh.icmpsh_m import main as icmpshmaster @@ -54,15 +56,29 @@ class ICMPsh: if self.localIP: message += "[Enter for '%s' (detected)] " % self.localIP - while not address: - address = readInput(message, default=self.localIP) + valid = None + while not valid: + valid = True + address = readInput(message, default=self.localIP or "") + + try: + socket.inet_aton(address) + except socket.error: + valid = False + finally: + valid = valid and re.search(r"\d+\.\d+\.\d+\.\d+", address) is not None if conf.batch and not address: raise SqlmapDataException("local host address is missing") + elif address and not valid: + warnMsg = "invalid local host address" + logger.warn(warnMsg) return address def _prepareIngredients(self, encode=True): + self.localIP = getattr(self, "localIP", None) + self.remoteIP = getattr(self, "remoteIP", None) self.lhostStr = ICMPsh._selectLhost(self) self.rhostStr = ICMPsh._selectRhost(self)