5555from lib .core .optiondict import optDict
5656from lib .core .settings import MSSQL_ALIASES
5757from lib .core .settings import MYSQL_ALIASES
58+ from lib .core .settings import IS_WIN
5859from lib .core .settings import PLATFORM
5960from lib .core .settings import SITE
6061from lib .core .settings import SUPPORTED_DBMS
@@ -267,6 +268,26 @@ def __setMetasploit():
267268 if not conf .osPwn and not conf .osSmb and not conf .osBof :
268269 return
269270
271+ debugMsg = "setting the takeover out-of-band functionality"
272+ logger .debug (debugMsg )
273+
274+ msfEnvPathExists = False
275+
276+ if IS_WIN is True :
277+ warnMsg = "Metasploit's msfconsole and msfcli are not supported "
278+ warnMsg += "on the native Windows Ruby interpreter. Please "
279+ warnMsg += "install Metasploit, Python interpreter and sqlmap on "
280+ warnMsg += "Cygwin or use Linux in VMWare to use sqlmap takeover "
281+ warnMsg += "out-of-band features. sqlmap will now continue "
282+ warnMsg += "without calling any takeover feature"
283+ logger .warn (warnMsg )
284+
285+ conf .osPwn = None
286+ conf .osSmb = None
287+ conf .osBof = None
288+
289+ return
290+
270291 if conf .osSmb :
271292 isAdmin = False
272293
@@ -276,7 +297,7 @@ def __setMetasploit():
276297 if isinstance (isAdmin , (int , float , long )) and isAdmin == 0 :
277298 isAdmin = True
278299
279- elif "win" in PLATFORM :
300+ elif IS_WIN is True :
280301 isAdmin = ctypes .windll .shell32 .IsUserAnAdmin ()
281302
282303 if isinstance (isAdmin , (int , float , long )) and isAdmin == 1 :
@@ -292,18 +313,13 @@ def __setMetasploit():
292313
293314 isAdmin = True
294315
295- if isAdmin != True :
296- errMsg = "you need to run sqlmap as an administrator /root "
316+ if isAdmin is not True :
317+ errMsg = "you need to run sqlmap as an Administrator /root "
297318 errMsg += "user if you want to perform a SMB relay attack "
298319 errMsg += "because it will need to listen on a user-specified "
299320 errMsg += "SMB TCP port for incoming connection attempts"
300321 raise sqlmapMissingPrivileges , errMsg
301322
302- debugMsg = "setting the out-of-band functionality"
303- logger .debug (debugMsg )
304-
305- msfEnvPathExists = False
306-
307323 if conf .msfPath :
308324 condition = os .path .exists (os .path .normpath (conf .msfPath ))
309325 condition &= os .path .exists (os .path .normpath ("%s/msfcli" % conf .msfPath ))
@@ -337,7 +353,7 @@ def __setMetasploit():
337353
338354 envPaths = os .environ ["PATH" ]
339355
340- if "darwin" not in PLATFORM and "win" in PLATFORM :
356+ if IS_WIN is True :
341357 envPaths = envPaths .split (";" )
342358 else :
343359 envPaths = envPaths .split (":" )
0 commit comments