NC65 报表license校验工具类以及补丁下载

357 篇文章 103 订阅
该代码段展示了用于报表许可验证的工具类`BQLicenseUtil`和接口实现类`LicenseService`。`BQLicenseUtil`包含了不同产品的报表许可标志号,并提供了多种许可检查方法。`LicenseService`实现了报表数量是否超过许可的检查,考虑了开发环境和不同产品类型的许可限制,同时获取并计算了报表、透视表和仪表板的数量。
摘要由CSDN通过智能技术生成
package uap.itf.bq.license;

import nc.bs.framework.common.NCLocator;
import nc.bs.framework.common.RuntimeEnv;
import nc.pub.iufo.exception.UFOSrvException;

import com.ufida.iufo.pub.tools.AppDebug;

/**
 * 报表license校验工具
 * @author 
 *
 */
public class BQLicenseUtil {
	
	/**
	 * 报表平台中的自由报表产品license标志号
	 */
	public static final String REPORT_PRODUCT_OF_SYSTEM = "14130RPTM01";
	/**
	 * 商业分析平台中的自由报表产品license标志号
	 */
	public static final String REPORT_PRODUCT_OF_BQ = "05030RPTM01";
	
	/**
	 * 报表平台中的自由报表license校验(报表数量不允许与license相同)
	 * @return
	 */
	public static boolean checkLicense() {
		return checkLicense(REPORT_PRODUCT_OF_SYSTEM);
	}
	
	/**
	 * 报表平台中的自由报表license校验
	 * @param isAllowSame :报表数量是否允许与license相同(执行时允许数量与license相同,新增、导入、粘贴时不允许相同)
	 * @return
	 */
	public static boolean checkLicense(boolean isAllowSame) {
		return checkLicense(isAllowSame , REPORT_PRODUCT_OF_SYSTEM);
	}
	
	/**
	 * 报表license校验
	 * @param product :产品license标志号
	 * @return
	 */
	public static boolean checkLicense(String product) {
		return checkLicense(false , product);
	}
	
	/**
	 * 报表license校验
	 * @param product :产品license标志号
	 * @return
	 */
	public static boolean checkLicense(boolean isAllowSame , String product) {
		// 开发环境不走license校验
		if(RuntimeEnv.getInstance().isDevelopMode())
			return true ;
		try {
			ILicenseService srv = NCLocator.getInstance().lookup(
					ILicenseService.class);
			return srv.isReportCountLessThanLicense(isAllowSame , product);
//			return srv.isReportCountLessThanLicense(isAllowSame , product) || PrintCil.isTraining();
		} catch (UFOSrvException ex) {
			AppDebug.debug(ex);
		}
		AppDebug.debug(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
				"1413006_0", "01413006-1576")/* @res "报表数目已达到产品授权数" */);
		return false;
	}
}

package uap.itf.bq.license;

import com.ufida.iufo.pub.tools.AppDebug;

import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;
import nc.bs.framework.common.NCLocator;
import nc.itf.uap.IUAPQueryBS;
import nc.itf.uap.cil.ICilService;
import nc.pub.iufo.exception.UFOSrvException;
import nc.pub.iufo.processor.CountQryProcessor;
import nc.pub.smart.util.SmartUtilities;

public class LicenseService implements ILicenseService{

