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

Skip to content

Commit 50bbb0c

Browse files
committed
Deprecate sqlmap update code, will use pysvn to update from latest development version from subversion repository.
1 parent 9c9988c commit 50bbb0c

3 files changed

Lines changed: 4 additions & 131 deletions

File tree

lib/core/update.py

Lines changed: 1 addition & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -196,135 +196,8 @@ def __updateMSSQLXML():
196196
infoMsg += "last update"
197197
logger.info(infoMsg)
198198

199-
def __createFile(pathname, data):
200-
mkpath(os.path.dirname(pathname))
201-
202-
fileFP = open(pathname, "wb")
203-
fileFP.write(data)
204-
fileFP.close()
205-
206-
def __extractZipFile(tempDir, zipFile):
207-
# Check if the saved binary file is really a ZIP file
208-
if zipfile.is_zipfile(zipFile):
209-
sqlmapZipFile = zipfile.ZipFile(zipFile)
210-
else:
211-
raise sqlmapFilePathException, "the downloaded file does not seem to be a ZIP file"
212-
213-
# Extract each file within the ZIP file in the temporary directory
214-
for info in sqlmapZipFile.infolist():
215-
if info.filename[-1] != '/':
216-
data = sqlmapZipFile.read(info.filename)
217-
__createFile(os.path.join(tempDir, info.filename), data)
218-
219199
def __updateSqlmap():
220-
infoMsg = "updating sqlmap"
221-
logger.info(infoMsg)
222-
223-
debugMsg = "checking if a new version is available"
224-
logger.debug(debugMsg)
225-
226-
try:
227-
sqlmapNewestVersion, _ = Request.getPage(url=SQLMAP_VERSION_URL, direct=True)
228-
except sqlmapConnectionException, _:
229-
__sqlmapPath = urlparse.urlsplit(SQLMAP_VERSION_URL)
230-
__sqlmapHostname = __sqlmapPath[1]
231-
232-
warnMsg = "sqlmap was unable to connect to %s" % __sqlmapHostname
233-
warnMsg += ", check your Internet connection and retry"
234-
logger.warn(warnMsg)
235-
236-
return
237-
238-
sqlmapNewestVersion = str(sqlmapNewestVersion).replace("\n", "")
239-
240-
if not re.search("^([\w\.\-]+)$", sqlmapNewestVersion):
241-
errMsg = "sqlmap version is in a wrong syntax"
242-
logger.error(errMsg)
243-
244-
return
245-
246-
if sqlmapNewestVersion == VERSION:
247-
infoMsg = "you are already running sqlmap latest stable version"
248-
logger.info(infoMsg)
249-
250-
return
251-
252-
elif sqlmapNewestVersion > VERSION:
253-
infoMsg = "sqlmap latest stable version is %s. " % sqlmapNewestVersion
254-
infoMsg += "Going to download it from the SourceForge File List page"
255-
logger.info(infoMsg)
256-
257-
elif sqlmapNewestVersion < VERSION:
258-
infoMsg = "you are running a version of sqlmap more updated than "
259-
infoMsg += "the latest stable version (%s)" % sqlmapNewestVersion
260-
logger.info(infoMsg)
261-
262-
return
263-
264-
sqlmapBinaryStringUrl = SQLMAP_SOURCE_URL % sqlmapNewestVersion
265-
266-
try:
267-
sqlmapBinaryString, _ = Request.getPage(url=sqlmapBinaryStringUrl, direct=True)
268-
except sqlmapConnectionException, _:
269-
__sqlmapPath = urlparse.urlsplit(sqlmapBinaryStringUrl)
270-
__sqlmapHostname = __sqlmapPath[1]
271-
272-
warnMsg = "sqlmap was unable to connect to %s" % __sqlmapHostname
273-
warnMsg += ", check your Internet connection and retry"
274-
logger.warn(warnMsg)
275-
276-
return
277-
278-
debugMsg = 'saving the sqlmap compressed source to a ZIP file into '
279-
debugMsg += 'the temporary directory and extract it'
280-
logger.debug(debugMsg)
281-
282-
tempDir = tempfile.gettempdir()
283-
zipFile = os.path.join(tempDir, "sqlmap-%s.zip" % sqlmapNewestVersion)
284-
__createFile(zipFile, sqlmapBinaryString)
285-
__extractZipFile(tempDir, zipFile)
286-
287-
# For each file and directory in the temporary directory copy it
288-
# to the sqlmap root path and set right permission
289-
for root, _, files in os.walk(os.path.join(tempDir, "sqlmap-%s" % sqlmapNewestVersion)):
290-
# Just for development release
291-
if '.svn' in root:
292-
continue
293-
294-
cleanRoot = root.replace(tempDir, "")
295-
cleanRoot = cleanRoot.replace("%ssqlmap-%s" % (os.sep, sqlmapNewestVersion), "")
296-
297-
if cleanRoot.startswith(os.sep):
298-
cleanRoot = cleanRoot[1:]
299-
300-
for f in files:
301-
# Just for development release
302-
if f.endswith(".pyc") or f.endswith(".pyo"):
303-
continue
304-
305-
srcFile = os.path.join(root, f)
306-
dstFile = os.path.join(paths.SQLMAP_ROOT_PATH, os.path.join(cleanRoot, f))
307-
308-
if f == "sqlmap.conf" and os.path.exists(dstFile):
309-
infoMsg = "backupping configuration file to '%s.bak'" % dstFile
310-
logger.info(infoMsg)
311-
shutil.move(dstFile, "%s.bak" % dstFile)
312-
313-
if os.path.exists(dstFile):
314-
debugMsg = "replacing file '%s'" % dstFile
315-
else:
316-
debugMsg = "creating new file '%s'" % dstFile
317-
318-
logger.debug(debugMsg)
319-
320-
mkpath(os.path.dirname(dstFile))
321-
shutil.copy(srcFile, dstFile)
322-
323-
if f.endswith(".py"):
324-
os.chmod(dstFile, 0755)
325-
326-
infoMsg = "sqlmap updated successfully"
327-
logger.info(infoMsg)
200+
pass
328201

329202
def update():
330203
if not conf.updateAll:

lib/parse/cmdline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,10 @@ def cmdLineParser():
395395
"estimated time of arrival")
396396

397397
miscellaneous.add_option("--gpage", dest="googlePage", type="int",
398-
help="Use google dork results from specified page number")
398+
help="Use google dork results from specified page number")
399399

400400
miscellaneous.add_option("--update", dest="updateAll", action="store_true",
401-
help="Update sqlmap to the latest stable version")
401+
help="Update Microsoft SQL Server XML signature file")
402402

403403
miscellaneous.add_option("--save", dest="saveCmdline", action="store_true",
404404
help="Save options on a configuration INI file")

sqlmap.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ eta = False
401401
# Default: 1
402402
googlePage = 1
403403

404-
# Update sqlmap to the latest stable version.
404+
# Update Microsoft SQL Server XML signature file.
405405
# Valid: True or False
406406
updateAll = False
407407

0 commit comments

Comments
 (0)