Example #1
0
    def __init__(self, parent=None):
        super(FtpClient, self).__init__(parent)
        self.ftp = ftp()
        self.setupGui()
        self.downloads = []
        self.remote.homeButton.clicked.connect(self.cdToRemoteHomeDirectory)
        self.remote.fileList.itemDoubleClicked.connect(
            self.cdToRemoteDirectory)
        self.remote.fileList.itemClicked.connect(
            lambda: self.remote.downloadButton.setEnabled(True))
        self.remote.backButton.clicked.connect(self.cdToRemoteBackDirectory)
        self.remote.nextButton.clicked.connect(self.cdToRemoteNextDirectory)
        self.remote.downloadButton.clicked.connect(self.download)
        QObject.connect(self.remote.pathEdit, SIGNAL('returnPressed( )'),
                        self.cdToRemotePath)

        self.local.homeButton.clicked.connect(self.cdToLocalHomeDirectory)
        self.local.fileList.itemDoubleClicked.connect(self.cdToLocalDirectory)
        self.local.fileList.itemClicked.connect(
            lambda: self.local.uploadButton.setEnabled(True))
        self.local.backButton.clicked.connect(self.cdToLocalBackDirectory)
        self.local.nextButton.clicked.connect(self.cdToLocalNextDirectory)
        self.local.uploadButton.clicked.connect(self.upload)
        self.local.connectButton.clicked.connect(self.connect)
        QObject.connect(self.local.pathEdit, SIGNAL('returnPressed( )'),
                        self.cdToLocalPath)

        self.progressDialog = ProgressDialog(self)
Example #2
0
 def __download():
     fp = ftp()
     fp.connect(host=self.ftp.host,
                port=self.ftp.port,
                timeout=self.ftp.timeout)
     fp.login(user=self.ftp.user, passwd=self.ftp.passwd)
     fp.retrbinary(cmd='RETR ' + srcfile, callback=__callback)
Example #3
0
 def __upload():
     fp = ftp()
     fp.connect(host=self.ftp.host,
                port=self.ftp.port,
                timeout=self.ftp.timeout)
     fp.login(user=self.ftp.user, passwd=self.ftp.passwd)
     fp.storbinary(cmd='STOR ' + dstfile, fp=file, callback=__callback)
Example #4
0
    def login(self, ftpInfo={}, safe=False):
        """
        @ftpInfo is dict:
            key ip : is string ipv4 value
            key user : is ftp user ,value is stirng
            key pwd : is ftp password ,value is string
            key port : is ftp port ,value is int

        @safe is bool:
            is true ,use FTP_TLS
            is false, use FTP
        return : no return
        """
        if len(self._ftpInfo):
            ftpInfo = self._ftpInfo
        elif not len(ftpInfo):
            return 13
        try:
            try:
                if safe is False:
                    self._ftp = ftp()
                else:
                    self._ftp = ftps()
                self._ftp.connect(ftpInfo['ip'], ftpInfo['port'])
            except Exception, e:
                print 'ftp init/connect faile'
                print e
                sys.exit(1)

            try:
                self._ftp.login(ftpInfo['user'], ftpInfo['pwd'])
            except Exception, e:
                print 'ftp login faile please check you username/password'
                print e
                sys.exit(1)
Example #5
0
 def __init__(self,rootDir,host,user,pwd):
     self.conn=ftp(host)
     self.conn.login(user,pwd)
     try:
         self.conn.cwd(rootDir) 
     except ftplib.error_perm,e:
         print '远程目录不存在或无权限访问!'
         sys.exit(1)
Example #6
0
 def __init__(self, localPath, ftpPath, host, user, pwd):
     self.conn = ftp(host)
     self.conn.login(user, pwd)
     try:
         self.conn.cwd(ftpPath)
     except ftplib.error_perm, e:
         print "远程目录不存在或无权限访问!"
         sys.exit(1)
Example #7
0
 def __init__(self, rootDir, host, user, pwd):
     self.conn = ftp(host)
     self.conn.login(user, pwd)
     try:
         self.conn.cwd(rootDir)
     except ftplib.error_perm, e:
         print '远程目录不存在或无权限访问!'
         sys.exit(1)
Example #8
0
 def __init__(self, localPath, ftpPath, host, user, pwd):
     self.conn = ftp(host)
     self.conn.login(user, pwd)
     try:
         self.conn.cwd(ftpPath)
     except ftplib.error_perm, e:
         print '远程目录不存在或无权限访问!'
         sys.exit(1)
Example #9
0
def get_new_software():
    for fn,ad,dr in update_files.values():
        print("login to {}".format(ad))
        ft=ftp(ad)
        ft.login()
        print("change to {}".format(dr))
        ft.cwd(dr)
        print("download {}".format(fn))
        with open(fn,"wb") as f:
            ft.retrbinary('RETR %s' % fn, f.write)
    print("done")
Example #10
0
def call(ip, uname, words):
    for passwd in words:
        passwd = passwd.rstrip()
        f = ftp(ip)
        try:
            f.login(user=uname, passwd=passwd)
            print(f'For the username : {uname} the password is ...{passwd}')
            os._exit(1)
        except:
            pass
        finally:
            f.quit()
