file_sharing.py 文件源码

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

项目:idiot 作者: snare 项目源码 文件源码
def run(self):
        """
        Run the check.

        All check scripts must implement this method. It must return a tuple of:
        (<success>, <message>)

        In this example, if the check succeeds and FileSharing processes are nowhere
        to be found, the check will return (True, "No FileSharing processes found").

        If the check fails and an FileSharing process is found, it returns
        (False, "Found SMB or AFP FileSharing processes with pids <pids>")
        """
        pids = []
        for p in psutil.process_iter():
            try:
                if (p.name() == 'AppleFileServer' or p.name() == 'smbd'):
                    pids.append(p.pid)
            except psutil.NoSuchProcess:
                pass

        if len(pids):
            return (False, "found SMB or AFP file sharing processes with pids: {} - Disable Sharing Prefs: File Sharing".format(', '.join([str(p) for p in pids])))
        else:
            return (True, "disabled")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号