Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ea45d75

Browse files
committed
Major bug fix to parse and store all HTTP headers from the request file (-r)
1 parent 7cad3cb commit ea45d75

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

lib/core/option.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,20 @@ def __feedTargetsDict(reqFile, addedTargetUrls):
151151
else:
152152
index = 5
153153

154-
url = line[index:line.index(" HTTP/")]
154+
url = line[index:line.index(" HTTP/")]
155155
method = line[:index-1]
156156

157157
if "?" in line and "=" in line:
158158
params = True
159159

160160
getPostReq = True
161161

162+
# POST parameters
163+
elif data is not None and params:
164+
data += line
165+
162166
# GET parameters
163167
elif "?" in line and "=" in line and ": " not in line:
164-
data = line
165168
params = True
166169

167170
# Cookie and Host headers
@@ -173,10 +176,12 @@ def __feedTargetsDict(reqFile, addedTargetUrls):
173176
elif key.lower() == "host":
174177
host = value
175178

176-
# POST parameters
177-
elif method is not None and method == "POST" and "=" in line:
178-
data = line
179-
params = True
179+
if key == "Content-Length":
180+
data = ""
181+
params = True
182+
183+
elif key not in ( "Proxy-Connection", "Connection" ):
184+
conf.httpHeaders.append((str(key), str(value)))
180185

181186
if conf.scope:
182187
getPostReq &= re.search(conf.scope, host) is not None
@@ -188,7 +193,7 @@ def __feedTargetsDict(reqFile, addedTargetUrls):
188193
port = None
189194

190195
if not kb.targetUrls or url not in addedTargetUrls:
191-
kb.targetUrls.add(( url, method, data, cookie ))
196+
kb.targetUrls.add((url, method, data, cookie))
192197
addedTargetUrls.add(url)
193198

194199
def __setMultipleTargets():
@@ -714,7 +719,7 @@ def __setHTTPExtraHeaders():
714719

715720
if header and value:
716721
conf.httpHeaders.append((header, value))
717-
else:
722+
elif not conf.httpHeaders:
718723
conf.httpHeaders.append(("Accept", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"))
719724
conf.httpHeaders.append(("Accept-Language", "en-us,en;q=0.5"))
720725
conf.httpHeaders.append(("Accept-Charset", "ISO-8859-15,utf-8;q=0.7,*;q=0.7"))

0 commit comments

Comments
 (0)