utils

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BodyA0 = `(?:`
	BodyB0 = `(`
	BodyC0 = `(?:[\.]{1,2}/[A-Za-z0-9\-_/\\?&@\.?=%]+)`
	BodyC1 = `|(https?://[A-Za-z0-9_\-\.]+([\.]{0,2})?\/[A-Za-z0-9\-_/\\?&@\.?=%]+)`
	BodyC2 = `|(/[A-Za-z0-9\-_/\\?&@\.%]+\.(aspx?|action|cfm|cgi|do|pl|css|x?html?|js(p|on)?|pdf|php5?|py|rss))`
	BodyC3 = `|([A-Za-z0-9\-_?&@\.%]+/[A-Za-z0-9/\\\-_?&@\.%]+\.(aspx?|action|cfm|cgi|do|pl|css|x?html?|js(p|on)?|pdf|php5?|py|rss))`
	BodyB1 = `)`
	BodyA1 = `)`

	JsA0 = `(?:"|'|\s)`
	JsB0 = `(`
	JsC0 = `((https?://[A-Za-z0-9_\-\.]+(:\d{1,5})?)+([\.]{1,2})?/[A-Za-z0-9/\-_\.\\%]+([\?|#][^"']+)?)`
	JsC1 = `|((\.{1,2}/)?[a-zA-Z0-9\-_/\\%]+\.(aspx?|js(on|p)?|html|php5?|html|action|do)([\?|#][^"']+)?)`
	JsC2 = `|((\.{0,2}/)[a-zA-Z0-9\-_/\\%]+(/|\\)[a-zA-Z0-9\-_]{3,}([\?|#][^"|']+)?)`
	JsC3 = `|((\.{0,2})[a-zA-Z0-9\-_/\\%]{3,}/)`
	JsB1 = `)`
	JsA1 = `(?:"|'|\s)`
)
View Source
var (
	// CommonJSLibraryFileRegex is a regex to match common js library files.
	CommonJSLibraryFileRegex = `` /* 367-byte string literal not displayed */

)
View Source
var DefaultFormFillData = FormFillData{
	Email:       fmt.Sprintf("%s@katanacrawler.io", xid.New().String()),
	Color:       "#e66465",
	Password:    "katanaP@assw0rd1",
	PhoneNumber: "2124567890",
	Placeholder: "katana",
}

Functions

func ExtractBodyEndpoints

func ExtractBodyEndpoints(data string) []string

ExtractBodyEndpoints extracts body endpoints from a data item

func ExtractRelativeEndpoints

func ExtractRelativeEndpoints(data string) []string

ExtractRelativeEndpoints extracts relative endpoints from a data item

func FlattenHeaders

func FlattenHeaders(headers map[string][]string) map[string]string

func FormInputFillSuggestions

func FormInputFillSuggestions(inputs []FormInput) mapsutil.OrderedMap[string, string]

FormInputFillSuggestions returns a list of form filling suggestions for inputs returning the specified recommended values.

func IsPathCommonJSLibraryFile

func IsPathCommonJSLibraryFile(path string) bool

IsPathCommonJSLibraryFile checks if a given path is a common js library file.

func IsURL

func IsURL(url string) bool

IsURL returns true if a provided string is URL

func ParseFormFields

func ParseFormFields(document *goquery.Document) []navigation.Form

parses form, input, textarea & select elements

func ParseLinkTag

func ParseLinkTag(value string) []string

ParseLinkTag parses link tag values returning found urls

Inspired from: https://github.com/tomnomnom/linkheader

func ParseRefreshTag

func ParseRefreshTag(value string) string

ParseRefreshTag parses refresh tag values returning found urls

func ParseSRCSetTag

func ParseSRCSetTag(value string) []string

ParseSRCSetTag parses srcset tag returning found URLs

func ReplaceAllQueryParam

func ReplaceAllQueryParam(reqUrl, val string) string

ReplaceAllQueryParam replaces all the query param with the given value

func WebUserAgent

func WebUserAgent() string

WebUserAgent returns the chrome-web user agent

Types

type FormFillData

type FormFillData struct {
	Email       string `yaml:"email"`
	Color       string `yaml:"color"`
	Password    string `yaml:"password"`
	PhoneNumber string `yaml:"phone"`
	Placeholder string `yaml:"placeholder"`
}

FormFillData contains suggestions for form filling

var FormData FormFillData

FormData is the global form fill data instance

type FormInput

type FormInput struct {
	Type       string
	Name       string
	Value      string
	Attributes mapsutil.OrderedMap[string, string]
}

FormInput is an input for a form field

func ConvertGoquerySelectionToFormInput

func ConvertGoquerySelectionToFormInput(item *goquery.Selection) FormInput

ConvertGoquerySelectionToFormInput converts goquery selection to form input

type JSLuiceEndpoint

type JSLuiceEndpoint struct {
	Endpoint string
	Type     string
}

func ExtractJsluiceEndpoints

func ExtractJsluiceEndpoints(data string) []JSLuiceEndpoint

ExtractJsluiceEndpoints extracts jsluice endpoints from a given string.

We use tomnomnom and bishopfox's jsluice to extract endpoints from javascript files.

We apply several optimizations before running jsluice:

  • We skip common js library files.
  • We skip lines that are too long and contain a lot of characters.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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