def test_injecting_into_all_interpreters(self):
     program = generate_program()
     try:
         for exe in interpreters():
             print("sys.executable = %s" % sys.executable)
             print("injecting into %s" % exe)
             p = run_program(program, exe=exe)
             pyrasite.inject(p.pid,
                     'pyrasite/payloads/helloworld.py', verbose=True)
             stop_program(p)
             stdout, stderr = p.communicate()
             self.assert_output_contains(stdout, stderr, 'Hello World!')
     finally:
         os.unlink(program)
 def test_pyrasite_script(self):
     program = generate_program()
     try:
         for exe in interpreters():
             print("sys.executable = %s" % sys.executable)
             print("injecting into %s" % exe)
             p = run_program(program, exe=exe)
             subprocess.call([sys.executable, 'pyrasite/main.py',
                 str(p.pid), 'pyrasite/payloads/helloworld.py'],
                 env={'PYTHONPATH': os.getcwd()})
             stop_program(p)
             stdout, stderr = p.communicate()
             self.assert_output_contains(stdout, stderr, 'Hello World!')
     finally:
         os.unlink(program)
 def test_many_payloads_into_program_with_many_threads(self):
     program = generate_program(threads=25)
     num_payloads = 25
     try:
         for exe in interpreters():
             p = run_program(program, exe=exe)
             for i in range(num_payloads):
                 pyrasite.inject(p.pid,
                         'pyrasite/payloads/helloworld.py', verbose=True)
             stop_program(p)
             stdout, stderr = p.communicate()
             count = 0
             for line in stdout.decode('utf-8').split('\n'):
                 if line.strip() == 'Hello World!':
                     count += 1
             assert count == num_payloads, "Read %d hello worlds" % count
     finally:
         os.unlink(program)
Beispiel #4
0
 def setUp(self):
     self.prog = generate_program()
     self.p = run_program(self.prog)
     self.ipc = pyrasite.PyrasiteIPC(self.p.pid)
Beispiel #5
0
 def setUp(self):
     self.prog = generate_program()
     self.p = run_program(self.prog)
     self.ipc = pyrasite.PyrasiteIPC(self.p.pid)
Beispiel #6
0
 def setUp(self):
     self.prog = generate_program()
     self.p = run_program(self.prog)
Beispiel #7
0
 def setUp(self):
     self.prog = generate_program()
     self.p = run_program(self.prog)