Documentation ¶
Overview ¶
Package output handles structured logging for the framework and exploits.
Our goals for logging in go-exploit were something like this:
- Structured logging for easy parsing (text and JSON).
- The option to log to the CLI or directly to a file.
- Program output to stdout, and errors to stderr
- Different log level controls for the framework and the exploits implementation.
To achieve all of the above, we split the implementation into two logging APIs: exploitlog.go and frameworklog.go. Exploit should use exploitlog.go API such as output.PrintFrameworkSuccess(), output.PrintFrameworkError(), etc. Framework should use frameworklog.go API such as output.PrintFrameworkSuccess(), output.PrintFrameworkError(), etc.
Index ¶
- Constants
- Variables
- func PrintDebug(msg string, keys ...any)
- func PrintError(msg string, keys ...any)
- func PrintFrameworkDebug(msg string, keys ...any)
- func PrintFrameworkError(msg string, keys ...any)
- func PrintFrameworkStatus(msg string, keys ...any)
- func PrintFrameworkSuccess(msg string, keys ...any)
- func PrintFrameworkTrace(msg string, keys ...any)
- func PrintFrameworkWarn(msg string, keys ...any)
- func PrintShell(msg string)
- func PrintStatus(msg string, keys ...any)
- func PrintSuccess(msg string, keys ...any)
- func PrintTrace(msg string, keys ...any)
- func PrintVersion(msg string, host string, port int, version string)
- func PrintWarn(msg string, keys ...any)
- func PrintfDebug(format string, msg ...interface{})
- func PrintfError(format string, msg ...interface{})
- func PrintfFrameworkDebug(format string, msg ...interface{})
- func PrintfFrameworkError(format string, msg ...interface{})
- func PrintfFrameworkStatus(format string, msg ...interface{})
- func PrintfFrameworkSuccess(format string, msg ...interface{})
- func PrintfFrameworkTrace(format string, msg ...interface{})
- func PrintfFrameworkWarn(format string, msg ...interface{})
- func PrintfStatus(format string, msg ...interface{})
- func PrintfSuccess(format string, msg ...interface{})
- func PrintfTrace(format string, msg ...interface{})
- func PrintfWarn(format string, msg ...interface{})
- func SetExploitLogLevel(level slog.Level)
- func SetFrameworkLogLevel(level slog.Level)
- func SetOutputFile(file string) bool
Constants ¶
const ( // Extreme debugging that shows executions. LevelTrace = slog.Level(-8) // Useful tidbits for debugging potential problems. LevelDebug = slog.LevelDebug // A hihg-level status updat. LevelStatus = slog.LevelInfo // A non-critical issue that is bubbled up to the user. LevelWarning = slog.LevelWarn // A special message for outputing software versions. LevelVersion = slog.Level(5) // An important status message. LevelSuccess = slog.Level(6) // An important error message. LevelError = slog.LevelError )
Variables ¶
var FormatJSON = false
FormatJSON indicates if we should use TextHandler or NJSONHandler for logging.
var LogLevels = map[string]slog.Level{ "TRACE": LevelTrace, "DEBUG": LevelDebug, "STATUS": LevelStatus, "WARNING": LevelWarning, "VERSION": LevelVersion, "SUCCESS": LevelSuccess, "ERROR": LevelError, }
LogLevels is a mapping of the log names to slog level.
Functions ¶
func PrintDebug ¶ added in v1.0.16
PrintDebug logs a string as TRACE If the exploit is not logging to file, this will go to standard error.
func PrintError ¶
PrintError logs a string as ERROR If the exploit is not logging to file, this will go to standard error.
func PrintFrameworkDebug ¶ added in v1.0.16
PrintFrameworkDebug logs a string as TRACE If the framework is not logging to file, this will go to standard error.
func PrintFrameworkError ¶ added in v1.0.16
PrintFrameworkError logs a string as ERROR If the framework is not logging to file, this will go to standard error.
func PrintFrameworkStatus ¶ added in v1.0.16
PrintFrameworkStatus logs a string as STATUS (aka INFO) If the framework is not logging to file, this will go to standard out.
func PrintFrameworkSuccess ¶ added in v1.0.16
PrintFrameworkSuccess logs a string as SUCCESS If the framework is not logging to file, this will go to standard out.
func PrintFrameworkTrace ¶ added in v1.0.16
PrintFrameworkTrace logs a string as TRACE If the framework is not logging to file, this will go to standard error.
func PrintFrameworkWarn ¶ added in v1.0.16
PrintFrameworkWarn logs a string as WARN If the framework is not logging to file, this will go to standard error.
func PrintShell ¶ added in v1.0.16
func PrintShell(msg string)
Displaying content on our fake shell. Need to hold the log mutex for writing to stdout. In theory we could log here too if wanted?
func PrintStatus ¶
PrintStatus logs a string as STATUS (aka INFO) If the exploit is not logging to file, this will go to standard out.
func PrintSuccess ¶
PrintStatus logs a string as SUCCESS If the exploit is not logging to file, this will go to standard out.
func PrintTrace ¶ added in v1.0.16
PrintTrace logs a string as TRACE If the exploit is not logging to file, this will go to standard error.
func PrintVersion ¶ added in v1.0.16
PrintVersion logs a string as VERSION If the exploit is not logging to file, this will go to standard output.
func PrintWarn ¶ added in v1.0.16
PrintWarn logs a string as WARN If the exploit is not logging to file, this will go to standard error.
func PrintfDebug ¶ added in v1.0.16
func PrintfDebug(format string, msg ...interface{})
PrintfDebug formats according to a format specifier and logs as DEBUG If the exploit is not logging to file, this will go to standard error.
func PrintfError ¶
func PrintfError(format string, msg ...interface{})
PrintfError formats according to a format specifier and logs as ERROR If the exploit is not logging to file, this will go to standard error.
func PrintfFrameworkDebug ¶ added in v1.0.16
func PrintfFrameworkDebug(format string, msg ...interface{})
PrintfFrameworkDebug formats according to a format specifier and logs as DEBUG If the framework is not logging to file, this will go to standard error.
func PrintfFrameworkError ¶ added in v1.0.16
func PrintfFrameworkError(format string, msg ...interface{})
PrintfFrameworkError formats according to a format specifier and logs as ERROR If the framework is not logging to file, this will go to standard error.
func PrintfFrameworkStatus ¶ added in v1.0.16
func PrintfFrameworkStatus(format string, msg ...interface{})
PrintfFrameworkStatus formats according to a format specifier and logs as STATUS (aka INFO) If the framework is not logging to file, this will go to standard out.
func PrintfFrameworkSuccess ¶ added in v1.0.16
func PrintfFrameworkSuccess(format string, msg ...interface{})
PrintfFrameworkSuccess formats according to a format specifier and logs as SUCCESS If the framework is not logging to file, this will go to standard out.
func PrintfFrameworkTrace ¶ added in v1.0.16
func PrintfFrameworkTrace(format string, msg ...interface{})
PrintfFrameworkTrace formats according to a format specifier and logs as TRACE If the framework is not logging to file, this will go to standard error.
func PrintfFrameworkWarn ¶ added in v1.0.16
func PrintfFrameworkWarn(format string, msg ...interface{})
PrintfFrameworkWarn formats according to a format specifier and logs as WARN If the framework is not logging to file, this will go to standard error.
func PrintfStatus ¶
func PrintfStatus(format string, msg ...interface{})
PrintfStatus formats according to a format specifier and logs as STATUS (aka INFO) If the exploit is not logging to file, this will go to standard out.
func PrintfSuccess ¶
func PrintfSuccess(format string, msg ...interface{})
PrintfSuccess formats according to a format specifier and logs as SUCCESS If the exploit is not logging to file, this will go to standard out.
func PrintfTrace ¶ added in v1.0.16
func PrintfTrace(format string, msg ...interface{})
PrintfTrace formats according to a format specifier and logs as TRACE If the exploit is not logging to file, this will go to standard error.
func PrintfWarn ¶ added in v1.0.16
func PrintfWarn(format string, msg ...interface{})
PrintfWarn formats according to a format specifier and logs as WARN If the exploit is not logging to file, this will go to standard error.
func SetExploitLogLevel ¶ added in v1.0.16
Sets the log level for exploit logging. Anything below the provided value will not get logged.
func SetFrameworkLogLevel ¶ added in v1.0.16
Sets the log level for framework logging. Anything below the provided value will not get logged.
func SetOutputFile ¶ added in v1.0.16
If logging to a file, function will create/append the file and assign the file as output for all log types.
Types ¶
This section is empty.