From b4cf8b05b35f7a23ed74013265a4c91750fbd977 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 7 Mar 2012 14:48:45 +0000 Subject: [PATCH] added switch --load-cookies --- lib/core/option.py | 7 ++++++- lib/core/optiondict.py | 1 + lib/parse/cmdline.py | 3 +++ lib/utils/google.py | 2 +- sqlmap.conf | 3 +++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index 91ba1ed80..b7f4ed4bf 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -148,7 +148,12 @@ def __urllib2Opener(): handlers = [proxyHandler, authHandler, redirectHandler, rangeHandler] if not conf.dropSetCookie: - conf.cj = cookielib.LWPCookieJar() + if not conf.loC: + conf.cj = cookielib.CookieJar() + else: + conf.cj = cookielib.MozillaCookieJar() + conf.cj.load(conf.loC) + handlers.append(urllib2.HTTPCookieProcessor(conf.cj)) # Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html diff --git a/lib/core/optiondict.py b/lib/core/optiondict.py index f4fdbfd27..87f947314 100644 --- a/lib/core/optiondict.py +++ b/lib/core/optiondict.py @@ -26,6 +26,7 @@ optDict = { "data": "string", "pDel": "string", "cookie": "string", + "loC": "string", "cookieUrlencode": "boolean", "dropSetCookie": "boolean", "agent": "string", diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index 88901969a..31cad8c6a 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -73,6 +73,9 @@ def cmdLineParser(): request.add_option("--cookie", dest="cookie", help="HTTP Cookie header") + request.add_option("--load-cookies", dest="loC", + help="File containing cookies in Netscape/wget format") + request.add_option("--cookie-urlencode", dest="cookieUrlencode", action="store_true", help="URL Encode generated cookie injections") diff --git a/lib/utils/google.py b/lib/utils/google.py index 5aa69a770..0e6ff73a3 100644 --- a/lib/utils/google.py +++ b/lib/utils/google.py @@ -35,7 +35,7 @@ class Google: def __init__(self, handlers): self._matches = [] - self._cj = cookielib.LWPCookieJar() + self._cj = cookielib.CookieJar() handlers.append(urllib2.HTTPCookieProcessor(self._cj)) diff --git a/sqlmap.conf b/sqlmap.conf index b2b5906ef..fbc1adccd 100644 --- a/sqlmap.conf +++ b/sqlmap.conf @@ -42,6 +42,9 @@ pDel = # HTTP Cookie header. cookie = +# File containing cookies in Netscape/wget format +loC = + # URL-encode generated cookie injections. # Valid: True or False cookieUrlencode = False