proxy

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2020 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Overview

NOTE: This version has been modified for the Muraena needs, for instance removing the X-Forwarded-For header

Index

Constants

View Source
const (
	// Base64Padding is the padding to use within base64 operations
	Base64Padding = '='

	// Wildcard key
	WildcardPrefix = "wld"
)

Variables

View Source
var (
	Wildcards = false
)

Functions

func ArmorDomain

func ArmorDomain(slice []string) []string

ArmorDomain filters duplicate strings in place and returns a slice with only unique strings.

func IsSubdomain

func IsSubdomain(domain string, toCheck string) bool

Types

type Base64

type Base64 struct {
	Enabled bool
	Padding []string
}

Base64 identifies if the transformation should consider base-64 data and the related padding rules

type BufferPool

type BufferPool interface {
	Get() []byte
	Put([]byte)
}

A BufferPool is an interface for getting and returning temporary byte slices for use by io.CopyBuffer.

type MuraenaProxy

type MuraenaProxy struct {
	Session *session.Session

	Origin       string   // proxy origin (phishing site)
	Target       *url.URL // proxy destination (real site)
	Victim       string   // UUID
	ReverseProxy *ReverseProxy
	Tracker      *tracking.Tracker
	Replacer     *Replacer
}

func (*MuraenaProxy) ProxyErrHandler

func (muraena *MuraenaProxy) ProxyErrHandler(response http.ResponseWriter, request *http.Request, err error)

func (*MuraenaProxy) RequestBodyProcessor

func (muraena *MuraenaProxy) RequestBodyProcessor(request *http.Request, track *tracking.Trace, base64 Base64) (err error)

func (*MuraenaProxy) RequestProcessor

func (muraena *MuraenaProxy) RequestProcessor(request *http.Request) (err error)

func (*MuraenaProxy) ResponseProcessor

func (muraena *MuraenaProxy) ResponseProcessor(response *http.Response) (err error)

type MuraenaProxyInit

type MuraenaProxyInit struct {
	Session  *session.Session
	Replacer *Replacer

	Origin string // proxy origin (phishing site)
	Target string // proxy destination (real site)
}

func (*MuraenaProxyInit) Spawn

func (init *MuraenaProxyInit) Spawn() *MuraenaProxy

type Replacer

type Replacer struct {
	Phishing                 string
	Target                   string
	ExternalOrigin           []string
	ExternalOriginPrefix     string
	OriginsMapping           map[string]string // The origin map who maps between external origins and internal origins
	WildcardMapping          map[string]string
	TBodyUniversal           [][]string
	TBodyCustom              [][]string
	ForwardReplacements      []string
	BackwardReplacements     []string
	LastForwardReplacements  []string
	LastBackwardReplacements []string

	WildcardDomain string
}

Replacer structure used to populate the transformation rules

func (*Replacer) DomainMapping

func (r *Replacer) DomainMapping() (err error)

func (*Replacer) MakeReplacements

func (r *Replacer) MakeReplacements()

MakeReplacements prepares the forward and backward replacements to be used in the proxy

func (*Replacer) Transform

func (r *Replacer) Transform(input string, forward bool, b64 Base64) (result string)

If used with forward=true, Transform uses Replacer to replace all occurrences of the phishing origin, the external domains defined, as well as the rest of the data to be replaced defined in MakeReplacements(), with the target real origin. If used with forward=false, Transform will replace data coming from the targeted origin with the real proxied origin (target). Forward: - true > change requests, i.e. phishing > target origin - false > change response, i.e. target origin > phishing Base64: Since some request parameter values can be base64 encoded, we need to decode first, apply the transformation and re-encode (hello ReCaptcha)

type ReverseProxy

type ReverseProxy struct {
	// Director must be a function which modifies
	// the request into a new request to be sent
	// using Transport. Its response is then copied
	// back to the original client unmodified.
	// Director must not access the provided Request
	// after returning.
	Director func(*http.Request)

	// The transport used to perform proxy requests.
	// If nil, http.DefaultTransport is used.
	Transport http.RoundTripper

	// FlushInterval specifies the flush interval
	// to flush to the client while copying the
	// response body.
	// If zero, no periodic flushing is done.
	FlushInterval time.Duration

	// ErrorLog specifies an optional logger for errors
	// that occur when attempting to proxy the request.
	// If nil, logging goes to os.Stderr via the log package's
	// standard logger.
	ErrorLog *log.Logger

	// BufferPool optionally specifies a buffer pool to
	// get byte slices for use by io.CopyBuffer when
	// copying HTTP response bodies.
	BufferPool BufferPool

	// ModifyResponse is an optional function that modifies the
	// Response from the backend. It is called if the backend
	// returns a response at all, with any HTTP status code.
	// If the backend is unreachable, the optional ErrorHandler is
	// called without any call to ModifyResponse.
	//
	// If ModifyResponse returns an error, ErrorHandler is called
	// with its error value. If ErrorHandler is nil, its default
	// implementation is used.
	ModifyResponse func(*http.Response) error

	// ErrorHandler is an optional function that handles errors
	// reaching the backend or errors from ModifyResponse.
	//
	// If nil, the default is to log the provided error and return
	// a 502 Status Bad Gateway response.
	ErrorHandler func(http.ResponseWriter, *http.Request, error)
}

ReverseProxy is an HTTP Handler that takes an incoming request and sends it to another server, proxying the response back to the client.

func NewSingleHostReverseProxy

func NewSingleHostReverseProxy(target *url.URL) *ReverseProxy

NewSingleHostReverseProxy returns a new ReverseProxy that routes URLs to the scheme, host, and base path provided in target. If the target's path is "/base" and the incoming request was for "/dir", the target request will be for /base/dir. NewSingleHostReverseProxy does not rewrite the Host header. To rewrite Host headers, use ReverseProxy directly with a custom Director policy.

func (*ReverseProxy) ServeHTTP

func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type SessionType

type SessionType struct {
	Session  *session.Session
	Replacer *Replacer
}

func (*SessionType) HandleFood

func (st *SessionType) HandleFood(response http.ResponseWriter, request *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL