better output

This commit is contained in:
juzeon
2024-02-11 20:29:56 -05:00
committed by yuhan6665
parent a356902789
commit 88ad754999
4 changed files with 18 additions and 6 deletions
+1
View File
@@ -4,3 +4,4 @@ results.txt
.idea
in.txt
out.txt
out.csv
View File
+3
View File
@@ -53,6 +53,8 @@ func main() {
slog.Error("Error opening file", "path", out)
return
}
defer f.Close()
_, _ = f.WriteString("IP,DOMAIN,CERTIFICATE\n")
outWriter = f
}
var ipChan <-chan net.IP
@@ -64,6 +66,7 @@ func main() {
slog.Error("Error reading file", "path", in)
return
}
defer f.Close()
ipChan = Iterate(f)
}
var wg sync.WaitGroup
+14 -6
View File
@@ -6,6 +6,7 @@ import (
"log/slog"
"net"
"strconv"
"strings"
"time"
)
@@ -40,11 +41,18 @@ func ScanTLS(ip net.IP, out io.Writer) {
}
state := c.ConnectionState()
alpn := state.NegotiatedProtocol
log := slog.Debug
if state.Version == 0x0304 && alpn == "h2" {
log = slog.Info
_, _ = io.WriteString(out, ip.String()+"\n")
domain := state.PeerCertificates[0].Subject.CommonName
issuers := strings.Join(state.PeerCertificates[0].Issuer.Organization, " | ")
log := slog.Info
feasible := true
if state.Version != 0x0304 || alpn != "h2" || len(domain) == 0 || len(issuers) == 0 {
// not feasible
log = slog.Debug
feasible = false
} else {
_, _ = io.WriteString(out, strings.Join([]string{ip.String(), domain, "\"" + issuers + "\""}, ",")+"\n")
}
log("Connected to target", "host", ip.String(), "tls", TLSDictionary[state.Version],
"alpn", alpn, "cert", state.PeerCertificates[0].Subject)
log("Connected to target", "feasible", feasible, "host", ip.String(),
"tls", TLSDictionary[state.Version],
"alpn", alpn, "domain", domain, "issuer", issuers)
}