mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-29 04:53:48 +03:00
Minor update regarding --load-cookies (warning about expired ones)
This commit is contained in:
parent
c9447fbbe7
commit
212e92ea01
|
@ -3356,20 +3356,34 @@ def resetCookieJar(cookieJar):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
if not cookieJar.filename:
|
if not cookieJar.filename:
|
||||||
|
infoMsg = "loading cookies from '%s'" % conf.loadCookies
|
||||||
|
logger.info(infoMsg)
|
||||||
|
|
||||||
content = readCachedFileContent(conf.loadCookies)
|
content = readCachedFileContent(conf.loadCookies)
|
||||||
lines = filter(None, (line.strip() for line in content.split("\n") if not line.startswith('#')))
|
lines = filter(None, (line.strip() for line in content.split("\n") if not line.startswith('#')))
|
||||||
handle, filename = tempfile.mkstemp()
|
handle, filename = tempfile.mkstemp()
|
||||||
os.close(handle)
|
os.close(handle)
|
||||||
|
|
||||||
with open(filename, "w+b") as f:
|
with open(filename, "w+b") as f:
|
||||||
f.write("%s\n" % NETSCAPE_FORMAT_HEADER_COOKIES)
|
f.write("%s\n" % NETSCAPE_FORMAT_HEADER_COOKIES)
|
||||||
for line in lines:
|
for line in lines:
|
||||||
f.write("\n%s" % "\t".join(line.split()))
|
f.write("\n%s" % "\t".join(line.split()))
|
||||||
|
|
||||||
cookieJar.filename = filename
|
cookieJar.filename = filename
|
||||||
cookieJar.load(cookieJar.filename)
|
|
||||||
|
cookieJar.load(cookieJar.filename, ignore_expires=True)
|
||||||
|
|
||||||
|
for cookie in cookieJar:
|
||||||
|
if cookie.expires < time.time():
|
||||||
|
warnMsg = "cookie '%s' has expired" % cookie
|
||||||
|
singleTimeWarnMessage(warnMsg)
|
||||||
|
|
||||||
|
cookieJar.clear_expired_cookies()
|
||||||
|
|
||||||
if not cookieJar._cookies:
|
if not cookieJar._cookies:
|
||||||
errMsg = "no valid cookies found. Please "
|
errMsg = "no valid cookies found"
|
||||||
errMsg += "make sure that cookies aren't expired"
|
|
||||||
raise SqlmapGenericException(errMsg)
|
raise SqlmapGenericException(errMsg)
|
||||||
|
|
||||||
except cookielib.LoadError, msg:
|
except cookielib.LoadError, msg:
|
||||||
errMsg = "there was a problem loading "
|
errMsg = "there was a problem loading "
|
||||||
errMsg += "cookies file ('%s')" % msg
|
errMsg += "cookies file ('%s')" % msg
|
||||||
|
|
Loading…
Reference in New Issue
Block a user