improve ua modifier with client side spoofing
This commit is contained in:
@@ -1,20 +1,29 @@
|
||||
package requestmodifers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"ladder/proxychain"
|
||||
tx "ladder/proxychain/responsemodifers"
|
||||
)
|
||||
|
||||
// SpoofReferrer modifies the referrer header
|
||||
// useful if the page can be accessed from a search engine
|
||||
// or social media site, but not by browsing the website itself
|
||||
// if url is "", then the referrer header is removed
|
||||
// SpoofReferrer modifies the referrer header.
|
||||
// It is useful if the page can be accessed from a search engine
|
||||
// or social media site, but not by browsing the website itself.
|
||||
// if url is "", then the referrer header is removed.
|
||||
func SpoofReferrer(url string) proxychain.RequestModification {
|
||||
return func(px *proxychain.ProxyChain) error {
|
||||
return func(chain *proxychain.ProxyChain) error {
|
||||
|
||||
// change refer on client side js
|
||||
script := fmt.Sprintf(`document.referrer = "%s"`, url)
|
||||
chain.AddOnceResponseModifications(
|
||||
tx.InjectScriptBeforeDOMContentLoaded(script),
|
||||
)
|
||||
|
||||
if url == "" {
|
||||
px.Request.Header.Del("referrer")
|
||||
chain.Request.Header.Del("referrer")
|
||||
return nil
|
||||
}
|
||||
px.Request.Header.Set("referrer", url)
|
||||
chain.Request.Header.Set("referrer", url)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user