When creating a HTTP request to a JavaScript file with this code, it returns the actual JS code itself just like it would when looking at the Network tab in the browser's developer tab.
var client = &http.Client{Timeout: 10 * time.Second}
req, err := http.NewRequest("GET", "https://www.iana.org/_js/jquery.js", nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36")
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
resp.Body.Close()
fmt.Println(string(body))
However, creating a request to the same URL, but defining all the request headers that would be used in the browser:
req.Header = http.Header{
"Accept": []string{"*/*"},
"Accept-Encoding": []string{"gzip, deflate, br"},
"Accept-Language": []string{"en-US,en;q=0.5"},
"Cache-Control": []string{"no-cache"},
"Connection": []string{"keep-alive"},
"DNT": []string{"1"},
"Host": []string{"www.iana.org"},
"Pragma": []string{"no-cache"},
"Referer": []string{"https://www.iana.org/domains/reserved"},
"Sec-Fetch-Dest": []string{"script"},
"Sec-Fetch-Mode": []string{"no-cors"},
"Sec-Fetch-Site": []string{"same-origin"},
}
The response body returns a byte array that when converted to a string with fmt.Println(string(body))
as in the first section of code, seems to be purely binary.
I'm trying to figure out if this binary response is the result of the JavaScript function itself (for example a token generator or whatever else the script's purpose could be) or whether it's something else.
Anyway, explanation or insight would be much appreciated <3