fix "modifer" -> "modifier" typo everywhere
This commit is contained in:
43
proxychain/requestmodifiers/request_wayback_machine.go
Normal file
43
proxychain/requestmodifiers/request_wayback_machine.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package requestmodifiers
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"regexp"
|
||||
|
||||
"ladder/proxychain"
|
||||
tx "ladder/proxychain/responsemodifiers"
|
||||
)
|
||||
|
||||
const waybackUrl string = "https://web.archive.org/web/"
|
||||
|
||||
// RequestWaybackMachine modifies a ProxyChain's URL to request the wayback machine (archive.org) version.
|
||||
func RequestWaybackMachine() proxychain.RequestModification {
|
||||
return func(chain *proxychain.ProxyChain) error {
|
||||
chain.Request.URL.RawQuery = ""
|
||||
rURL := preventRecursiveWaybackURLs(chain.Request.URL.String())
|
||||
newURLString := waybackUrl + rURL
|
||||
newURL, err := url.Parse(newURLString)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
chain.Request.URL = newURL
|
||||
|
||||
// cleanup wayback headers
|
||||
script := `["wm-ipp-print", "wm-ipp-base"].forEach(id => { try { document.getElementById(id).remove() } catch{ } })`
|
||||
chain.AddOnceResponseModifications(
|
||||
tx.InjectScriptAfterDOMContentLoaded(script),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func preventRecursiveWaybackURLs(url string) string {
|
||||
re := regexp.MustCompile(`https:\/\/web\.archive\.org\/web\/\d+\/\*(https?:\/\/.*)`)
|
||||
|
||||
match := re.FindStringSubmatch(url)
|
||||
if match != nil {
|
||||
return match[1]
|
||||
}
|
||||
return url
|
||||
}
|
||||
Reference in New Issue
Block a user