Documentation
¶
Overview ¶
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AddCmd = &cobra.Command{ Use: "add", Short: "Add targets", Long: `Adding targets It takes urls from stdin, Target Group ID is optional. Example: echo "https://127.0.0.1" | acucli target add : Add the target without target group cat targets.txt | acucli target add --gid=cd3db1f4-6275-478c-8830-8d96d37120f3 : Add targets from a file with target group `, Run: func(cmd *cobra.Command, args []string) { groups := []string{} input := filehelper.ReadStdin() inputGID, _ := cmd.Flags().GetString("gid") if inputGID != "" { groups = append(groups, inputGID) } if input != nil { targets := []Target{} for _, line := range input { targets = append(targets, Target{Address: line, Description: "", Type: "default", Criticality: 30}) } makeRequest(targets, groups) } else { fmt.Println("Please provide addresses to add") } }, }
addCmd represents the add command
View Source
var GetConfigCmd = &cobra.Command{ Use: "getConfig", Short: "Get scan configuration for target", Long: `Takes target ID from stdin example: echo "5fac63fd-088c-4445-a2bf-a9f03f014832" | acucli target getConfig`, Run: func(cmd *cobra.Command, args []string) { input := filehelper.ReadStdin() if input != nil { responseCode, respBody := getConfigRequest(input[0]) if responseCode == 200 { filehelper.PrintStructFields(respBody) } else { fmt.Fprintf(os.Stderr, "%sTarget not found%s\n", chalk.Red, chalk.Reset) } } }, }
getConfigCmd represents the getConfig command
View Source
var ListCmd = &cobra.Command{ Use: "list", Short: "List all the targets", Long: `Lists all the targets with their name and their corresponding id to use it for other commands`, Run: func(cmd *cobra.Command, args []string) { req, err := http.NewRequest("GET", fmt.Sprintf("%s%s", viper.GetString("URL"), "/targets"), nil) if err != nil { fmt.Println("Error creating request:", err) return } resp, err := httpclient.MyHTTPClient.Do(req) if err != nil { fmt.Println("Error making request:", err) return } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) var targetList TargetList err = json.Unmarshal(body, &targetList) if err != nil { fmt.Println("Error parsing JSON:", err) return } for _, target := range targetList.Targets { fmt.Printf("%s\t%s\n", target.Address, target.TargetID) } }, }
listCmd represents the list command
View Source
var RemoveCmd = &cobra.Command{ Use: "remove", Short: "Removes target", Long: `Takes input as stdin. Example: echo "9797f3aa-80f7-41a6-9e24-4926b35147cf" | acucli target remove : Removes the target acucli target list | echo $(awk '{print $2}') | acucli target remove : Removes all targets`, Run: func(cmd *cobra.Command, args []string) { input := filehelper.ReadStdin() if input != nil { makeDeleteRequest(input) } }, }
RemoveCmd represents the remove command
View Source
var SetConfigCmd = &cobra.Command{ Use: "setConfig", Short: "Set scan config for target", Long: `Takes scan config variables from the config yaml file and the target from stdin. Example acucli targetGroup --id e3e5afcc-ee2e-431f-a8dc-9d894c93875d | cut -f2 | acucli target setConfig : Sets config for the targets in a target group `, Run: func(cmd *cobra.Command, args []string) { input := filehelper.ReadStdin() noIssues := true for _, id := range input { responseCode := setConfigRequest(id) if responseCode != 204 { fmt.Fprintf(os.Stderr, "%sProblem occurred%s\n", chalk.Red, chalk.Reset) noIssues = false break } } if noIssues { fmt.Println("Successfully configured targets") } }, }
setConfigCmd represents the setConfig command
View Source
var TargetCmd = &cobra.Command{ Use: "target", Short: "Endpoint for target operations", Long: `Retrieve target information from id flag`, Run: func(cmd *cobra.Command, args []string) { id, _ = cmd.Flags().GetString("id") responseCode, respBody := GetTargetRequest(id) if responseCode == 200 { filehelper.PrintStructFields(respBody) } else { fmt.Fprintf(os.Stderr, "%sTarget not found%s\n", chalk.Red, chalk.Reset) } }, }
targetCmd represents the target command
Functions ¶
func GetTargetRequest ¶
Types ¶
type ConfigResponseBody ¶
type ConfigResponseBody struct {
Description string `json:"description"`
LimitCrawlerScope bool `json:"limit_crawler_scope"`
Login struct {
Kind string `json:"kind"`
} `json:"login"`
Sensor bool `json:"sensor"`
SSHCredentials struct {
Kind string `json:"kind"`
} `json:"ssh_credentials"`
Proxy struct {
Enabled bool `json:"enabled"`
} `json:"proxy"`
Authentication struct {
Enabled bool `json:"enabled"`
} `json:"authentication"`
ClientCertificatePassword string `json:"client_certificate_password"`
ScanSpeed string `json:"scan_speed"`
CaseSensitive string `json:"case_sensitive"`
Technologies string `json:"technologies"`
CustomHeaders string `json:"custom_headers"`
CustomCookies string `json:"custom_cookies"`
ExcludedPaths string `json:"excluded_paths"`
UserAgent string `json:"user_agent"`
Debug bool `json:"debug"`
}
type RemovePostBody ¶
type RemovePostBody struct {
TargetIDList []string `json:"target_id_list"`
}
type TargetList ¶
type TargetList struct {
Targets []struct {
Address string `json:"address"`
Agents any `json:"agents"`
ContinuousMode bool `json:"continuous_mode"`
Criticality int `json:"criticality"`
DefaultScanningProfileID string `json:"default_scanning_profile_id"`
DeletedAt any `json:"deleted_at"`
Description string `json:"description"`
Fqdn string `json:"fqdn"`
FqdnHash string `json:"fqdn_hash"`
FqdnStatus string `json:"fqdn_status"`
FqdnTmHash string `json:"fqdn_tm_hash"`
IssueTrackerID any `json:"issue_tracker_id"`
LastScanDate string `json:"last_scan_date"`
LastScanID string `json:"last_scan_id"`
LastScanSessionID string `json:"last_scan_session_id"`
LastScanSessionStatus string `json:"last_scan_session_status"`
ManualIntervention bool `json:"manual_intervention"`
SeverityCounts struct {
Critical int `json:"critical"`
High int `json:"high"`
Info int `json:"info"`
Low int `json:"low"`
Medium int `json:"medium"`
} `json:"severity_counts"`
TargetID string `json:"target_id"`
Threat int `json:"threat"`
Type any `json:"type"`
Verification any `json:"verification"`
} `json:"targets"`
Pagination struct {
Count int `json:"count"`
CursorHash string `json:"cursor_hash"`
Cursors []any `json:"cursors"`
Sort any `json:"sort"`
} `json:"pagination"`
}
Click to show internal directories.
Click to hide internal directories.