smbmap.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:pentestly 作者: praetorian-inc 项目源码 文件源码
def list_path(self, host, share, path, pattern, verbose=False, only_output=False):
        '''
        List shares and regex search for files in the shares to download

        If only_output, will not try to download
        '''
        pwd = self.pathify(path)
        width = 16
        try:
            output_file = True
            pathList = self.smbconn[host].listPath(share, pwd)
            if verbose:
                info('\t.%s' % (path.ljust(50)))
            if only_output:
                if not pathList:
                    return []
                return pathList
            for item in pathList:
                filesize = item.get_filesize() 
                readonly = 'w' if item.is_readonly() > 0 else 'r'
                date = time.ctime(float(item.get_mtime_epoch()))
                isDir = 'd' if item.is_directory() > 0 else 'f'
                filename = item.get_longname()
                if item.is_directory() <= 0:
                    info(pattern.lower(), filename.lower())
                    fileMatch = re.search(pattern.lower(), filename.lower())
                    if fileMatch:
                        dlThis = '%s\\%s/%s' % (share, ntpath.normpath(pwd.strip('*')), filename)
                        dlThis = dlThis.replace('/','\\') 
                        output_file = self.download_file(host, dlThis, True) 
                if verbose:
                    info('\t%s%s--%s--%s-- %s %s\t%s' % (isDir, readonly, readonly, readonly, str(filesize).rjust(width), date, filename))
            return output_file
        except Exception as e:
            # import traceback; traceback.print_exc()
            return []
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号