Skip to content

Commit

Permalink
Not parsing responses correctly when curl returns 2 headers. Fixes xm…
Browse files Browse the repository at this point in the history
  • Loading branch information
xmendez committed Jan 9, 2018
1 parent 741db89 commit e13cea0
Showing 1 changed file with 34 additions and 23 deletions.
57 changes: 34 additions & 23 deletions src/wfuzz/externals/reqresp/Response.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,42 @@ def parseResponse (self,rawResponse,type="curl"):
tp=TextParser()
tp.setSource("string",rawResponse)

while True:
tp.readUntil("(HTTP\S*) ([0-9]+)")
tp.readUntil("(HTTP\S*) ([0-9]+)")
while True:
while True:
try:
self.protocol=tp[0][0]
except:
self.protocol="unknown"

try:
self.code=tp[0][1]
except:
self.code="0"

if self.code!="100":
break
else:
tp.readUntil("(HTTP\S*) ([0-9]+)")


self.code=int(self.code)

while True:
tp.readLine()
if (tp.search("^([^:]+): ?(.*)$")):
self.addHeader(tp[0][0],tp[0][1])
else:
break

# curl sometimes sends two headers when using follow, 302 and the final header
tp.readLine()
if not tp.search("(HTTP\S*) ([0-9]+)"):
break
else:
self._headers=[]

try:
self.protocol=tp[0][0]
except:
self.protocol="unknown"

try:
self.code=tp[0][1]
except:
self.code="0"

if self.code!="100":
break


self.code=int(self.code)

while True:
tp.readLine()
if (tp.search("^([^:]+): ?(.*)$")):
self.addHeader(tp[0][0],tp[0][1])
else:
break

while tp.skip(1):
self.addContent(tp.lastFull_line)
Expand Down

0 comments on commit e13cea0

Please sign in to comment.