Documentation ¶
Overview ¶
Package utils contains helper functions that can be used throughout the project
Exported function(s): CopyFile, GetPhishingDomains, FirefoxFolder
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseFile ¶
CloseFile is a utility function that closes a given file and logs any errors that occur during the process.
Parameters:
- file *filemock.File: The file that needs to be closed. It is an instance of a File from the filemock package.
Returns:
- error: An error object that wraps any error that occurs during file closure. If the file is closed successfully, it returns nil.
func CopyFile ¶
CopyFile is a utility function that copies a file from a source path to a destination path.
Parameters:
- src string: The path to the source file that needs to be copied.
- dst string: The path to the destination where the source file should be copied to.
dst - the destination file
Returns:
- error: An error object that wraps any error that occurs during the file copying process. If the file is copied successfully, it returns nil.
func CurrentUsername ¶
CurrentUsername retrieves the username of the currently logged-in user in a Windows environment.
This function uses the os/user package to access the current user's information. It then parses the Username field to extract the actual username, discarding the domain if present.
Returns:
- string: The username of the currently logged-in user. If the username cannot be retrieved, an empty string is returned.
- error: An error object that wraps any error that occurs during the retrieval of the username. If the username is retrieved successfully, it returns nil.
func FirefoxFolder ¶
FirefoxFolder retrieves the paths to all Firefox profile folders for the currently logged-in user.
This function uses the os/user package to access the current user's information and constructs the path to the Firefox profile directory. It then reads the directory and filters out all non-directory files. For each directory, it checks if a 'logins.json' file exists. If such a file exists, the directory is considered a Firefox profile folder and its path is added to the returned list.
Returns:
- []string: A slice containing the paths to all Firefox profile folders. If no profile folders are found or an error occurs, an empty slice is returned.
- error: An error object that wraps any error that occurs during the retrieval of the Firefox profile folders. If the folders are retrieved successfully, it returns nil.
func GetPhishingDomains ¶
func GetPhishingDomains() []string
GetPhishingDomains retrieves a list of active phishing domains from a remote GitHub repository.
This function sends a GET request to the URL of the phishing database hosted on GitHub. It reads the response body, which contains a list of active phishing domains, each on a new line. The function then splits this response into a slice of strings, where each string represents a single phishing domain.
Returns:
- []string: A slice containing the phishing domains. If an error occurs during the retrieval or parsing of the domains, an empty slice is returned.
func RemoveDuplicateStr ¶
RemoveDuplicateStr is a utility function that eliminates duplicate string values from a given slice.
Parameters:
- strSlice []string: The input slice from which duplicate string values need to be removed.
Returns:
- []string: A new slice that contains the unique string values from the input slice. The order of the elements is preserved based on their first occurrence in the input slice.
Types ¶
This section is empty.