Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
AD-Control-Golang
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
陶腾飞
AD-Control-Golang
Commits
328fd35d
Commit
328fd35d
authored
Jul 31, 2022
by
陶腾飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2022/07-31 v2.6.4
parent
8c3999aa
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
148 additions
and
33 deletions
+148
-33
README.MD
+1
-0
public/env.go
+3
-4
public/go.mod
+1
-4
public/go.sum
+1
-7
public/msg_deal.go
+48
-1
public/msg_init.go
+35
-6
public/network.go
+7
-4
public/send.go
+13
-1
public/win.go
+2
-6
public/win_key.go
+30
-0
win_key.yaml
+7
-0
No files found.
README.MD
View file @
328fd35d
...
...
@@ -110,6 +110,7 @@
-
2022/07/21 v2.6.1 自动初始化
-
2022/07/21 v2.6.2 修复发送企业微信消息失败的问题
-
2022/07/28 v2.6.3 小工具初始化excel保护视图问题
-
2022/07-31 v2.6.4 为支持windows激活添加功能
## 四、其他说明
...
...
public/env.go
View file @
328fd35d
...
...
@@ -14,7 +14,7 @@ const SymbolDH = "、"
// AD-Control //
const
Version
string
=
"2.6.
3
"
const
Version
string
=
"2.6.
4
"
const
Host_adserver_lan
string
=
"192.168.0.20"
const
Host_adserver_wan
string
=
"115.231.214.234"
const
Host_adserver
string
=
"ADSERVER"
...
...
@@ -34,8 +34,6 @@ const ZZServerLogDaemon string = Host_zzserver + DaemonLogListen
var
Host_server_download
=
Host_adserver_lan
+
DaemonListen
// users //
// user //
var
User_computername
string
=
GetEnv
(
"COMPUTERNAME"
)
...
...
@@ -67,7 +65,8 @@ const Dir_application string = `H:\software\application\`
// application //
const
App_MultiSplit
string
=
SMB_ADSoftOthTool
+
"win_MultiSplit.exe"
// reg info //
// yaml //
const
Yaml_key
=
`..\win_key.yaml`
const
(
HKCU
=
iota
...
...
public/go.mod
View file @
328fd35d
...
...
@@ -3,22 +3,19 @@ module git.zhiweidata.top/taotengfei/AD-Control-Golang/public
go 1.17
require (
git.zhiweidata.top/taotengfei/AD-Control-Golang/registry v0.0.0
github.com/go-ldap/ldap/v3 v3.4.2
github.com/gookit/color v1.5.0
github.com/lxn/walk v0.0.0-20210112085537-c389da54e794
github.com/mozillazg/go-pinyin v0.19.0
golang.org/x/text v0.3.7
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
)
require (
github.com/Azure/go-ntlmssp v0.0.0-20211209120228-48547f28849e // indirect
github.com/go-asn1-ber/asn1-ber v1.5.3 // indirect
github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 // indirect
golang.org/x/sys v0.0.0-20220403020550-483a9cbc67c0 // indirect
gopkg.in/Knetic/govaluate.v3 v3.0.0 // indirect
)
replace git.zhiweidata.top/taotengfei/AD-Control-Golang/registry v0.0.0 => ..\registry
public/go.sum
View file @
328fd35d
...
...
@@ -10,10 +10,6 @@ github.com/go-ldap/ldap/v3 v3.4.2 h1:zFZKcXKLqZpFMrMQGHeHWKXbDTdNCmhGY9AK41zPh+8
github.com/go-ldap/ldap/v3 v3.4.2/go.mod h1:iYS1MdmrmceOJ1QOTnRXrIs7i3kloqtmGQjRvjKpyMg=
github.com/gookit/color v1.5.0 h1:1Opow3+BWDwqor78DcJkJCIwnkviFi+rrOANki9BUFw=
github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo=
github.com/lxn/walk v0.0.0-20210112085537-c389da54e794 h1:NVRJ0Uy0SOFcXSKLsS65OmI1sgCCfiDUPj+cwnH7GZw=
github.com/lxn/walk v0.0.0-20210112085537-c389da54e794/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ=
github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc=
github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
github.com/mozillazg/go-pinyin v0.19.0 h1:p+J8/kjJ558KPvVGYLvqBhxf8jbZA2exSLCs2uUVN8c=
github.com/mozillazg/go-pinyin v0.19.0/go.mod h1:iR4EnMMRXkfpFVV5FMi4FNB6wGq9NV6uDWbUuPhP4Yc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
...
...
@@ -31,7 +27,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
...
...
@@ -44,8 +39,7 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/Knetic/govaluate.v3 v3.0.0 h1:18mUyIt4ZlRlFZAAfVetz4/rzlJs9yhN+U02F4u1AOc=
gopkg.in/Knetic/govaluate.v3 v3.0.0/go.mod h1:csKLBORsPbafmSCGTEh3U7Ozmsuq8ZSIlKk1bcqph0E=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
public/msg_deal.go
View file @
328fd35d
...
...
@@ -80,6 +80,13 @@ func DealMsg(url []string, query string, unmsg []byte) ([]byte, error) {
ice
:=
msg
.
MsgDeal
()
ret
=
ReParseJson
(
&
ice
)
// BOOM 消息
case
Msg_Boom
:
var
msg
MJBoom
ParseJson
(
unmsg
,
&
msg
)
ice
:=
msg
.
MsgDeal
()
ret
=
ReParseJson
(
&
ice
)
// 将包含关于知微运维平台的人员、权限变化的任何消息
default
:
msg
:=
ParseWX
(
query
,
&
unmsg
)
...
...
@@ -884,7 +891,47 @@ func (wxwork *MJwxwork) MsgDealSend() {
wxwork
.
SendResult
()
}
// /wxauth的企业微信登录后 的 消息处理
// 关于 Boom 的消息处理
func
(
boom
*
MJBoom
)
MsgDeal
()
interface
{}
{
switch
boom
.
Status
{
case
Msg_status_commit
:
LOG
(
INFO
,
""
,
fmt
.
Sprintf
(
"请求激活的对象是%s,状态为%s"
,
boom
.
DataStr
,
boom
.
Instruction
))
m
,
err
:=
getYAML
(
Yaml_key
)
if
err
!=
nil
{
LOG
(
ERROR
,
""
,
err
)
boom
.
Error
=
true
boom
.
Errmsg
=
err
.
Error
()
}
key
,
err
:=
getkeyFromYAML
(
boom
.
DataStr
,
m
[
boom
.
DataStr
],
key_time
)
if
err
!=
nil
{
LOG
(
ERROR
,
""
,
err
)
boom
.
Error
=
true
boom
.
Errmsg
=
err
.
Error
()
break
}
boom
.
PlusStr
=
key
boom
.
Error
=
false
case
Msg_status_deal
:
MS
.
S
=
boom
.
PlusStr
MS
.
Error
=
boom
.
Error
MS
.
Errmsg
=
boom
.
Errmsg
}
// 修改状态
switch
boom
.
Status
{
// 服务器
case
Msg_status_commit
:
boom
.
Status
=
Msg_status_deal
// 客户端
case
Msg_status_deal
:
return
nil
}
return
boom
}
// wxauth的企业微信登录后 的 消息处理
func
WXAuth
(
query
string
)
string
{
s
:=
strings
.
Split
(
query
,
"&"
)
q
:=
make
(
map
[
string
]
string
,
len
(
s
))
...
...
public/msg_init.go
View file @
328fd35d
...
...
@@ -21,8 +21,9 @@ const Msg_WXAuth string = "wxauth"
const
Msg_Report
string
=
"report"
const
Msg_Exec
string
=
"exec"
const
Msg_Wake
string
=
"wake"
const
Msg_CmdbInfo
string
=
"cmdbinfo"
const
Msg_Wxwork
string
=
"wxwork"
const
Msg_CmdbInfo
string
=
"cmdbinfo"
const
Msg_Boom
string
=
"boom"
// msg report type ///////////////////////////////////////////////////////////
...
...
@@ -57,7 +58,7 @@ const Msg_Exec_InstallSoftware string = "installsoftware"
const
Msg_Exec_OpenAdminEXE
string
=
"OpenAdmin"
const
Msg_Exec_OpenRemoteTerminal
string
=
"OpenRemoteTerminal"
// msg w
ka
e type ////////////////////////////////////////////////////////////////
// msg w
ak
e type ////////////////////////////////////////////////////////////////
const
Msg_Wake_Status_Req
string
=
"WakeReq"
const
Msg_Wake_Status_Start
string
=
"WakeStart"
...
...
@@ -66,6 +67,9 @@ const Msg_Wake_Status_Over string = "WakeOver"
// msg cmdb info key //
const
Msg_CmdbInfo_update
string
=
"update"
// msg boom type //
const
Msg_Boom_Active
string
=
"active"
// msg wxwork event key ////////////////////////////////////////////////////////////////
const
WXEK_zwDevopsPowerWake
string
=
"zwdevops_power_wake"
...
...
@@ -89,10 +93,12 @@ const (
)
type
MsgSwitch
struct
{
S
string
B
bool
SS
[]
string
I
int
S
string
Error
bool
Errmsg
string
B
bool
SA
[]
string
I
int
}
//
...
...
@@ -150,6 +156,9 @@ type MJwxwork struct {
Result
string
Content
string
}
// CMDB Json Format /////////////////////////////////////////////////////
type
MJCmdbInfo
struct
{
MsgType
string
`json:"msgtype"`
Status
string
`json:"status"`
...
...
@@ -159,6 +168,15 @@ type MJCmdbInfo struct {
DataBool
bool
`json:"databool"`
}
// BOOM Json Format /////////////////////////////////////////////////////
type
MJBoom
struct
{
MJbase
BoomStatus
string
`json:"Boomstatus"`
Error
bool
`json:"error"`
Errmsg
string
`json:"errmsg"`
}
//
//
// quickly Get & Set Json
...
...
@@ -294,3 +312,14 @@ func (wxwork *MJwxwork) SplitMessage() (string, string, string) {
s
:=
strings
.
Split
(
wxwork
.
Content
,
"
\n
"
)
return
strings
.
Split
(
s
[
1
],
":"
)[
1
],
strings
.
Split
(
s
[
2
],
":"
)[
1
],
strings
.
Split
(
s
[
3
],
":"
)[
1
]
}
// Boom
func
GJBoom
(
i
,
s
string
)
MJBoom
{
var
boom
MJBoom
boom
.
MsgType
=
Msg_Boom
boom
.
Status
=
Msg_status_commit
boom
.
Instruction
=
i
boom
.
DataStr
=
s
return
boom
}
public/network.go
View file @
328fd35d
...
...
@@ -8,15 +8,16 @@ import (
func
Telnet
(
ip
,
port
string
)
bool
{
// 3 秒超时
conn
,
err
:=
net
.
DialTimeout
(
"tcp"
,
ip
+
port
,
3
*
time
.
Second
)
conn
,
err
:=
net
.
DialTimeout
(
"tcp"
,
fmt
.
Sprintf
(
"%s:%s"
,
ip
,
port
)
,
3
*
time
.
Second
)
if
err
!=
nil
{
return
false
// todo log handler
}
else
{
if
conn
!=
nil
{
_
=
conn
.
Close
()
return
true
}
else
{
fmt
.
Printf
(
"conn错误"
)
return
false
}
}
...
...
@@ -24,7 +25,7 @@ func Telnet(ip, port string) bool {
var
initServer
=
false
func
DownloadFileInside
(
url
,
saveFile
string
)
error
{
func
initDownloadServer
()
{
if
!
initServer
{
if
Telnet
(
Host_adserver_wan
,
DaemonListen
[
1
:
])
{
Host_server_download
=
Host_adserver_wan
+
DaemonListen
...
...
@@ -33,9 +34,11 @@ func DownloadFileInside(url, saveFile string) error {
}
initServer
=
true
}
}
func
DownloadFileInside
(
url
,
saveFile
string
)
error
{
initDownloadServer
()
fullurl
:=
fmt
.
Sprintf
(
"http://%s/%s"
,
Host_server_download
,
url
)
LOG
(
INFO
,
"Download"
,
fullurl
)
// 采用外部工具进行下载的原因时,文件会写入变量中
// 对于大文件将加载超过文件本身大小的4倍内存
...
...
public/send.go
View file @
328fd35d
...
...
@@ -146,7 +146,7 @@ func SendWX(Content string) {
}
// 发送应用消息
(
// 发送应用消息
给个人
// https://developer.work.weixin.qq.com/document/path/90236
func
SendWxworkTextToAUser
(
nameOrID
,
text
string
)
error
{
...
...
@@ -174,6 +174,8 @@ func SendWxworkTextToAUser(nameOrID, text string) error {
}
return
nil
}
// 发送应用消息给指定ID的群
func
SendWXWrokTextToChat
(
chatid
string
,
Content
string
)
error
{
if
DomainCotroller
()
{
if
Opt_SendWX_state
==
"0"
{
...
...
@@ -204,15 +206,25 @@ func SendWXWrokTextToChat(chatid string, Content string) error {
}
return
nil
}
// 发送应用消息给管理员
func
SendWxworkTextToAdmins
(
nameOrID
string
)
error
{
return
SendWxworkTextToAUser
(
"TaoTengFei|BaoJiaQi"
,
nameOrID
)
}
// 发送应用消息给HR
func
SendWxworkTextToHR
(
nameOrID
string
)
error
{
return
SendWxworkTextToAUser
(
"TaoTengFei|BaoJiaQi|BianShuang"
,
nameOrID
)
}
// 发送应用消息给群聊 域用户管理与通知
func
SendWXWrokTextToChatAccountManager
(
content
string
)
error
{
return
SendWXWrokTextToChat
(
WXWORK_zwDevopsChatAccountManager
,
content
)
}
func
SendBoomServer
(
i
,
s
string
)
{
initDownloadServer
()
SendMsg
(
Host_server_download
,
Msg_Boom
,
GJBoom
(
i
,
s
))
}
// 根据主机位置定义发送的服务器
...
...
public/win.go
View file @
328fd35d
...
...
@@ -133,10 +133,9 @@ func Execcmd_output(cmdargs string) []byte {
return
nil
}
if
out
,
err2
:=
exec
.
Command
(
app
,
appargs
...
)
.
CombinedOutput
();
err2
!=
nil
{
LOG
(
ERROR
,
"CombinedOutput"
,
err2
)
return
ToChineseChar
(
out
)
}
else
{
return
out
return
ToChineseChar
(
out
)
}
return
nil
}
...
...
@@ -178,9 +177,6 @@ func PSCommandOutput(cmd string) (string, error) {
return
""
,
err
}
out
:=
ToChineseChar
(
r
)
if
err
!=
nil
{
return
""
,
err
}
return
strings
.
TrimSpace
(
string
(
out
)),
nil
}
func
PSCommandPromptWait
(
cmd
string
)
error
{
...
...
public/win_key.go
0 → 100644
View file @
328fd35d
package
public
import
(
"fmt"
"io/ioutil"
"gopkg.in/yaml.v3"
)
var
key_time
int
=
0
func
getYAML
(
file
string
)
(
map
[
string
][]
string
,
error
)
{
yamlFile
,
err
:=
ioutil
.
ReadFile
(
file
)
if
err
!=
nil
{
return
nil
,
err
}
m
:=
make
(
map
[
string
][]
string
)
yerr
:=
yaml
.
Unmarshal
(
yamlFile
,
&
m
)
if
yerr
!=
nil
{
return
nil
,
yerr
}
return
m
,
nil
}
func
getkeyFromYAML
(
obj
string
,
m
[]
string
,
c
int
)
(
string
,
error
)
{
if
len
(
m
)
==
0
{
return
""
,
fmt
.
Errorf
(
"暂不支持 %s"
,
obj
)
}
return
m
[
c
%
len
(
m
)],
nil
}
win_key.yaml
0 → 100644
View file @
328fd35d
Windows 10 Pro
:
-
W269N-WFGWX-YVC9B-4J6C9-T83GX
-
YC7N8-G7WR6-9WR4H-6Y2W4-KBT6X
# office:
# 16.0:
\ No newline at end of file
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