session

package
v1.21.1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: BSD-3-Clause Imports: 17 Imported by: 14

Documentation

Overview

Package session contains code to manage the interactive session, modules, environment, etc.

Index

Constants

View Source
const (
	InvalidCommand = "invalid option, enter help for assistance"
)

Variables

View Source
var (
	DefaultIP              = "0.0.0.0"
	DefaultListener        = "tcp"
	DefaultHTTPPort        = 80
	DefaultHTTPSPort       = 443
	DefaultBase64Padding   = []string{"=", "."}
	DefaultSkipContentType = []string{"font/*", "image/*"}
)
View Source
var (
	RedisPool *redis.Pool
)

Functions

func AsTag

func AsTag(name string) string

func DoModulePrompt added in v1.21.1

func DoModulePrompt(module string, items []string) (result string, err error)

DoModulePrompt generates a prompt for a specific module

func Prompt

func Prompt(s *Session)

Types

type Configuration

type Configuration struct {
	//
	// Proxy rules
	//
	Proxy struct {
		Phishing    string `toml:"phishing"`
		Target      string `toml:"destination"`
		IP          string `toml:"IP"`
		Listener    string `toml:"listener"`
		Port        int    `toml:"port"`
		PortMap     string `toml:"portmapping"`
		HTTPtoHTTPS struct {
			Enabled  bool `toml:"enable"`
			HTTPport int  `toml:"port"`
		} `toml:"HTTPtoHTTPS"`

		Protocol string `toml:"-"`
	} `toml:"proxy"`

	//
	// Origins
	//
	Origins struct {
		ExternalOriginPrefix string            `toml:"externalOriginPrefix"`
		ExternalOrigins      []string          `toml:"externalOrigins"`
		OriginsMapping       map[string]string `toml:"-"`

		SubdomainMap [][]string `toml:"subdomainMap"`
	} `toml:"origins"`

	//
	// Transforming rules
	//
	Transform struct {
		Base64 struct {
			Enabled bool     `toml:"enable"`
			Padding []string `toml:"padding"`
		} `toml:"base64"`

		Request struct {
			SkipExtensions []string `toml:"-"`

			UserAgent string `toml:"userAgent"`
			// Headers list to consider for the transformation
			Headers []string `toml:"headers"`

			Remove struct {
				Headers []string `toml:"headers"`
			} `toml:"remove"`

			Add struct {
				Headers []struct {
					Name  string `toml:"name"`
					Value string `toml:"value"`
				} `toml:"headers"`
			} `toml:"add"`
		} `toml:"request"`

		Response struct {
			SkipContentType []string `toml:"skipContentType"`

			Headers []string `toml:"headers"`

			// CustomContent Transformations
			CustomContent [][]string `toml:"customContent"`

			Cookie struct {
				SameSite string `toml:"sameSite"`
			} `toml:"cookie"`

			Remove struct {
				Headers []string `toml:"headers"`
			} `toml:"remove"`

			Add struct {
				Headers []struct {
					Name  string `toml:"name"`
					Value string `toml:"value"`
				} `toml:"headers"`
			} `toml:"add"`
		} `toml:"response"`
	} `toml:"transform"`

	Redirects []Redirect `toml:"redirect"`

	//
	// Logging
	//
	Log struct {
		Enabled  bool   `toml:"enable"`
		FilePath string `toml:"filePath"`
	} `toml:"log"`

	//
	// DB (Redis)
	//
	Redis struct {
		Host     string `toml:"host"`     // default: 127.0.0.1
		Port     int    `toml:"port"`     // default: 6379
		Password string `toml:"password"` // default: ""
	} `toml:"redis"`

	//
	// TLS
	//
	TLS struct {
		Enabled     bool   `toml:"enable"`
		Expand      bool   `toml:"expand"`
		Certificate string `toml:"certificate"`
		Key         string `toml:"key"`
		Root        string `toml:"root"`
		SSLKeyLog   string `toml:"sslKeyLog"`

		CertificateContent string `toml:"-"`
		KeyContent         string `toml:"-"`
		RootContent        string `toml:"-"`

		// Minimum supported TLS version: SSL3, TLS1, TLS1.1, TLS1.2, TLS1.3
		MinVersion               string `toml:"minVersion"`
		MaxVersion               string `toml:"maxVersion"`
		PreferServerCipherSuites bool   `toml:"preferServerCipherSuites"`
		SessionTicketsDisabled   bool   `toml:"SessionTicketsDisabled"`
		InsecureSkipVerify       bool   `toml:"insecureSkipVerify"`
		RenegotiationSupport     string `toml:"renegotiationSupport"`
	} `toml:"tls"`

	//
	// Tracking
	//
	Tracking struct {
		Enabled             bool `toml:"enable"`
		TrackRequestCookies bool `toml:"trackRequestCookies"`

		Trace struct {
			Identifier     string `toml:"identifier"`
			Header         string `toml:"header"`
			Domain         string `toml:"domain"`
			ValidatorRegex string `toml:"validator"`

			Landing struct {
				Type       string `toml:"type"` // path or query
				Header     string `toml:"header"`
				RedirectTo string `toml:"redirectTo"` // redirect url once the landing is detected (applicable only if type is path)
			} `toml:"landing"`
		} `toml:"trace"`

		Secrets struct {
			Paths []string `toml:"paths"`

			Patterns []struct {
				Label    string `toml:"label"`
				Matching string `toml:"matching"`
				Start    string `toml:"start"`
				End      string `toml:"end"`
			} `toml:"patterns"`
		} `toml:"secrets"`
	} `toml:"tracking"`

	// Crawler
	Crawler struct {
		Enabled bool `toml:"enable"`
		Depth   int  `toml:"depth"`
		UpTo    int  `toml:"upto"`
	} // `toml:"crawler"`  TODO: Temporarily disabled

	//
	// Necrobrowser
	//
	Necrobrowser struct {
		Enabled bool `toml:"enable"`

		SensitiveLocations struct {
			AuthSession         []string `toml:"authSession"`
			AuthSessionResponse []string `toml:"authSessionResponse"`
		} `toml:"urls"`

		Endpoint string `toml:"endpoint"`
		Profile  string `toml:"profile"`
		// Keepalive struct {
		// 	Enabled bool `toml:"enable"`
		// 	Minutes int  `toml:"minutes"`
		// } `toml:"keepalive"`
		Trigger struct {
			Type   string   `toml:"type"`
			Values []string `toml:"values"`
			Delay  int      `toml:"delay"`
		} `toml:"trigger"`
	} `toml:"necrobrowser"`

	StaticServer StaticHTTPConfig `toml:"staticServer"`

	//
	// Watchdog
	//
	Watchdog struct {
		Enabled bool   `toml:"enable"`
		Dynamic bool   `toml:"dynamic"`
		Rules   string `toml:"rules"`
		GeoDB   string `toml:"geoDB"`
	} `toml:"watchdog"`

	//
	// Telegram
	//
	Telegram struct {
		Enabled  bool     `toml:"enable"`
		BotToken string   `toml:"botToken"`
		ChatIDs  []string `toml:"chatIDs"`
	} `toml:"telegram"`
}

Configuration struct

type Module

type Module interface {
	Name() string
	Description() string
	Author() string
	Prompt()
}

type Redirect added in v1.21.1

type Redirect struct {
	Hostname       string `toml:"hostname"`
	Path           string `toml:"path"`
	Query          string `toml:"query"`
	RedirectTo     string `toml:"redirectTo"`
	HTTPStatusCode int    `toml:"httpStatusCode"`
}

type Session

type Session struct {
	Options core.Options
	Config  *Configuration
	Modules moduleList
}

Session structure

func New

func New() (*Session, error)

New session

func (*Session) CheckLog added in v1.21.1

func (s *Session) CheckLog() (err error)

CheckLog checks the log configuration and disables it if the file is not accessible.

func (*Session) CheckRedirect added in v1.21.1

func (s *Session) CheckRedirect()

CheckRedirect checks the redirect rules and removes invalid ones.

func (*Session) CheckStaticServer added in v1.21.1

func (s *Session) CheckStaticServer() (err error)

CheckStaticServer checks the static server configuration and disables it if the file is not accessible.

func (*Session) CheckTracking added in v1.21.1

func (s *Session) CheckTracking() (err error)

CheckTracking checks the tracking configuration and disables it if the file is not accessible.

func (*Session) DoChecks added in v1.21.1

func (s *Session) DoChecks() (err error)

func (*Session) GetConfiguration

func (s *Session) GetConfiguration() (err error)

GetConfiguration returns the configuration object

func (*Session) GetModuleNames added in v1.21.1

func (s *Session) GetModuleNames() (mods []string)

GetModuleNames returns a list of available modules

func (*Session) GetTLSClientConfig added in v1.21.1

func (s *Session) GetTLSClientConfig() *tls.Config

func (*Session) InitRedis added in v1.21.1

func (s *Session) InitRedis() error

InitRedis initialize the connection to a Redis database

func (*Session) Module

func (s *Session) Module(name string) (mod Module, err error)

Module retrieves a module from session modules

func (*Session) Register

func (s *Session) Register(mod Module, err error)

Register appends the provided module to the session

func (*Session) UpdateConfiguration

func (s *Session) UpdateConfiguration(domains *[]string) (err error)

type SessionModule

type SessionModule struct {
	Session *Session `toml:"-"`
	Name    string   `toml:"-"`
	// contains filtered or unexported fields
}

func NewSessionModule

func NewSessionModule(name string, s *Session) SessionModule

func (*SessionModule) Debug

func (m *SessionModule) Debug(format string, args ...interface{})

func (*SessionModule) Err added in v1.21.1

func (m *SessionModule) Err(error error)

func (*SessionModule) Error

func (m *SessionModule) Error(format string, args ...interface{})

func (*SessionModule) Important

func (m *SessionModule) Important(format string, args ...interface{})

func (*SessionModule) Info

func (m *SessionModule) Info(format string, args ...interface{})

func (*SessionModule) Raw added in v1.21.1

func (m *SessionModule) Raw(format string, args ...interface{})

func (*SessionModule) Verbose added in v1.21.1

func (m *SessionModule) Verbose(format string, args ...interface{})

func (*SessionModule) Warning

func (m *SessionModule) Warning(format string, args ...interface{})

type StaticHTTPConfig added in v1.21.1

type StaticHTTPConfig struct {
	Enabled       bool   `toml:"enable"`
	LocalPath     string `toml:"localPath"`
	URLPath       string `toml:"urlPath"`
	ListeningHost string `toml:"listeningHost"`
	ListeningPort int    `toml:"listeningPort"`
}

Jump to

Keyboard shortcuts

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