@@ -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-
219199def __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
329202def update ():
330203 if not conf .updateAll :
0 commit comments