Skip to content

Commit

Permalink
bug fix __str__ returns bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
NtAlexio2 authored Feb 17, 2024
1 parent efd6789 commit 900d5a2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions impacket/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 900d5a2

Please sign in to comment.