File tree Expand file tree Collapse file tree 5 files changed +41
-4
lines changed Expand file tree Collapse file tree 5 files changed +41
-4
lines changed Original file line number Diff line number Diff line change 56
56
"naabu_dns" : {},
57
57
"naabu" : {"TopPorts" : " http" ,"ScanAllIPS" : true },
58
58
"nuclei" : {},
59
- "enablEmbedYaml" : false ,
59
+ "enablEmbedYaml" : true ,
60
60
"httpx" : {},
61
61
"enableEsSv" : false ,
62
62
"esthread" : 8 ,
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ func main() {
46
46
// 弱密码检测
47
47
var wg sync.WaitGroup
48
48
wg .Add (1 )
49
- go hydra .DoNmapRst (wg )
49
+ go hydra .DoNmapRst (& wg )
50
50
err = naabuRunner .Httpxrun ()
51
51
if err != nil {
52
52
gologger .Fatal ().Msgf ("naabuRunner.Httpxrun Could not run httpRunner: %s\n " , err )
Original file line number Diff line number Diff line change 1
1
package pkg
2
2
3
3
import (
4
+ "bytes"
4
5
"encoding/json"
5
6
"fmt"
6
7
"github.com/spf13/viper"
7
8
"io/ioutil"
8
9
"log"
9
10
"os"
11
+ "os/exec"
12
+ "regexp"
13
+ "runtime"
10
14
"strings"
11
15
)
12
16
@@ -147,3 +151,35 @@ func init() {
147
151
}
148
152
149
153
var G_Options interface {}
154
+
155
+ func GetNmap () string {
156
+ nmap := "nmap"
157
+ if runtime .GOOS == "windows" {
158
+ nmap = "nmap.exe"
159
+ }
160
+ return nmap
161
+ }
162
+
163
+ func CheckHvNmap () bool {
164
+ r , _ := regexp .Compile (`.*Starting Nmap \d\.\d+.*` )
165
+ s , err := DoCmd (GetNmap (), "-v" )
166
+ if nil == err && r .Match ([]byte (s )) {
167
+ return true
168
+ }
169
+ return false
170
+ }
171
+
172
+ // 最佳的方法是将命令写到临时文件,并通过bash进行执行
173
+ func DoCmd (args ... string ) (string , error ) {
174
+ cmd := exec .Command (args [0 ], args [1 :]... )
175
+ var stdout , stderr bytes.Buffer
176
+ cmd .Stdout = & stdout // 标准输出
177
+ cmd .Stderr = & stderr // 标准错误
178
+ err := cmd .Run ()
179
+ outStr , errStr := string (stdout .Bytes ()), string (stderr .Bytes ())
180
+ // out, err := cmd.CombinedOutput()
181
+ if nil != err {
182
+ return "" , err
183
+ }
184
+ return string (outStr + "\n " + errStr ), err
185
+ }
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ func DoParseXml(s string) {
70
70
}
71
71
}
72
72
73
- func DoNmapRst (wg sync.WaitGroup ) {
73
+ func DoNmapRst (wg * sync.WaitGroup ) {
74
74
defer wg .Done ()
75
75
if x1 , ok := pkg .TmpFile [pkg .Naabu ]; ok {
76
76
for _ , x := range x1 {
Original file line number Diff line number Diff line change @@ -213,6 +213,7 @@ func (r *Runner) RunEnumeration() error {
213
213
if err := r .scanner .IPRanger .Add (cidr .String ()); err != nil {
214
214
gologger .Warning ().Msgf ("Couldn't track %s in scan results: %s\n " , cidr , err )
215
215
}
216
+ // 可以优化基于nmap
216
217
ipStream , _ := mapcidr .IPAddressesAsStream (cidr .String ())
217
218
for ip := range ipStream {
218
219
for _ , port := range r .scanner .Ports {
@@ -335,7 +336,7 @@ func (r *Runner) RunEnumeration() error {
335
336
r .options .ResumeCfg .Retry = currentRetry
336
337
r .options .ResumeCfg .Seed = currentSeed
337
338
r .options .ResumeCfg .Unlock ()
338
-
339
+ // 可以优化基于nmap
339
340
b := blackrock .New (int64 (Range ), currentSeed )
340
341
for index := int64 (0 ); index < int64 (Range ); index ++ {
341
342
xxx := b .Shuffle (index )
You can’t perform that action at this time.
0 commit comments