mirror of https://gitee.com/openkylin/genmai.git
update
This commit is contained in:
parent
275a8fa510
commit
04d16f8bb2
6
go.mod
6
go.mod
|
@ -4,7 +4,11 @@ go 1.17
|
|||
|
||||
require (
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
golang.org/x/crypto v0.2.0
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
)
|
||||
|
||||
require github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
require (
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
golang.org/x/sys v0.2.0 // indirect
|
||||
)
|
||||
|
|
31
go.sum
31
go.sum
|
@ -2,6 +2,37 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
|
|||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.2.0 h1:BRXPfhNivWL5Yq0BGQ39a2sW6t44aODpfxkWjYdzewE=
|
||||
golang.org/x/crypto v0.2.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM=
|
||||
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
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.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
|
|
27
main.go
27
main.go
|
@ -20,15 +20,13 @@ type Vul struct{
|
|||
Docs string //生成报告
|
||||
PoolStatNum int //启动协程任务数
|
||||
IP string //web 制定IP
|
||||
MD string //生成MD文件
|
||||
RemoteAssessment string //远程检测
|
||||
SSHHost string //主机IP
|
||||
SSHUser string //用户名
|
||||
SSHPassword string //密码
|
||||
}
|
||||
func main(){
|
||||
// ///////////////////////////////
|
||||
// // test "main/src/genmai"
|
||||
// genmai.Test()
|
||||
// // config := genmai.NewConfig()
|
||||
// fmt.Println(">>")
|
||||
// //fmt.Println(config["id"])
|
||||
// return
|
||||
|
||||
//检测架构是否符合漏扫架构
|
||||
// result:=Actuator.OsCheck()
|
||||
|
@ -43,15 +41,28 @@ func main(){
|
|||
flag.StringVar(&vul.System, "system", "false", "使用系统漏洞的验证模块,可联合其他模块使用")
|
||||
flag.StringVar(&vul.Kernel, "kernel", "false", "使用内核漏洞的验证模块,可联合其他模块使用")
|
||||
flag.StringVar(&vul.BaseLine, "baseline", "false", "使用基线检测模块,可联合其他模块使用")
|
||||
|
||||
|
||||
var RA = flag.Bool("RA", false, "使用远程检测,只能单独使用模块")
|
||||
flag.StringVar(&vul.SSHHost, "H", "false", "远程检测指定host")
|
||||
flag.StringVar(&vul.SSHUser, "user", "false", "远程检测指定用户")
|
||||
flag.StringVar(&vul.SSHPassword, "passwd", "false", "远程登录密码")
|
||||
|
||||
var All = flag.Bool("all", false, "只扫描除web模块外的所有模块的所有poc,不可联合其他参数使用")
|
||||
var Update = flag.Bool("update", false, "更新程序到最新版本,不可联合其他参数使用")
|
||||
|
||||
vul.PoolStatNum =0
|
||||
flag.Parse()
|
||||
|
||||
//初始化bool值
|
||||
sAll :=strconv.FormatBool(*All)
|
||||
vul.Update=strconv.FormatBool(*Update)
|
||||
ArgParser.ParameterParser(vul.System,vul.Kernel,vul.Web,vul.BaseLine,sAll,vul.PoolStatNum,vul.ParserNum,vul.Update,vul.IP)
|
||||
vul.RemoteAssessment=strconv.FormatBool(*RA)
|
||||
if vul.RemoteAssessment=="true"{
|
||||
ArgParser.RemoteArgParser(vul.SSHHost,vul.SSHUser,vul.SSHPassword)
|
||||
}else{
|
||||
ArgParser.ParameterParser(vul.System,vul.Kernel,vul.Web,vul.BaseLine,sAll,vul.PoolStatNum,vul.ParserNum,vul.Update,vul.IP)
|
||||
}
|
||||
return
|
||||
|
||||
///////////////////////////////
|
||||
|
|
|
@ -26,4 +26,4 @@ func IPCheck(IP string)(matchResult string){
|
|||
// fmt.Println(match)
|
||||
matchResult=strconv.FormatBool(match)
|
||||
return matchResult
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ var Num int
|
|||
var RequestsIP string
|
||||
var PoolStatNums int
|
||||
func ParameterParser(sSystem string,sKernel string,sWeb string,sBaseLine string,sAll string,PoolStatNum int,ParserNum int,Update string ,IP string){
|
||||
|
||||
if sSystem!="false"{
|
||||
if sSystem=="All"{
|
||||
PoolStatNum=PoolStatNum+1
|
||||
|
@ -120,8 +121,19 @@ func ParameterParser(sSystem string,sKernel string,sWeb string,sBaseLine string,
|
|||
flag.PrintDefaults()
|
||||
return
|
||||
}
|
||||
|
||||
//协程最大值为200
|
||||
if ParserNum<0 || ParserNum>200{
|
||||
fmt.Println("协程最大值为0-200")
|
||||
return
|
||||
}else{
|
||||
Num=ParserNum
|
||||
}
|
||||
|
||||
PoolStatNums=PoolStatNum
|
||||
Num=ParserNum
|
||||
fmt.Println(RequestsWeb)
|
||||
Pool.CoprogramPool(Num,RequestsSystem,RequestsKernel,RequestsWeb,RequestsBaseLine,PoolStatNums,RequestsIP)
|
||||
}
|
||||
|
||||
func RemoteArgParser(SSHHost string,SSHUser string,SSHPassword string){
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package RemoteCheck
|
||||
|
||||
import (
|
||||
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
|
||||
"log"
|
||||
|
||||
"time"
|
||||
|
||||
)
|
||||
|
||||
func SSHConnect(){
|
||||
|
||||
sshHost := "127.0.0.1"
|
||||
|
||||
sshUser := "song"
|
||||
|
||||
sshPassword := "sbcj1999"
|
||||
|
||||
sshType := "password"
|
||||
|
||||
sshPort := 22
|
||||
|
||||
//创建sshp登陆配置
|
||||
|
||||
config := &ssh.ClientConfig{
|
||||
|
||||
Timeout: 5*time.Second,//ssh 连接time out 时间一秒钟, 如果ssh验证错误 会在一秒内返回
|
||||
|
||||
User: sshUser,
|
||||
|
||||
HostKeyCallback: ssh.InsecureIgnoreHostKey(), //这个可以, 但是不够安全
|
||||
|
||||
//HostKeyCallback: hostKeyCallBackFunc(h.Host),
|
||||
|
||||
}
|
||||
|
||||
if sshType == "password" {
|
||||
|
||||
config.Auth = []ssh.AuthMethod{ssh.Password(sshPassword)}
|
||||
|
||||
}
|
||||
|
||||
//dial 获取ssh client
|
||||
|
||||
addr := fmt.Sprintf("%s:%d", sshHost, sshPort)
|
||||
|
||||
sshClient, err := ssh.Dial("tcp", addr, config)
|
||||
|
||||
if err != nil {
|
||||
|
||||
log.Fatal("创建ssh client 失败",err)
|
||||
|
||||
}
|
||||
|
||||
defer sshClient.Close()
|
||||
|
||||
//创建ssh-session
|
||||
|
||||
session, err := sshClient.NewSession()
|
||||
|
||||
if err != nil {
|
||||
|
||||
log.Fatal("创建ssh session 失败",err)
|
||||
|
||||
}
|
||||
|
||||
defer session.Close()
|
||||
|
||||
//执行远程命令
|
||||
|
||||
command:="whoami"
|
||||
combo,err := session.CombinedOutput(command)
|
||||
|
||||
if err != nil {
|
||||
|
||||
log.Fatal("远程执行cmd 失败",err)
|
||||
|
||||
}
|
||||
|
||||
log.Println("命令输出:",string(combo))
|
||||
defer session.Close()
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
|
||||
"log"
|
||||
|
||||
"time"
|
||||
|
||||
)
|
||||
|
||||
func main(){
|
||||
|
||||
sshHost := "127.0.0.1"
|
||||
|
||||
sshUser := "song"
|
||||
|
||||
sshPassword := "sbcj1999"
|
||||
|
||||
sshType := "password"
|
||||
|
||||
sshPort := 22
|
||||
|
||||
//创建sshp登陆配置
|
||||
|
||||
config := &ssh.ClientConfig{
|
||||
|
||||
Timeout: 5*time.Second,//ssh 连接time out 时间一秒钟, 如果ssh验证错误 会在一秒内返回
|
||||
|
||||
User: sshUser,
|
||||
|
||||
HostKeyCallback: ssh.InsecureIgnoreHostKey(), //这个可以, 但是不够安全
|
||||
|
||||
//HostKeyCallback: hostKeyCallBackFunc(h.Host),
|
||||
|
||||
}
|
||||
|
||||
if sshType == "password" {
|
||||
|
||||
config.Auth = []ssh.AuthMethod{ssh.Password(sshPassword)}
|
||||
|
||||
}
|
||||
|
||||
//dial 获取ssh client
|
||||
|
||||
addr := fmt.Sprintf("%s:%d", sshHost, sshPort)
|
||||
|
||||
sshClient, err := ssh.Dial("tcp", addr, config)
|
||||
|
||||
if err != nil {
|
||||
|
||||
log.Fatal("创建ssh client 失败",err)
|
||||
|
||||
}
|
||||
|
||||
defer sshClient.Close()
|
||||
|
||||
//创建ssh-session
|
||||
|
||||
session, err := sshClient.NewSession()
|
||||
|
||||
if err != nil {
|
||||
|
||||
log.Fatal("创建ssh session 失败",err)
|
||||
|
||||
}
|
||||
|
||||
defer session.Close()
|
||||
|
||||
//执行远程命令
|
||||
|
||||
command:="whoami"
|
||||
combo,err := session.CombinedOutput(command)
|
||||
|
||||
if err != nil {
|
||||
|
||||
log.Fatal("远程执行cmd 失败",err)
|
||||
|
||||
}else{
|
||||
log.Println("命令输出:",string(combo))
|
||||
defer session.Close()
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue