Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
stamparm committed Oct 6, 2021
1 parent 7d31de1 commit 69900a6
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import codecs
import contextlib
import copy
import distutils.version
import functools
import getpass
import hashlib
Expand Down Expand Up @@ -47,6 +46,7 @@
from extra.cloak.cloak import decloak
from lib.core.bigarray import BigArray
from lib.core.compat import cmp
from lib.core.compat import LooseVersion
from lib.core.compat import round
from lib.core.compat import xrange
from lib.core.convert import base64pickle
Expand Down Expand Up @@ -591,7 +591,7 @@ def isVersionGreaterOrEqualThan(version):

if Backend.getVersion() is not None and version is not None:
try:
retVal = distutils.version.LooseVersion(Backend.getVersion()) >= distutils.version.LooseVersion(version)
retVal = LooseVersion(Backend.getVersion()) >= LooseVersion(version)
except:
retVal = str(Backend.getVersion()) >= str(version)

Expand Down
5 changes: 5 additions & 0 deletions lib/core/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,8 @@ def __hash__(self):
else:
xrange = xrange
buffer = buffer

try:
from pkg_resources import parse_version as LooseVersion
except ImportError:
from distutils.version import LooseVersion
2 changes: 1 addition & 1 deletion lib/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from thirdparty.six import unichr as _unichr

# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.5.10.5"
VERSION = "1.5.10.6"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
Expand Down
1 change: 0 additions & 1 deletion lib/core/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from lib.core.common import randomStr
from lib.core.common import shellExec
from lib.core.compat import round
from lib.core.compat import xrange
from lib.core.convert import encodeBase64
from lib.core.data import kb
from lib.core.data import logger
Expand Down
4 changes: 2 additions & 2 deletions lib/request/httpshandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
See the file 'LICENSE' for copying permission
"""

import distutils.version
import re
import socket

from lib.core.common import filterNone
from lib.core.common import getSafeExString
from lib.core.compat import LooseVersion
from lib.core.compat import xrange
from lib.core.data import conf
from lib.core.data import kb
Expand Down Expand Up @@ -109,7 +109,7 @@ def create_sock():
if not success:
errMsg = "can't establish SSL connection"
# Reference: https://docs.python.org/2/library/ssl.html
if distutils.version.LooseVersion(PYVERSION) < distutils.version.LooseVersion("2.7.9"):
if LooseVersion(PYVERSION) < LooseVersion("2.7.9"):
errMsg += " (please retry with Python >= 2.7.9)"

if kb.sslSuccess and not self.retrying:
Expand Down
6 changes: 3 additions & 3 deletions plugins/dbms/mysql/takeover.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
See the file 'LICENSE' for copying permission
"""

import distutils.version
import os

from lib.core.agent import agent
Expand All @@ -17,6 +16,7 @@
from lib.core.common import ntToPosixSlashes
from lib.core.common import randomStr
from lib.core.common import unArrayizeValue
from lib.core.compat import LooseVersion
from lib.core.data import kb
from lib.core.data import logger
from lib.core.data import paths
Expand All @@ -38,13 +38,13 @@ def udfSetRemotePath(self):

banVer = kb.bannerFp["dbmsVersion"]

if banVer and distutils.version.LooseVersion(banVer) >= distutils.version.LooseVersion("5.0.67"):
if banVer and LooseVersion(banVer) >= LooseVersion("5.0.67"):
if self.__plugindir is None:
logger.info("retrieving MySQL plugin directory absolute path")
self.__plugindir = unArrayizeValue(inject.getValue("SELECT @@plugin_dir"))

# On MySQL 5.1 >= 5.1.19 and on any version of MySQL 6.0
if self.__plugindir is None and distutils.version.LooseVersion(banVer) >= distutils.version.LooseVersion("5.1.19"):
if self.__plugindir is None and LooseVersion(banVer) >= LooseVersion("5.1.19"):
logger.info("retrieving MySQL base directory absolute path")

# Reference: http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_basedir
Expand Down
6 changes: 3 additions & 3 deletions plugins/dbms/postgresql/takeover.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
See the file 'LICENSE' for copying permission
"""

import distutils.version
import os

from lib.core.common import Backend
Expand All @@ -17,6 +16,7 @@
from lib.core.common import isNoneValue
from lib.core.common import isStackingAvailable
from lib.core.common import randomStr
from lib.core.compat import LooseVersion
from lib.core.data import kb
from lib.core.data import logger
from lib.core.data import paths
Expand Down Expand Up @@ -54,9 +54,9 @@ def udfSetLocalPaths(self):
if not banVer or not banVer[0].isdigit():
errMsg = "unsupported feature on unknown version of PostgreSQL"
raise SqlmapUnsupportedFeatureException(errMsg)
elif distutils.version.LooseVersion(banVer) >= distutils.version.LooseVersion("10"):
elif LooseVersion(banVer) >= LooseVersion("10"):
majorVer = banVer.split('.')[0]
elif distutils.version.LooseVersion(banVer) >= distutils.version.LooseVersion("8.2") and '.' in banVer:
elif LooseVersion(banVer) >= LooseVersion("8.2") and '.' in banVer:
majorVer = '.'.join(banVer.split('.')[:2])
else:
errMsg = "unsupported feature on versions of PostgreSQL before 8.2"
Expand Down
4 changes: 2 additions & 2 deletions sqlmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
sys.exit("[!] wrong installation detected (missing modules). Visit 'https://github.com/sqlmapproject/sqlmap/#installation' for further details")

import bdb
import distutils
import glob
import inspect
import json
Expand Down Expand Up @@ -64,6 +63,7 @@
from lib.core.common import MKSTEMP_PREFIX
from lib.core.common import setColor
from lib.core.common import unhandledExceptionMessage
from lib.core.compat import LooseVersion
from lib.core.compat import xrange
from lib.core.exception import SqlmapBaseException
from lib.core.exception import SqlmapShellQuitException
Expand Down Expand Up @@ -114,7 +114,7 @@ def checkEnvironment():
logger.critical(errMsg)
raise SystemExit

if distutils.version.LooseVersion(VERSION) < distutils.version.LooseVersion("1.0"):
if LooseVersion(VERSION) < LooseVersion("1.0"):
errMsg = "your runtime environment (e.g. PYTHONPATH) is "
errMsg += "broken. Please make sure that you are not running "
errMsg += "newer versions of sqlmap with runtime scripts for older "
Expand Down

0 comments on commit 69900a6

Please sign in to comment.