Documentation
¶
Index ¶
- Variables
- type ClientID
- type Path
- type Paths
- func (paths *Paths) Add(path string, pathData *Path)
- func (paths *Paths) AddGeoIP(path string) error
- func (paths *Paths) AddProxyList(path string) error
- func (paths *Paths) IngestData(oPath string) error
- func (paths *Paths) IngestMeta(oPath string) error
- func (paths *Paths) IngestProxy(oPath string) error
- func (paths *Paths) Len() int
- func (paths *Paths) Match(URI string) (*Path, bool)
- func (paths *Paths) MatchAndServe(w http.ResponseWriter, req *http.Request) (bool, error)
- func (paths *Paths) Reload() error
- func (paths *Paths) Remove(path string)
- func (paths *Paths) RemoveDir(dir string)
- func (paths *Paths) Serve(w http.ResponseWriter, req *http.Request) error
- type RequestConditions
- type State
Constants ¶
This section is empty.
Variables ¶
var ErrNoURL = errors.New("No URL for request")
ErrNoURL is returned when a request has no URL in the request
Functions ¶
This section is empty.
Types ¶
type ClientID ¶
type ClientID struct {
// contains filtered or unexported fields
}
ClientID is client identification
type Path ¶
type Path struct { Path string `yaml:"path,omitempty"` // HostedFile is the file to host HostedFile string `yaml:"hosted_file" json:"-"` // ContentType tells the browser what content should be parsed. A list of MIME // types can be found here: https://www.freeformatter.com/mime-types-list.html ContentType string `yaml:"content_type,omitempty"` // Disposition sets the Content-Disposition header Disposition struct { // Type is the type of disposition. Usually either inline or attachment Type string `yaml:"type"` // FileName is the name of the file if Content.Type is attachment FileName string `yaml:"file_name"` } `yaml:"disposition,omitempty"` // OnFailure instructs the Path what to do when a failure occurs OnFailure struct { // Redirect will redirect the user with a 301 to a target address Redirect string `yaml:"redirect"` // Render will render the following path Render string `yaml:"render"` } `yaml:"on_failure,omitempty"` //ProxyHost proxies the path to this address ProxyHost string `yaml:"proxy,omitempty"` // CredentialCapture returns the credentials POSTed to the path CredentialCapture struct { FileOutput string `yaml:"file_output"` } `yaml:"credential_capture,omitempty"` // contains filtered or unexported fields }
Path is an available path that can be accessed on the server
func NewPathArray ¶
NewPathArray creates a Path array based on a target path
func NewPathData ¶
NewPathData creates a Path object from yaml data
func (*Path) ContentHeaders ¶
ContentHeaders sets the Content-Type and Content-Disposition headers.
type Paths ¶
type Paths struct {
// contains filtered or unexported fields
}
Paths is the compilation of parsed paths
func NewDefault ¶
NewDefault instantiates a Paths object with default configuration
func NewDefaultTest ¶
For many of the tests, we don't need to apply the global conditionals, so this helper function is for test cases
func (*Paths) AddProxyList ¶
AddProxyList is a flat list of proxies to add in YAML format
func (*Paths) IngestData ¶
AddPath adds a data path which is served when Path - Root is requested
func (*Paths) IngestMeta ¶
AddMeta adds a meta (or .info) file to the paths list
func (*Paths) IngestProxy ¶
IngestProxy adds the proxy from target path if it exists
func (*Paths) Match ¶
Match matches a page given a URI. It returns the specified Path and a boolean value to determine if there was a page that matched the URI
func (*Paths) MatchAndServe ¶
MatchAndServe matches a path, determines if the path should be served, and serves the file based on an HTTP request. If a failure occurs, this function will serve failed pages.
This is a helper function which combines already-exposed functions to make file serving easy.
Returns true when the file was served and false when a 404 page should be returned
type RequestConditions ¶
type RequestConditions struct { // AUserAgent is the authorized user agents for a file AuthorizedUserAgents []string `yaml:"authorized_useragents,omitempty"` // BlacklistUserAgents are blacklisted user agents BlacklistUserAgents []string `yaml:"blacklist_useragents,omitempty"` // AuthorizedIPRange is the authorized range of IPs who are allowed to access a file AuthorizedIPRange []string `yaml:"authorized_iprange,omitempty"` // BlacklistIPRange are blacklisted IPs BlacklistIPRange []string `yaml:"blacklist_iprange,omitempty"` // AuthorizedMethods are the HTTP methods which can access the page AuthorizedMethods []string `yaml:"authorized_methods,omitempty"` // AuthorizedHeaders are HTTP headers which must be present in order to access a file AuthorizedHeaders map[string]string `yaml:"authorized_headers,omitempty"` // AuthorizedJA3 are valid JA3 hashes AuthorizedJA3 []string `yaml:"authorized_ja3,omitempty"` // Exec file executes script/binary and checks stdout Exec struct { ScriptPath string `yaml:"script"` Output string `yaml:"output"` } `yaml:"exec,omitempty"` // NotServing does not serve the page when NotServing is true NotServing bool `yaml:"not_serving,omitempty"` // Serve is the number of times the file should be served Serve uint64 `yaml:"serve,omitempty"` // PrereqPaths path of hits that need to happen before the current one will succeed PrereqPaths []string `yaml:"prereq,omitempty"` GeoIP struct { AuthorizedCountries []string `yaml:"authorized_countries"` BlacklistCountries []string `yaml:"blacklist_countries"` } `yaml:"geoip"` }
RequestConditions are the conditions in the http.Request object
func MergeRequestConditions ¶
func MergeRequestConditions(conds ...RequestConditions) (RequestConditions, error)
MergeRequestConditions merges a list of RequestCondition. They are applied starting from the first to the last. It will overwrite later RequestCondition
func NewRequestConditions ¶
func NewRequestConditions(data []byte) (RequestConditions, error)
NewRequestConditions creates an object based on a YAML blob
func (*RequestConditions) ShouldHost ¶
ShouldHost returns when an HTTP request should be hosted or not
type State ¶
type State struct {
// contains filtered or unexported fields
}
State contains all state for Paths configuration
func (*State) Hit ¶
Hit will create a path in the DB if it does not exist, and increment the times_served if it does exist
func (*State) MatchPaths ¶
MatchPaths checks if an IP has hit the specified paths in order to make sure an IP can access a page