2008-10-15 19:38:22 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
2012-01-11 18:59:46 +04:00
|
|
|
Copyright (c) 2006-2012 sqlmap developers (http://www.sqlmap.org/)
|
2010-10-15 03:18:29 +04:00
|
|
|
See the file 'doc/COPYING' for copying permission
|
2008-10-15 19:38:22 +04:00
|
|
|
"""
|
|
|
|
|
|
|
|
import re
|
2010-01-18 17:59:24 +03:00
|
|
|
import time
|
2008-10-15 19:38:22 +04:00
|
|
|
|
2010-01-18 17:05:23 +03:00
|
|
|
from subprocess import PIPE
|
|
|
|
from subprocess import Popen as execute
|
|
|
|
|
|
|
|
from lib.core.common import dataToStdout
|
2010-10-21 02:09:03 +04:00
|
|
|
from lib.core.common import getUnicode
|
2008-10-15 19:38:22 +04:00
|
|
|
from lib.core.data import conf
|
|
|
|
from lib.core.data import logger
|
|
|
|
from lib.core.data import paths
|
2011-03-18 19:35:30 +03:00
|
|
|
from lib.core.settings import IS_WIN
|
2012-07-03 18:34:11 +04:00
|
|
|
from lib.core.settings import REVISION
|
2011-01-30 14:36:03 +03:00
|
|
|
from lib.core.settings import UNICODE_ENCODING
|
2010-10-29 14:51:09 +04:00
|
|
|
from lib.core.subprocessng import pollProcess
|
2008-10-15 19:38:22 +04:00
|
|
|
|
2011-01-31 14:38:00 +03:00
|
|
|
def update():
|
2012-07-02 03:00:46 +04:00
|
|
|
if not conf.updateAll:
|
|
|
|
return
|
|
|
|
|
2010-01-18 17:59:24 +03:00
|
|
|
rootDir = paths.SQLMAP_ROOT_PATH
|
|
|
|
|
2012-07-03 18:34:11 +04:00
|
|
|
infoMsg = "updating sqlmap to the latest development version from the "
|
|
|
|
infoMsg += "GitHub repository"
|
2010-01-18 17:05:23 +03:00
|
|
|
logger.info(infoMsg)
|
2010-01-18 17:59:24 +03:00
|
|
|
|
2012-07-03 18:34:11 +04:00
|
|
|
debugMsg = "sqlmap will try to update itself using 'git' command"
|
|
|
|
logger.debug(debugMsg)
|
2011-03-18 19:26:39 +03:00
|
|
|
|
2012-07-03 18:34:11 +04:00
|
|
|
dataToStdout("\r[%s] [INFO] update in progress " % time.strftime("%X"))
|
2012-07-03 18:50:05 +04:00
|
|
|
process = execute("git pull %s" % rootDir, shell=True, stdout=PIPE, stderr=PIPE)
|
2012-07-03 18:49:34 +04:00
|
|
|
pollProcess(process, True)
|
|
|
|
stdout, stderr = process.communicate()
|
2011-02-01 01:51:14 +03:00
|
|
|
|
2012-07-03 18:34:11 +04:00
|
|
|
if not process.returncode:
|
|
|
|
logger.info("%s the latest revision '%s'" % ("already at" if "Already" in stdout else "updated to", REVISION))
|
2012-07-03 18:49:34 +04:00
|
|
|
else:
|
|
|
|
logger.error("update could not be completed (%s)" % repr(stderr))
|
|
|
|
|
|
|
|
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/)"
|
|
|
|
else:
|
|
|
|
infoMsg = "for Linux platform it's recommended "
|
|
|
|
infoMsg += "to use a standard 'git' package (e.g.: 'sudo apt-get install git')"
|
2011-04-12 18:25:17 +04:00
|
|
|
|
2012-07-03 18:34:11 +04:00
|
|
|
logger.info(infoMsg)
|