Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- cat<<EOF >/tmp/fooz
- #!/bin/bash
- while true; do sleep 0.1; done
- EOF
- chmod 755 /tmp/fooz
- cat<<EOF >/tmp/test.py
- import getpass
- import paramiko
- import os
- import time
- client = paramiko.SSHClient()
- client.load_system_host_keys()
- client.connect("127.0.0.1", password=getpass.getpass())
- client.get_transport().set_keepalive(1)
- chan = client.get_transport().open_session()
- chan.get_pty()
- chan.exec_command("/tmp/fooz")
- chan.close()
- time.sleep(3)
- print "Looking for fooz with pty"
- os.system("ps ax | grep 'bash.*fooz' | grep -v grep")
- chan = client.get_transport().open_session()
- chan.exec_command("/tmp/fooz")
- chan.close()
- time.sleep(3)
- print "Looking for fooz without pty"
- os.system("ps ax | grep 'bash.*fooz' | grep -v grep")
- os.system("ps ax | grep 'bash.*fooz' | grep -v grep | awk '{print \$1}' | xargs kill -9")
- EOF
- python /tmp/test.py
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement