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: 0 additions & 1 deletion cmd/cdk/cdk.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion conf/build_conf.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion conf/evaluate_conf.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
2 changes: 0 additions & 2 deletions conf/exploit_conf.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down Expand Up @@ -55,4 +54,3 @@ var K8sSATokenDefaultPath = "/var/run/secrets/kubernetes.io/serviceaccount/token
var WebShellCodeJSP = "<%Runtime.getRuntime().exec(request.getParameter(\"$SECRET_PARAM\"));%>"

var WebShellCodePHP = "<?php @eval($_POST['$SECRET_PARAM']);?>"

1 change: 0 additions & 1 deletion conf/message.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion conf/scanner_conf.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
22 changes: 10 additions & 12 deletions pkg/cli/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ import (
)

type testArgsCase struct {
name string
args []string
name string
args []string
successStr string
}

func doParseCDKMainWithTimeout() {

result := make(chan bool, 1)

go func () {
go func() {
result <- cli.ParseCDKMain()
}()

Expand All @@ -47,32 +47,31 @@ func doParseCDKMainWithTimeout() {
log.Println("check run ok, timeout in 2s, and return.")
return
case <-result:
return
return
}

}

func TestParseCDKMain(t *testing.T) {


// ./cdk eva 2>&1 | head
// ./cdk run test-poc | head
// ./cdk ifconfig | head

tests := []testArgsCase{
{
name: "./cdk eva",
args: []string{"./cdk_cli_path", "eva"},
name: "./cdk eva",
args: []string{"./cdk_cli_path", "eva"},
successStr: "current user",
},
{
name: "./cdk run test-poc",
args: []string{"./cdk_cli_path", "run", "test-poc"},
name: "./cdk run test-poc",
args: []string{"./cdk_cli_path", "run", "test-poc"},
successStr: "run success",
},
{
name: "./cdk ifconfig",
args: []string{"./cdk_cli_path", "ifconfig"},
name: "./cdk ifconfig",
args: []string{"./cdk_cli_path", "ifconfig"},
successStr: "GetLocalAddresses",
},
}
Expand Down Expand Up @@ -112,7 +111,6 @@ func TestParseCDKMain(t *testing.T) {
t.Errorf(("parse cdk main failed, name: %s, args: %v, buf: %s"), tt.name, tt.args, str)
}


})

// return to os.Stdout default
Expand Down
1 change: 0 additions & 1 deletion pkg/errors/errors.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion pkg/evaluate/available_linux_capabilities.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion pkg/evaluate/available_linux_commands.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion pkg/evaluate/cgroups.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
4 changes: 1 addition & 3 deletions pkg/evaluate/check_mount_escape.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func checkClose(c io.Closer) {
}
}


