diff --git a/handlers/proxy.go b/handlers/proxy.go index ad8013e..8e3d5c5 100644 --- a/handlers/proxy.go +++ b/handlers/proxy.go @@ -32,7 +32,7 @@ func NewProxySiteHandler(opts *ProxyOptions) fiber.Handler { SetDebugLogging(opts.Verbose). SetRequestModifications( //rx.MasqueradeAsFacebookBot(), - rx.MasqueradeAsGoogleBot(), + //rx.MasqueradeAsGoogleBot(), //rx.DeleteOutgoingCookies(), rx.ForwardRequestHeaders(), rx.SetOutgoingCookie("nyt-a", " "), @@ -45,10 +45,10 @@ func NewProxySiteHandler(opts *ProxyOptions) fiber.Handler { //rx.RequestArchiveIs(), ). AddResponseModifications( - tx.BypassCORS(), - tx.BypassContentSecurityPolicy(), - //tx.DeleteIncomingCookies(), tx.ForwardResponseHeaders(), + //tx.BypassCORS(), + //tx.BypassContentSecurityPolicy(), + //tx.DeleteIncomingCookies(), tx.RewriteHTMLResourceURLs(), tx.PatchDynamicResourceURLs(), //tx.SetContentSecurityPolicy("default-src * 'unsafe-inline' 'unsafe-eval' data: blob:;"), diff --git a/proxychain/proxychain.go b/proxychain/proxychain.go index 748b84f..d73fd9d 100644 --- a/proxychain/proxychain.go +++ b/proxychain/proxychain.go @@ -354,7 +354,8 @@ func (chain *ProxyChain) _reset() { // NewProxyChain initializes a new ProxyChain func NewProxyChain() *ProxyChain { chain := new(ProxyChain) - chain.Client = http.DefaultClient + //chain.Client = http.DefaultClient + chain.Client = &http.Client{} return chain } diff --git a/proxychain/requestmodifers/forward_request_headers.go b/proxychain/requestmodifers/forward_request_headers.go index d706123..40cc5c1 100644 --- a/proxychain/requestmodifers/forward_request_headers.go +++ b/proxychain/requestmodifers/forward_request_headers.go @@ -1,6 +1,7 @@ package requestmodifers import ( + //"fmt" "ladder/proxychain" "strings" ) diff --git a/proxychain/responsemodifers/forward_response_headers.go b/proxychain/responsemodifers/forward_response_headers.go index 5e08a58..763c7a9 100644 --- a/proxychain/responsemodifers/forward_response_headers.go +++ b/proxychain/responsemodifers/forward_response_headers.go @@ -24,6 +24,7 @@ func init() { func ForwardResponseHeaders() proxychain.ResponseModification { return func(chain *proxychain.ProxyChain) error { + //fmt.Println(chain.Response.Header) for uname, headers := range chain.Response.Header { name := strings.ToLower(uname) if forwardBlacklist[name] { @@ -42,6 +43,7 @@ func ForwardResponseHeaders() proxychain.ResponseModification { // forward headers for _, value := range headers { + fmt.Println(name, value) chain.Context.Set(name, value) } } diff --git a/proxychain/responsemodifers/rewriters/html_token_url_rewriter.go b/proxychain/responsemodifers/rewriters/html_token_url_rewriter.go index ca71fee..f52569b 100644 --- a/proxychain/responsemodifers/rewriters/html_token_url_rewriter.go +++ b/proxychain/responsemodifers/rewriters/html_token_url_rewriter.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "net/url" + "path" "regexp" "strings" @@ -113,7 +114,7 @@ func (r *HTMLTokenURLRewriter) ModifyToken(token *html.Token) (string, string) { case !rewriteAttrs[token.Data][attr.Key]: continue // don't touch attributes with special URIs (like data:) - case schemeBlacklist[strings.Split(attr.Key, ":")[0]]: + case schemeBlacklist[strings.Split(attr.Val, ":")[0]]: continue // don't double-overwrite the url case strings.HasPrefix(attr.Val, r.proxyURL): @@ -184,15 +185,17 @@ func handleRootRelativePath(attr *html.Attribute, baseURL *url.URL) { // Document-relative URLs: These are relative to the current document's path and don't start with a "/". func handleDocumentRelativePath(attr *html.Attribute, baseURL *url.URL) { log.Printf("PROCESSING: key: %s val: %s\n", attr.Key, attr.Val) + if strings.HasPrefix(attr.Val, "#") { + return + } + relativePath := path.Join(strings.Trim(baseURL.RawPath, "/"), strings.Trim(attr.Val, "/")) attr.Val = fmt.Sprintf( - "%s://%s/%s%s", + "%s://%s/%s", baseURL.Scheme, strings.Trim(baseURL.Host, "/"), - strings.Trim(baseURL.RawPath, "/"), - strings.Trim(attr.Val, "/"), + relativePath, ) attr.Val = escape(attr.Val) - attr.Val = fmt.Sprintf("%s://%s/%s", baseURL.Scheme, baseURL.Host, attr.Val) log.Printf("doc rel url rewritten-> '%s'='%s'", attr.Key, attr.Val) } @@ -204,7 +207,7 @@ func handleAbsolutePath(attr *html.Attribute, baseURL *url.URL) { if err != nil { return } - if u.Scheme != "http" || u.Scheme != "https" { + if !(u.Scheme == "http" || u.Scheme == "https") { return } attr.Val = fmt.Sprintf("/%s", escape(strings.TrimPrefix(attr.Val, "/"))) @@ -232,7 +235,7 @@ func handleMetaRefresh(attr *html.Attribute, baseURL *url.URL) { url := strings.Split(attr.Val, ";url=")[1] f := &html.Attribute{Val: url, Key: "src"} handleURLPart(f, baseURL) - attr.Val = fmt.Sprintf("%s;url=%s", sec, url) + attr.Val = fmt.Sprintf("%s;url=%s", sec, f.Val) } func handleSrcSet(attr *html.Attribute, baseURL *url.URL) { @@ -246,14 +249,14 @@ func handleSrcSet(attr *html.Attribute, baseURL *url.URL) { continue } - fakeAttr := &html.Attribute{Val: srcParts[0], Key: "src"} - handleURLPart(fakeAttr, baseURL) + f := &html.Attribute{Val: srcParts[0], Key: "src"} + handleURLPart(f, baseURL) if i > 0 { srcSetBuilder.WriteString(", ") } - srcSetBuilder.WriteString(fakeAttr.Val) + srcSetBuilder.WriteString(f.Val) if len(srcParts) > 1 { srcSetBuilder.WriteString(" ") srcSetBuilder.WriteString(strings.Join(srcParts[1:], " ")) @@ -264,5 +267,6 @@ func handleSrcSet(attr *html.Attribute, baseURL *url.URL) { } func escape(str string) string { + //return str return strings.ReplaceAll(url.PathEscape(str), "%2F", "/") }