Update for --load-cookies

This commit is contained in:
Miroslav Stampar 2013-02-12 12:42:12 +01:00
parent c2672e78fc
commit 72984a578d
2 changed files with 13 additions and 2 deletions

View File

@ -104,6 +104,7 @@ from lib.core.settings import MIN_ENCODED_LEN_CHECK
from lib.core.settings import MIN_TIME_RESPONSES from lib.core.settings import MIN_TIME_RESPONSES
from lib.core.settings import MIN_VALID_DELAYED_RESPONSE from lib.core.settings import MIN_VALID_DELAYED_RESPONSE
from lib.core.settings import ML from lib.core.settings import ML
from lib.core.settings import NETSCAPE_FORMAT_HEADER_COOKIES
from lib.core.settings import NULL from lib.core.settings import NULL
from lib.core.settings import PARAMETER_AMP_MARKER from lib.core.settings import PARAMETER_AMP_MARKER
from lib.core.settings import PARAMETER_SEMICOLON_MARKER from lib.core.settings import PARAMETER_SEMICOLON_MARKER
@ -3354,8 +3355,15 @@ def resetCookieJar(cookieJar):
cookieJar.clear() cookieJar.clear()
else: else:
try: try:
cookieJar.load(conf.loadCookies) content = readCachedFileContent(conf.loadCookies)
cookieJar.clear_expired_cookies() lines = filter(None, (line.strip() for line in content.split("\n") if not line.startswith('#')))
handle, filename = tempfile.mkstemp()
os.close(handle)
with open(filename, "w+b") as f:
f.write("%s\n" % NETSCAPE_FORMAT_HEADER_COOKIES)
for line in lines:
f.write("\n%s" % "\t".join(line.split()))
cookieJar.load(filename)
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

View File

@ -516,6 +516,9 @@ MIN_ENCODED_LEN_CHECK = 5
# Timeout in seconds in which Metasploit remote session has to be initialized # Timeout in seconds in which Metasploit remote session has to be initialized
METASPLOIT_SESSION_TIMEOUT = 120 METASPLOIT_SESSION_TIMEOUT = 120
# Reference: http://www.cookiecentral.com/faq/#3.5
NETSCAPE_FORMAT_HEADER_COOKIES = "# Netscape HTTP Cookie File."
# CSS style used in HTML dump format # CSS style used in HTML dump format
HTML_DUMP_CSS_STYLE = """<style> HTML_DUMP_CSS_STYLE = """<style>
table{ table{