Documentation
¶
Index ¶
- Constants
- Variables
- func GetSHA256Hash(text string) string
- func InitializeYara(yaraRulesPath string) error
- func NormalizeURL(url string) string
- func SliceContains(slice []string, item string) bool
- func TextContains(text, pattern string) bool
- type Analysis
- type Brands
- type Browser
- type ByChronologicalOrder
- type Check
- type CheckFunction
- type Dialog
- type Download
- type Link
- type LogCodec
- type Page
- type Request
- type Response
- type Warning
Constants ¶
const BrowserEventWaitTime time.Duration = 15
BrowserEventWaitTime is the seconds we wait while attempting to fetch some events from DevTools, before failing.
const BrowserTimeout time.Duration = 1
BrowserTimeout is the minutes we will wait before declaring failed the connection to our debugged browser or to the URL failed.
const BrowserWaitTime time.Duration = 5
BrowserWaitTime is the seconds we will wait before fetching navigation results.
Variables ¶
var SafeBrowsingKey string
SafeBrowsingKey contains the API key to use Google SafeBrowsing API.
var YaraRules *yara.Rules
YaraRules will contain compiled Yara rules provided by InitializeYara.
Functions ¶
func GetSHA256Hash ¶ added in v1.8.0
GetSHA256Hash retrieves a SHA256 hash of a string.
func InitializeYara ¶
InitializeYara will load any rule files found at the specified path and compile them into a Rules object.
func NormalizeURL ¶
NormalizeURL fixes a URL that is e.g. missing a scheme, etc.
func SliceContains ¶
SliceContains checks whether a string is contained in a slice of strings.
func TextContains ¶
TextContains will determine if a substring is present in a string. It is case-insensitive.
Types ¶
type Analysis ¶
type Analysis struct {
URL string `json:"url"`
FinalURL string `json:"final_url"`
HTML string `json:"html"`
Warnings []Warning `json:"warnings"`
Score int `json:"score"`
Safelisted bool `json:"safelisted"`
Dangerous bool `json:"dangerous"`
Brands *Brands `json:"brands"`
}
Analysis contains information on the outcome of the URL and/or HTML analysis.
func NewAnalysis ¶
NewAnalysis instantiates a new Analysis struct.
func (*Analysis) AnalyzeBrowserResults ¶ added in v1.15.1
AnalyzeBrowserResults performs all the available checks to be run on an HTML string as well as the provided list of HTTP requests (e.g. downloaded scripts).
func (*Analysis) AnalyzeDomain ¶
AnalyzeDomain performs all the available checks to be run on a URL or domain.
func (*Analysis) AnalyzeHTML ¶
AnalyzeHTML performs all the available checks to be run on an HTML string.
func (*Analysis) AnalyzeURL ¶
AnalyzeURL performs all the available checks to be run on a URL or domain.
type Brands ¶
Brands defines the attribute of our list of supported brands.
func (*Brands) GetBrand ¶
GetBrand determines which among the marked brands is most likely the one impersonated by the page.
func (*Brands) IsDomainSafelisted ¶
IsDomainSafelisted checks if the specified domain is in any of the safelists of the supported brands.
func (*Brands) IsLinkDangerous ¶ added in v1.9.1
IsLinkDangerous checks if the specified link matches a brand's dangerous regexp.
type Browser ¶
type Browser struct {
URL string `json:"url"`
FinalURL string `json:"final_url"`
Requests []Request `json:"requests"`
Responses []Response `json:"responses"`
Downloads []Download `json:"downloads"`
Dialogs []Dialog `json:"dialogs"`
HTML string `json:"html"`
ScreenshotPath string `json:"screenshot_path"`
ScreenshotData string `json:"screenshot_data"`
UseTor bool `json:"use_tor"`
DebugPort int `json:"debug_port"`
DebugURL string `json:"debug_url"`
LogEvents bool `json:"log_events"`
UserAgent string `json:"user_agent"`
ImageName string `json:"image_name"`
ContainerID string `json:"container_id"`
FrameID string `json:"frame_id"`
}
Browser is a struct containing details over a browser navigation to a URL.
type ByChronologicalOrder ¶ added in v1.14.0
type ByChronologicalOrder []Request
func (ByChronologicalOrder) Len ¶ added in v1.14.0
func (a ByChronologicalOrder) Len() int
func (ByChronologicalOrder) Less ¶ added in v1.14.0
func (a ByChronologicalOrder) Less(i, j int) bool
func (ByChronologicalOrder) Swap ¶ added in v1.14.0
func (a ByChronologicalOrder) Swap(i, j int)
type Check ¶
type Check struct {
Call CheckFunction
Score int
Name string
Description string
}
Check defines the general proprties of a CheckFunction.
func GetDomainChecks ¶
func GetDomainChecks() []Check
GetDomainChecks returns a list of only the checks that work for domain names.
func GetHTMLChecks ¶
func GetHTMLChecks() []Check
GetHTMLChecks returns a list of all the available HTML checks.
func GetURLChecks ¶
func GetURLChecks() []Check
GetURLChecks returns a list of all the available URL checks.
type CheckFunction ¶
CheckFunction defines the functions used to implement URL or HTML checks.
type Dialog ¶ added in v1.13.0
type Dialog struct {
URL string `json:"url"`
Type string `json:"type"`
Message string `json:"message"`
}
Dialog contains details of JavaScript dialogs opened.
type Download ¶ added in v1.13.0
Download contains details of files which were offered for download at the link.
type Link ¶
type Link struct {
URL string
Scheme string
Domain string
Port string
TopDomain string
Path string
RawQuery string
Parameters map[string]string
}
Link defines details of a parsed URL.
type LogCodec ¶ added in v1.13.0
type LogCodec struct {
// contains filtered or unexported fields
}
Adapted from: https://pkg.go.dev/github.com/mafredri/cdp#example-package-Logging LogCodec captures the output from writing RPC requests and reading responses on the connection. It implements rpcc.Codec via WriteRequest and ReadResponse.
func (*LogCodec) ReadResponse ¶ added in v1.13.0
ReadResponse unmarshals from the connection into v whilst echoing what is read into a buffer for logging.
type Page ¶
Page contains information on the HTML page.
func (*Page) GetEntities ¶
GetEntities returns any HTML entity of the specified type.
type Request ¶ added in v1.15.0
type Request struct {
Timestamp int64 `json:"timestamp"`
Method string `json:"method"`
URL string `json:"url"`
Type string `json:"type"`
Headers interface{} `json:"headers"`
Initiator string `json:"initiator"`
RequestID string `json:"request_id"`
FrameID string `json:"frame_id"`
Response Response `json:"response"`
}
type Response ¶ added in v1.15.0
type Response struct {
RequestID string `json:"request_id"`
LoaderID string `json:"loader_id"`
Failed bool `json:"failed"`
Error string `json:"error"`
Status int `json:"status"`
StatusText string `json:"status_text"`
IPAddress string `json:"ip_address"`
PortNumber int `json:"port_number"`
Protocol string `json:"protocol"`
URL string `json:"url"`
Type string `json:"type"`
Headers interface{} `json:"headers"`
Mime string `json:"mime"`
SHA256 string `json:"sha256"`
Content string `json:"content"`
SecurityState string `json:"security_state"`
SecurityDetails interface{} `json:"security_details"`
Timing interface{} `json:"timing"`
}
