-
Notifications
You must be signed in to change notification settings - Fork 116
/
envCheck.go
52 lines (44 loc) · 1.27 KB
/
envCheck.go
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
40
41
42
43
44
45
46
47
48
49
50
51
52
package conf
import (
"fmt"
"github.com/go-rod/rod/lib/launcher"
"os"
"os/exec"
)
/**
@author: yhy
@since: 2024/4/12
@desc: 检查 namp、masscan、chrome 是否已经安装
**/
var ChromePath string
func Preparations() {
if !GlobalConfig.NoPortScan { // 不进行端口扫描时,不检查这些
Plugin["portScan"] = false
// 检查 nmap 是否已安装
nmapInstalled := commandExists("nmap")
if !nmapInstalled {
fmt.Println("nmap not found, please install")
os.Exit(1)
}
// 检查 masscan 是否已安装
masscanInstalled := commandExists("masscan")
if !masscanInstalled {
fmt.Println("masscan not found, please install")
os.Exit(1)
}
}
if GlobalConfig.WebScan.Craw == "c" {
// 检查 chromium 是否已安装
if path, exists := launcher.LookPath(); exists {
ChromePath = path
} else {
fmt.Println("chromium does not follow, please install https://www.chromium.org/getting-involved/download-chromium/")
os.Exit(1)
}
}
}
// 检查命令是否可执行
func commandExists(cmd string) bool {
_, err := exec.LookPath(cmd)
return err == nil
}