mirror of
https://github.com/XTLS/RealiTLScanner.git
synced 2026-09-22 22:28:08 +03:00
better output
This commit is contained in:
@@ -4,3 +4,4 @@ results.txt
|
||||
.idea
|
||||
in.txt
|
||||
out.txt
|
||||
out.csv
|
||||
|
||||
@@ -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
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user