A-A+

docker 安装最新RASP 及 相关环境搭建

2020年04月16日 16:53 学习笔记 暂无评论 共6505字 (阅读2,939 views次)

【注意:此文章为博主原创文章!转载需注意,请带原文链接,至少也要是txt格式!】

首先要自己装好docker环境。这里只教全部的RASP docker环境的安装。

Docker安装MongoDB、ElasticSearch

安装RASP需要的管控后台,必须要安装MongoDB、ElasticSearch。既然全程Docker里面安装,那么就简单了。具体安装方法请查看:centos7 docker 安装最新 MongoDB、ElasticSearch

都安装完毕后记得开放端口例如:9200、27017

firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --zone=public --add-port=27017/tcp --permanent
firewall-cmd --zone=public --add-port=8086/tcp --permanent
firewall-cmd --reload

 

安装RASP管理后台(非docker下)

 

cd /opt
wget https://packages.baidu.com/app/openrasp/release/latest/rasp-cloud.tar.gz
tar -zxf rasp-cloud.tar.gz
####cd到解压好的目录
./rasp-cloud -d

####最后在浏览器打开 http://your-ip:8086,就看到启动成功了
####(用户名固定为 openrasp,初始密码为 admin@123)

 

至此,OPENRASP的管理后台就安装完毕了。

 

Docker安装最新apache、php环境

 

docker pull eboraas/apache-php
mkdir /opt/www/
docker run -p 80:80 -v /opt/www/:/var/www/html/ -d eboraas/apache-php

 

其实这步狠简单,直接拉下来别人搭建好的环境,这里是最新的apache与 php7.3

 

Docker安装最新版本openrasp

 

cd /opt/www
curl https://packages.baidu.com/app/openrasp/release/latest/rasp-php-linux.tar.bz2 -o rasp-php-linux.tar.bz2
tar -xvf rasp-php-linux.tar.bz2
wget https://raw.githubusercontent.com/baidu/openrasp/master/plugins/official/plugin.js

##以上的命令都是在主机中执行,下面的就要注意了,可能涉及docker内来回切换,不过都有标注。

到这里之后注意,需要先用浏览器登陆你的RASP管理后台。例如我的地址是http://192.xxx.xx.130:8086/
进入之后点击添加主机。然后会弹出界面,如下图:

openrasp docker

注意图中标注的,①、②、③ 先点击“添加主机”、然后点击“PHP服务器”,就会看到如图界面。
然后我们复制② 红框里面的内容。之后我们进入docker

docker exec -it  pensive_jang bash

###############################################
######注意下面的命令都是在docker容器中执行的######
###############################################

cd /var/www/html

#下面就执行你在控制台复制的命令。
###注意###下面的命令只是我个人的举例,你需要实际执行你自己复制的②红框里面的命令。

php install.php -d /opt/rasp --heartbeat 90 --app-id 45xxxd8 --app-secret nJh4aPxxNvs --backend-url http://192.xxx.xx.130:8086/

执行后你应该会看到如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
OpenRASP Installer for PHP servers - Copyright 2017-2019 Baidu Inc.
For more details visit: https://rasp.baidu.com/doc/install/software.html
 
[INFO]: openrasp.root_dir => /opt/rasp
[INFO]: openrasp.backend_url => http://192.xxx.xx.130:8086/
[INFO]: openrasp.app_id => 457e58af0xxxxx2dc3d8
[INFO]: openrasp.app_secret => nJh4axxxxxW1Nvs
[INFO]: openrasp.heartbeat_interval => 90
***********************************************************
 1. Check whether required PHP extensions are installed
***********************************************************
***********************************************************
 2. Installing OpenRASP PHP extension
***********************************************************
[INFO]: Successfully copied 'openrasp.so' to '/usr/lib/php/20180731'
***********************************************************
 3. Updating php.ini
***********************************************************
[INFO]: Successfully write openrasp config to '/etc/php/7.3/mods-available/z_openrasp.ini'
[INFO]: Detected symbol links of openrasp.ini:
apache2 =>/etc/php/7.3/apache2/conf.d/99-openrasp.ini
cli =>/etc/php/7.3/cli/conf.d/99-openrasp.ini
***********************************************************
 4. Initializing OpenRASP root folder (openrasp.root_dir)
***********************************************************
[INFO]: Successfully update openrasp config (openrasp.yml): /opt/rasp/conf/openrasp.yml
***********************************************************
 5. All javascript plugins will be removed since remote management is turned on
***********************************************************
***********************************************************
 6. Installation completed without errors, please restart PHP server to take effect.
***********************************************************

当你看到这个就表示你已经成功安装RASP了。下面还要再DOCKER中执行命令,重启apache

apachectl -k restart
cd /var/www/html
cp plugin.js /opt/rasp/plugins/plugin.js

#################################################################
######注意所有docker容器中的命令已结束,下面执行的是主机中的命令######
#################################################################

