diff --git a/impacket/structure.py b/impacket/structure.py index 7209c11595..f69e8f5808 100644 --- a/impacket/structure.py +++ b/impacket/structure.py @@ -11,11 +11,9 @@ from __future__ import print_function from struct import pack, unpack, calcsize from six import b, PY3 -from sys import stdout +from binascii import hexlify -encoding = stdout.encoding - class Structure: """ sublcasses can define commonHdr and/or structure. each of them is an tuple of either two: (fieldName, format) or three: (fieldName, ':', class) fields. @@ -164,7 +162,7 @@ def fromString(self, data): data = data[size:] return self - + def __setitem__(self, key, value): self.fields[key] = value self.data = None # force recompute @@ -174,9 +172,9 @@ def __getitem__(self, key): def __delitem__(self, key): del self.fields[key] - + def __str__(self): - return self.getData().decode(encoding) + return hexlify(self.getData()) def __len__(self): # XXX: improve