Documentation ¶
Index ¶
- Variables
- type Client
- type Generator
- type Rule
- type Server
- func (s *Server) Close() error
- func (s *Server) Connect(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(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
Constants ¶
This section is empty.
Variables ¶
var ( // Default is the default web c2 client that can be used to create client connections. Default = &Client{Generator: DefaultGenerator, Client: DefaultClient} // DefaultClient is the HTTP Client struct that is used when the provided client is nil. // This is a standard struct that uses DefaultTimeout as the timeout value. DefaultClient = &http.Client{Timeout: com.DefaultTimeout, Transport: DefaultTransport} // DefaultTransport is the default HTTP transport struct that contains the default settings // and timeout values used in DefaultClient. This struct uses any set proxy settings contained // in the execution environment. DefaultTransport = &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{Timeout: com.DefaultTimeout, KeepAlive: com.DefaultTimeout, DualStack: true}).DialContext, MaxIdleConns: limits.SmallLimit(), IdleConnTimeout: com.DefaultTimeout, TLSHandshakeTimeout: com.DefaultTimeout, ExpectContinueTimeout: com.DefaultTimeout, ResponseHeaderTimeout: com.DefaultTimeout, } )
var DefaultGenerator = Generator{ URL: text.Matcher("/news/post/%d/"), Agent: text.Matcher("Mozilla/5.0 (Windows NT 10; WOW64; rv:79.0) Gecko/20101%100d Firefox/79.0"), }
DefaultGenerator is the generator used if no generator is provided when a client attempts a connection. The default values are a URL for an news post, Windows host and a Firefox version 70 user agent.
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 DefaultClient struct.
type Generator ¶
type Generator struct {
URL, Host, Agent stringer
}
Generator 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.
func (*Generator) Reset ¶
func (g *Generator) Reset()
Reset sets all the Generator values to nil. This allows for an empty Generator to be used.
type Rule ¶
type Rule struct {
URL, Host, Agent matcher
}
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 ¶
type Server struct { Generator Generator Client *http.Client // contains filtered or unexported fields }
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 Mapper struct to provide 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.
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.