mirror of
https://github.com/fortra/impacket
synced 2026-06-08 14:15:13 +00:00
Improved support for Unicode Strings inside and ENCODED_STRING value
* In those cases where a list of items was parsed, there were some inconsistencies * Should address https://github.com/CoreSecurity/impacket/issues/304 * Further testing is needed to be sure we're not breaking anything else.
This commit is contained in:
@@ -76,14 +76,19 @@ if __name__ == '__main__':
|
||||
pEnum = iEnum.Next(0xffffffff,1)[0]
|
||||
record = pEnum.getProperties()
|
||||
if printHeader is True:
|
||||
print '|',
|
||||
print '|',
|
||||
for col in record:
|
||||
print '%s |' % col,
|
||||
print
|
||||
printHeader = False
|
||||
print '|',
|
||||
for key in record:
|
||||
print '%s |' % record[key]['value'],
|
||||
if type(record[key]['value']) is list:
|
||||
for item in record[key]['value']:
|
||||
print item,
|
||||
print ' |',
|
||||
else:
|
||||
print '%s |' % record[key]['value'],
|
||||
print
|
||||
except Exception, e:
|
||||
#import traceback
|
||||
|
||||
@@ -136,26 +136,27 @@ class ENCODED_STRING(Structure):
|
||||
# Let's first check the commonHdr
|
||||
self.fromString(data)
|
||||
self.structure = ()
|
||||
self.isUnicode = False
|
||||
if len(data) > 1:
|
||||
if self['Encoded_String_Flag'] == 0:
|
||||
self.structure += self.tascii
|
||||
# Let's search for the end of the string
|
||||
index = data[1:].find('\x00')
|
||||
data = data[:index+1+1]
|
||||
self.fromString(data)
|
||||
else:
|
||||
self.structure = self.tunicode
|
||||
# index = data[1:].find('\x00\x00')
|
||||
# data = data[:index+1+2]
|
||||
self.fromString(data)
|
||||
try:
|
||||
self['Character'] = self['Character'].decode('utf-16le')
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
self.isUnicode = True
|
||||
|
||||
self.fromString(data)
|
||||
else:
|
||||
self.structure = self.tascii
|
||||
self.data = None
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key == 'Character' and self.isUnicode:
|
||||
return self.fields['Character'].decode('utf-16le')
|
||||
return Structure.__getitem__(self, key)
|
||||
|
||||
|
||||
# 2.2.8 DecServerName
|
||||
DEC_SERVER_NAME = ENCODED_STRING
|
||||
|
||||
Reference in New Issue
Block a user