mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-03 05:04:11 +03:00
minor update
This commit is contained in:
parent
1eecfb3dce
commit
d57d5e4b2c
|
@ -1379,9 +1379,6 @@ def __purgeOutput():
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if conf.purgeOutput and os.path.isdir(paths.SQLMAP_OUTPUT_PATH):
|
if conf.purgeOutput and os.path.isdir(paths.SQLMAP_OUTPUT_PATH):
|
||||||
infoMsg = "purging content of output directory ('%s')" % paths.SQLMAP_OUTPUT_PATH
|
|
||||||
logger.info(infoMsg)
|
|
||||||
|
|
||||||
purge(paths.SQLMAP_OUTPUT_PATH)
|
purge(paths.SQLMAP_OUTPUT_PATH)
|
||||||
|
|
||||||
def __setConfAttributes():
|
def __setConfAttributes():
|
||||||
|
|
|
@ -20,6 +20,12 @@ def purge(directory):
|
||||||
Safely removes content from a given directory
|
Safely removes content from a given directory
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if not os.path.isdir(directory):
|
||||||
|
return
|
||||||
|
|
||||||
|
infoMsg = "purging content of directory ('%s'). Please wait. This could take a while..." % directory
|
||||||
|
logger.info(infoMsg)
|
||||||
|
|
||||||
filepaths = []
|
filepaths = []
|
||||||
dirpaths = []
|
dirpaths = []
|
||||||
|
|
||||||
|
@ -27,14 +33,14 @@ def purge(directory):
|
||||||
dirpaths.extend([os.path.abspath(os.path.join(rootpath, _)) for _ in directories])
|
dirpaths.extend([os.path.abspath(os.path.join(rootpath, _)) for _ in directories])
|
||||||
filepaths.extend([os.path.abspath(os.path.join(rootpath, _)) for _ in filenames])
|
filepaths.extend([os.path.abspath(os.path.join(rootpath, _)) for _ in filenames])
|
||||||
|
|
||||||
logger.info("changing file attributes...")
|
logger.debug("changing file attributes...")
|
||||||
for filepath in filepaths:
|
for filepath in filepaths:
|
||||||
try:
|
try:
|
||||||
os.chmod(filepath, stat.S_IREAD | stat.S_IWRITE)
|
os.chmod(filepath, stat.S_IREAD | stat.S_IWRITE)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
logger.info("writing random data to files...")
|
logger.debug("writing random data to files...")
|
||||||
for filepath in filepaths:
|
for filepath in filepaths:
|
||||||
try:
|
try:
|
||||||
filesize = os.path.getsize(filepath)
|
filesize = os.path.getsize(filepath)
|
||||||
|
@ -43,7 +49,7 @@ def purge(directory):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
logger.info("truncating files...")
|
logger.debug("truncating files...")
|
||||||
for filepath in filepaths:
|
for filepath in filepaths:
|
||||||
try:
|
try:
|
||||||
with open(filepath, 'w') as f:
|
with open(filepath, 'w') as f:
|
||||||
|
@ -51,7 +57,7 @@ def purge(directory):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
logger.info("renaming filenames to random values...")
|
logger.debug("renaming filenames to random values...")
|
||||||
for filepath in filepaths:
|
for filepath in filepaths:
|
||||||
try:
|
try:
|
||||||
os.rename(filepath, os.path.join(os.path.dirname(filepath), "".join(random.sample(string.letters, random.randint(4, 8)))))
|
os.rename(filepath, os.path.join(os.path.dirname(filepath), "".join(random.sample(string.letters, random.randint(4, 8)))))
|
||||||
|
@ -60,15 +66,13 @@ def purge(directory):
|
||||||
|
|
||||||
dirpaths.sort(cmp = lambda x, y: y.count(os.path.sep) - x.count(os.path.sep))
|
dirpaths.sort(cmp = lambda x, y: y.count(os.path.sep) - x.count(os.path.sep))
|
||||||
|
|
||||||
logger.info("renaming directory names to random values...")
|
logger.debug("renaming directory names to random values...")
|
||||||
for dirpath in dirpaths:
|
for dirpath in dirpaths:
|
||||||
try:
|
try:
|
||||||
os.rename(dirpath, os.path.join(os.path.dirname(dirpath), "".join(random.sample(string.letters, random.randint(4, 8)))))
|
os.rename(dirpath, os.path.join(os.path.dirname(dirpath), "".join(random.sample(string.letters, random.randint(4, 8)))))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
logger.info("deleting the whole directory tree...")
|
logger.debug("deleting the whole directory tree...")
|
||||||
os.chdir(os.path.join(directory, ".."))
|
os.chdir(os.path.join(directory, ".."))
|
||||||
shutil.rmtree(directory)
|
shutil.rmtree(directory)
|
||||||
|
|
||||||
logger.info("purging done")
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user