Skip to content

Commit 418b5a3

Browse files
committed
fix 当将非http端口加上http进行盲打时发生当req和header无效导致当内存错误 2022-07-10 02:42:1657392140
1 parent a95bc4a commit 418b5a3

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

brute/filefuzz.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ func reqPage(u string) (*page, *pkg.Response, error) {
7070
InitGeneral()
7171
regs = append(regs, ret...)
7272
for _, reg := range regs {
73-
matched, _ := regexp.Match(reg, []byte(req.Header.Get("Content-Type")))
74-
if matched {
75-
page.isBackUpPage = true
73+
if x0, ok := req.Header["Content-Type"]; ok && 0 < len(x0) {
74+
matched, _ := regexp.Match(reg, []byte(x0[0]))
75+
if matched {
76+
page.isBackUpPage = true
77+
}
7678
}
7779
}
7880
if req.StatusCode == 403 && strings.HasSuffix(u, "/") {

nuclei_Yaml/nuclei_yaml.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package nuclei_Yaml
22

33
import (
44
"bytes"
5-
"fmt"
65
"github.com/hktalent/scan4all/pkg"
6+
"log"
77
"os"
88
"strings"
99
"time"
@@ -22,7 +22,7 @@ var (
2222
options = &types.Options{}
2323
)
2424

25-
func RunNuclei(buf bytes.Buffer, xx chan bool) {
25+
func RunNuclei(buf *bytes.Buffer, xx chan bool) {
2626
defer func() {
2727
xx <- true
2828
close(xx)
@@ -34,7 +34,8 @@ func RunNuclei(buf bytes.Buffer, xx chan bool) {
3434
}
3535

3636
readConfig()
37-
options.Targets = strings.Split(buf.String(), "\n")
37+
options.Targets = strings.Split(strings.TrimSpace(buf.String()), "\n")
38+
log.Printf("options.Targets = %+v", options.Targets)
3839
runner.ParseOptions(options)
3940
/////////////////////////////////////
4041
options.Verbose = false
@@ -54,7 +55,7 @@ func RunNuclei(buf bytes.Buffer, xx chan bool) {
5455
////////////////////////////////////*/
5556
nucleiRunner, err := runner.New(options)
5657
if err != nil {
57-
fmt.Println(options)
58+
//fmt.Println(options)
5859
gologger.Fatal().Msgf("nucleiRunner Could not create runner: %s\n", err)
5960
}
6061
if nucleiRunner == nil {

pkg/naabu/v2/pkg/runner/options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func ParseOptions() *Options {
150150

151151
flagSet.CreateGroup("optimization", "Optimization",
152152
flagSet.IntVar(&options.Retries, "retries", DefaultRetriesSynScan, "number of retries for the port scan"),
153-
flagSet.IntVar(&options.Timeout, "timeout", DefaultPortTimeoutSynScan/2, "millisecond to wait before timing out"),
153+
flagSet.IntVar(&options.Timeout, "timeout", DefaultPortTimeoutSynScan, "millisecond to wait before timing out"),
154154
flagSet.IntVar(&options.WarmUpTime, "warm-up-time", 2, "time in seconds between scan phases"),
155155
flagSet.BoolVar(&options.Ping, "ping", false, "ping probes for verification of host"),
156156
flagSet.BoolVar(&options.Verify, "verify", false, "validate the ports again with TCP verification"),
@@ -162,7 +162,7 @@ func ParseOptions() *Options {
162162
flagSet.BoolVarP(&options.NoColor, "nc", "no-color", false, "disable colors in CLI output"),
163163
flagSet.BoolVar(&options.Silent, "silent", false, "display only results in output"),
164164
flagSet.BoolVar(&options.Version, "version", false, "display version of naabu"),
165-
flagSet.BoolVar(&options.EnableProgressBar, "stats", true, "display stats of the running scan"),
165+
flagSet.BoolVar(&options.EnableProgressBar, "stats", false, "display stats of the running scan"),
166166
flagSet.IntVarP(&options.StatsInterval, "stats-interval", "si", DefautStatsInterval, "number of seconds to wait between showing a statistics update"),
167167
)
168168

pkg/naabu/v2/pkg/runner/runner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (r *Runner) Httpxrun() error {
5656
//log.Println("httpxrunner.Naabubuffer = ", httpxrunner.Naabubuffer.String())
5757
//Naabubuffer1 := bytes.Buffer{}
5858
//Naabubuffer1.Write(httpxrunner.Naabubuffer.Bytes())
59-
go nuclei_Yaml.RunNuclei(httpxrunner.Naabubuffer, nucleiDone)
59+
go nuclei_Yaml.RunNuclei(&httpxrunner.Naabubuffer, nucleiDone)
6060
httpxoptions := httpxrunner.ParseOptions()
6161
httpxoptions.Output = r.options.Output
6262
httpxoptions.CSVOutput = r.options.CSV
@@ -571,7 +571,7 @@ func (r *Runner) handleOutput() {
571571
if host == "ip" {
572572
host = hostIP
573573
}
574-
log.Println("%s found ports: %i", hostIP, len(ports))
574+
log.Printf("%s found ports: %d", hostIP, len(ports))
575575
for port := range ports {
576576
Add2Naabubuffer(fmt.Sprintf("%s:%d\n", host, port))
577577
}

0 commit comments

Comments
 (0)