Couple of bug fixes
Some checks are pending
/ build (macos-latest, 3.8) (push) Waiting to run
/ build (ubuntu-latest, pypy-2.7) (push) Waiting to run
/ build (windows-latest, 3.14) (push) Waiting to run

This commit is contained in:
Miroslav Štampar 2026-06-14 17:05:32 +02:00
parent bc4ce6e44a
commit e24678fc31
11 changed files with 66 additions and 34 deletions

View file

@ -327,10 +327,10 @@ def check_authentication():
except:
request.environ["PATH_INFO"] = "/error/401"
else:
if creds.count(':') != 1:
if ':' not in creds:
request.environ["PATH_INFO"] = "/error/401"
else:
username, password = creds.split(':')
username, password = creds.split(':', 1)
if username.strip() != (DataStore.username or "") or password.strip() != (DataStore.password or ""):
request.environ["PATH_INFO"] = "/error/401"

View file

@ -13,11 +13,9 @@ import stat
import string
from lib.core.common import getSafeExString
from lib.core.common import openFile
from lib.core.compat import xrange
from lib.core.convert import getUnicode
from lib.core.data import logger
from thirdparty.six import unichr as _unichr
from lib.core.settings import PURGE_BLOCK_SIZE
def purge(directory):
"""
@ -46,12 +44,25 @@ def purge(directory):
except:
pass
logger.debug("writing random data to files")
logger.debug("overwriting file contents")
for filepath in filepaths:
try:
filesize = os.path.getsize(filepath)
with openFile(filepath, "w+") as f:
f.write("".join(_unichr(random.randint(0, 255)) for _ in xrange(filesize)))
if filesize:
# Note: NIST SP 800-88 ("Clear") / DoD 5220.22-M style multi-pass in-place overwrite
# (zeros, ones, random) forcing each pass to disk; performed BEFORE the truncation below
# so the original bytes are actually overwritten and not just released to free blocks.
# Written in bounded blocks so peak memory stays O(PURGE_BLOCK_SIZE), not O(filesize)
with open(filepath, "r+b") as f:
for getBlock in (lambda n: b"\x00" * n, lambda n: b"\xff" * n, lambda n: os.urandom(n)):
f.seek(0)
remaining = filesize
while remaining > 0:
count = min(PURGE_BLOCK_SIZE, remaining)
f.write(getBlock(count))
remaining -= count
f.flush()
os.fsync(f.fileno())
except:
pass

View file

@ -82,7 +82,7 @@ class SQLAlchemy(GenericConnector):
engine = _sqlalchemy.create_engine(self.address, connect_args={})
self.connector = engine.connect()
except (TypeError, ValueError):
except (TypeError, ValueError) as ex:
if "_get_server_version_info" in traceback.format_exc():
try:
import pymssql
@ -90,10 +90,14 @@ class SQLAlchemy(GenericConnector):
raise SqlmapConnectionException("SQLAlchemy connection issue (obsolete version of pymssql ('%s') is causing problems)" % pymssql.__version__)
except ImportError:
pass
# Note: surface (as a proper SqlmapConnectionException) instead of silently continuing with self.connector left None
raise SqlmapConnectionException("SQLAlchemy connection issue ('%s')" % getSafeExString(ex))
elif "invalid literal for int() with base 10: '0b" in traceback.format_exc():
raise SqlmapConnectionException("SQLAlchemy connection issue ('https://bitbucket.org/zzzeek/sqlalchemy/issues/3975')")
else:
pass
# Note: raise as SqlmapConnectionException (like the generic handler below) so the caller's native-connector
# fallback engages and no raw TypeError/ValueError can reach sqlmap's top-level handler
raise SqlmapConnectionException("SQLAlchemy connection issue ('%s')" % getSafeExString(ex))
except SqlmapFilePathException:
raise
except Exception as ex: