Documentation ¶
Index ¶
- Variables
- type Client
- type Matcher
- type Rule
- type Server
- func (s *Server) Close() error
- func (s *Server) Connect(x context.Context, a string) (net.Conn, error)
- func (s *Server) Handle(p string, h http.Handler)
- func (s *Server) HandleFunc(p string, h func(http.ResponseWriter, *http.Request))
- func (s *Server) Listen(x context.Context, a string) (net.Listener, error)
- func (s *Server) Rule(r ...Rule)
- func (s *Server) Serve(p, f string) error
- func (s *Server) ServeDirectory(p, f string) error
- func (s *Server) ServeFile(p, f string) error
- func (s *Server) TargetAsRule()
- type Stringer
- type Target
Constants ¶
This section is empty.
Variables ¶
var ( // Default is the default web c2 client that can be used to create client // connections. Default = &Client{Client: DefaultHTTP} // DefaultHTTP is the HTTP Client struct that is used when the provided // client is nil. DefaultHTTP = &http.Client{Jar: jar, Transport: DefaultTransport} // DefaultTransport is the default HTTP transport struct that contains the // default settings and timeout values used in DefaultHTTP. This struct uses // any set proxy settings contained in the execution environment. DefaultTransport = &http.Transport{ Proxy: device.Proxy, DialContext: (&net.Dialer{Timeout: com.DefaultTimeout, KeepAlive: com.DefaultTimeout, DualStack: true}).DialContext, MaxIdleConns: 64, IdleConnTimeout: com.DefaultTimeout, ForceAttemptHTTP2: false, TLSHandshakeTimeout: com.DefaultTimeout, ExpectContinueTimeout: com.DefaultTimeout, ResponseHeaderTimeout: com.DefaultTimeout, ReadBufferSize: 1, WriteBufferSize: 1, DisableKeepAlives: true, } )
RuleAny is a Rule that can be used to match any Request that comes in.
Useful for debugging.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a simple struct that supports the C2 client connector interface. This can be used by clients to connect to a Web instance.
By default, this struct will use the DefaultHTTP struct.
The initial unspecified Target state will be empty and will use the default (Golang) values.
func NewClient ¶ added in v0.1.0
NewClient returns a new WC2 client instance with the supplied timeout and Target options.
If the durartion is less than one or equals 'com.DefaultTimeout' than this function will use the cached 'DefaultTransport' variable instead.
type Matcher ¶ added in v0.1.0
Matcher is a utility interface that takes a single 'MatchString(string) bool' function and reports true if the string matches.
type Rule ¶
Rule is a struct that represents a rule set used by the Web server to determine the difference between normal and C2 traffic.
type Server ¶
Server is a C2 profile that mimics a standard web server and client setup. This struct inherits the http.Server struct and can be used to serve real files and pages.
Use the Target Rules a URL mapping that can be used by clients to access the C2 functions.
func New ¶
New creates a new Web C2 server instance. This can be passed to the Listen function of a controller to serve a Web Server that also acts as a C2 instance.
This struct supports all the default Golang http.Server functions and can be used to serve real web pages. Rules must be defined using the 'Rule' function to allow the server to differentiate between C2 and real traffic.
func NewTLS ¶
NewTLS creates a new TLS wrapped Web C2 server instance. This can be passed to the Listen function of a Controller to serve a Web Server that also acts as a C2 instance. This struct supports all the default Golang http.Server functions and can be used to serve real web pages. Rules must be defined using the 'Rule' function to allow the server to differentiate between C2 and real traffic.
func (*Server) Close ¶
Close terminates this Web instance and signals all current listeners and clients to disconnect. This will close all connections related to this struct.
This function does not block.
func (*Server) Connect ¶
Connect creates a C2 client connector that uses the same properties of the Web struct parent.
func (*Server) Handle ¶
Handle registers the handler for the given pattern. If a handler already exists for pattern, Handle panics.
func (*Server) HandleFunc ¶
HandleFunc registers the handler function for the given pattern.
func (*Server) Listen ¶
Listen returns a new C2 listener for this Web instance. This function creates a separate server, but still shares the handler for the base Web instance that it's created from.
func (*Server) Rule ¶
Rule adds the specified rules to the Web instance to assist in determing real and C2 traffic.
func (*Server) Serve ¶
Serve attempts to serve the specified filesystem path 'f' at the URL mapped path 'p'. This function will determine if the path represents a file or directory and will call 'ServeFile' or 'ServeDirectory' depending on the path result. This function will return an error if the filesystem path does not exist or is invalid.
func (*Server) ServeDirectory ¶
ServeDirectory attempts to serve the specified filesystem path 'f' at the URL mapped path 'p'. This function is used to serve directories and will return an error if the filesystem path does not exist or the path destination is not a directory.
func (*Server) ServeFile ¶
ServeFile attempts to serve the specified filesystem path 'f' at the URL mapped path 'p'. This function is used to serve files and will return an error if the filesystem path does not exist or the path destination is not a file.
func (*Server) TargetAsRule ¶ added in v0.1.0
func (s *Server) TargetAsRule()
TargetAsRule will take the server 'Target' and create a matching ruleset using the 'Rule' function.
type Stringer ¶ added in v0.1.0
type Stringer interface {
String() string
}
Stringer is a utility interface that takes a single 'String() string' function for returning a string to be used as a Target.
type Target ¶ added in v0.1.0
type Target struct {
URL, Host, Agent Stringer
Headers map[string]Stringer
// contains filtered or unexported fields
}
Target is a struct that is composed of three separate Stringer interfaces. These are called via their 'String' function to specify the User-Agent, URL and Host string values. They can be set to static strings using the 'text.String' wrapper. This struct can be used as a C2 client connector. If the Client property is not set, the DefaultClient value will be used.
var TargetEmpty Target
TargetEmpty is a Target that does not have anything set and will not mutate a Request.
func (*Target) Header ¶ added in v0.1.0
Header adds the stringer too the Target's header set.
This function will create the headers map if it's nil.
func (*Target) Reset ¶ added in v0.1.0
func (t *Target) Reset()
Reset sets all the Target values to nil. This allows for an empty Target to be used.
func (Target) Rule ¶ added in v0.1.0
Rule will attempt to generate a Rule that matches this generator using the current configuration.
Rules will only be added if the settings implement the 'MatchString(string) bool' function. Otherwise, the specified rule will attempt to match using a Text Matcher.
Empty Target return an empty rule.