Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ __debug_bin
/pkg/tool/kubectl/assets/

/cdk
.cache/
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ Exploit:
cdk run --list List all available exploits.
cdk run <exploit> [<args>...] Run single exploit, docs in https://github.com/cdk-team/CDK/wiki
Auto Escape:
cdk auto-escape <cmd> Escape container in different ways then let target execute <cmd>.
Tool:
vi <file> Edit files in container like "vi" command.
ps Show process information like "ps -ef" command.
Expand All @@ -91,6 +88,7 @@ Tool:
Options:
-h --help Show this help msg.
-v --version Show version.
--profile=<name> Select evaluation profile.
```

## Features
Expand All @@ -107,7 +105,6 @@ Usage
```
cdk evaluate [--full]
```
This command will run the scripts below without local file scanning, using `--full` to enable all.

|Tactics|Script|Supported|Usage/Example|
|---|---|---|---|
Expand Down Expand Up @@ -264,4 +261,3 @@ Project CDK is now included in 404Team [Starlink Project 2.0](https://github.com
### Kubernetes community Days 2021

- [https://community.cncf.io/events/details/cncf-kcd-china-presents-kubernetes-community-days-china/](https://community.cncf.io/events/details/cncf-kcd-china-presents-kubernetes-community-days-china/)

6 changes: 6 additions & 0 deletions conf/evaluate_conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ type cloudAPIS struct {
}

var CloudAPI = []cloudAPIS{
{
CloudProvider: "Volcano Engine (Volcengine)",
API: "http://100.96.0.96/latest",
ResponseMatch: "instance",
DocURL: "https://www.volcengine.com/docs/6396/113780",
},
{
CloudProvider: "Alibaba Cloud",
API: "http://100.100.100.200/latest/meta-data/",
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ Find tutorial, configuration and use-case in https://github.com/cdk-team/CDK/

var BannerContainerTpl = BannerHeader + `
%s
cdk eva
cdk eva --full
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The usage examples show 'cdk eva' and 'cdk eva --full' before 'cdk evaluate [--full]', but the new --profile flag is only documented in the Options section. Consider adding a usage example like 'cdk eva --profile=extended' to demonstrate the new feature.

Suggested change
cdk eva --full
cdk eva --full
cdk eva --profile=extended

