File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020from thirdparty import six
2121
2222# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
23- VERSION = "1.10.9.31 "
23+ VERSION = "1.10.9.32 "
2424TYPE = "dev" if VERSION .count ('.' ) > 2 and VERSION .split ('.' )[- 1 ] != '0' else "stable"
2525TYPE_COLORS = {"dev" : 33 , "stable" : 90 , "pip" : 34 }
2626VERSION_STRING = "sqlmap/%s#%s" % ('.' .join (VERSION .split ('.' )[:- 1 ]) if VERSION .count ('.' ) > 2 and VERSION .split ('.' )[- 1 ] == '0' else VERSION , TYPE )
Original file line number Diff line number Diff line change @@ -666,8 +666,12 @@ def _createFilesDir():
666666 if not any ((conf .fileRead , conf .commonFiles , conf .xxe )):
667667 return
668668
669- # Note: normalize the hostname consistently with conf.outputPath / conf.dumpPath (see _createDumpDir)
670- conf .filePath = paths .SQLMAP_FILES_PATH % normalizeUnicode (getUnicode (conf .hostname ))
669+ # Note: normalize the hostname consistently with conf.outputPath / conf.dumpPath (see _createDumpDir).
670+ # safeStringFormat() (not raw '%') because SQLMAP_FILES_PATH embeds SQLMAP_OUTPUT_PATH, which comes
671+ # straight from --output-dir - a literal '%' anywhere in that user-supplied path (e.g. an unexpanded
672+ # '$(date +%Y%m%d)' on a shell that doesn't support command substitution) would otherwise make the
673+ # '%' operator try to parse it as a format directive and crash
674+ conf .filePath = safeStringFormat (paths .SQLMAP_FILES_PATH , normalizeUnicode (getUnicode (conf .hostname )))
671675
672676 if not os .path .isdir (conf .filePath ):
673677 try :
Original file line number Diff line number Diff line change @@ -483,6 +483,18 @@ def test_files_dir_created_per_host(self):
483483 self .assertTrue (os .path .isdir (conf .filePath ))
484484 self .assertIn ("example.com" , conf .filePath )
485485
486+ def test_files_dir_survives_percent_in_output_dir (self ):
487+ # --output-dir carries a literal '%' straight into SQLMAP_FILES_PATH (e.g. an unexpanded
488+ # '$(date +%Y%m%d)' on a shell without command substitution, as in #6133) - the '%' operator
489+ # would try to parse '%Y' as a format directive and crash; safeStringFormat() must not
490+ self ._outdir ("f_out_%Y%m%d_%H%M%S" )
491+ conf .hostname = "example.com"
492+ conf .fileRead = "/etc/passwd"
493+ conf .commonFiles = None
494+ _createFilesDir ()
495+ self .assertTrue (os .path .isdir (conf .filePath ))
496+ self .assertIn ("example.com" , conf .filePath )
497+
486498 def test_target_dir_and_target_txt (self ):
487499 self ._outdir ("t_out" )
488500 conf .hostname = "example.com"
You can’t perform that action at this time.
0 commit comments