I have created a simple reverse shell in python using subprocess.Popen(cmd, shell=True)
for the client to run commands. However, when I use commands in the user directory, I get a shell-init error. This is what I get when I try to use ls
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
ls: .: Operation not permitted
Running the ls
command as sudo does not work.
It is worth mentioning that commands do work as intended in directories outside of the user directory.
Here is the code that calls the command:
output = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)