Skip to content

Commit e5b4e04

Browse files
committed
fix 异步nmap无结果的bug 2022-07-08 08:24:1657239869
1 parent f45d918 commit e5b4e04

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

config/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"naabu_dns": {},
5757
"naabu": {"TopPorts": "full","ScanAllIPS": true},
5858
"nuclei": {},
59-
"enablEmbedYaml": true,
59+
"enablEmbedYaml": false,
6060
"httpx": {},
6161
"enableEsSv": false,
6262
"esthread": 8,

pkg/hydra/doNmapResult.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import (
1212
)
1313

1414
// 弱口令检测
15-
func CheckWeakPassword(ip, service string, port int) {
15+
func CheckWeakPassword(ip, service string, port int, wg *sync.WaitGroup) {
16+
defer wg.Done()
1617
// 在弱口令检测范围就开始检测,结果....
1718
service = strings.ToLower(service)
1819
if pkg.Contains(ProtocolList, service) {
1920
//log.Println("start CheckWeakPassword ", ip, ":", port, "(", service, ")")
20-
Start(ip, port, service)
21+
wg.Add(1)
22+
Start(ip, port, service, wg)
2123
}
2224
}
2325

@@ -30,7 +32,8 @@ func GetAttr(att []xmlquery.Attr, name string) string {
3032
return ""
3133
}
3234

33-
func DoParseXml(s string) {
35+
func DoParseXml(s string, wg *sync.WaitGroup) {
36+
defer wg.Done()
3437
doc, err := xmlquery.Parse(strings.NewReader(s))
3538
if err != nil {
3639
log.Println(err)
@@ -47,7 +50,8 @@ func DoParseXml(s string) {
4750
szPort := GetAttr(x.Attr, "portid")
4851
port, _ := strconv.Atoi(szPort)
4952
service := GetAttr(x.SelectElement("service").Attr, "name")
50-
go CheckWeakPassword(ip, service, port)
53+
wg.Add(1)
54+
go CheckWeakPassword(ip, service, port, wg)
5155
// 存储结果到其他地方
5256
//x9 := AuthInfo{IPAddr: ip, Port: port, Protocol: service}
5357
if "true" == enableEsSv {
@@ -81,7 +85,8 @@ func DoNmapRst(wg *sync.WaitGroup) {
8185
b, err := ioutil.ReadFile(x.Name())
8286
if nil == err && 0 < len(b) {
8387
//log.Println("read config file ok: ", s)
84-
DoParseXml(string(b))
88+
wg.Add(1)
89+
DoParseXml(string(b), wg)
8590
}
8691
}
8792
} else {

pkg/hydra/runner.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/logrusorgru/aurora"
88
"log"
99
"strings"
10+
"sync"
1011
)
1112

1213
func init() {
@@ -26,7 +27,8 @@ func init() {
2627
}
2728

2829
// 密码破解
29-
func Start(IPAddr string, Port int, Protocol string) {
30+
func Start(IPAddr string, Port int, Protocol string, wg *sync.WaitGroup) {
31+
defer wg.Done()
3032
authInfo := NewAuthInfo(IPAddr, Port, Protocol)
3133
crack := NewCracker(authInfo, true, 128)
3234
fmt.Printf("\n[hydra]->开始对%v:%v[%v]进行暴力破解,字典长度为:%d\n", IPAddr, Port, Protocol, crack.Length())

0 commit comments

Comments
 (0)