mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-25 19:13:48 +03:00
Making work on Issue #52
This commit is contained in:
parent
793fa464e3
commit
70f754f6c5
|
@ -16,8 +16,8 @@ from lib.core.common import getUnicode
|
|||
from lib.core.data import conf
|
||||
from lib.core.data import logger
|
||||
from lib.core.data import paths
|
||||
from lib.core.exception import sqlmapUnsupportedFeatureException
|
||||
from lib.core.settings import IS_WIN
|
||||
from lib.core.settings import REVISION
|
||||
from lib.core.settings import UNICODE_ENCODING
|
||||
from lib.core.subprocessng import pollProcess
|
||||
|
||||
|
@ -25,76 +25,25 @@ def update():
|
|||
if not conf.updateAll:
|
||||
return
|
||||
|
||||
errMsg = "sqlmap is now hosted on GitHub at https://github.com/sqlmapproject/sqlmap. "
|
||||
errMsg += "The --update switch is currently outdated and not working. Please, "
|
||||
errMsg += "update sqlmap running 'git pull' for the time being"
|
||||
raise sqlmapUnsupportedFeatureException, errMsg
|
||||
|
||||
rootDir = paths.SQLMAP_ROOT_PATH
|
||||
|
||||
infoMsg = "updating sqlmap to latest development version from the "
|
||||
infoMsg += "subversion repository"
|
||||
infoMsg = "updating sqlmap to the latest development version from the "
|
||||
infoMsg += "GitHub repository"
|
||||
logger.info(infoMsg)
|
||||
|
||||
try:
|
||||
import pysvn
|
||||
debugMsg = "sqlmap will try to update itself using 'git' command"
|
||||
logger.debug(debugMsg)
|
||||
|
||||
debugMsg = "sqlmap will update itself using installed python-svn "
|
||||
debugMsg += "third-party library, http://pysvn.tigris.org/"
|
||||
logger.debug(debugMsg)
|
||||
dataToStdout("\r[%s] [INFO] update in progress " % time.strftime("%X"))
|
||||
process = execute("git pull %s" % rootDir, shell=True, stdout=PIPE, stderr=PIPE)
|
||||
pollProcess(process)
|
||||
stdout, _ = process.communicate()
|
||||
|
||||
def notify(event_dict):
|
||||
action = getUnicode(event_dict['action'])
|
||||
index = action.find('_')
|
||||
prefix = action[index + 1].upper() if index != -1 else action.capitalize()
|
||||
if not process.returncode:
|
||||
logger.info("%s the latest revision '%s'" % ("already at" if "Already" in stdout else "updated to", REVISION))
|
||||
|
||||
if action.find('_update') != -1:
|
||||
return
|
||||
|
||||
if action.find('_completed') == -1:
|
||||
dataToStdout("%s\t%s\n" % (prefix, event_dict['path']))
|
||||
else:
|
||||
revision = getUnicode(event_dict['revision'], UNICODE_ENCODING)
|
||||
index = revision.find('number ')
|
||||
|
||||
if index != -1:
|
||||
revision = revision[index+7:].strip('>')
|
||||
|
||||
logger.info('updated to the latest revision %s' % revision)
|
||||
|
||||
client = pysvn.Client()
|
||||
client.callback_notify = notify
|
||||
|
||||
try:
|
||||
client.update(rootDir)
|
||||
except pysvn.ClientError, e:
|
||||
errMsg = "unable to update sqlmap from subversion: '%s'. " % str(e)
|
||||
errMsg += "You are strongly advised to checkout "
|
||||
errMsg += "the clean copy from repository manually "
|
||||
if IS_WIN:
|
||||
errMsg += "(e.g. Right click -> TortoiseSVN -> Checkout... and type "
|
||||
errMsg += "\"https://svn.sqlmap.org/sqlmap/trunk/sqlmap\" into field \"URL of repository\")"
|
||||
else:
|
||||
errMsg += "(e.g. \"svn checkout https://svn.sqlmap.org/sqlmap/trunk/sqlmap sqlmap-dev\")"
|
||||
logger.error(errMsg)
|
||||
|
||||
except ImportError, _:
|
||||
debugMsg = "sqlmap will try to update itself using 'svn' command"
|
||||
logger.debug(debugMsg)
|
||||
|
||||
dataToStdout("\r[%s] [INFO] update in progress " % time.strftime("%X"))
|
||||
process = execute("svn update %s" % rootDir, shell=True, stdout=PIPE)
|
||||
pollProcess(process)
|
||||
svnStdout, _ = process.communicate()
|
||||
|
||||
if svnStdout:
|
||||
revision = re.search("revision\s+([\d]+)", svnStdout, re.I)
|
||||
|
||||
if revision:
|
||||
logger.info('updated to the latest revision %s' % revision.group(1))
|
||||
|
||||
if IS_WIN:
|
||||
infoMsg = "for Windows platform it's recommended "
|
||||
infoMsg += "to use a TortoiseSVN GUI client for updating "
|
||||
infoMsg += "purposes (http://tortoisesvn.net/downloads.html)"
|
||||
logger.info(infoMsg)
|
||||
if IS_WIN:
|
||||
infoMsg = "for Windows platform it's recommended "
|
||||
infoMsg += "to use a GitHub for Windows client for updating "
|
||||
infoMsg += "purposes (http://windows.github.com/)"
|
||||
logger.info(infoMsg)
|
||||
|
|
|
@ -717,7 +717,7 @@ def cmdLineParser():
|
|||
if not any((args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, \
|
||||
args.requestFile, args.updateAll, args.smokeTest, args.liveTest, args.realTest, args.wizard, args.dependencies, args.purgeOutput)):
|
||||
errMsg = "missing a mandatory option (-d, -u, -l, -m, -r, -g, -c, --wizard, --update, --purge-output or --dependencies), "
|
||||
errMsg += "use -h for basic help and -hh for advanced help"
|
||||
errMsg += "use -h for basic or -hh for advanced help"
|
||||
parser.error(errMsg)
|
||||
|
||||
return args
|
||||
|
|
Loading…
Reference in New Issue
Block a user