Created
April 4, 2013 07:03
-
-
Save securitytube/5308423 to your computer and use it in GitHub Desktop.
SSH Upload and Execute Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Author: Vivek Ramachandran | |
Website: http://SecurityTube.net | |
Online Infosec Training: http://SecurityTube-Training.com | |
""" | |
import paramiko | |
import sys | |
def UploadFileAndExecute(sshConnection, fileName) : | |
sftpClient = ssh.open_sftp() | |
sftpClient.put(fileName, "/tmp/" +fileName) | |
ssh.exec_command("chmod a+x /tmp/" +fileName) | |
ssh.exec_command("nohup /tmp/" +fileName+ " &") | |
if __name__ == "__main__" : | |
ssh = paramiko.SSHClient() | |
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
ssh.connect(sys.argv[1], username=sys.argv[2], password=sys.argv[3]) | |
UploadFileAndExecute(ssh, sys.argv[4]) | |
ssh.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment