Skip to content

Commit 34a8cd7

Browse files
committed
added support for setting HTTP method manualy
1 parent 798ab49 commit 34a8cd7

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

lib/request/connect.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from lib.request.basic import parseResponse
4545
from lib.request.direct import direct
4646
from lib.request.comparison import comparison
47+
from lib.request.methodrequest import MethodRequest
4748

4849

4950
class Connect:
@@ -71,6 +72,7 @@ def getPage(**kwargs):
7172
url = kwargs.get('url', conf.url).replace(" ", "%20")
7273
get = kwargs.get('get', None)
7374
post = kwargs.get('post', None)
75+
method = kwargs.get('method', None)
7476
cookie = kwargs.get('cookie', None)
7577
ua = kwargs.get('ua', None)
7678
direct = kwargs.get('direct', False)
@@ -127,7 +129,12 @@ def getPage(**kwargs):
127129

128130
# Perform HTTP request
129131
headers = forgeHeaders(cookie, ua)
130-
req = urllib2.Request(url, post, headers)
132+
133+
if method:
134+
req = MethodRequest(url, post, headers)
135+
req.set_method(method)
136+
else:
137+
req = urllib2.Request(url, post, headers)
131138

132139
if not req.has_header("Accept-Encoding"):
133140
requestHeaders += "Accept-Encoding: identity\n"

lib/request/methodrequest.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
$Id$
5+
6+
This file is part of the sqlmap project, http://sqlmap.sourceforge.net.
7+
8+
Copyright (c) 2010 Miroslav Stampar <miroslav.stampar@gmail.com>
9+
10+
sqlmap is free software; you can redistribute it and/or modify it under
11+
the terms of the GNU General Public License as published by the Free
12+
Software Foundation version 2 of the License.
13+
14+
sqlmap is distributed in the hope that it will be useful, but WITHOUT ANY
15+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17+
details.
18+
19+
You should have received a copy of the GNU General Public License along
20+
with sqlmap; if not, write to the Free Software Foundation, Inc., 51
21+
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22+
"""
23+
24+
import urllib2
25+
26+
27+
class MethodRequest(urllib2.Request):
28+
''' Used to create HEAD/PUT/DELETE/... requests with urllib2 '''
29+
def set_method(self, method):
30+
self.method = method.upper()
31+
def get_method(self):
32+
return getattr(self, 'method', urllib2.Request.get_method(self))

0 commit comments

Comments
 (0)