lmacken / pyrasite

Inject code into running Python processes
http://pyrasite.com
GNU General Public License v3.0
2.8k stars 220 forks source link

pyrasite-shell getting permission denied in debugged process #71

Open aarontp opened 6 years ago

aarontp commented 6 years ago

Hello:

I'm seeing the following in the ouput of the debugged process when trying to run pyrasite-shell on it:

Traceback (most recent call last):
File "<string>", line 1, in <module>
IOError: [Errno 13] Permission denied: '/tmp/tmplzhk39'

And that file does not exist. My usage is just:

sudo pyrasite-shell <pid>

Normal pyrasite seems to work, at least this does:

sudo pyrasite <pid> hellowworld.py

Any thoughts?

ZmingZinnia commented 6 years ago

same problem

gdgrc commented 5 years ago

I fix it by letting the user of program needed to be injected run pyrasite-shell By:

sudo vi /etc/sysctl.d/10-ptrace.conf ; set the value from 1 to 0; sudo sysctl -p; sudo vi /proc/sys/kernel/yama/ptrace_scope; set the value from 1 to 0; sudo +s /usr/bin/gdb

user202729 commented 4 years ago

I fix it by letting everyone to read the temp file used to store the injected commands: (in file ipc.py)

     def create_payload(self):
         """Write out a reverse python connection payload with a custom port"""
         (fd, filename) = tempfile.mkstemp()
+        os.chmod(filename, 0o644)
         tmp = os.fdopen(fd, 'w')
         path = dirname(abspath(pyrasite.__file__))
         payload = open(join(path, 'reverse.py'))