include.py 文件源码

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

项目:locasploit 作者: lightfaith 项目源码 文件源码
def is_admin(user=lib.global_parameters['USER'], activeroot='/'):
    """ Check if the specified user has administrative privileges on given system"""
    platform = get_system_type_from_active_root(activeroot)
    ip = get_address_from_active_root(activeroot)
    if activeroot.startswith('/'):
        if platform.startswith('linux'):
            # on linux check if euid is 0
            from pwd import getpwnam
            if getpwnam(user).pw_uid == 0:
                return True
            return False

        elif platform.startswith('win'):
            from win32net import NetUserGetLocalGroups
            return 'Administrators' in NetUserGetLocalGroups(ip, user) # should work on remote systems too
            # on Windows only admins can write to C:\Windows\temp
            #if os.access(os.path.join(os.environ.get('SystemRoot', 'C:\\Windows'), 'temp'), os.W_OK):
            #    return True
            #return False
        else:
            log.warn('Cannot check root privileges, platform is not fully supported (%s).' % platform)
            return False
    else:
        log.warn('Cannot check root privileges, remote system analysis (%s) not supported yet.' % activeroot)
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号