99
1010import codecs
1111import cookielib
12- import ctypes
1312import difflib
1413import inspect
1514import logging
3130from lib .core .common import parseTargetUrl
3231from lib .core .common import paths
3332from lib .core .common import randomRange
33+ from lib .core .common import runningAsAdmin
3434from lib .core .common import sanitizeStr
3535from lib .core .common import UnicodeRawConfigParser
3636from lib .core .data import conf
@@ -340,12 +340,10 @@ def __setMetasploit():
340340 msfEnvPathExists = False
341341
342342 if IS_WIN :
343- warnMsg = "Metasploit's msfconsole and msfcli are not supported "
344- warnMsg += "on the native Windows Ruby interpreter. Please "
345- warnMsg += "install Metasploit, Python interpreter and sqlmap on "
346- warnMsg += "Cygwin or use Linux in VMWare to use sqlmap takeover "
347- warnMsg += "out-of-band features. sqlmap will now continue "
348- warnMsg += "without calling any takeover feature"
343+ warnMsg = "some sqlmap takeover functionalities are not yet "
344+ warnMsg += "supported on Windows. Please use Linux in a virtual "
345+ warnMsg += "machine for out-of-band features. sqlmap will now "
346+ warnMsg += "carry on ignoring out-of-band switches"
349347 logger .warn (warnMsg )
350348
351349 conf .osPwn = None
@@ -355,35 +353,13 @@ def __setMetasploit():
355353 return
356354
357355 if conf .osSmb :
358- isAdmin = False
359-
360- if PLATFORM in ( "posix" , "mac" ):
361- isAdmin = os .geteuid ()
362-
363- if isinstance (isAdmin , (int , float , long )) and isAdmin == 0 :
364- isAdmin = True
365-
366- elif IS_WIN :
367- isAdmin = ctypes .windll .shell32 .IsUserAnAdmin ()
368-
369- if isinstance (isAdmin , (int , float , long )) and isAdmin == 1 :
370- isAdmin = True
371-
372- else :
373- warnMsg = "sqlmap is not able to check if you are running it "
374- warnMsg += "as an Administrator accout on this platform. "
375- warnMsg += "sqlmap will assume that you are an Administrator "
376- warnMsg += "which is mandatory for the SMB relay attack to "
377- warnMsg += "work properly"
378- logger .warn (warnMsg )
379-
380- isAdmin = True
356+ isAdmin = runningAsAdmin ()
381357
382358 if isAdmin is not True :
383- errMsg = "you need to run sqlmap as an Administrator/root "
384- errMsg += "user if you want to perform a SMB relay attack "
385- errMsg += "because it will need to listen on a user-specified "
386- errMsg += "SMB TCP port for incoming connection attempts"
359+ errMsg = "you need to run sqlmap as an administrator "
360+ errMsg += "if you want to perform a SMB relay attack because "
361+ errMsg += "it will need to listen on a user-specified SMB "
362+ errMsg += "TCP port for incoming connection attempts"
387363 raise sqlmapMissingPrivileges , errMsg
388364
389365 if conf .msfPath :
0 commit comments