Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
windows-boom
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陶腾飞
windows-boom
Commits
fc7f08f5
Commit
fc7f08f5
authored
Aug 02, 2022
by
陶腾飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2022-08-02 v1.1
parent
614bcb50
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
155 additions
and
11 deletions
+155
-11
README.MD
+4
-3
main.exe
+0
-0
main.go
+6
-3
office.go
+139
-0
win.go
+6
-5
No files found.
README.MD
View file @
fc7f08f5
...
...
@@ -4,7 +4,7 @@
## 说明
目前仅支持Windows 10 Pro
,之后将更新office 2016和
2019版本
目前仅支持Windows 10 Pro
、Office 16.0 ProPlus,之后将更新office
2019版本
## 用法
...
...
@@ -12,4 +12,5 @@
## 更新记录
2022-07-31 v1.0 支持windows 10 Pro的激活
\ No newline at end of file
2022-07-31 v1.0 支持windows 10 Pro的激活
2022-08-02 v1.1 支持Office 16.0 ProPlus的激活
\ No newline at end of file
main.exe
View file @
fc7f08f5
No preview for this file type
client
.go
→
main
.go
View file @
fc7f08f5
package
main
import
(
"fmt"
"log"
pub
"git.zhiweidata.top/taotengfei/AD-Control-Golang/public"
...
...
@@ -14,9 +13,13 @@ func main() {
log
.
Printf
(
"该主机属于知微域"
)
}
if
err
:=
activeWindows
();
err
!=
nil
{
log
.
Println
(
err
)
log
.
Println
(
"Windows 激活失败"
)
}
if
err
:=
activeOffice
();
err
!=
nil
{
log
.
Println
(
err
)
log
.
Println
(
"Office 激活失败"
)
}
log
.
Println
(
"
按任意键继续
"
)
fmt
.
Scan
(
"233"
)
log
.
Println
(
"
程序运行结束
"
)
select
{}
}
office.go
0 → 100644
View file @
fc7f08f5
package
main
import
(
"fmt"
"log"
"os/exec"
"strings"
pub
"git.zhiweidata.top/taotengfei/AD-Control-Golang/public"
reg
"git.zhiweidata.top/taotengfei/AD-Control-Golang/registry"
)
func
checkOffice
(
path
string
)
bool
{
out
,
err
:=
execcmd
(
path
,
"/dstatus"
)
if
err
!=
nil
{
log
.
Println
(
out
)
return
false
}
outstr
:=
string
(
out
)
if
strings
.
Contains
(
outstr
,
"---LICENSED---"
)
{
log
.
Printf
(
"当前已激活Office"
)
return
false
}
else
if
strings
.
Contains
(
outstr
,
"No installed product keys detected"
)
{
log
.
Printf
(
"当前未激活Office"
)
return
true
}
return
false
}
func
getOfficeVersion
(
path
string
)
(
string
,
error
)
{
var
officeVersion
string
out
,
err
:=
execcmd_filter
(
path
,
"/dstatus"
,
`"LICENSE.NAME"`
)
if
err
!=
nil
{
return
""
,
err
}
outstr
:=
string
(
out
)
if
strings
.
Contains
(
outstr
,
"Office16ProPlus"
)
{
log
.
Printf
(
"Office版本为2016专业增强版"
)
officeVersion
=
"Office 16.0 ProPlus"
}
else
{
return
""
,
fmt
.
Errorf
(
"查询错误或不支持该版本: %s"
,
outstr
)
}
return
officeVersion
,
err
}
func
activeOffice
()
error
{
log
.
Printf
(
"正在检查Office的安装路径"
)
path
:=
reg
.
Query_key_one
(
reg
.
HKLM
,
`SOFTWARE\Microsoft\Office\16.0\Outlook\InstallRoot`
,
"Path"
)
if
path
==
""
{
return
fmt
.
Errorf
(
"不支持该版本的Office"
)
}
log
.
Printf
(
"Office的安装路径:%s"
,
path
)
log
.
Printf
(
"检查激活Office状态"
)
if
!
checkOffice
(
path
)
{
return
nil
}
log
.
Printf
(
"准备激活Office"
)
// log.Printf("获取Office版本")
// officeVersion, err := getOfficeVersion(path)
// if err != nil {
// return err
// }
// 从服务器获取密钥
officeVersion
:=
"Office 16.0 ProPlus"
pub
.
SendBoomServer
(
pub
.
Msg_Boom_Active
,
officeVersion
)
if
pub
.
MS
.
Error
{
return
fmt
.
Errorf
(
pub
.
MS
.
Errmsg
)
}
key
:=
pub
.
MS
.
S
log
.
Printf
(
"请求到%s的版本的密钥为%s"
,
officeVersion
,
key
)
out
,
err
:=
execcmd
(
path
,
"/sethst:192.168.0.21"
)
outstr
:=
string
(
out
)
if
err
!=
nil
{
if
strings
.
Contains
(
outstr
,
"0x80070005"
)
{
return
fmt
.
Errorf
(
"请使用管理员权限打开本程序"
)
}
else
if
strings
.
Contains
(
outstr
,
"The Software Licensing Service reported that the action requires administrator privilege"
)
{
return
fmt
.
Errorf
(
"请使用管理员权限打开本程序"
)
}
}
if
strings
.
Contains
(
outstr
,
"Successfully applied setting"
)
{
log
.
Printf
(
"kms的IP设置成功"
)
}
out
,
err
=
execcmd
(
path
,
"/setprt:1688"
)
outstr
=
string
(
out
)
if
err
!=
nil
{
if
strings
.
Contains
(
outstr
,
"0x80070005"
)
{
return
fmt
.
Errorf
(
"请使用管理员权限打开本程序"
)
}
else
if
strings
.
Contains
(
outstr
,
"The Software Licensing Service reported that the action requires administrator privilege"
)
{
return
fmt
.
Errorf
(
"请使用管理员权限打开本程序"
)
}
}
if
strings
.
Contains
(
outstr
,
"Successfully applied setting"
)
{
log
.
Printf
(
"kms的port设置成功"
)
}
else
{
log
.
Println
(
outstr
)
}
out
,
err
=
execcmd
(
path
,
"/inpkey:"
+
key
)
outstr
=
string
(
out
)
if
err
!=
nil
{
if
strings
.
Contains
(
outstr
,
"0x80070005"
)
{
return
fmt
.
Errorf
(
"请使用管理员权限打开本程序"
)
}
else
if
strings
.
Contains
(
outstr
,
"The Software Licensing Service reported that the action requires administrator privilege"
)
{
return
fmt
.
Errorf
(
"请使用管理员权限打开本程序"
)
}
else
if
strings
.
Contains
(
outstr
,
"The Software Licensing Service reported that the product key is invalid"
)
{
return
fmt
.
Errorf
(
"激活使用了错误的密钥"
)
}
}
if
strings
.
Contains
(
outstr
,
"Product key installation successful"
)
{
log
.
Printf
(
"产品密钥激活成功"
)
}
else
{
log
.
Println
(
outstr
)
}
return
nil
}
func
execcmd
(
path
,
args1
string
)
([]
byte
,
error
)
{
cmd
:=
exec
.
Command
(
"powershell"
,
`cscript`
,
"OSPP.VBS"
,
args1
,
"//nologo"
)
cmd
.
Dir
=
path
out
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
return
pub
.
ToChineseChar
(
out
),
err
}
return
pub
.
ToChineseChar
(
out
),
nil
}
func
execcmd_filter
(
path
,
args1
,
args2
string
)
([]
byte
,
error
)
{
cmd
:=
exec
.
Command
(
"powershell"
,
`cscript`
,
"OSPP.VBS"
,
args1
,
"//nologo"
,
"|"
,
"findstr"
,
args2
)
cmd
.
Dir
=
path
out
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
return
pub
.
ToChineseChar
(
out
),
err
}
return
pub
.
ToChineseChar
(
out
),
nil
}
win.go
View file @
fc7f08f5
...
...
@@ -11,7 +11,7 @@ import (
func
checkWindows
()
bool
{
var
status
bool
out
:=
pub
.
Execcmd_output
(
`cscript C:\Windows\SysWOW64\slmgr.vbs /xpr`
)
out
:=
pub
.
Execcmd_output
(
`cscript
/nologo
C:\Windows\SysWOW64\slmgr.vbs /xpr`
)
outs
:=
strings
.
TrimSpace
(
string
(
out
))
winProductName
:=
reg
.
Query_key_one
(
reg
.
HKLM
,
`SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform`
,
"BackupProductKeyDefault"
)
if
strings
.
Contains
(
outs
,
"计算机已永久激活"
)
{
...
...
@@ -22,7 +22,7 @@ func checkWindows() bool {
}
else
if
strings
.
Contains
(
outs
,
"处于通知模式"
)
{
status
=
true
}
else
if
strings
.
Contains
(
outs
,
"批量激活将于"
)
{
log
.
Printf
(
"当前已激活"
)
log
.
Printf
(
"当前已激活
Windows
"
)
return
false
}
else
{
fmt
.
Println
(
outs
)
...
...
@@ -38,6 +38,7 @@ func requestWindowsKey() (string, string, error) {
return
""
,
""
,
fmt
.
Errorf
(
"无法查询到系统产品名称"
)
}
log
.
Printf
(
"系统产品名称:%s
\n
"
,
product
)
// 从服务器获取密钥
pub
.
SendBoomServer
(
pub
.
Msg_Boom_Active
,
product
)
if
pub
.
MS
.
Error
{
return
""
,
""
,
fmt
.
Errorf
(
pub
.
MS
.
Errmsg
)
...
...
@@ -70,7 +71,7 @@ func activeWindows() error {
}
log
.
Printf
(
"探测到kms服务器已经运行"
)
outstr
:=
string
(
pub
.
Execcmd_output
(
`cscript C:\Windows\SysWOW64\slmgr.vbs /skms 192.168.0.21:1688`
))
outstr
:=
string
(
pub
.
Execcmd_output
(
`cscript
/nologo
C:\Windows\SysWOW64\slmgr.vbs /skms 192.168.0.21:1688`
))
if
strings
.
Contains
(
outstr
,
"拒绝访问: 所请求的操作需要提升特权"
)
{
return
fmt
.
Errorf
(
"请使用管理员权限打开本程序"
)
...
...
@@ -78,14 +79,14 @@ func activeWindows() error {
log
.
Printf
(
"kms设置成功"
)
}
outstr
=
string
(
pub
.
Execcmd_output
(
`cscript C:\Windows\SysWOW64\slmgr.vbs /ipk `
+
key
))
outstr
=
string
(
pub
.
Execcmd_output
(
`cscript
/nologo
C:\Windows\SysWOW64\slmgr.vbs /ipk `
+
key
))
if
strings
.
Contains
(
outstr
,
"拒绝访问: 所请求的操作需要提升特权"
)
{
return
fmt
.
Errorf
(
"请使用管理员权限打开本程序"
)
}
else
if
strings
.
Contains
(
outstr
,
"成功地安装了产品密钥"
)
{
log
.
Printf
(
"成功安装产品密钥"
)
}
outstr
=
string
(
pub
.
Execcmd_output
(
`cscript C:\Windows\SysWOW64\slmgr.vbs /ato`
))
outstr
=
string
(
pub
.
Execcmd_output
(
`cscript
/nologo
C:\Windows\SysWOW64\slmgr.vbs /ato`
))
if
strings
.
Contains
(
outstr
,
"拒绝访问: 所请求的操作需要提升特权"
)
{
return
fmt
.
Errorf
(
"请使用管理员权限打开本程序"
)
}
else
if
strings
.
Contains
(
outstr
,
"0x8007000D 数据无效"
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment