首页 > 其他分享 >容器化部署GVM扫漏系统

容器化部署GVM扫漏系统

时间:2024-04-13 13:34:08浏览次数:23  
标签:24 容器 greenbone gvm vol GVM 扫漏 hours data

官网

https://greenbone.github.io/docs/latest/index.html

docker版本

快速安装docker

目前的docker已经自带了docker compose工具,所以无需单独安装

$ docker version
Client: Docker Engine - Community
 Version:           26.0.0
 API version:       1.45
 Go version:        go1.21.8
 Git commit:        2ae903e
 Built:             Wed Mar 20 15:17:48 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          26.0.0
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.8
  Git commit:       8b79278
  Built:            Wed Mar 20 15:17:48 2024
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

$ docker compose version
Docker Compose version v2.25.0

注意:因为还需要对ipv6地址的主机扫描,所以还需要让docker支持ipv6的功能
可以参考之前的博客 如何让docker支持IPv6

部署

参考

Greenbone 社区容器 - Greenbone 社区文档

docker compose资源清单文件

services:
  vulnerability-tests:
    image: greenbone/vulnerability-tests
    networks:
      - gvm-net
    environment:
      STORAGE_PATH: /var/lib/openvas/22.04/vt-data/nasl
    volumes:
      - vt_data_vol:/mnt

  notus-data:
    image: greenbone/notus-data
    networks:
      - gvm-net
    volumes:
      - notus_data_vol:/mnt

  scap-data:
    image: greenbone/scap-data
    networks:
      - gvm-net
    volumes:
      - scap_data_vol:/mnt

  cert-bund-data:
    image: greenbone/cert-bund-data
    networks:
      - gvm-net
    volumes:
      - cert_data_vol:/mnt

  dfn-cert-data:
    image: greenbone/dfn-cert-data
    networks:
      - gvm-net
    volumes:
      - cert_data_vol:/mnt
    depends_on:
      - cert-bund-data

  data-objects:
    image: greenbone/data-objects
    networks:
      - gvm-net
    volumes:
      - data_objects_vol:/mnt

  report-formats:
    image: greenbone/report-formats
    networks:
      - gvm-net
    volumes:
      - data_objects_vol:/mnt
    depends_on:
      - data-objects

  gpg-data:
    image: greenbone/gpg-data
    networks:
      - gvm-net
    volumes:
      - gpg_data_vol:/mnt

  redis-server:
    image: greenbone/redis-server
    restart: on-failure
    networks:
      - gvm-net
    volumes:
      - redis_socket_vol:/run/redis/

  pg-gvm:
    image: greenbone/pg-gvm:stable
    restart: on-failure
    networks:
      - gvm-net
    volumes:
      - psql_data_vol:/var/lib/postgresql
      - psql_socket_vol:/var/run/postgresql

  gvmd:
    image: greenbone/gvmd:stable
    restart: on-failure
    networks:
      - gvm-net
    volumes:
      - gvmd_data_vol:/var/lib/gvm
      - scap_data_vol:/var/lib/gvm/scap-data/
      - cert_data_vol:/var/lib/gvm/cert-data
      - data_objects_vol:/var/lib/gvm/data-objects/gvmd
      - vt_data_vol:/var/lib/openvas/plugins
      - psql_data_vol:/var/lib/postgresql
      - gvmd_socket_vol:/run/gvmd
      - ospd_openvas_socket_vol:/run/ospd
      - psql_socket_vol:/var/run/postgresql
    depends_on:
      pg-gvm:
        condition: service_started
      scap-data:
        condition: service_completed_successfully
      cert-bund-data:
        condition: service_completed_successfully
      dfn-cert-data:
        condition: service_completed_successfully
      data-objects:
        condition: service_completed_successfully
      report-formats:
        condition: service_completed_successfully

  gsa:
    image: greenbone/gsa:stable
    restart: on-failure
    ports:
      - 127.0.0.1:9392:80
    networks:
      - gvm-net
    volumes:
      - gvmd_socket_vol:/run/gvmd
    depends_on:
      - gvmd

  ospd-openvas:
    image: greenbone/ospd-openvas:stable
    restart: on-failure
    hostname: ospd-openvas.local
    cap_add:
      - NET_ADMIN # for capturing packages in promiscuous mode
      - NET_RAW # for raw sockets e.g. used for the boreas alive detection
    security_opt:
      - seccomp=unconfined
      - apparmor=unconfined
    networks:
      - gvm-net
    command:
      [
        "ospd-openvas",
        "-f",
        "--config",
        "/etc/gvm/ospd-openvas.conf",
        "--mqtt-broker-address",
        "mqtt-broker",
        "--notus-feed-dir",
        "/var/lib/notus/advisories",
        "-m",
        "666"
      ]
    volumes:
      - gpg_data_vol:/etc/openvas/gnupg
      - vt_data_vol:/var/lib/openvas/plugins
      - notus_data_vol:/var/lib/notus
      - ospd_openvas_socket_vol:/run/ospd
      - redis_socket_vol:/run/redis/
    depends_on:
      redis-server:
        condition: service_started
      gpg-data:
        condition: service_completed_successfully
      vulnerability-tests:
        condition: service_completed_successfully

  mqtt-broker:
    restart: on-failure
    image: greenbone/mqtt-broker
    networks:
      gvm-net:
        aliases:
          - mqtt-broker
          - broker

  notus-scanner:
    restart: on-failure
    image: greenbone/notus-scanner:stable
    volumes:
      - notus_data_vol:/var/lib/notus
      - gpg_data_vol:/etc/openvas/gnupg
    networks:
      gvm-net:
        aliases:
          - mqtt-broker
          - broker
    environment:
      NOTUS_SCANNER_MQTT_BROKER_ADDRESS: mqtt-broker
      NOTUS_SCANNER_PRODUCTS_DIRECTORY: /var/lib/notus/products
    depends_on:
      - mqtt-broker
      - gpg-data
      - vulnerability-tests

  gvm-tools:
    image: greenbone/gvm-tools
    networks:
      - gvm-net
    volumes:
      - gvmd_socket_vol:/run/gvmd
      - ospd_openvas_socket_vol:/run/ospd
    depends_on:
      - gvmd
      - ospd-openvas
networks:
  gvm-net:
    driver: bridge
    enable_ipv6: true
    ipam:
      driver: default
      config:
        - subnet: 2001:1111:1111:1111::/64
          gateway: 2001:1111:1111:1111::1
volumes:
  gpg_data_vol:
  scap_data_vol:
  cert_data_vol:
  data_objects_vol:
  gvmd_data_vol:
  psql_data_vol:
  vt_data_vol:
  notus_data_vol:
  psql_socket_vol:
  gvmd_socket_vol:
  ospd_openvas_socket_vol:
  redis_socket_vol:

这里是原docker compose资源清单文件

curl -f -L https://greenbone.github.io/docs/latest/_static/docker-compose-22.4.yml -o docker-compose.yml

需要做一定的修改,可以直接用我上面贴的修改后的资源清单

运行资源清单

docker compose up -d

运行后,也无法直接开始扫漏,需要等一段时间,需要加载资源,短则几分钟,多则几小时

创建用户

docker compose exec -u gvmd gvmd gvmd --user=admin --new-password='<password>'

查看日志

docker compose logs -f

刚启动查看日志很重要,因为,需要看到标志性的日志出现,才表示可以正常提供服务了

可以参考这里

https://greenbone.github.io/docs/latest/22.4/source-build/index.html#vulnerability-tests-data

对应的服务输出了对应的日志,则表示初始化完成

查看容器

$ docker compose ps
NAME                  IMAGE                            COMMAND                  SERVICE         CREATED        STATUS        PORTS
gvm-gsa-1             greenbone/gsa:stable             "/usr/local/bin/entr…"   gsa             24 hours ago   Up 24 hours   127.0.0.1:9392->80/tcp
gvm-gvmd-1            greenbone/gvmd:stable            "/usr/local/bin/entr…"   gvmd            24 hours ago   Up 24 hours   
gvm-mqtt-broker-1     greenbone/mqtt-broker            "/bin/sh -c 'mosquit…"   mqtt-broker     24 hours ago   Up 24 hours   
gvm-notus-scanner-1   greenbone/notus-scanner:stable   "/usr/local/bin/entr…"   notus-scanner   24 hours ago   Up 24 hours   
gvm-ospd-openvas-1    greenbone/ospd-openvas:stable    "/usr/bin/tini -- /u…"   ospd-openvas    24 hours ago   Up 24 hours   
gvm-pg-gvm-1          greenbone/pg-gvm:stable          "/usr/local/bin/entr…"   pg-gvm          24 hours ago   Up 24 hours   
gvm-redis-server-1    greenbone/redis-server           "/bin/sh -c 'rm -f /…"   redis-server    24 hours ago   Up 24 hours 

看资源清单文件可以发现其实不止这些容器,还有其他容器

$ docker compose ps -a
NAME                        IMAGE                            COMMAND                  SERVICE               CREATED        STATUS                    PORTS
gvm-cert-bund-data-1        greenbone/cert-bund-data         "/bin/init.sh"           cert-bund-data        24 hours ago   Exited (0) 24 hours ago   
gvm-data-objects-1          greenbone/data-objects           "/bin/init.sh"           data-objects          24 hours ago   Exited (0) 24 hours ago   
gvm-dfn-cert-data-1         greenbone/dfn-cert-data          "/bin/init.sh"           dfn-cert-data         24 hours ago   Exited (0) 24 hours ago   
gvm-gpg-data-1              greenbone/gpg-data               "/bin/init.sh"           gpg-data              24 hours ago   Exited (0) 24 hours ago   
gvm-gsa-1                   greenbone/gsa:stable             "/usr/local/bin/entr…"   gsa                   24 hours ago   Up 24 hours               127.0.0.1:9392->80/tcp
gvm-gvm-tools-1             greenbone/gvm-tools              "/usr/local/bin/entr…"   gvm-tools             24 hours ago   Exited (0) 24 hours ago   
gvm-gvmd-1                  greenbone/gvmd:stable            "/usr/local/bin/entr…"   gvmd                  24 hours ago   Up 24 hours               
gvm-mqtt-broker-1           greenbone/mqtt-broker            "/bin/sh -c 'mosquit…"   mqtt-broker           24 hours ago   Up 24 hours               
gvm-notus-data-1            greenbone/notus-data             "/bin/init.sh"           notus-data            24 hours ago   Exited (0) 24 hours ago   
gvm-notus-scanner-1         greenbone/notus-scanner:stable   "/usr/local/bin/entr…"   notus-scanner         24 hours ago   Up 24 hours               
gvm-ospd-openvas-1          greenbone/ospd-openvas:stable    "/usr/bin/tini -- /u…"   ospd-openvas          24 hours ago   Up 24 hours               
gvm-pg-gvm-1                greenbone/pg-gvm:stable          "/usr/local/bin/entr…"   pg-gvm                24 hours ago   Up 24 hours               
gvm-redis-server-1          greenbone/redis-server           "/bin/sh -c 'rm -f /…"   redis-server          24 hours ago   Up 24 hours               
gvm-report-formats-1        greenbone/report-formats         "/bin/init.sh"           report-formats        24 hours ago   Exited (0) 24 hours ago   
gvm-scap-data-1             greenbone/scap-data              "/bin/init.sh"           scap-data             24 hours ago   Exited (0) 24 hours ago   
gvm-vulnerability-tests-1   greenbone/vulnerability-tests    "/bin/init.sh"           vulnerability-tests   24 hours ago   Exited (0) 24 hours ago  

很多容器是失败的,这个不用担心,只有上面的七个容器时提供服务的,剩下的都是用来初始化的,初始化完成,就会停止

配置https服务

安装nginx

$ apt install nginx

生成证书

cd /etc/nginx/
mkdir ssl
cd ssl

openssl req -new -newkey rsa:2048 -sha256 -nodes -out server.csr -keyout server.key -subj "/C=CN/ST=xxxx/L=xxxxx/O=xxxxx Inc./OU=Web Security/CN=xxx.com"
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt

配置nginx

$ vim /etc/nginx/sites-enabled/default
server {
    listen 80;
    server_name 192.168.140.73;
    return 301 https://$host$request_uri;
}

server {
	listen      443 ssl;
	server_name  192.168.140.73;
	charset utf-8;
	
	#证书 证书的位置 /etc/nginx/ssl
	ssl_certificate ssl/server.crt;
	ssl_certificate_key ssl/server.key;
	ssl_prefer_server_ciphers on;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4";
	ssl_session_cache shared:SSL:10m;
	#服务部分
	location / {
		proxy_pass http://127.0.0.1:9392; 
		proxy_set_header Host $host; 
		proxy_set_header X-Real-IP $remote_addr; 
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
                proxy_http_version 1.1;  
                proxy_set_header Upgrade $http_upgrade;  
                proxy_set_header Connection "upgrade"; 
		# 设置会话cookie
		proxy_cookie_path / "/; HTTPOnly; Secure; SameSite=Strict";
	}
	
	#错误部分
	error_page  404              /404.html;
	error_page   500 502 503 504  /50x.html;
	location = /50x.html {
            root   html;
    }
}

启动服务

systemctl restart nginx
systemctl enable nginx

就可以访问了

然后使用上面创建的用户名和密码登录

标签:24,容器,greenbone,gvm,vol,GVM,扫漏,hours,data
From: https://www.cnblogs.com/guangdelw/p/18132749

相关文章

  • CIG容器重量级 监控系统介绍: CAdvisor+InfluxDB+Granfana
       Docker重量级容器监控:CAdvisor+InfluxDB+Granfana查看docker宿主机的所有容器的cpu内存以及网络等数据:dockerstatus CAdivisor介绍-收集数据: InfluxDB--存储数据: Granfana可视化平台展示:  ......
  • docker network之 自定义网络(重点,多容器时都是使用这个)
    原来的默认使用bridge模式,创建好容器以后,2个容器使用ip地址去ping对方的ip是ok的,但是按照容器的服务名字取ping就失败: 我们知道容器在重启后,ip是可能变化的。所以那总不可能按照ip去访问吧,最好是按照服务名去访问,那怎么处理呢,请看下方:dockernetworklsdockernetworkcrea......
  • 修改docker容器内部的时区
    部署在docker内部的服务在查看日志的时候使用的时区可能是伦敦或者美国等时区,这很不方便我们查看程序,所以需要对内部时区进行修改,办法如下:通过 dockerexec-it你的容器名称/bin/bash进入容器然后执行 rm/etc/localtime删除原有的时区文件使用软连接命......
  • Docker创建运行Nacos容器
     1简单创建nacos,进入容器配置数据库#查看镜像dockersearchnacos#拉取镜像dockerpullnacos/nacos-server:v2.2.3#创建容器dockerrun-d--namenacos-p9007:8848-ePREFER_HOST_MODE=hostname-eMODE=standalonenacos/nacos-server:v2.2.3#进入容器dockerexec-it......
  • 自编概念补充容器启动流程
    1、初始化流程 ①:如果我想生成bean对象,那么就需要一个beanFactory工厂(DefaultListableBeanFactory);②:如果我想对加了特定注解(如 @Service、@Repository)的类进行读取转化成 BeanDefinition 对象(BeanDefinition 是Spring中极其重要的一个概念,它存储了bean对象的所有......
  • Qt 如何遍历序列容器(QVector|QMap|...)
    QT提供了两种风格的遍历器:Java和STL一、Java风格遍历器Java风格的遍历器是Qt首先推荐使用的形式。这种风格比起STL风格的遍历器更方便。方便的代价就是不如后者高效。Java风格的遍历器指向的是两个元素之间的位置,而不是指向元素本身。因此,它们可能会指向集合第一......
  • 不同虚拟机之间的docker容器互相访问
    虚拟机平台VMwareWrokStationPro16虚拟机环境Unbuntu22.04目标:在VM2中创建1个bridge虚拟网络,在VM2中,创建容器x,并能访问VM1中的容器,在两个虚拟机中创建birdge网络,虚拟机中的容器可以互相访问解决方案:使用overlay来实现不同虚拟机中的容器的互相访问在虚拟机1使用命令do......
  • 深入了解 Docker:革命性的容器化技术
    简介在当今软件开发和部署的世界中,Docker已经成为一种不可或缺的技术。它的出现极大地改变了软件交付和部署的方式。本文将带您深入了解Docker,从它的起源、历史发展,到它所能做的事情以及为什么它如此受欢迎。Docker的出现背景Docker的出现源于解决传统软件开发和部署过程......
  • 新建微服务工程并形成jar包,部署到docker容器
    流程:1.创建微服务使用springcloud  2.打jar包:  3.把jar包上传到linux服务器中。4.编写dockerfile文件vimdockerfiledockerfile文件内容: 5.构建镜像 dockerbuild-tzzyy_docker:1.6. 6.运行容器dockerrun-d-p6001:6001容器Id  7.访问测......
  • Docker安装Nginx容器
    安装Nginx#查找官方镜像dockersearchnginx#下载最新版Nginx镜像(其实此命令就等同于:dockerpullnginx:latest)dockerpullnginx#下载指定版本的Nginx镜像(xxx指具体版本号)dockerpullnginx:xxx#检查当前所有Docker下载的镜像dockerimages创建Nginx配置......