mirror of
https://github.com/edoardottt/cariddi.git
synced 2026-09-13 05:07:45 +02:00
linter (godot)
This commit is contained in:
+1
-1
@@ -45,7 +45,7 @@ import (
|
||||
|
||||
//Crawler it's the actual crawler engine.
|
||||
//It controls all the behaviours of a scan
|
||||
//(event handlers, secrets, errors, extensions and endpoints scanning)
|
||||
//(event handlers, secrets, errors, extensions and endpoints scanning).
|
||||
func Crawler(target string, txt string, html string, delayTime int, concurrency int,
|
||||
ignore string, ignoreTxt string, cache bool, timeout int, intensive bool, rua bool,
|
||||
proxy string, insecure bool, secrets bool, secretsFile []string, plain bool, endpoints bool,
|
||||
|
||||
+3
-3
@@ -34,7 +34,7 @@ import (
|
||||
)
|
||||
|
||||
//GetRequest performs a GET request and return
|
||||
//a string (the body of the response)
|
||||
//a string (the body of the response).
|
||||
func GetRequest(target string) (string, error) {
|
||||
resp, err := http.Get(target)
|
||||
if err != nil {
|
||||
@@ -57,7 +57,7 @@ func GetRequest(target string) (string, error) {
|
||||
//a string (the body of the response)
|
||||
//the map in the input should contains the data fields and values
|
||||
//in this way for example:
|
||||
//{ email: test@example.com, password: stupid_pwd }
|
||||
//{ email: test@example.com, password: stupid_pwd }.
|
||||
func PostRequest(target string, data map[string]string) (string, error) {
|
||||
postBody, _ := json.Marshal(data)
|
||||
responseBody := bytes.NewBuffer(postBody)
|
||||
@@ -80,7 +80,7 @@ func PostRequest(target string, data map[string]string) (string, error) {
|
||||
}
|
||||
|
||||
//HeadRequest performs a HEAD request and return
|
||||
//a string (the headers of the response)
|
||||
//a string (the headers of the response).
|
||||
func HeadRequest(target string) (string, error) {
|
||||
resp, err := http.Head(target)
|
||||
if err != nil {
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ import (
|
||||
|
||||
//CheckDataPost should take as input a string and checks
|
||||
//if it's correctly formatted to be represented as post data
|
||||
//TODO - for now cariddi sends only GET requests
|
||||
//TODO - for now cariddi sends only GET requests.
|
||||
func CheckDataPost(input string) (map[string]string, error) {
|
||||
// ===== TODO =======
|
||||
return map[string]string{}, nil
|
||||
@@ -55,7 +55,7 @@ func CheckOutputFile(input string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
//CheckFlags checks the flags taken as input
|
||||
//CheckFlags checks the flags taken as input.
|
||||
func CheckFlags(flags Input) {
|
||||
if flags.TXT != "" {
|
||||
if !CheckOutputFile(flags.TXT) {
|
||||
|
||||
+2
-2
@@ -30,8 +30,8 @@ import (
|
||||
"flag"
|
||||
)
|
||||
|
||||
//Input struct
|
||||
//It contains all the possible options
|
||||
//Input struct.
|
||||
//It contains all the possible options.
|
||||
type Input struct {
|
||||
Version bool
|
||||
Delay int
|
||||
|
||||
+6
-6
@@ -33,7 +33,7 @@ import (
|
||||
)
|
||||
|
||||
//EncapsulateGreen takes as input a string and
|
||||
//print a green prefix
|
||||
//print a green prefix.
|
||||
func EncapsulateGreen(inp string) {
|
||||
// Create a custom print function for convenience
|
||||
green := color.New(color.FgGreen).PrintfFunc()
|
||||
@@ -42,7 +42,7 @@ func EncapsulateGreen(inp string) {
|
||||
}
|
||||
|
||||
//EncapsulateRed takes as input a string and
|
||||
//print a red prefix
|
||||
//print a red prefix.
|
||||
func EncapsulateRed(inp string) {
|
||||
// Create a custom print function for convenience
|
||||
red := color.New(color.FgRed).PrintfFunc()
|
||||
@@ -51,7 +51,7 @@ func EncapsulateRed(inp string) {
|
||||
}
|
||||
|
||||
//EncapsulateYellow takes as input a string and
|
||||
//print a yellow prefix
|
||||
//print a yellow prefix.
|
||||
func EncapsulateYellow(inp string) {
|
||||
// Create a custom print function for convenience
|
||||
yellow := color.New(color.FgYellow).PrintfFunc()
|
||||
@@ -60,7 +60,7 @@ func EncapsulateYellow(inp string) {
|
||||
}
|
||||
|
||||
//EncapsulateCustomGreen takes as input a string and
|
||||
//print it with the green color
|
||||
//print it with the green color.
|
||||
func EncapsulateCustomGreen(alert string, inp string) {
|
||||
// Create a custom print function for convenience
|
||||
green := color.New(color.FgGreen).PrintfFunc()
|
||||
@@ -69,7 +69,7 @@ func EncapsulateCustomGreen(alert string, inp string) {
|
||||
}
|
||||
|
||||
//EncapsulateCustomRed takes as input a string and
|
||||
//print it with the red color
|
||||
//print it with the red color.
|
||||
func EncapsulateCustomRed(alert string, inp string) {
|
||||
// Create a custom print function for convenience
|
||||
red := color.New(color.FgRed).PrintfFunc()
|
||||
@@ -78,7 +78,7 @@ func EncapsulateCustomRed(alert string, inp string) {
|
||||
}
|
||||
|
||||
//EncapsulateCustomYellow takes as input a string and
|
||||
//print it with the yellow color
|
||||
//print it with the yellow color.
|
||||
func EncapsulateCustomYellow(alert string, inp string) {
|
||||
// Create a custom print function for convenience
|
||||
yellow := color.New(color.FgYellow).PrintfFunc()
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import (
|
||||
)
|
||||
|
||||
//AppendOutputToTxt opens the output file and append
|
||||
//the string taken as input
|
||||
//the string taken as input.
|
||||
func AppendOutputToTxt(output string, filename string) {
|
||||
file, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
|
||||
@@ -26,23 +26,23 @@ along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
package scanner
|
||||
|
||||
//Parameter struct
|
||||
// Parameter = the name of the parameter
|
||||
// Attacks = Possible attacks
|
||||
//Parameter struct.
|
||||
// Parameter = the name of the parameter.
|
||||
// Attacks = Possible attacks.
|
||||
type Parameter struct {
|
||||
Parameter string
|
||||
Attacks []string
|
||||
}
|
||||
|
||||
//EndpointMatched struct
|
||||
// Parameters = a list of parameters in a particular endpoint
|
||||
// Url = url (aka endpoint)
|
||||
//EndpointMatched struct.
|
||||
// Parameters = a list of parameters in a particular endpoint.
|
||||
// Url = url (aka endpoint).
|
||||
type EndpointMatched struct {
|
||||
Parameters []Parameter
|
||||
URL string
|
||||
}
|
||||
|
||||
//GetJuicyParameters returns juicy parameters and their possible attacks
|
||||
//GetJuicyParameters returns juicy parameters and their possible attacks.
|
||||
func GetJuicyParameters() []Parameter {
|
||||
var juicyParameters = []Parameter{
|
||||
{"apikey", []string{"Info"}},
|
||||
@@ -186,7 +186,7 @@ func GetJuicyParameters() []Parameter {
|
||||
return juicyParameters
|
||||
}
|
||||
|
||||
//RemovDuplicateEndpoints removes duplicate endpoints found
|
||||
//RemovDuplicateEndpoints removes duplicate endpoints found.
|
||||
func RemovDuplicateEndpoints(input []EndpointMatched) []EndpointMatched {
|
||||
keys := make(map[string]bool)
|
||||
list := []EndpointMatched{}
|
||||
|
||||
+9
-9
@@ -23,25 +23,25 @@ along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
package scanner
|
||||
|
||||
//Error struct
|
||||
// ErrorName = the name that identifies the error
|
||||
// Regex = The regular expression to be matched
|
||||
//Error struct.
|
||||
// ErrorName = the name that identifies the error.
|
||||
// Regex = The regular expression to be matched.
|
||||
type Error struct {
|
||||
ErrorName string
|
||||
Regex []string
|
||||
}
|
||||
|
||||
//ErrorMatched struct
|
||||
// Error = Error struct
|
||||
// Url = url in which the error is found
|
||||
// Match = the string matching the regex
|
||||
//ErrorMatched struct.
|
||||
// Error = Error struct.
|
||||
// Url = url in which the error is found.
|
||||
// Match = the string matching the regex.
|
||||
type ErrorMatched struct {
|
||||
Error Error
|
||||
URL string
|
||||
Match string
|
||||
}
|
||||
|
||||
//GetErrorRegexes returns all the error structs
|
||||
//GetErrorRegexes returns all the error structs.
|
||||
func GetErrorRegexes() []Error {
|
||||
var regexes = []Error{
|
||||
{
|
||||
@@ -150,7 +150,7 @@ func GetErrorRegexes() []Error {
|
||||
return regexes
|
||||
}
|
||||
|
||||
//RemoveDuplicateErrors removes duplicates from Errors found
|
||||
//RemoveDuplicateErrors removes duplicates from Errors found.
|
||||
func RemoveDuplicateErrors(input []ErrorMatched) []ErrorMatched {
|
||||
keys := make(map[string]bool)
|
||||
list := []ErrorMatched{}
|
||||
|
||||
@@ -26,23 +26,23 @@ along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
package scanner
|
||||
|
||||
//FileType struct
|
||||
// Extension = the file extension (doc, txt ..etc..)
|
||||
// Severity = the 'importance' of the file found. Higher is better
|
||||
//FileType struct.
|
||||
// Extension = the file extension (doc, txt ..etc..).
|
||||
// Severity = the 'importance' of the file found. Higher is better.
|
||||
type FileType struct {
|
||||
Extension string
|
||||
Severity int
|
||||
}
|
||||
|
||||
//FileTypeMatched struct
|
||||
// Filetype = Filetype struct
|
||||
// Url = url of the file found
|
||||
//FileTypeMatched struct.
|
||||
// Filetype = Filetype struct.
|
||||
// Url = url of the file found.
|
||||
type FileTypeMatched struct {
|
||||
Filetype FileType
|
||||
URL string
|
||||
}
|
||||
|
||||
//GetExtensions returns all the extension structs
|
||||
//GetExtensions returns all the extension structs.
|
||||
func GetExtensions() []FileType {
|
||||
//extensions contains a list of known extensions
|
||||
//and the TYPICAL (also say `in general`) associated severity.
|
||||
@@ -111,7 +111,7 @@ func GetExtensions() []FileType {
|
||||
return extensions
|
||||
}
|
||||
|
||||
//RemoveDuplicateExtensions removes duplicates from Extensions found
|
||||
//RemoveDuplicateExtensions removes duplicates from Extensions found.
|
||||
func RemoveDuplicateExtensions(input []FileTypeMatched) []FileTypeMatched {
|
||||
keys := make(map[string]bool)
|
||||
list := []FileTypeMatched{}
|
||||
|
||||
+9
-9
@@ -23,25 +23,25 @@ along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
package scanner
|
||||
|
||||
//Info struct
|
||||
// Name = the name that identifies the information
|
||||
// Regex = The regular expression to be matched
|
||||
//Info struct.
|
||||
// Name = the name that identifies the information.
|
||||
// Regex = The regular expression to be matched.
|
||||
type Info struct {
|
||||
Name string
|
||||
Regex []string
|
||||
}
|
||||
|
||||
//InfoMatched struct
|
||||
// Info = Info struct
|
||||
// Url = url in which the information is found
|
||||
// Match = the string matching the regex
|
||||
//InfoMatched struct.
|
||||
// Info = Info struct.
|
||||
// Url = url in which the information is found.
|
||||
// Match = the string matching the regex.
|
||||
type InfoMatched struct {
|
||||
Info Info
|
||||
URL string
|
||||
Match string
|
||||
}
|
||||
|
||||
//GetInfoRegexes returns all the info structs
|
||||
//GetInfoRegexes returns all the info structs.
|
||||
func GetInfoRegexes() []Info {
|
||||
var regexes = []Info{
|
||||
{
|
||||
@@ -83,7 +83,7 @@ func GetInfoRegexes() []Info {
|
||||
return regexes
|
||||
}
|
||||
|
||||
//RemoveDuplicateInfos removes duplicates from Infos found
|
||||
//RemoveDuplicateInfos removes duplicates from Infos found.
|
||||
func RemoveDuplicateInfos(input []InfoMatched) []InfoMatched {
|
||||
keys := make(map[string]bool)
|
||||
list := []InfoMatched{}
|
||||
|
||||
+12
-12
@@ -26,12 +26,12 @@ along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
package scanner
|
||||
|
||||
//Secret struct
|
||||
// Name = the name that identifies the secret
|
||||
// Description
|
||||
// Regex = The regular expression matching the secret
|
||||
// FalsePositives = A list of known false positives
|
||||
// PoC = cli command to check if the secret is valid or not
|
||||
//Secret struct.
|
||||
// Name = the name that identifies the secret.
|
||||
// Description.
|
||||
// Regex = The regular expression matching the secret.
|
||||
// FalsePositives = A list of known false positives.
|
||||
// PoC = cli command to check if the secret is valid or not.
|
||||
type Secret struct {
|
||||
Name string
|
||||
Description string
|
||||
@@ -40,10 +40,10 @@ type Secret struct {
|
||||
Poc string
|
||||
}
|
||||
|
||||
//SecretMatched struct
|
||||
// Secret = The secret matched (struct)
|
||||
// Url = url in which is present the secret
|
||||
// Match = the string matching the regex
|
||||
//SecretMatched struct.
|
||||
// Secret = The secret matched (struct).
|
||||
// Url = url in which is present the secret.
|
||||
// Match = the string matching the regex.
|
||||
type SecretMatched struct {
|
||||
Secret Secret
|
||||
URL string
|
||||
@@ -51,7 +51,7 @@ type SecretMatched struct {
|
||||
}
|
||||
|
||||
//GetSecretRegexes returns a slice of all
|
||||
//the secret structs
|
||||
//the secret structs.
|
||||
func GetSecretRegexes() []Secret {
|
||||
var regexes = []Secret{
|
||||
{
|
||||
@@ -342,7 +342,7 @@ func GetSecretRegexes() []Secret {
|
||||
return regexes
|
||||
}
|
||||
|
||||
//RemoveDuplicateSecrets removes duplicates from secrets found
|
||||
//RemoveDuplicateSecrets removes duplicates from secrets found.
|
||||
func RemoveDuplicateSecrets(input []SecretMatched) []SecretMatched {
|
||||
keys := make(map[string]bool)
|
||||
list := []SecretMatched{}
|
||||
|
||||
+4
-4
@@ -37,7 +37,7 @@ import (
|
||||
)
|
||||
|
||||
//CreateOutputFolder creates the output folder
|
||||
//If it fails exits with an error message
|
||||
//If it fails exits with an error message.
|
||||
func CreateOutputFolder() {
|
||||
//Create a folder/directory at a full qualified path
|
||||
err := os.Mkdir("output-cariddi", 0755)
|
||||
@@ -97,7 +97,7 @@ func CreateOutputFile(target string, subcommand string, format string) string {
|
||||
}
|
||||
|
||||
//ReplaceBadCharacterOutput replaces forward-slashes
|
||||
//with dashes (to avoid problems with output folder)
|
||||
//with dashes (to avoid problems with output folder).
|
||||
func ReplaceBadCharacterOutput(input string) string {
|
||||
result := strings.ReplaceAll(input, "/", "-")
|
||||
return result
|
||||
@@ -123,7 +123,7 @@ func ReadFile(inputFile string) []string {
|
||||
return text
|
||||
}
|
||||
|
||||
//ElementExists returns whether the given file or directory exists
|
||||
//ElementExists returns whether the given file or directory exists.
|
||||
func ElementExists(path string) (bool, error) {
|
||||
_, err := os.Stat(path)
|
||||
if err == nil {
|
||||
@@ -138,7 +138,7 @@ func ElementExists(path string) (bool, error) {
|
||||
}
|
||||
|
||||
//ReadHTTPRequestFromFile reads from a file an HTTP
|
||||
//request and returns a *http.Request object
|
||||
//request and returns a *http.Request object.
|
||||
func ReadHTTPRequestFromFile(inputFile string) (*http.Request, error) {
|
||||
f, err := os.Open(inputFile)
|
||||
if err != nil {
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@ import (
|
||||
)
|
||||
|
||||
//RemoveDuplicateValues removes duplicates from a slice
|
||||
//of strings
|
||||
//of strings.
|
||||
func RemoveDuplicateValues(strSlice []string) []string {
|
||||
keys := make(map[string]bool)
|
||||
list := []string{}
|
||||
@@ -49,8 +49,8 @@ func RemoveDuplicateValues(strSlice []string) []string {
|
||||
|
||||
//CheckInputArray checks the basic rules to
|
||||
//be valid and then returns the array as input.
|
||||
// - Delete duplicates
|
||||
// - Avoid empty strings
|
||||
// - Delete duplicates.
|
||||
// - Avoid empty strings.
|
||||
func CheckInputArray(input string) []string {
|
||||
delimiter := byte(',')
|
||||
sliceOut := strings.Split(input, string(delimiter))
|
||||
@@ -69,7 +69,7 @@ func CheckInputArray(input string) []string {
|
||||
//CheckCookies checks if the string provided to the
|
||||
//-cookie option is valid.
|
||||
//format: "name1:value1;name2:value2"
|
||||
//It returns a slice of Cookies
|
||||
//It returns a slice of Cookies.
|
||||
func CheckCookies(input string) []*http.Cookie {
|
||||
var result []*http.Cookie
|
||||
if input == "" {
|
||||
|
||||
+12
-12
@@ -35,7 +35,7 @@ import (
|
||||
//GetHost takes as input a string and
|
||||
//tries to parse it as url, if it's a
|
||||
//well formatted url this function returns
|
||||
//the host (the domain if you prefer)
|
||||
//the host (the domain if you prefer).
|
||||
func GetHost(input string) string {
|
||||
u, err := url.Parse(input)
|
||||
if err != nil {
|
||||
@@ -48,7 +48,7 @@ func GetHost(input string) string {
|
||||
//GetProtocol takes as input a string and
|
||||
//tries to parse it as url, if it's a
|
||||
//well formatted url this function returns
|
||||
//the protocol (the scheme if you prefer)
|
||||
//the protocol (the scheme if you prefer).
|
||||
func GetProtocol(input string) string {
|
||||
u, err := url.Parse(input)
|
||||
if err != nil {
|
||||
@@ -61,7 +61,7 @@ func GetProtocol(input string) string {
|
||||
//GetRootHost takes as input a string and
|
||||
//tries to parse it as url, if it's a
|
||||
//well formatted url this function returns
|
||||
//the second level domain
|
||||
//the second level domain.
|
||||
func GetRootHost(input string) (string, error) {
|
||||
u, err := url.Parse(input)
|
||||
if err != nil {
|
||||
@@ -80,15 +80,15 @@ func GetRootHost(input string) (string, error) {
|
||||
|
||||
//HasProtocol takes as input a string and
|
||||
//checks if it has a protocol ( like in a
|
||||
//URI/URL)
|
||||
//URI/URL).
|
||||
func HasProtocol(input string) bool {
|
||||
res := strings.Index(input, "://")
|
||||
return res >= 0
|
||||
}
|
||||
|
||||
//RemoveProtocol removes the protocol from
|
||||
//the input string (something://...)
|
||||
//If it's not present it returns the input
|
||||
//the input string (something://...).
|
||||
//If it's not present it returns the input.
|
||||
func RemoveProtocol(input string) string {
|
||||
res := strings.Index(input, "://")
|
||||
if res >= 0 {
|
||||
@@ -98,8 +98,8 @@ func RemoveProtocol(input string) string {
|
||||
return input
|
||||
}
|
||||
|
||||
//RemovePort removes port from the input string
|
||||
//If it's not present it returns the input
|
||||
//RemovePort removes port from the input string.
|
||||
//If it's not present it returns the input.
|
||||
func RemovePort(input string) string {
|
||||
res := strings.Index(input, ":")
|
||||
if res >= 0 {
|
||||
@@ -111,7 +111,7 @@ func RemovePort(input string) string {
|
||||
|
||||
//RetrieveParameters takes as input a string and
|
||||
//if it's correctly url-formatted returns a slice
|
||||
//of strings that are the parameters of the URL
|
||||
//of strings that are the parameters of the URL.
|
||||
func RetrieveParameters(input string) []string {
|
||||
var result []string
|
||||
|
||||
@@ -129,7 +129,7 @@ func RetrieveParameters(input string) []string {
|
||||
}
|
||||
|
||||
//AbsoluteURL takes as input a protocol, a domain and a path
|
||||
//and returns the absolute URL with protocol + domain + path
|
||||
//and returns the absolute URL with protocol + domain + path.
|
||||
func AbsoluteURL(protocol string, target string, path string) string {
|
||||
// if the path variable starts with a scheme, it means that the
|
||||
// path is itself an absolute path.
|
||||
@@ -144,7 +144,7 @@ func AbsoluteURL(protocol string, target string, path string) string {
|
||||
return protocol + "://" + target + "/" + path
|
||||
}
|
||||
|
||||
//SameDomain checks if two urls have the same domain
|
||||
//SameDomain checks if two urls have the same domain.
|
||||
func SameDomain(url1 string, url2 string) bool {
|
||||
u1, err := url.Parse(url1)
|
||||
if err != nil {
|
||||
@@ -164,7 +164,7 @@ func SameDomain(url1 string, url2 string) bool {
|
||||
}
|
||||
|
||||
//GetPath returns the path of the input string
|
||||
//(if correctly URL-formatted)
|
||||
//(if correctly URL-formatted).
|
||||
func GetPath(input string) (string, error) {
|
||||
u, err := url.Parse(input)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user