Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

winregistry.py: handle value name containting backslash character #1767

Merged
merged 6 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/registry-read.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def enumValues(reg, searchKey):

for value in values:
print(" %-30s: " % value, end=' ')
data = reg.getValue('%s\\%s'%(searchKey,value.decode('utf-8')))
data = reg.getValue(searchKey, value.decode('utf-8'))
# Special case for binary string.. so it looks better formatted
if data[0] == winregistry.REG_BINARY:
print('')
Expand Down
16 changes: 12 additions & 4 deletions impacket/winregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,18 @@ def enumValues(self,key):

return resp

def getValue(self, keyValue):
# returns a tuple with (ValueType, ValueData) for the requested keyValue
regKey = ntpath.dirname(keyValue)
regValue = ntpath.basename(keyValue)
def getValue(self, keyValue, valueName=None):
""" returns a tuple with (ValueType, ValueData) for the requested keyValue
valueName is the name of the value (which can contain '\\')
if valueName is not given, keyValue must be a string containing the full path to the value
if valueName is given, keyValue should be the string containing the path to the key containing valueName
"""
if valueName is None:
regKey = ntpath.dirname(keyValue)
regValue = ntpath.basename(keyValue)
else:
regKey = keyValue
regValue = valueName

key = self.findKey(regKey)

Expand Down
Loading