Skip to content

Commit

Permalink
Fixing how REG_MULTI_SZ are printed to stdout (query, add) - replacin…
Browse files Browse the repository at this point in the history
…g \0 with \n
  • Loading branch information
gabrielg5 committed Aug 6, 2024
1 parent 90724a5 commit 7544a3e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions examples/reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def add(self, dce, keyName):
if dwType == rrp.REG_MULTI_SZ:
vd = '\0'.join(self.__options.vd)
valueData = vd + 2 * '\0' # REG_MULTI_SZ ends with 2 null-bytes
valueDataToPrint = vd.replace('\0', '\n')
else:
vd = self.__options.vd[0] if len(self.__options.vd) > 0 else ''
if dwType in (
Expand All @@ -307,18 +308,19 @@ def add(self, dce, keyName):
valueData = binascii.a2b_hex(vd.ljust(bin_value_len, '0'))
else:
valueData = vd + "\0" # Add a NULL Byte as terminator for Non Binary values
valueDataToPrint = valueData

ans3 = rrp.hBaseRegSetValue(
dce, ans2['phkResult'], self.__options.v, dwType, valueData
)

if ans3['ErrorCode'] == 0:
print('Successfully set key %s\\%s of type %s to value %s' % (
keyName, self.__options.v, self.__options.vt, valueData
keyName, self.__options.v, self.__options.vt, valueDataToPrint
))
else:
print('Error 0x%08x while setting key %s\\%s of type %s to value %s' % (
ans3['ErrorCode'], keyName, self.__options.v, self.__options.vt, valueData
ans3['ErrorCode'], keyName, self.__options.v, self.__options.vt, valueDataToPrint
))

def delete(self, dce, keyName):
Expand Down Expand Up @@ -512,7 +514,7 @@ def __parse_lp_data(valueType, valueData):
except:
print(" NULL")
elif valueType == rrp.REG_MULTI_SZ:
print("%s" % (valueData.decode('utf-16le')[:-2]))
print("%s" % (valueData.decode('utf-16le')[:-2].replace('\0', '\n')))
else:
print("Unknown Type 0x%x!" % valueType)
hexdump(valueData)
Expand Down

0 comments on commit 7544a3e

Please sign in to comment.