automatic tls data extraction for https protocol

This commit is contained in:
Mzack9999 2020-07-23 14:17:19 +02:00
parent c826768acf
commit 9b9dcc5889
4 changed files with 51 additions and 5 deletions

View File

@ -316,7 +316,18 @@ retry:
}
}
output <- Result{URL: fullURL, ContentLength: resp.ContentLength, StatusCode: resp.StatusCode, Title: title, str: builder.String(), VHost: isvhost, WebServer: serverHeader, Response: serverResponseRaw, WebSocket: isWebSocket}
output <- Result{
URL: fullURL,
ContentLength: resp.ContentLength,
StatusCode: resp.StatusCode,
Title: title,
str: builder.String(),
VHost: isvhost,
WebServer: serverHeader,
Response: serverResponseRaw,
WebSocket: isWebSocket,
TlsData: resp.TlsData,
}
}
// Result of a scan
@ -327,10 +338,11 @@ type Result struct {
Title string `json:"title"`
str string
err error
VHost bool `json:"vhost"`
WebServer string `json:"webserver"`
Response string `json:"serverResponse,omitempty"`
WebSocket bool `json:"websocket,omitempty"`
VHost bool `json:"vhost"`
WebServer string `json:"webserver"`
Response string `json:"serverResponse,omitempty"`
WebSocket bool `json:"websocket,omitempty"`
TlsData *httpx.TlsData `json:"tls,omitempty"`
}
// JSON the result

View File

@ -134,6 +134,9 @@ func (h *HTTPX) Do(req *retryablehttp.Request) (*Response, error) {
// number of lines
resp.Lines = len(strings.Split(respbodystr, "\n"))
// extracts TLS data if any
resp.TlsData = h.TlsGrab(httpresp)
return &resp, nil
}

View File

@ -13,6 +13,7 @@ type Response struct {
Raw string
Words int
Lines int
TlsData *TlsData
}
// GetHeader value

30
common/httpx/tls.go Normal file
View File

@ -0,0 +1,30 @@
package httpx
import (
"net/http"
)
type TlsData struct {
DNSNames []string `json:"dns_names,omitempty"`
Emails []string `json:"emails,omitempty"`
CommonName []string `json:"common_name,omitempty"`
Organization []string `json:"organization,omitempty"`
IssuerCommonName []string `json:"issuer_common_name,omitempty"`
IssuerOrg []string `json:"issuer_organization,omitempty"`
}
func (h *HTTPX) TlsGrab(r *http.Response) *TlsData {
if r.TLS != nil {
var tlsdata TlsData
for _, certificate := range r.TLS.PeerCertificates {
tlsdata.DNSNames = append(tlsdata.DNSNames, certificate.DNSNames...)
tlsdata.Emails = append(tlsdata.Emails, certificate.EmailAddresses...)
tlsdata.CommonName = append(tlsdata.CommonName, certificate.Subject.CommonName)
tlsdata.Organization = append(tlsdata.Organization, certificate.Subject.Organization...)
tlsdata.IssuerOrg = append(tlsdata.IssuerOrg, certificate.Issuer.Organization...)
tlsdata.IssuerCommonName = append(tlsdata.IssuerCommonName, certificate.Issuer.CommonName)
}
return &tlsdata
}
return nil
}