Skip to content

Commit 00de1aa

Browse files
committed
[*]修复一个会漏资产的bug,之前会漏掉某些SSL端口的非SSL资产
1 parent c17c6cb commit 00de1aa

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

get-appbanner.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ func GetAppBannerFromTcpBanner(banner *TcpBanner) *AppBanner {
3737
return getAppBanner(parse, banner)
3838
}
3939

40-
func GetAppBannerFromUrl(url *urlparse.URL) *AppBanner {
41-
if url.Scheme != "http" && url.Scheme != "https" {
42-
banner := GetTcpBanner(url.Netloc, url.Port, New(), HttpTimeout*20)
40+
func GetAppBannerFromUrlString(urlString string) *AppBanner {
41+
Url, err := urlparse.Load(urlString)
42+
if err != nil {
43+
logger.Println(err)
44+
}
45+
if Url.Scheme != "http" && Url.Scheme != "https" {
46+
banner := GetTcpBanner(Url.Netloc, Url.Port, New(), HttpTimeout*20)
4347
if banner == nil {
4448
return nil
4549
}
@@ -48,18 +52,16 @@ func GetAppBannerFromUrl(url *urlparse.URL) *AppBanner {
4852
}
4953
return GetAppBannerFromTcpBanner(banner)
5054
}
51-
52-
if url.Port == 0 && url.Scheme == "" {
53-
url.Port = 80
54-
url.Scheme = "http"
55+
if Url.Port == 0 && Url.Scheme == "http" {
56+
Url.Port = 80
5557
}
56-
if url.Port == 0 && url.Scheme == "https" {
57-
url.Port = 443
58+
if Url.Port == 0 && Url.Scheme == "https" {
59+
Url.Port = 443
5860
}
59-
if url.Port == 0 {
60-
url.Port = 80
61+
if Url.Port == 0 {
62+
Url.Port = 80
6163
}
62-
return getAppBanner(url, nil)
64+
return getAppBanner(Url, nil)
6365
}
6466

6567
func getAppBanner(url *urlparse.URL, tcpBanner *TcpBanner) *AppBanner {

lib/urlparse/urlparse.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,10 @@ func Load(s string) (*URL, error) {
3737
}
3838
return &URL{
3939
Scheme: func() string {
40-
if r.Port() == "80" {
41-
return "http"
40+
if r.Scheme != "" {
41+
return r.Scheme
4242
}
43-
if r.Port() == "443" {
44-
return "https"
45-
}
46-
return r.Scheme
43+
return ""
4744
}(),
4845
Netloc: r.Hostname(),
4946
Path: func() string {

type-probe.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ func (p *probe) loads(sArr []string) {
5353
func (p *probe) scan(t target) (response, error) {
5454
tls := p.sslports.Exist(t.port)
5555
text, err := simplenet.Send(p.request.protocol, tls, t.URI(), p.request.string, p.totalwaitms, 512)
56+
if err != nil {
57+
if strings.Contains(err.Error(), "STEP1") && tls == true {
58+
tls = false
59+
text, err = simplenet.Send(p.request.protocol, tls, t.URI(), p.request.string, p.totalwaitms, 512)
60+
}
61+
}
5662
return response{
5763
string: text,
5864
tls: tls,

0 commit comments

Comments
 (0)