Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 70f754f

Browse files
committed
Making work on Issue #52
1 parent 793fa46 commit 70f754f

2 files changed

Lines changed: 17 additions & 68 deletions

File tree

lib/core/update.py

Lines changed: 16 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -16,85 +16,34 @@
1616
from lib.core.data import conf
1717
from lib.core.data import logger
1818
from lib.core.data import paths
19-
from lib.core.exception import sqlmapUnsupportedFeatureException
2019
from lib.core.settings import IS_WIN
20+
from lib.core.settings import REVISION
2121
from lib.core.settings import UNICODE_ENCODING
2222
from lib.core.subprocessng import pollProcess
2323

2424
def update():
2525
if not conf.updateAll:
2626
return
2727

28-
errMsg = "sqlmap is now hosted on GitHub at https://github.com/sqlmapproject/sqlmap. "
29-
errMsg += "The --update switch is currently outdated and not working. Please, "
30-
errMsg += "update sqlmap running 'git pull' for the time being"
31-
raise sqlmapUnsupportedFeatureException, errMsg
32-
3328
rootDir = paths.SQLMAP_ROOT_PATH
3429

35-
infoMsg = "updating sqlmap to latest development version from the "
36-
infoMsg += "subversion repository"
30+
infoMsg = "updating sqlmap to the latest development version from the "
31+
infoMsg += "GitHub repository"
3732
logger.info(infoMsg)
3833

39-
try:
40-
import pysvn
41-
42-
debugMsg = "sqlmap will update itself using installed python-svn "
43-
debugMsg += "third-party library, http://pysvn.tigris.org/"
44-
logger.debug(debugMsg)
45-
46-
def notify(event_dict):
47-
action = getUnicode(event_dict['action'])
48-
index = action.find('_')
49-
prefix = action[index + 1].upper() if index != -1 else action.capitalize()
50-
51-
if action.find('_update') != -1:
52-
return
53-
54-
if action.find('_completed') == -1:
55-
dataToStdout("%s\t%s\n" % (prefix, event_dict['path']))
56-
else:
57-
revision = getUnicode(event_dict['revision'], UNICODE_ENCODING)
58-
index = revision.find('number ')
59-
60-
if index != -1:
61-
revision = revision[index+7:].strip('>')
62-
63-
logger.info('updated to the latest revision %s' % revision)
64-
65-
client = pysvn.Client()
66-
client.callback_notify = notify
67-
68-
try:
69-
client.update(rootDir)
70-
except pysvn.ClientError, e:
71-
errMsg = "unable to update sqlmap from subversion: '%s'. " % str(e)
72-
errMsg += "You are strongly advised to checkout "
73-
errMsg += "the clean copy from repository manually "
74-
if IS_WIN:
75-
errMsg += "(e.g. Right click -> TortoiseSVN -> Checkout... and type "
76-
errMsg += "\"https://svn.sqlmap.org/sqlmap/trunk/sqlmap\" into field \"URL of repository\")"
77-
else:
78-
errMsg += "(e.g. \"svn checkout https://svn.sqlmap.org/sqlmap/trunk/sqlmap sqlmap-dev\")"
79-
logger.error(errMsg)
80-
81-
except ImportError, _:
82-
debugMsg = "sqlmap will try to update itself using 'svn' command"
83-
logger.debug(debugMsg)
84-
85-
dataToStdout("\r[%s] [INFO] update in progress " % time.strftime("%X"))
86-
process = execute("svn update %s" % rootDir, shell=True, stdout=PIPE)
87-
pollProcess(process)
88-
svnStdout, _ = process.communicate()
34+
debugMsg = "sqlmap will try to update itself using 'git' command"
35+
logger.debug(debugMsg)
8936

90-
if svnStdout:
91-
revision = re.search("revision\s+([\d]+)", svnStdout, re.I)
37+
dataToStdout("\r[%s] [INFO] update in progress " % time.strftime("%X"))
38+
process = execute("git pull %s" % rootDir, shell=True, stdout=PIPE, stderr=PIPE)
39+
pollProcess(process)
40+
stdout, _ = process.communicate()
9241

93-
if revision:
94-
logger.info('updated to the latest revision %s' % revision.group(1))
42+
if not process.returncode:
43+
logger.info("%s the latest revision '%s'" % ("already at" if "Already" in stdout else "updated to", REVISION))
9544

96-
if IS_WIN:
97-
infoMsg = "for Windows platform it's recommended "
98-
infoMsg += "to use a TortoiseSVN GUI client for updating "
99-
infoMsg += "purposes (http://tortoisesvn.net/downloads.html)"
100-
logger.info(infoMsg)
45+
if IS_WIN:
46+
infoMsg = "for Windows platform it's recommended "
47+
infoMsg += "to use a GitHub for Windows client for updating "
48+
infoMsg += "purposes (http://windows.github.com/)"
49+
logger.info(infoMsg)

lib/parse/cmdline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ def cmdLineParser():
717717
if not any((args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, \
718718
args.requestFile, args.updateAll, args.smokeTest, args.liveTest, args.realTest, args.wizard, args.dependencies, args.purgeOutput)):
719719
errMsg = "missing a mandatory option (-d, -u, -l, -m, -r, -g, -c, --wizard, --update, --purge-output or --dependencies), "
720-
errMsg += "use -h for basic help and -hh for advanced help"
720+
errMsg += "use -h for basic or -hh for advanced help"
721721
parser.error(errMsg)
722722

723723
return args

0 commit comments

Comments
 (0)