mirror of https://gitee.com/openkylin/genmai.git
commit
d5ed0a92b9
14
main.go
14
main.go
|
@ -6,7 +6,8 @@ import (
|
|||
"fmt"
|
||||
"flag"
|
||||
"strconv"
|
||||
// "main/src/Actuator"
|
||||
"strings"
|
||||
|
||||
genmai "main/src/genmai"
|
||||
)
|
||||
type Vul struct{
|
||||
|
@ -58,8 +59,17 @@ func main(){
|
|||
sAll :=strconv.FormatBool(*All)
|
||||
vul.Update=strconv.FormatBool(*Update)
|
||||
vul.RemoteAssessment=strconv.FormatBool(*RA)
|
||||
|
||||
//是否开启远程检测
|
||||
if vul.RemoteAssessment=="true"{
|
||||
ArgParser.RemoteArgParser(vul.SSHHost,vul.SSHUser,vul.SSHPassword)
|
||||
checkResult:=ArgParser.RemoteArgParser(vul.SSHHost,vul.SSHUser,vul.SSHPassword)
|
||||
checkResult=strings.TrimSpace(checkResult)
|
||||
if checkResult=="true"{
|
||||
fmt.Println("不允许登录root用户进行验证")
|
||||
}else if checkResult=="false"{
|
||||
ArgParser.ParameterParser(vul.System,vul.Kernel,vul.Web,vul.BaseLine,sAll,vul.PoolStatNum,vul.ParserNum,vul.Update,vul.IP)
|
||||
}
|
||||
|
||||
}else{
|
||||
ArgParser.ParameterParser(vul.System,vul.Kernel,vul.Web,vul.BaseLine,sAll,vul.PoolStatNum,vul.ParserNum,vul.Update,vul.IP)
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@ import(
|
|||
"flag"
|
||||
"fmt"
|
||||
"main/src/genmai/Pool"
|
||||
"main/src/genmai/RemoteCheck"
|
||||
"strings"
|
||||
"strconv"
|
||||
)
|
||||
var RequestsWeb string
|
||||
var RequestsSystem string
|
||||
|
@ -134,6 +137,17 @@ func ParameterParser(sSystem string,sKernel string,sWeb string,sBaseLine string,
|
|||
Pool.CoprogramPool(Num,RequestsSystem,RequestsKernel,RequestsWeb,RequestsBaseLine,PoolStatNums,RequestsIP)
|
||||
}
|
||||
|
||||
func RemoteArgParser(SSHHost string,SSHUser string,SSHPassword string){
|
||||
func RemoteArgParser(SSHHost string,SSHUser string,SSHPassword string)(checkResult string){
|
||||
if SSHHost !="false" && SSHUser !="false" &&SSHPassword !="false"{
|
||||
|
||||
SSHHostCheck:=IPCheck(SSHHost)
|
||||
if SSHHostCheck !="true"{
|
||||
fmt.Println("host错误")
|
||||
}else{
|
||||
command:="id"
|
||||
result:=RemoteCheck.SSHConnect(SSHHost,SSHUser,SSHPassword,command)
|
||||
checkResult=strconv.FormatBool(strings.Contains(result, "root"))
|
||||
}
|
||||
}
|
||||
return checkResult
|
||||
}
|
|
@ -64,7 +64,6 @@ func CoprogramPool(Num int,RequestsSystem string,RequestsKernel string,RequestsW
|
|||
}
|
||||
WebTask := func() {
|
||||
fmt.Println("webTask..")
|
||||
fmt.Println(RequestsWeb)
|
||||
//处理web
|
||||
|
||||
wg.Done()
|
||||
|
|
|
@ -12,13 +12,13 @@ import (
|
|||
|
||||
)
|
||||
|
||||
func SSHConnect(){
|
||||
func SSHConnect(SSHHost string,SSHUser string, SSHPassword string,command string)(result string){
|
||||
|
||||
sshHost := "127.0.0.1"
|
||||
sshHost := SSHHost
|
||||
|
||||
sshUser := "song"
|
||||
sshUser := SSHUser
|
||||
|
||||
sshPassword := "sbcj1999"
|
||||
sshPassword := SSHPassword
|
||||
|
||||
sshType := "password"
|
||||
|
||||
|
@ -54,6 +54,7 @@ func SSHConnect(){
|
|||
|
||||
log.Fatal("创建ssh client 失败",err)
|
||||
|
||||
|
||||
}
|
||||
|
||||
defer sshClient.Close()
|
||||
|
@ -65,22 +66,24 @@ func SSHConnect(){
|
|||
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.Fatal("远程执行cmd 失败",err,command)
|
||||
|
||||
|
||||
}
|
||||
|
||||
log.Println("命令输出:",string(combo))
|
||||
defer session.Close()
|
||||
result=string(combo)
|
||||
return result
|
||||
}
|
Loading…
Reference in New Issue