Skip to content

Commit ffc4c8a

Browse files
committed
feat: update -ldp option to show default ports in CLI output
- Modified URL formatting in runner.go to respect LeaveDefaultPorts option - Fixed AddURLDefaultPort function to actually add default ports (80/443) - When -ldp is used, CLI output now shows https://example.com:443 instead of https://example.com - Maintains backward compatibility - default behavior unchanged Fixes CLI output inconsistency where -ldp flag only affected Host headers but not the displayed URL in console output.
1 parent 8b04cd9 commit ffc4c8a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

common/stringz/stringz.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ func AddURLDefaultPort(rawURL string) string {
8383
if err != nil {
8484
return rawURL
8585
}
86+
// Force default port to be added if not present
87+
if u.Port() == "" {
88+
if u.Scheme == urlutil.HTTP {
89+
u.UpdatePort("80")
90+
} else if u.Scheme == urlutil.HTTPS {
91+
u.UpdatePort("443")
92+
}
93+
}
8694
return u.String()
8795
}
8896

runner/runner.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,11 @@ retry:
17231723
}
17241724

17251725
builder := &strings.Builder{}
1726-
builder.WriteString(stringz.RemoveURLDefaultPort(fullURL))
1726+
if scanopts.LeaveDefaultPorts {
1727+
builder.WriteString(stringz.AddURLDefaultPort(fullURL))
1728+
} else {
1729+
builder.WriteString(stringz.RemoveURLDefaultPort(fullURL))
1730+
}
17271731

17281732
if r.options.Probe {
17291733
builder.WriteString(" [")

0 commit comments

Comments
 (0)