Closed badboycxcc closed 2 months ago
Function implementation code, very simple but very practical (my code is not good)
func GetRemoteCerts(addr string) (certs *x509.Certificate, err error) {
conn, err := tls.DialWithDialer(&net.Dialer{
Timeout: time.Second * 10,
Deadline: time.Now().Add(time.Second * 9),
}, "tcp", addr, &tls.Config{
InsecureSkipVerify: true,
})
if err != nil {
// fmt.Println(err)
return
}
defer conn.Close()
stats := conn.ConnectionState()
// fmt.Println(stats.HandshakeComplete)
// fmt.Printf("SSl Info: %s\n", stats.PeerCertificates[0].Subject.String())
// fmt.Printf("SSl Info: %s\n", stats.PeerCertificates[0].Subject.CommonName)
certs = stats.PeerCertificates[0]
return
}
func GetSSl(target string) (sslinfo string, err error) {
if strings.HasPrefix(target, "https://") {
target = strings.ReplaceAll(target, "https://", "")
}
if !strings.Contains(target, ":") {
fmt.Println("Please input target's port number")
return "", errors.New("Please input target's port number")
}
// args := os.Args
certs, err := GetRemoteCerts(target)
if err != nil {
fmt.Println(err)
return "", err
}
return certs.Subject.CommonName, nil
// fmt.Printf("Host: %s,SSl Info Subject: %s\n", target, certs.Subject)
}
@badboycxcc this is already supported with -tls-grab
option, for example echo google.com | httpx -tls-grab -j | jq .
Cool
../Tools/httpx -l a.txt -tls-grab -j | jq '.tls | {host, subject_cn}'
Closing the issue as the functionality is already supported
Please describe your feature request:
I need this information.Request https url, parse the CN information and print it.
Describe the use case of this feature:
Usage scenarios I have a lot of urls. I need to extract the certificate CN information in batches to obtain the domain name to confirm my company.