参数说明

    具体插件可注册的回调类型 type,以及回调参数 params 的样例如下。另外,所有检测点都可以使用 params.stack 参数,以获取当前堆栈信息。

    数据库查询

    1. type = sql
    2. params = {
    3. "server": "mysql / oracle / pgsql / mssql / sqlite",
    4. "query": "select * from users",
    5. }

    读取目录

    1. type = directory
    2. params = {
    3. "path": "/home/servers/tomcat/webapps/mywar/../../../../../../../../../etc/",
    4. "realpath": "/etc/",
    5. "stack": [
    6. "java.lang.ProcessBuilder.start",
    7. "sun.reflect.NativeMethodAccessorImpl.invoke0",
    8. "sun.reflect.NativeMethodAccessorImpl.invoke",
    9. "sun.reflect.DelegatingMethodAccessorImpl.invoke",
    10. ...
    11. ]
    12. }

    请求参数

    当应用接受到请求时,插件可以对请求进行拦截。(注意: PHP Agent 1.1 开始才支持)

    1. type = request
    2. params = {}

    这里不会传递任何参数,如果需要获取请求相关信息,请使用 API接口

    读取文件

    注意:

    1. type = readFile
    2. params = {
    3. "path": "/home/servers/tomcat/webapps/mywar/../../../../../../../../../etc/hosts",
    4. "realpath": "/etc/hosts"
    5. }

    写入文件

    出于性能考虑,OpenRASP 目前只会提供文件名和绝对路径两个参数

    注意:

    1. tomcat 等应用服务器,在部署war包时,暂时不会触发这个回调
    2. 对于NTFS数据流,e.g abc.php::$DATA,插件看到的 path 可能是 abc.php::$DATArealpath 可能是 c:\inetpub\wwwroot\abc.php
    1. type = writeFile
    2. params = {
    3. "path": "abc.jsp",
    4. "realpath": "/home/tomcat/webapps/ROOT/abc.jsp",
    5. "stack": [
    6. ...
    7. ]
    8. }

    删除文件

    文件包含操作

    支持的文件包含方式如下,

    1. Java - JSTL import 方式
      • 只有 url 里出现了 :// 且不为 开头时,我们才会调用插件
    2. PHP - include/require/include_once/require_once 四种方式
      • url 里包含 :// 时,调用插件
      • 如果文件以 .php 或者 .inc 结尾,或者真实路径在 webroot 下面,不会进入插件
      • 其他情况进入插件

    具体参数

    1. # Java 示例
    2. type = include,
    3. params = {
    4. url: "file:///etc/passwd",
    5. function: "jstl_import",
    6. realpath: "/etc/passwd"
    7. }
    8. # PHP 示例
    9. type = include,
    10. params = {
    11. url: "/home/webroot/footer/../../../../../../../../../etc/passwd",
    12. function: "require_once",
    13. realpath: "/etc/passwd"
    14. }

    WebDAV 操作

    目前仅支持 MOVECOPY 两种方法

    1. type = webdav,
    2. params = {
    3. "source": "/home/rsync/apache-tomcat-7.0.78/webapps/webdav/1.txt",
    4. "dest": "/home/rsync/apache-tomcat-7.0.78/webapps/webdav/1.jsp"
    5. }

    文件上传

    目前,OpenRASP 支持 org.apache.commons.fileupload 上传组件(SpringMVC、Struts 底层使用)

    出于性能考虑,OpenRASP 只会提取文件前 4 KB 的内容,若要获取更多字节,请参考

    1. type = fileUpload
    2. params = {
    3. "name": "file",
    4. "filename": "a.jsp",
    5. "content": "<% ... %>",
    6. "dest_path": "upload/a.jpg", # v1.2 加入
    7. "dest_realpath": "/home/www/upload/a.jpg" # v1.2 加入
    8. }

    文件重命名

    当源是文件,且目标不为文件夹(可以不存在)时才会进入插件

    1. type = rename,
    2. params = {
    3. "source": "/var/www/html/uploads/hello.txt",
    4. "dest": "/var/www/html/uploads/hello.php"
    5. }

    命令执行

    1. type = command,
    2. params = {
    3. "stack": [
    4. "sun.reflect.NativeMethodAccessorImpl.invoke0",
    5. "sun.reflect.NativeMethodAccessorImpl.invoke",
    6. "sun.reflect.DelegatingMethodAccessorImpl.invoke",
    7. ...
    8. ]
    9. "command": "/bin/sh -c 'whoami; ls; '"
    10. }

    XML 外部实体引用

    Struts OGNL 表达式解析

    注意: 为了减少性能影响,仅当表达式长度超过 时才会调用插件。可手动 ognl.expression.minlength 选项来进行调整

    1. type = ognl
    2. params = {
    3. "expression": "_memberAccess" //ognl表达式
    4. }

    RMI 反序列化

    1. type = deserialization
    2. params = {
    3. "clazz": "InvokerTransformer" //被反序列化对象的类型
    4. }

    服务器端 HTTP 请求

    支持的请求方式包含如下 (对应 function 字段),

    1. JDK 中的 URL.openConnection 的方式 (url_open_connection)
    2. commons-httpclient 框架请求方式 (commons_http_client)
    3. httpclient 框架请求方式 (http_client)
    4. PHP stream 请求、cURL 请求
    1. type = ssrf
    2. params = {
    3. "url": "http://0x7f.0x0.0x0.0x1:8080/v1/api/get", // http 请求的 url
    4. "hostname": "0x7f.0x0.0x0.0x1" // http 请求的 hostname
    5. "ip": ["1.1.1.1", "2.2.2.2"] // 无法解析则为空;目前只解析 IPv4 地址
    6. "port": "8080", // 未提供端口为空。对于http模式是80,https默认是443的情况,如果没指定也是空
    7. "function": "commons_http_client"
    8. }

    服务器端 HTTP 请求 - 重定向之后

    支持的请求方式包含如下 (对应 function 字段),

    1. JDK 中的 URL.openConnection 的方式 (url_open_connection)
    2. httpclient 框架请求方式 (http_client)
    3. PHP stream 请求、cURL 请求
    1. type = ssrfRedirect
    2. params = {
    3. "url": "http://0x7f.0x0.0x0.0x1:8080/v1/api/get", // 原始请求的 URL
    4. "hostname": "0x7f.0x0.0x0.0x1" // 原始请求的域名
    5. "ip": ["1.1.1.1", "2.2.2.2"] // 原始请求目标 IP
    6. "port": "8080", // 原始请求的端口,未提供端口为空。对于http模式是80,https默认是443的情况,如果没指定也是空
    7. "url2": "http://127.0.0.1:8080/v1/api/get", // 重定向后的 URL
    8. "hostname2": "0x7f.0x0.0x0.0x1" // 重定向后的域名
    9. "ip2": ["1.1.1.1", "2.2.2.2"] // 重定向后目标 IP
    10. "port2": "8080", // 重定向后的端口,说明同上
    11. "function": "commons_http_client"
    12. }

    代码执行

    目前支持 eval/function 两种函数

    1. type = eval
    2. params = {
    3. "function": "eval",
    4. "code": "gzuncompress(base64_decode(...));"
    5. "stack": [
    6. ...
    7. ]
    8. }

    类库加载

    目前仅支持 java System.load() 方式

    响应检查

    说明

    1. Java 下面如果 body 过大,会多次分段调用
    2. 当响应类型包含 imageaudiovideo 字样,不会进入插件
    3. 该检测点不支持拦截
    1. type = response
    2. params = {
    3. "content_type": "text/html",
    4. }