Skip to content

Commit

Permalink
Fixed headers_to_dict such that HTTP responses are correctly parsed. …
Browse files Browse the repository at this point in the history
…Also fixed an incorrect call to parse_ntlm_chal. This allows one to correctly parse NETNTLMv2 challenge/responses sent in HTTP/Proxy authentication, thereby fixing the CHALLENGE NOT FOUND issue.
  • Loading branch information
randomwalksp committed Dec 22, 2017
1 parent 1ecdb01 commit 49713f4
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions net-creds.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,15 +740,13 @@ def headers_to_dict(header_lines):
Convert the list of header lines into a dictionary
'''
headers = {}
# Incomprehensible list comprehension flattens list of headers
# that are each split at ': '
# http://stackoverflow.com/a/406296
headers_list = [x for line in header_lines for x in line.split(': ', 1)]
headers_dict = dict(zip(headers_list[0::2], headers_list[1::2]))
# Make the header key (like "Content-Length") lowercase
for header in headers_dict:
headers[header.lower()] = headers_dict[header]

for line in header_lines:
lineList=line.split(': ', 1)
key=lineList[0].lower()
if len(lineList)>1:
headers[key]=lineList[1]
else:
headers[key]=""
return headers

def parse_http_line(http_line, http_methods):
Expand Down Expand Up @@ -828,7 +826,7 @@ def parse_netntlm_chal(headers, chal_header, ack):
msg2 = base64.decodestring(msg2)
parse_ntlm_chal(ack, msg2)

def parse_ntlm_chal(msg2, ack):
def parse_ntlm_chal(ack, msg2):
'''
Parse server challenge
'''
Expand Down

0 comments on commit 49713f4

Please sign in to comment.