到这里,你的OPENRASP、RASP控制台、PHP环境等其它环境都已安装完毕。其实就已经完事了。
下一步你可以把测试程序放入网站目录了。

cd /opt/www
wget https://packages.baidu.com/app/openrasp/testcases/php-vulns.tar.gz
tar -xvf php-vulns.tar.gz

到这里就已经全部完成,你可以访问 http://192.xxx.xx.130/vulns 通过这个来测试你的RASP啦。
你的后台地址是:http://192.xxx.xx.130:8086/

 

 

 

 

 

++++++++++++++++++++++++++++++++++++++++++++++

#################################################################
######以上都做完了是不是特别高兴?是不是特别欣喜?是不是很爽?? ######
#################################################################

MD。。。累成狗全部都写完了。结果我发现官方有一个 一键的脚本。所有环境,最狠的是同时包含了rasp的灰盒扫描工具。。。
我fuck。。。。。。。

不墨迹。如下

提供了一整套的测试环境,包含 IAST 扫描器、OpenRASP 管理后台 以及 漏洞测试用例。如果你已经安装了docker-compose, 首先修改 vm.max_map_count (参考这篇文档])

sudo sysctl -w vm.max_map_count=262144
然后执行如下命令,即可启动环境:

git clone https://github.com/baidu-security/openrasp-iast.git
cd openrasp-iast/docker/iast-cloud
docker-compose up
之后,请按照顺序分别:

访问 http://127.0.0.1:18662/vulns/ 触发PHP测试用例
访问 http://127.0.0.1:18661/ IAST控制台启动扫描
访问 http://127.0.0.1:18660/ 云控后台(账号openrasp/admin@123),左上角选择IAST应用查看扫描结果

 

 

 
下方是docker compose的代码

version: '3.4'
services:
    apache-php7.2:
        build:
            context: ./images/apache-php7.2
            args: 
                - RASP_VERSION
        image: openrasp/iast-cloud/apache-php:7.2
        hostname: apache-php7.2
        depends_on:
            - rasp-cloud
        ports:
            - "18662:18662"
        volumes:
            - "./volumes/apache-php7.2/html:/var/www/html"
        tty: true

    tomcat-8.5:
        build:
            context: ./images/tomcat-8.5
            args: 
                - RASP_VERSION
        image: openrasp/iast-cloud/tomcat-8.5
        hostname: tomcat-8.5
        ports: 
            - "18663:18663"
        depends_on:
            - rasp-cloud
        tty: true

    mysql5.6:
        build:
            context: ./images/mysql5.6
        image: openrasp/iast-cloud/mysql:5.6
        hostname: mysql5.6
        tty: true

    rasp-cloud:
        build:
            context: ./images/rasp-cloud
            args: 
                - RASP_VERSION
        image: openrasp/iast-cloud/rasp-cloud
        hostname: rasp-cloud
        ports: 
            - "18660:8086"
        depends_on:
            - elasticsearch6.4.2
            - mongodb3.6
        tty: true

    elasticsearch6.4.2:
        build:
            context: ./images/elasticsearch6.4.2
        image: openrasp/iast-cloud/elasticsearch6.4.2
        ulimits: 
            nofile:
                soft: 131071
                hard: 131071
        hostname: elasticsearch6.4.2
        tty: true

    mongodb3.6:
        build:
            context: ./images/mongodb3.6
        image: openrasp/iast-cloud/mongodb3.6
        hostname: mongodb3.6
        tty: true

    openrasp-iast:
        build:
            context: ./images/openrasp-iast
        image: openrasp/iast-cloud/openrasp-iast
        hostname: openrasp-iast
        ports: 
            - "18661:18664"
        depends_on:
            - mysql5.6
            - rasp-cloud
            # - owasp-benchmark
            - apache-php7.2
        volumes:
            - "../../openrasp_iast:/root/openrasp-iast-code"
            - "./volumes/openrasp-iast/config/:/root/openrasp-iast/"
            - "./volumes/openrasp-iast/logs/:/root/openrasp-iast-logs/"
            - "./volumes/testfiles/:/testfiles"
        tty: true

    # owasp-benchmark:
    #     build:
    #         # network: host
    #         context: ./images/owasp-benchmark
    #         args: 
    #             - RASP_VERSION
    #     image: openrasp/iast-cloud/owasp-benchmark
    #     hostname: owasp-benchmark
    #     ports: 
    #         - "8443:8443"
    #     depends_on:
    #         - rasp-cloud
    #     volumes: 
    #         - "./volumes/testfiles/:/testfiles"
    #     tty: true

    webgoat:
        build:
            context: ./images/webgoat
            args: 
                - RASP_VERSION
        image: openrasp/iast-cloud/webgoat
        hostname: webgoat
        ports: 
            - "8444:8444"
        depends_on:
            - rasp-cloud
        tty: true

布施恩德可便相知重

微信扫一扫打赏

支付宝扫一扫打赏

×

给我留言