Reputation: 120
I have this wrong code and can't find the fix.
49 os.system('powershell -enc
'+base64.b64encode(addpermissions.encode('utf_16_le')))
.
.
.
137 HexRegHash, HexRegSysk, jd, skew1, gbg, data = getRegistryValues(HexRID)
I have this error:
Traceback (most recent call last):
File "hash.py", line 137, in <module>
HexRegHash, HexRegSysk, jd, skew1, gbg, data =
getRegistryValues(HexRID)
File "hash.py", line 49, in getRegistryValues
os.system('powershell -enc
'+base64.b64encode(addpermissions.encode('utf_16_le')))
TypeError: can only concatenate str (not "bytes") to str
Upvotes: 4
Views: 21440
Reputation: 978
base64.b64encode
produces a byte-stream, not a string. So for your concatenation to work, you have to convert it into a string first with str(base64.b64encode(addpermissions.encode('utf_16_le')))
b64cmd = base64.b64encode(cmd.encode('utf_16_le')).decode('utf-8')
os.system('powershell -enc ' + b64cmd)
EDIT: Normal string conversion didn't work with os.system, used decode('utf-8')
instead
Upvotes: 8