Hi all,
I am a little bit confused on runner options while using httpx as a library. Is there a way to just tell the runner to not omit empty (I am having trouble if it returns empty because it can not found and returns nil or because it does not execute the related code) and do all the checks? (for ex. similar to all headers when output format is given). Do I need to define all needed parameters on runner options or by default all options are used and can be retrieved from runner if found unlike CLI output?
I now most of them are directly accessible but i can not access some basic (and always present ones) like response body and response headers.
Here is the function to execute httpx runner
func runHTTPX(targetDomains []string) {
options := runner.Options{
Methods: "GET",
OutputAll: true,
Hashes: "sha1",
Resolvers: goflags.StringSlice{"1.1.1.1"},
InputTargetHost: targetDomains,
OnResult: func(r runner.Result) {
if r.Err != nil {
fmt.Printf("[Err] %s: %s\n", r.Input, r.Err)
return
}
resultData := map[string]interface{}{
"Input": r.Input,
"Host": r.Host,
"Port": r.Port,
"Status Code": r.StatusCode,
"Content Length": r.ContentLength,
"Title": r.Title,
"Server": r.WebServer,
"Response Time": r.ResponseTime,
"Response Body": r.ResponseBody,
"Response Headers": r.ResponseHeaders,
"TLS Data": r.TLSData,
"Favicon Hashes": map[string]string{
"MMH3": r.FavIconMMH3,
"MD5": r.FavIconMD5,
},
"CDN Information": map[string]interface{}{
"CDN Name": r.CDNName,
"CDN Type": r.CDNType,
"Is CDN": r.CDN,
},
"Extracted Technologies": r.Technologies,
"JARM Hash": r.JarmHash,
"Final URL": r.FinalURL,
"HTTP2 Supported": r.HTTP2,
"Pipeline Supported": r.Pipeline,
"WebSocket Supported": r.WebSocket,
"DNS Records": map[string]interface{}{
"A Records": r.A,
"AAAA Records": r.AAAA,
"CNAMEs": r.CNAMEs,
},
"Chain Status Codes": r.ChainStatusCodes,
}
resultJSON, err := json.MarshalIndent(resultData, "", " ")
if err != nil {
fmt.Printf("[Err] %s: Failed to JSON data: %s\n", r.Input, err)
return
}
fmt.Printf("%s\n", resultJSON)
},
}
//standart error controls
}
Here are some example results on targets after running,
https://pay.unity.com
{
"CDN Information": {
"CDN Name": "google",
"CDN Type": "cdn",
"Is CDN": true
},
"Chain Status Codes": null,
"Content Length": 8045,
"DNS Records": {
"A Records": [
"35.205.92.229"
],
"AAAA Records": null,
"CNAMEs": [
"api.unity.com.akadns.net",
"sc-lb.eu-west-1.unityops.net"
]
},
"Extracted Technologies": null,
"Favicon Hashes": {
"MD5": "",
"MMH3": ""
},
"Final URL": "",
"HTTP2 Supported": false,
"Host": "35.205.92.229",
"Input": "pay.unity.com",
"JARM Hash": "",
"Pipeline Supported": false,
"Port": "443",
"Response Body": "",
"Response Headers": null,
"Response Time": "682.490461ms",
"Server": "",
"Status Code": 404,
"TLS Data": null,
"Title": "Unity - Page not found",
"WebSocket Supported": false
}
Fairly new to golang, execuse my lack of knowledge.