Skip to content

Commit 4bab930

Browse files
authored
added logic in code to handle IPv6 in nessus (#293)
1 parent 5589403 commit 4bab930

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

pkg/readers/nessus.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/xml"
55
"fmt"
66
"os"
7+
"net"
78

89
"github.com/sensepost/gowitness/internal/islazy"
910
)
@@ -134,15 +135,21 @@ func (nr *NessusReader) Read(ch chan<- string) error {
134135
func (nr *NessusReader) urlsFor(target string, ports []int) []string {
135136
var urls []string
136137

138+
ip := net.ParseIP(target)
139+
140+
host := target
141+
if ip != nil && ip.To4() == nil {
142+
host = fmt.Sprintf("[%s]", target)
143+
}
144+
137145
for _, port := range ports {
138146
if !nr.Options.NoHTTP {
139-
urls = append(urls, fmt.Sprintf("http://%s:%d", target, port))
147+
urls = append(urls, fmt.Sprintf("http://%s:%d", host, port))
140148
}
141-
142149
if !nr.Options.NoHTTPS {
143-
urls = append(urls, fmt.Sprintf("https://%s:%d", target, port))
150+
urls = append(urls, fmt.Sprintf("https://%s:%d", host, port))
144151
}
145152
}
146-
153+
147154
return urls
148155
}

0 commit comments

Comments
 (0)