Example #11
0
def FTPinput(host, userf, passf, filename):
    ftp = ftplib.ftp(host)
    user = open(userf, 'r')
    passwd = open(passf, 'r')
    for u in user:
        for p in passwd:
            try:
                ftp.login(u, p)
            except:
                pass
    uf = u
    pf = p
    bufsize = 1024
    command = 'STOR' + filename
    filehandler = open(filename, 'rb')
    ftp.storbinary(command, filehandler, bufsize)
    filehandler.close()
def try_login(ip, username, passwords):

    for password in passwords:
        server = ftp(ip)
        try:
            server.login(user=username, passwd=password.rstrip())
            print(
                colored(
                    f'[+] Password cracked user: {username}   passwd: {password}',
                    'green'))
            # new_file = open('creds.txt', 'w')
            # new_file.write('Creds found '+username+' '+password)
            # new_file.close()
            os._exit(1)
        except Exception:
            # print(e)
            print(f'[-] Wrong password user: {username}  passwd: {password}')
        finally:
            server.quit()
Example #13
0
def get_new_software():
    print("login to {}".format(ad))
    ft=ftp(ad)
    ft.login(user, passwd)
    ft.cwd(root)
    cur_flist=ft.nlst()
    print(cur_flist)
    while True:
        pat=raw_input("Pattern to move: ")
        if pat.startswith("*"):
            subset=[f for f in cur_flist if f.endswith(pat[1:])]
        else:
            subset=[f for f in cur_flist if f.startswith(pat)]
        for fn in subset:
            with open("{goal}/{fn}".format(goal=goal,fn=fn),"wb") as f:
                print(fn)
                try:
                    ft.retrbinary("RETR {fn}".format(fn=fn), f.write)
                except ftplib.error_perm:
                    print("Not a binary file!")
    print("done")
    ft.quit()
Example #14
0
    def __init__(self, parent=None):
        super(FtpClient, self).__init__(parent)
        self.ftp = ftp( )
        self.setupGui( )
        self.downloads=[ ]
        self.remote.homeButton.clicked.connect(self.cdToRemoteHomeDirectory)
        self.remote.fileList.itemDoubleClicked.connect(self.cdToRemoteDirectory)
        self.remote.fileList.itemClicked.connect(lambda: self.remote.downloadButton.setEnabled(True))
        self.remote.backButton.clicked.connect(self.cdToRemoteBackDirectory)
        self.remote.nextButton.clicked.connect(self.cdToRemoteNextDirectory)
        self.remote.downloadButton.clicked.connect(self.download)
        QObject.connect(self.remote.pathEdit, SIGNAL('returnPressed( )'), self.cdToRemotePath)

        self.local.homeButton.clicked.connect(self.cdToLocalHomeDirectory)
        self.local.fileList.itemDoubleClicked.connect(self.cdToLocalDirectory)
        self.local.fileList.itemClicked.connect(lambda: self.local.uploadButton.setEnabled(True))
        self.local.backButton.clicked.connect(self.cdToLocalBackDirectory)
        self.local.nextButton.clicked.connect(self.cdToLocalNextDirectory)
        self.local.uploadButton.clicked.connect(self.upload)
        self.local.connectButton.clicked.connect(self.connect)
        QObject.connect(self.local.pathEdit, SIGNAL('returnPressed( )'), self.cdToLocalPath)

        self.progressDialog = ProgressDialog(self)
Example #15
0
 def __download( ):
     fp = ftp( )
     fp.connect(host=self.ftp.host, port=self.ftp.port, timeout=self.ftp.timeout)
     fp.login(user=self.ftp.user, passwd=self.ftp.passwd)
     fp.retrbinary(cmd='RETR '+srcfile, callback=__callback)
Example #16
0
 def __upload( ):
     fp = ftp( )
     fp.connect(host=self.ftp.host, port=self.ftp.port, timeout=self.ftp.timeout)
     fp.login(user=self.ftp.user, passwd=self.ftp.passwd)
     fp.storbinary(cmd='STOR '+dstfile, fp=file, callback=__callback)
Example #17
0
import os
import time
import picamera

from ftplib import FTP as ftp

with picamera.PiCamera() as camera:
    camera.start_preview()
    camera.hflip = True
    camera.vflip = True
    camera.resolution = (2592, 1944)
    time.sleep(2)
    for filename in camera.capture_continuous("{timestamp:%Y-%m-%d-%H-%M-%S}.jpg"):
        print("Captured %s" % filename)
        try:
            session = ftp()
            session.connect("192.168.1.2", 21)
            session.login("username", "password")
            session.cwd("admin/timelapse/")
            session.storbinary("STOR " + filename, open(filename, "rb"))
            print("Uploaded to NAS" + filename)
            session.close()
        except Exception as ex:
            print("Error: " + str(ex))
        try:
            session = ftp()
            session.connect("ftp.oureportfolio.com", 21)
            session.login("username", "password")
            session.cwd("public_html/timelapse/")
            session.storbinary("STOR " + filename, open(filename, "rb"))
            print("Uploaded to webserver" + filename)
 def connection(self):
     self.ftp = ftp(self.hostname)
     self.ftp.login(self.username,self.password)
     self.ftp.cwd('/public_html/')