	/**
	 * 	/**
	 * 报表数量是否超过license
	 * @param isAllowSame:报表数量是否允许与licensee相同
	 * @param product:产品
	 * @return
	 * @throws UFOSrvException
	 */
	@Override
	public boolean isReportCountLessThanLicense(boolean isAllowSame,
			String product) throws UFOSrvException {
		int license = 0;
		ICilService cilSrv = (ICilService) NCLocator.getInstance().lookup(ICilService.class);
		if (cilSrv.isNCDEMO())
			license = 50;
		else
			license = cilSrv.getProductLicense(product);

		Integer count = 0 ;
		if (BQLicenseUtil.REPORT_PRODUCT_OF_SYSTEM.equals(product)) {
			count = getReportCount(product) + getPivotCount() + getDashboardCount();
		}else{
			count = getReportCount(product);
		}
		if (count <= license) {
			//如果允许报表数=license(比如报表执行过程中的license校验),则返回true
			if (!isAllowSame && count == license) {
				return false;
			}
			return true;
		} else {
			AppDebug.debug(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1413006_0", "01413006-1578", null,
					new String[] { Integer.valueOf(license).toString() })/*
																			* @res ""报表数目已达到产品授权数(授权数=
																			* " + license + ")""
																			*/);
			return false;
		}
	}
	
	/**
	 * 获得自定义自由报表数量
	 * @param reportType
	 * @return
	 * @throws UFOSrvException
	 */
	private Integer getReportCount(String reportType) throws UFOSrvException {
		String sql = "select count(id) from iufo_freereport ";
		if (BQLicenseUtil.REPORT_PRODUCT_OF_SYSTEM.equals(reportType)) {
			sql += " where pk_dir not in (select pk_dir from iufo_freerep_dir where sysInit = 'Y' or modulecode = 'hr' or modulecode = 'bq')";
		} else if(BQLicenseUtil.REPORT_PRODUCT_OF_BQ.equals(reportType)) {
			sql += "where pk_dir in (select pk_dir from iufo_freerep_dir where modulecode = 'bq')";
		}
		try {
			IUAPQueryBS querySrv = NCLocator.getInstance().lookup(IUAPQueryBS.class);

			Integer iCount = (Integer) querySrv.executeQuery(sql, new CountQryProcessor());
			return iCount;
		} catch (Exception ex) {
			AppDebug.debug(ex);
			throw new UFOSrvException();
		}
	}
	
	/**
	 * 获得自定义透视表数量
	 * @return
	 * @throws UFOSrvException
	 */
	private Integer getPivotCount() throws UFOSrvException{
		String sql = "select count(pk_def) from bi_pivot_def where sysInit is null or sysInit = 'N'";
		BaseDAO dao = new BaseDAO(SmartUtilities.getDefDsName());
		try {
			Integer iCount = (Integer) dao.executeQuery(sql, new CountQryProcessor());
			return iCount;
		} catch (DAOException e) {
			AppDebug.debug(e);
			throw new UFOSrvException();
		}
	}
	
	/**
	 * 获得自定义仪表板数量
	 * @return
	 * @throws UFOSrvException
	 */
	private Integer getDashboardCount() throws UFOSrvException{
		String sql = "select count(pk) from bi_dashboard_def where sysInit is null or sysInit = 'N'";
		BaseDAO dao = new BaseDAO(SmartUtilities.getDefDsName());
		try {
			Integer iCount = (Integer) dao.executeQuery(sql, new CountQryProcessor());
			return iCount;
		} catch (DAOException e) {
			AppDebug.debug(e);
			throw new UFOSrvException();
		}
	}

}

NC65_自定义报表超过license解除补丁.zip 补丁下载:
链接:https://pan.baidu.com/s/1YEtUXPDTzX7zpNwyB3Ov_Q
提取码:ls5v

用友 NC 是一款企业级管理软件,在近万家大中型企业使用。实现建模、开发、继承、运行、管理一体化的 IT 解决方案信息化平台,其代码实现逻辑上存在多处反序列化漏洞。   2020 年 6 月 4 日,有国内安全组织披露用友 NC 存在反序列化远程命令执行“0-Day”漏洞。经分析,漏洞真实存在,攻击者通过构造特定的 HTTP 请求,可以成功利用漏洞在目标服务器上执行任意命令,该漏洞风险极大,可能造成严重的信息泄露事件。鉴于漏洞利用的源代码已经公开,建议用户尽快修复此漏洞。   2、攻击原理   通过UClient打开用友NC,UClient本质为UBroswer,一个专用的用友NC浏览器嵌入了JAVA运行环境,以解决NC 6系列之前的版本中applet在不同设备上的应用问题。经过文件目录查看分析得知用友UClient安装后,会在用户目录下新建uclient文件夹,根据看到的NCLogin65.jar文件,结合java运行进程信息,分析得知是一些界面和登陆逻辑代码,nc_client_home则是NC应用依赖的其他一些代码和jar包,因此可以使用Luyten反编译工具查看NCLogin65.jar,通过简单运行NC应用,尝试进行用户登陆,使用wireshark抓包,查看app.log运行日志,发现大量serialize和deserialize,说明系统中应用了序列化方式来传送据。在LoginUI类中的login方法打断点,启动Idea进行跟踪调试,当跟踪到loginImple方法时,发现多处调用了NCLocator的lookup方法查找Service接口进行操作,通过跟踪发现,实际使用了RmiNCLocator类,RmiNCLocator类的lookup方法,这里的lookup,已初步判断出无需继续跟踪调试,可以直接通过jndi注入漏洞进行利用。   黑客就是通过构造特定的 HTTP 请求,成功利用漏洞可在目标服务器上执行任意命令,漏洞暂无安全补丁发布,属 0Day 等级,风险极大。黑客利用漏洞可完全控制服务器,获取服务器的敏感信息。   3、影响范围   用友NC全版本
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值