Copilot uses AI. Check for mistakes.
cdk evaluate [--full]
cdk eva [--full]
cdk run (--list | <exploit> [<args>...])
cdk auto-escape <cmd>
cdk <tool> [<args>...]
%s
Expand All @@ -54,7 +54,6 @@ var BannerContainerTpl = BannerHeader + `
%s
cdk run --list List all available exploits.
cdk run <exploit> [<args>...] Run single exploit, docs in https://github.com/cdk-team/CDK/wiki
cdk auto-escape <cmd> Escape container in different ways then let target execute <cmd>.
%s
vi <file> Edit files in container like "vi" command.
Expand All @@ -70,6 +69,7 @@ var BannerContainerTpl = BannerHeader + `
%s
-h --help Show this help msg.
-v --version Show version.
--profile=<name> Select evaluation profile (basic, extended, additional).
`

// BannerContainer is the banner of CDK command line with colorful.
Expand Down
25 changes: 17 additions & 8 deletions pkg/cli/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ func ParseCDKMain() bool {
// docopt argparse start
parseDocopt()

if Args["auto-escape"].(bool) {
plugin.RunSingleTask("auto-escape")
return true
}
// delete auto-escape

// if Args["auto-escape"].(bool) {
// plugin.RunSingleTask("auto-escape")
// return true
// }

Comment on lines +64 to 68
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out code should be removed rather than left in the codebase. If the auto-escape feature is being deleted as the comment suggests, remove these lines entirely. If it's temporarily disabled for testing, add a TODO comment with context and a tracking issue.

Suggested change
// if Args["auto-escape"].(bool) {
// plugin.RunSingleTask("auto-escape")
// return true
// }

Copilot uses AI. Check for mistakes.
// support for cdk eva(Evangelion) and cdk evaluate
fok := Args["evaluate"]
Expand All @@ -73,10 +75,17 @@ func ParseCDKMain() bool {
if ok.(bool) || fok.(bool) {

fmt.Printf(BannerHeader)
evaluate.CallBasics()

if Args["--full"].(bool) {
evaluate.CallAddedFunc()
profileID := evaluate.ProfileBasic
if rawProfile, ok := Args["--profile"]; ok {
if v, ok := rawProfile.(string); ok && v != "" {
profileID = v
}
}
if profileID == evaluate.ProfileBasic && Args["--full"].(bool) {
profileID = evaluate.ProfileExtended
}
if err := evaluate.NewEvaluator().RunProfile(profileID, nil); err != nil {
log.Printf("evaluate profile %q failed: %v", profileID, err)
}
return true
}
Expand Down
11 changes: 9 additions & 2 deletions pkg/cli/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type testArgsCase struct {
successStr string
}

const parseTimeout = 5 * time.Second

func doParseCDKMainWithTimeout() {

result := make(chan bool, 1)
Expand All @@ -43,8 +45,8 @@ func doParseCDKMainWithTimeout() {
}()

select {
case <-time.After(time.Second * 2):
log.Println("check run ok, timeout in 2s, and return.")
case <-time.After(parseTimeout):
log.Printf("check run ok, timeout reached in %s, and return.", parseTimeout)
return
case <-result:
return
Expand All @@ -64,6 +66,11 @@ func TestParseCDKMain(t *testing.T) {
args: []string{"./cdk_cli_path", "eva"},
successStr: "current user",
},
// {
// name: "./cdk eva --profile=additional",
// args: []string{"./cdk_cli_path", "eva", "--profile=additional"},
// successStr: "randomize_va_space",
// },
Comment on lines +69 to +73
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out test case should either be enabled or removed. If this test is being temporarily disabled, add a comment explaining why and add a TODO or tracking issue to re-enable it.

Copilot uses AI. Check for mistakes.
{
name: "./cdk run test-poc",
args: []string{"./cdk_cli_path", "run", "test-poc"},
Expand Down
11 changes: 11 additions & 0 deletions pkg/evaluate/available_linux_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,14 @@ func getAddCaps(currentCaps []string) []string {
}
return addCaps
}

func init() {
RegisterSimpleCheck(
CategoryCommands,
"commands.capabilities",
"Inspect process capabilities",
func() {
GetProcCapabilities()
},
)
}
4 changes: 4 additions & 0 deletions pkg/evaluate/available_linux_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ func SearchAvailableCommands() {
}
log.Printf("available commands:\n\t%s\n", strings.Join(ans, ","))
}

func init() {
RegisterSimpleCheck(CategoryCommands, "commands.available", "Enumerate available commands", SearchAvailableCommands)
}
88 changes: 88 additions & 0 deletions pkg/evaluate/categories.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package evaluate

var (
CategorySystemInfo = CategorySpec{
ID: "information.system",
Title: "Information Gathering - System Info",
DefaultProfiles: []string{ProfileBasic, ProfileExtended},
Order: 100,
}
CategoryServices = CategorySpec{
ID: "information.services",
Title: "Information Gathering - Services",
DefaultProfiles: []string{ProfileBasic, ProfileExtended},
Order: 200,
}
CategoryCommands = CategorySpec{
ID: "information.commands",
Title: "Information Gathering - Commands and Capabilities",
DefaultProfiles: []string{ProfileBasic, ProfileExtended},
Order: 300,
}
CategoryMounts = CategorySpec{
ID: "information.mounts",
Title: "Information Gathering - Mounts",
DefaultProfiles: []string{ProfileBasic, ProfileExtended},
Order: 400,
}
CategoryNetNamespace = CategorySpec{
ID: "information.netns",
Title: "Information Gathering - Net Namespace",
DefaultProfiles: []string{ProfileBasic, ProfileExtended},
Order: 500,
}
CategorySysctl = CategorySpec{
ID: "information.sysctl",
Title: "Information Gathering - Sysctl Variables",
DefaultProfiles: []string{ProfileBasic, ProfileExtended},
Order: 600,
}
CategoryDNS = CategorySpec{
ID: "information.dns",
Title: "Information Gathering - DNS-Based Service Discovery",
DefaultProfiles: []string{ProfileBasic, ProfileExtended},
Order: 700,
}
CategoryK8sAPIServer = CategorySpec{
ID: "discovery.k8s_api",
Title: "Discovery - K8s API Server",
DefaultProfiles: []string{ProfileBasic, ProfileExtended},
Order: 800,
}
CategoryK8sServiceAccount = CategorySpec{
ID: "discovery.k8s_sa",
Title: "Discovery - K8s Service Account",
DefaultProfiles: []string{ProfileBasic, ProfileExtended},
Order: 900,
}
CategoryCloudMetadata = CategorySpec{
ID: "discovery.cloud_metadata",
Title: "Discovery - Cloud Provider Metadata API",
DefaultProfiles: []string{ProfileBasic, ProfileExtended},
Order: 1000,
}
CategoryKernel = CategorySpec{
ID: "exploit.kernel",
Title: "Exploit Pre - Kernel Exploits",
DefaultProfiles: []string{ProfileBasic, ProfileExtended},
Order: 1100,
}
CategorySensitiveFiles = CategorySpec{
ID: "information.sensitive_files",
Title: "Information Gathering - Sensitive Files",
DefaultProfiles: []string{ProfileExtended, ProfileAdditional},
Order: 1200,
}
CategoryASLR = CategorySpec{
ID: "information.aslr",
Title: "Information Gathering - ASLR",
DefaultProfiles: []string{ProfileExtended, ProfileAdditional},
Order: 1300,
}
CategoryCgroups = CategorySpec{
ID: "information.cgroups",
Title: "Information Gathering - Cgroups",
DefaultProfiles: []string{ProfileExtended, ProfileAdditional},
Order: 1400,
}
)
4 changes: 4 additions & 0 deletions pkg/evaluate/cgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ func DumpCgroup() {
}

}

func init() {
RegisterSimpleCheck(CategoryCgroups, "cgroups.dump", "Dump cgroup configuration", DumpCgroup)
}
4 changes: 4 additions & 0 deletions pkg/evaluate/check_mount_escape.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ func MountEscape() {

}
}

func init() {
RegisterSimpleCheck(CategoryMounts, "mounts.escape", "Inspect mount escape opportunities", MountEscape)
}
4 changes: 4 additions & 0 deletions pkg/evaluate/cloud_metadata_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ func CheckCloudMetadataAPI() {
}
}
}

func init() {
RegisterSimpleCheck(CategoryCloudMetadata, "cloud.metadata_api", "Probe cloud metadata API endpoints", CheckCloudMetadataAPI)
}
Loading