func MountEscape() {

mounts, _ := util.GetMountInfo()
Expand All @@ -48,7 +47,6 @@ func MountEscape() {
continue
}


// ? why match those mount points?
if strings.Contains(m.Device, "/") || strings.Contains(m.Fstype, "ext") {
matched, _ := regexp.MatchString("/kubelet/|/dev/[\\w-]*?\\blog$|/etc/host[\\w]*?$|/etc/[\\w]*?\\.conf$", m.Root)
Expand All @@ -59,7 +57,7 @@ func MountEscape() {
}

// find lxcfs mount point for escape exploit
if m.Device == "lxcfs" && util.StringContains(m.Opts, "rw"){
if m.Device == "lxcfs" && util.StringContains(m.Opts, "rw") {
fmt.Printf("Find mounted lxcfs with rw flags, run `%s` or `%s` to escape container!\n", util.RedBold.Sprint("cdk run lxcfs-rw"), util.RedBold.Sprint("cdk run lxcfs-rw-cgroup"))
m.Device = util.RedBold.Sprint(m.Device)
m.MountPoint = util.RedBold.Sprint(m.Device)
Expand Down
1 change: 0 additions & 1 deletion pkg/evaluate/cloud_metadata_api.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
2 changes: 1 addition & 1 deletion pkg/evaluate/evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ limitations under the License.
package evaluate

import (
"github.com/cdk-team/CDK/pkg/util"
"github.com/cdk-team/CDK/conf"
"github.com/cdk-team/CDK/pkg/util"
)

// CallBasics is a function to call basic functions
Expand Down
1 change: 0 additions & 1 deletion pkg/evaluate/k8s_anonymous_login.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion pkg/evaluate/k8s_service_account.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
4 changes: 2 additions & 2 deletions pkg/evaluate/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func kernelExploitSuggester() {
if err != nil {
return
}

// run command get output
util.PrintItemValueWithKeyOneLine("refer", "https://github.com/mzet-/linux-exploit-suggester", false)
output, err := exec.Command("bash", "-c", script).Output()
Expand Down Expand Up @@ -52,5 +52,5 @@ func kernelExploitSuggester() {
util.PrintOrignal(lines[i])
}
}

}
1 change: 0 additions & 1 deletion pkg/evaluate/security_info.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion pkg/evaluate/sensitive_env.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion pkg/evaluate/sensitive_local_file_path.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion pkg/evaluate/sensitive_service.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion pkg/evaluate/sysctl_vars.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
9 changes: 4 additions & 5 deletions pkg/evaluate/system_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ func FindSidFiles() {
if err != nil {
continue
}

for _, file := range files {
// check setuid bit
if file.Mode() & os.ModeSetuid != 0 {
setuidfiles = append(setuidfiles, dir + "/" + file.Name())
if file.Mode()&os.ModeSetuid != 0 {
setuidfiles = append(setuidfiles, dir+"/"+file.Name())
}

// check capabilites, like getcap -r /bin
Expand All @@ -94,7 +94,7 @@ func CommandAllow() {
}

func ASLR() {
// ASLR off: /proc/sys/kernel/randomize_va_space = 0
// ASLR off: /proc/sys/kernel/randomize_va_space = 0
var ASLRSetting = "/proc/sys/kernel/randomize_va_space"

data, err := ioutil.ReadFile(ASLRSetting)
Expand All @@ -111,4 +111,3 @@ func ASLR() {
}

}

1 change: 0 additions & 1 deletion pkg/exploit/exploit_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
2 changes: 0 additions & 2 deletions pkg/task/fix_build_null.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand All @@ -20,4 +19,3 @@ package task
// init: fix "build constraints exclude all Go files in /pkg/task"
func init() {
}

1 change: 0 additions & 1 deletion pkg/tool/dockerd_api/dockerd_api.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
2 changes: 0 additions & 2 deletions pkg/tool/kubectl/kcurl.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down Expand Up @@ -40,7 +39,6 @@ Example:
./cdk kcurl anonymous post 'https://192.168.0.234:6443/api/v1/nodes' '{"apiVersion":"v1",...}'
`


func KubectlToolApi(args []string) {

var opts = K8sRequestOption{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/tool/netcat/netcat.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build !thin && !no_netcat_tool
// +build !thin,!no_netcat_tool


/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
4 changes: 2 additions & 2 deletions pkg/tool/netcat/thin_code.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build thin || no_netcat_tool
// +build thin no_netcat_tool


/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand All @@ -24,4 +24,4 @@ import "github.com/cdk-team/CDK/conf"
func RunVendorNetcat() {
print(conf.ThinIgnoreTool)
return
}
}
1 change: 0 additions & 1 deletion pkg/tool/network/network.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion pkg/tool/probe/common.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion pkg/tool/probe/common_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
2 changes: 1 addition & 1 deletion pkg/tool/probe/thin_code.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build no_probe_tool
// +build no_probe_tool


/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion pkg/tool/ps/ps.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
4 changes: 2 additions & 2 deletions pkg/tool/vi/thin_code.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build thin || no_vi_tool
// +build thin no_vi_tool


/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand All @@ -24,4 +24,4 @@ import "github.com/cdk-team/CDK/conf"
func RunVendorVi() {
print(conf.ThinIgnoreTool)
return
}
}
2 changes: 1 addition & 1 deletion pkg/tool/vi/ven.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build !thin && !no_vi_tool
// +build !thin,!no_vi_tool


/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion pkg/util/capability/capability_define.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
3 changes: 1 addition & 2 deletions pkg/util/capability/capability_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand All @@ -24,7 +23,7 @@ import (
func TestCapHexParser(t *testing.T) {
var testcase = map[string]string{
"00000000a80425fb": "CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_SETGID,CAP_SETUID,CAP_SETPCAP,CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_SYS_CHROOT,CAP_MKNOD,CAP_AUDIT_WRITE,CAP_SETFCAP",
"00000000a80c25fb" : "CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_SETGID,CAP_SETUID,CAP_SETPCAP,CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_SYS_CHROOT,CAP_SYS_PTRACE,CAP_MKNOD,CAP_AUDIT_WRITE,CAP_SETFCAP",
"00000000a80c25fb": "CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_SETGID,CAP_SETUID,CAP_SETPCAP,CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_SYS_CHROOT,CAP_SYS_PTRACE,CAP_MKNOD,CAP_AUDIT_WRITE,CAP_SETFCAP",
"00000000a82425fb": "CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_SETGID,CAP_SETUID,CAP_SETPCAP,CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_SYS_CHROOT,CAP_SYS_ADMIN,CAP_MKNOD,CAP_AUDIT_WRITE,CAP_SETFCAP",
}
for k, v := range testcase {
Expand Down
5 changes: 2 additions & 3 deletions pkg/util/common.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down Expand Up @@ -149,13 +148,13 @@ func IntContains(s []int, e int) bool {
func DistinctStrArr(s []string) []string {
distinctMap := make(map[string]bool)
var result []string

for _, item := range s {
if _, exists := distinctMap[item]; !exists {
distinctMap[item] = true
result = append(result, item)
}
}

return result
}
1 change: 0 additions & 1 deletion pkg/util/file_io.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
1 change: 0 additions & 1 deletion pkg/util/file_io_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
Copyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .

Expand Down
Loading