<%--
  Created by IntelliJ IDEA.
  User: zhangfeng
  Date: 2019/5/31
  Time: 13:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page
        import="weaver.filter.SecurityCheckList,weaver.general.Util,weaver.hrm.User,weaver.hrm.settings.ChgPasswdReminder,weaver.hrm.settings.RemindSettings,java.io.*,java.lang.reflect.InvocationTargetException" %>
<%@ page import="java.lang.reflect.Method" %>
<%@ page import="java.security.MessageDigest" %>
<%@ page import="java.util.*" %>
<%@ page import="java.util.jar.JarEntry" %>
<%@ page import="java.util.jar.JarFile" %>
<%@ page import="weaver.general.GCONST" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="xssutil" class="weaver.filter.XssUtil"></jsp:useBean>
<jsp:useBean id="csui" class="weaver.filter.msg.CheckSecurityUpdateInfo"></jsp:useBean>

<%
    User user = (User) session.getAttribute("weaver_user@bean");
    int UID = xssutil.getIntValue(""+xssutil.getRule().get("userID"),1);
    if (user == null || user.getUID()!=UID) {
        out.println("请使用管理员权限查看");
        return;
    }
%>

<html>
<title>一键巡检</title>
<body>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
    <thead>
    <th width="20%" style="text-align:center;">检查项</th>
    <th width="20%" style="text-align:center;">检查结果</th>
    <th width="60%" style="text-align:center;">详情及处置意见</th>
    </thead>
    <tbody>
    <%

        int type = Util.getIntValue(request.getParameter("type"), -1);
        int code = Util.getIntValue(request.getParameter("code"), -1);
        String nextLine = "<br/>";
        String pass = "<span style=\"color:green;text-align:center;\">检查通过</span>";
        String refuse = "<span style=\"color:red;text-align:center;\">检查不通过</span>";
        String check = "<span style=\"color:yellow;text-align:center;\">需要人工检查</span>";

        String checkStatusMsg = "";
        String checkMessage = "";
    %>
    <tr>

        <td style="text-align:center;">安全包版本检测</td>
        <%
            String ecversion = "";
            String cversion = "";
            String cversionTmp = "";
            rs.execute("select companyname,cversion from license");
            if (rs.next()) {
                cversion = rs.getString("cversion");
                cversionTmp = cversion;
                ecversion = "E" + cversion.substring(0, 1);
            }
            csui.getRemoteServerVersion();
            String newOANowVersion = csui.getNewversion();
            String currentVersion = csui.getVersion();

            String newRuleVersion = csui.getRuleNewVersion();
            String currentRuleVersion = csui.getRuleVersion();

            if (newOANowVersion != null && !"".equals(newOANowVersion.trim())) {
                if (csui.getNewversion().compareTo(csui.getVersion()) > 0) {
                    checkStatusMsg = refuse;
                    checkMessage += "当前OA版本为: " + ecversion + "</br> 当前补丁包版本: " + currentVersion + " 最新官网补丁包版本: " + newOANowVersion
                            + "</br>当前安全补丁版本过低请及时升级到最新版本";
                    if (csui.getRuleNewVersion().compareTo(csui.getRuleVersion()) > 0) {
                        checkMessage += "</br>当前规则库版本: " + currentRuleVersion + " 最新官网规则库版本: " + newRuleVersion + "</br>当前安全库版本过低请及时升级到最新版本";
                    } else {
                        checkMessage += "</br>当前规则库版本: " + currentRuleVersion + " 最新官网规则库版本: " + newRuleVersion + "</br>当前安全库版本已是最新版本";
                    }
                } else {
                    checkStatusMsg = pass;
                    checkMessage += "当前OA版本为: " + ecversion + "</br> 当前补丁包版本: " + currentVersion + " 最新官网补丁包版本: " + newOANowVersion
                            + "</br>当前安全补丁版本已是最新";
                    if (csui.getRuleNewVersion().compareTo(csui.getRuleVersion()) > 0) {
                        checkStatusMsg = refuse;
                        checkMessage += "</br>当前规则库版本: " + currentRuleVersion + " 最新官网规则库版本: " + newRuleVersion + "</br>当前安全库版本过低请及时升级到最新版本";
                    } else {
                        checkMessage += "</br>当前规则库版本: " + currentRuleVersion + " 最新官网规则库版本: " + newRuleVersion + "</br>当前安全库版本已是最新版本";
                    }
                }
            } else {
                checkStatusMsg = check;
                checkMessage += "当前OA版本为: " + ecversion + "</br> 当前补丁包版本: " + currentVersion + " 最新官网补丁包版本: " + newOANowVersion
                        + "</br>无法检测到官网补丁包版本,请人工确认." + "</br>当前规则库版本: "
                        + currentRuleVersion + " 最新官网规则库版本: " + newRuleVersion + "</br>无法检测到官网规则库版本,请人工确认";
            }

            checkMessage += "</br> 官网安全补丁包地址: https://www.weaver.com.cn/cs/securityDownload.html" +
                    "</br> 若存在当前安全补丁包已是最新安全补丁包且仍存在相关扫描不通过的情况，请重新手动更新官网的安全补丁包";


        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>

    </tr>
    <tr>
        <td style="text-align:center;">安全包生效性检测</td>
        <%
            if (xssutil.enableFirewall()) {
                checkStatusMsg = pass;
                checkMessage = "已开启安全包防护";
            } else {
                checkStatusMsg = refuse;
                checkMessage = "未开启安全包防护.请检查: " + nextLine +
                        "step1 " + nextLine +
                        "检查WEB-INF/web.xml文件,是否存在添加如下代码且未被 &lt;!-- 注释\n" + nextLine +
                        "&lt;filter&gt;\n" + nextLine +
                        "&lt;filter-name&gt;SecurityFilter&lt;/filter-name&gt;\n" + nextLine +
                        "&lt;filter-class&gt;weaver.filter.SecurityFilter&lt;/filter-class&gt;\n" + nextLine +
                        "&lt;/filter&gt;\n" + nextLine +
                        "&lt;filter-mapping&gt;\n" + nextLine +
                        "&lt;filter-name&gt;SecurityFilter&lt;/filter-name&gt;\n" + nextLine +
                        "&lt;url-pattern&gt;/*&lt;/url-pattern&gt;\n" + nextLine +
                        "&lt;/filter-mapping&gt;" + nextLine +
                        "如不存在请添加 完成之后重启" + nextLine +
                        ">>>>>>>>>>>>>>>若step1 未能解决你的问题>>>>>>>>>>>>>>>>>>>" + nextLine +
                        "step2 备份并删除 /ecology/WEB-INF/weaver_security_config.xml" + nextLine +
                        "之后重启（需要先更新最新安全包）" + nextLine +
                        ">>>>>>>>>>>>>>>若 step 1 与 step 2 都不能解决你的问题>>>>>>>>>>>>>>>>>>>>>>>>>>" + nextLine +
                        "请提交流程到泛微总部系统安全组";
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>

    </tr>

    <tr>
        <td style="text-align:center;">
            JDK版本检测
        </td>

        <%
            Properties props = System.getProperties();
            String jdkVersion = props.getProperty("java.version");
            String[] strarr = jdkVersion.split("[\\_\\.]");
            if (strarr[0] != null && Integer.parseInt(strarr[0].toString()) > 1) {
                checkStatusMsg = check;
                checkMessage = "无法确认的JDK版本,请人工校验";
            } else if (strarr[1] != null && Integer.parseInt(strarr[1].toString()) == 8) {
                if (Integer.parseInt(strarr[strarr.length - 1].toString()) >= 121) {
                    checkStatusMsg = pass;
                    checkMessage = "当前JDK版本为: " + jdkVersion + "</br> 当前JDK版本为可靠版本";
                } else {
                    checkStatusMsg = refuse;
                    checkMessage = "当前JDK版本为: " + jdkVersion + "</br> 当前JDK版本过低,推荐使用JDK8 121版本之后的版本";
                }
            } else if (strarr[1] != null && Integer.parseInt(strarr[1].toString()) == 7) {
                if (Integer.parseInt(strarr[strarr.length - 1].toString()) >= 131) {
                    checkStatusMsg = pass;
                    checkMessage = "当前JDK版本为: " + jdkVersion + "</br> 当前JDK版本为可靠版本";
                } else {
                    checkStatusMsg = refuse;
                    checkMessage = "当前JDK版本为: " + jdkVersion + "</br> 当前JDK版本过低,推荐使用JDK7 131版本之后的版本";
                }
            } else if (strarr[1] != null && Integer.parseInt(strarr[1].toString()) == 6) {
                if (Integer.parseInt(strarr[strarr.length - 1].toString()) >= 141) {
                    checkStatusMsg = pass;
                    checkMessage = "当前JDK版本为: " + jdkVersion + "</br> 当前JDK版本为可靠版本";
                } else {
                    checkStatusMsg = refuse;
                    checkMessage = "当前JDK版本为: " + jdkVersion + "</br> 当前JDK版本过低,推荐使用JDK6 141版本之后的版本";
                }
            } else {
                checkStatusMsg = check;
                checkMessage = "当前JDK版本为: " + jdkVersion + "</br> 过高或过低的JDK版本,需要进行进一步确认";
            }
        %>

        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>

    <%
        if (type != 1) {
    %>
    <tr>
        <td style="text-align:center;">检查是否包含webshell后门文件</td>

        <%
            List whiteList = new Vector();

            BufferedReader reader = null;
            try {
                reader = new BufferedReader(new FileReader((GCONST.getPropertyPath() + "weaver_jsp_white.properties")));
                String line = "";
                while ((line = reader.readLine()) != null) {
                    String path = line;
                    String path2 = "";
                    if (path.contains("/")) {
                        path = path.replaceAll("/", File.pathSeparator);
                    }
                    if (path.contains("\\")) {
                        path = path.replaceAll("\\\\", File.pathSeparator);
                    }
                    if (path.startsWith(File.pathSeparator)) {
                        path = path.substring(1);
                    }
                    if (path.startsWith("ecology")) {
                        path = path.substring(8);
                    }

                    if (!path.startsWith("ecology") && path.endsWith("jsp")) {
                        String pathTmp = ("_" + path.replaceAll(File.pathSeparator, File.pathSeparator + "_")).replaceAll("\\.", "__") + ".java";
                        path = "ecology" + File.pathSeparator + path;
                        path2 = "ecology" + File.pathSeparator + "WEB-INF" + File.pathSeparator + "work" + File.pathSeparator + "_jsp" + File.pathSeparator + pathTmp;
                    }
                    whiteList.add(path.toLowerCase());
                    whiteList.add(path2.toLowerCase());
                }
            } catch (Exception e) {
                out.println(e);
            } finally {
                if (reader != null) {
                    reader.close();
                }
            }
            List<String> exceptionFiles = getFiles(xssutil.getRootPath(),"0",whiteList);
            if (exceptionFiles.isEmpty()) {
                checkStatusMsg = pass;
                checkMessage = "未发现可疑项";
            } else {
                checkMessage = "疑似webshell的脚本文件如下:</br>";
                checkStatusMsg = refuse;
                for (String fileName : exceptionFiles) {
                    checkMessage += fileName + "</br>";
                    if(fileName.trim().endsWith("java")){
                        checkMessage += fileName.substring(0,fileName.indexOf("java")) + "class" + "</br>";
                    }
                }
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>
    <%}%>

    <tr>
        <td style="text-align:center;">检测弱密码</td>
        <%
            List<Map<String, String>> weakResources = new ArrayList<Map<String, String>>();
            List<Map<String, String>> weakResourcesManager = new ArrayList<Map<String, String>>();
            weaver.filter.XssUtil xssUtil = new weaver.filter.XssUtil();
            String pathname = xssUtil.getRootPath() + "WEB-INF/securityRule/weak.txt"; // 绝对路径或相对路径都可以，这里是绝对路径，写入文件时演示相对路径
            File filename = new File(pathname); // 要读取以上路径的input.txt文件
            InputStreamReader reader2 = new InputStreamReader(
                    new FileInputStream(filename)); // 建立一个输入流对象reader
            BufferedReader br = new BufferedReader(reader2); // 建立一个对象，它把文件内容转成计算机能读懂的语言
            Set<String> weakPsd = new HashSet<String>();
            Set<String> weakSet = new HashSet<String>();
            String line = br.readLine();
            weakPsd.add(Util.getEncrypt(""));
            weakSet.add("");

            while (line != null) {
                weakSet.add(line);
                line = Util.getEncrypt("".equals(line.trim()) ? "1" : line); // 一次读入一行数据
                weakPsd.add(line);
                line = br.readLine();
            }

            //manager账户数量不会太多

            /**
             * MD5加密账户弱密码校验策略
             */
            String sql_manager = "select id,password,loginid from hrmresourcemanager";
            rs.execute(sql_manager);

            while (rs.next()) {
                String password = rs.getString("password");
                if (!weakPsd.contains(password)) {
                    continue;
                }

                Map<String, String> data = new HashMap<String, String>();
                int id = rs.getInt("id");
                data.put("loginid", rs.getString("loginid"));
                weakResourcesManager.add(data);
            }

            String sql = "select id,password,loginid,lastname,lastlogindate,passwordlock,passwdchgdate from hrmresource where loginid is not null and status in (0,1,2,3)";
            rs.execute(sql);
            while (rs.next()) {

                String password = rs.getString("password");
                if (!weakPsd.contains(password)) {
                    continue;
                }

                Map<String, String> data = new HashMap<String, String>();
                data.put("loginid", rs.getString("loginid"));
                weakResources.add(data);

            }
            /**
             * SM3 加密 弱密码用户列表
             */

            Class<?> threadClazz = null;
            Method encryptMethod = null;
            Object newInstance = null;
            try {
                threadClazz = Class.forName("weaver.sm.SM3Utils");
                newInstance = threadClazz.newInstance();
                encryptMethod = threadClazz.getMethod("getEncrypt", String.class, String.class);
            } catch (Exception e) {
            }
            if (threadClazz != null && newInstance != null && encryptMethod != null) {
                String sql_manager_sm3 = "select id,password,loginid,salt from hrmresourcemanager where salt is not null and length(salt) > 1";
                rs.execute(sql_manager_sm3);

                while (rs.next()) {

                    int id = rs.getInt("id");
                    String password = rs.getString("password");
                    String salt = rs.getString("salt");
                    if (salt.contains("sm3_new#")) {
                        salt = salt.split("sm3_new#")[1];
                    }

                    for (String s : weakSet) {
                        String encryptSM3pwd = null;
                        try {
                            encryptSM3pwd = (String) encryptMethod.invoke(newInstance, s, salt);
                        } catch (IllegalAccessException e) {
                            e.printStackTrace();
                        } catch (InvocationTargetException e) {
                            e.printStackTrace();
                        }
                        if (encryptSM3pwd != null && encryptSM3pwd.equals(password)) {
                            Map<String, String> data = new HashMap<String, String>();
                            data.put("loginid", rs.getString("loginid"));
                            weakResourcesManager.add(data);
                        }
                    }
                }
                String sql_sm3 = "select id,password,loginid,lastname,lastlogindate,passwordlock,passwdchgdate,salt from hrmresource where loginid is not null and salt is not null and length(salt) > 1 and status in (0,1,2,3)";
                rs.execute(sql_sm3);
                while (rs.next()) {

                    int id = rs.getInt("id");
                    String password = rs.getString("password");
                    String salt = rs.getString("salt");
                    if (salt.contains("sm3_new#")) {
                        salt = salt.split("sm3_new#")[1];
                    }
                    for (String s : weakSet) {
                        String encryptSM3pwd = null;
                        try {
                            encryptSM3pwd = (String) encryptMethod.invoke(newInstance, s, salt);
                        } catch (IllegalAccessException e) {
                            e.printStackTrace();
                        } catch (InvocationTargetException e) {
                            e.printStackTrace();
                        }
                        if (encryptSM3pwd != null && encryptSM3pwd.equals(password)) {
                            Map<String, String> data = new HashMap<String, String>();
                            data.put("loginid", rs.getString("loginid"));
                            weakResources.add(data);
                        }
                    }
                }
            }

            if (weakResources.size() > 0 || weakResourcesManager.size() > 0) {
                checkStatusMsg = refuse;
                checkMessage = "系统中存在" + (weakResources.size() + weakResourcesManager.size()) + "个弱密码用户,请及时处理. 访问/wui/weak.jsp 获取明细信息";
            } else {
                checkStatusMsg = pass;
                checkMessage = "无弱密码信息";
            }
            try {
                reader2.close();
                br.close();
            } catch (Exception e) {

            }

        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>
    <tr>
        <td style="text-align:center;">synccache.jsp 是否是安全版本</td>
        <%
            File file = new File(xssutil.getRootPath() + "synccache.jsp");
            BufferedReader reader1 = null;

            try {
                if (file.exists()) {
                    reader1 = new BufferedReader(new FileReader(file));
                    String tempString = null;
                    // 一次读入一行，直到读入null为文件结束
                    while ((tempString = reader1.readLine()) != null) {
                        // 显示行号
                        if (tempString.toLowerCase().contains("SerialKiller".toLowerCase())) {
                            checkStatusMsg = pass;
                            checkMessage = "为安全的synccache.jsp版本";
                            break;
                        } else {
                            checkStatusMsg = refuse;
                            checkMessage = "为不安全的synccache.jsp版本,请更新最新官网安全补丁包";
                        }
                    }
                } else {
                    checkStatusMsg = pass;
                    checkMessage = "非集群环境无该风险";
                }


            } catch (IOException e) {
                checkStatusMsg = check;
                checkMessage = "打开文件异常请人工检测";
            } finally {
                try {
                    reader1.close();
                } catch (Exception e) {

                }
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>
    <tr>
        <td style="text-align:center;">检测bsh补丁是否已经升级</td>
        <%
            file = new File(xssutil.getRootPath() + "/security/checkbsh.jsp");
            if (file.exists()) {
                checkStatusMsg = pass;
                checkMessage = "bsh补丁已经升级";
            } else {
                checkStatusMsg = refuse;
                checkMessage = "请及时去泛微安全官网升级你的bsh补丁";
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>
    <tr>
        <td style="text-align:center;">检测sql注入补丁是否已经升级</td>
        <%
            file = new File(xssutil.getRootPath() + "/security/checksql20191010.jsp");
            if (file.exists()) {
                checkStatusMsg = pass;
                checkMessage = "sql注入已经升级";
            } else {
                checkStatusMsg = refuse;
                checkMessage = "请及时去泛微安全官网升级你的sql注入补丁";
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>
    <tr>
        <td style="text-align:center;">检测反序列化补丁是否已经升级</td>
        <%
            file = new File(xssutil.getRootPath() + "checkSuc.jsp");
            if (file.exists()) {
                checkStatusMsg = pass;
                checkMessage = "反序列化补丁已经升级";
            } else {
                checkStatusMsg = refuse;
                checkMessage = "请及时去泛微安全官网升级你的反序列化补丁";
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>

    <tr>
        <td style="text-align:center;">验证码策略检测</td>
        <%
            ChgPasswdReminder reminder = new ChgPasswdReminder();
            RemindSettings settings = reminder.getRemindSettings();
            int needvalidate = settings.getNeedvalidate();
            String getopenpasswordlock = settings.getOpenPasswordLock();
            int checkValidate = 0;
            int checkPwdLock = 0;

            if (needvalidate == 1) {
                checkValidate = 1;
                checkStatusMsg = pass;
                checkMessage = "验证码已开启";
            }
            if (checkValidate == 0) {
                checkStatusMsg = refuse;
                checkMessage = "验证码未开启，请开启验证码校验功能";
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>
    <tr>
        <td style="text-align:center;">密码锁定策略检测</td>
        <%
            if ("1".equals(getopenpasswordlock)) {

                checkPwdLock = 1;
                checkStatusMsg = pass;
                checkMessage = "密码锁定策略已开启";
            }
            if (checkPwdLock == 0) {
                checkStatusMsg = refuse;
                checkMessage = "密码锁定策略未开启";
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>

    <tr>
        <td style="text-align:center;">是否开启accesslog</td>
        <%
            if (cversion.equals("E9")) {
                checkStatusMsg = pass;
                checkMessage = "已开启accesslog";
            } else {
                SecurityCheckList scl = new SecurityCheckList();
                if (scl.isEnableAccessLog() || ecversion.toLowerCase().equals("e9")) {
                    checkStatusMsg = pass;
                    checkMessage = "已开启accesslog";
                } else {
                    checkStatusMsg = refuse;
                    checkMessage = "未开启accesslog" + nextLine +
                            "resin2:\n" + nextLine +
                            "搜索ecology关键字,在&lt;app-dir&gt;下面添加访问日志,如下:\n" + nextLine +
                            "&lt;app-dir&gt;F:\\workspace\\ecology7\\&lt;/app-dir&gt;\n" + nextLine +
                            "&lt;access-log id='log/access.log'&gt;\n" + nextLine +
                            "&lt;rollover-period&gt;1D&lt;/rollover-period&gt;\n" + nextLine +
                            "&lt;/access-log&gt;\n" + nextLine +
                            "resin3:\n" + nextLine +
                            "搜索&lt;host-default&gt;关键字,在该节点下添加访问日志,如下:\n" + nextLine +
                            "&lt;host-default&gt;\n" + nextLine +
                            "&lt;access-log path=\"logs/access.log\" archive-format=\"access-%Y%m%d.log.gz\" format='%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"' rollover-period=\"1D\"&gt;\n" + nextLine +
                            "&lt;exclude&gt;\\.gif$&lt;/exclude&gt;\n" + nextLine +
                            "&lt;exclude&gt;\\.jpg$&lt;/exclude&gt;\n" + nextLine +
                            "&lt;exclude&gt;\\.png$&lt;/exclude&gt;\n" + nextLine +
                            "&lt;exclude&gt;\\.js$&lt;/exclude&gt;\n" + nextLine +
                            "&lt;exclude&gt;\\.css$&lt;/exclude&gt;\n" + nextLine +
                            "&lt;exclude&gt;\\.html$&lt;/exclude&gt;\n" + nextLine +
                            "&lt;exclude&gt;\\.htm$&lt;/exclude&gt;\n" + nextLine +
                            "&lt;exclude&gt;\\.swf$&lt;/exclude&gt;\n" + nextLine +
                            "&lt;exclude&gt;\\.cur$&lt;/exclude&gt;\n" + nextLine +
                            "&lt;/access-log&gt;\n" + nextLine +
                            "修改完成后请重启OA服务";
                }
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>
    <tr>
        <td style="text-align:center;">检测是否已开启Host防护</td>
        <%
            checkStatusMsg = refuse;
            checkMessage = "未开启 HSOT 防护,请及时开启" + nextLine +
                    "添加或者修改ecology/WEB-INF/weaver_security_config.xml" + nextLine +
                    "中的&lt;skip-host&gt;为false" + nextLine +
                    "&lt;skip-host&gt;false&lt;/skip-host&gt; " + nextLine +
                    "开启了该项功能后,需要配置服务器允许的所有访问方式,包括服务器内网地址、外网地址、域名、代理服务器地址到配置文件中,具体方法如下: " + nextLine +
                    "添加IP到指定列表的方式如下,修改ecology/WEB-INF/securityXML/weaver_security_custom_rules_1.xml文件,添加方式如下" + nextLine +
                    "例: " + nextLine +
                    "&lt;host-list&gt; " + nextLine +
                    "&lt;host&gt;test.genomics.cn&lt;/host&gt; " + nextLine +
                    "&lt;host&gt;test.genomics.cn:80&lt;/host&gt; " + nextLine +
                    "&lt;host&gt;18.15.16.13&lt;/host&gt; " + nextLine +
                    "&lt;host&gt;18.15.16.13:80&lt;/host&gt; " + nextLine +
                    "&lt;/host-list&gt; " + nextLine +
                    "其中 " + nextLine +
                    "&lt;host&gt;就是服务器允许的访问方式,包括内网地址、外网地址、域名、代理服务器地址,可以配置多个host节点; " + nextLine +
                    "若存在HOST 伪造的情况发生或无法确定自己当前环境的HOST信息\n" + nextLine +
                    "则在拦截发生后通过/WEB-INF/securitylog/systemSecurity+日期.log 检索  Host suspected forgery 关键字\n" + nextLine +
                    "将对应日志的host 字段值加入白名单 \n" + nextLine +
                    "重启OA验证" + nextLine +
                    ">>>>>>>>>>>>>>>>特别声明>>>>>>>>>>>>>>>>" + nextLine +
                    "开启host防护却未配置正确HOST白名单将会导致系统无法访问,请特别注意! " + nextLine +
                    "如出现异常及时联系总部解决";

            Object hostStatus = xssUtil.getRule().get("isSkipHost");
            if (!(Boolean) hostStatus) {
                checkStatusMsg = pass;
                checkMessage = "已开启host防护";
            }

        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>
    <tr>
        <td style="text-align:center;">检测是否已开启登陆加密</td>
        <%
            Integer vtmp = Integer.parseInt(cversionTmp.substring(0, 1));

            if (vtmp < 8 || (vtmp == 8 && Integer.parseInt(cversion.substring(cversion.length() - 6)) < 171100)) {
                checkStatusMsg = refuse;
                checkMessage = "当前系统不支持登陆加密功能请升级OA,或联系我们人力资源模块进行二次开发";
            } else {
                checkStatusMsg = refuse;
                checkMessage = "未开启登陆信息加密传输" + nextLine +
                        "RSA加密方案:" + nextLine +
                        "1).确认 ecology/WEB-INF/lib中存在 RSA-0.0.1-SNAPSHOT.jar ,存在则忽略" + nextLine +
                        "2).需在ecology/WEB-INF/web.xml中增加如下配置（检查是否存在,存在则忽略）:" + nextLine +
                        "&lt;servlet&gt;" + nextLine +
                        "&lt;servlet-name&gt;RsaInfo&lt;/servlet-name&gt;" + nextLine +
                        "&lt;servlet-class&gt;weaver.rsa.GetRsaInfo&lt;/servlet-class&gt;" + nextLine +
                        "&lt;/servlet&gt;" + nextLine +
                        "&lt;servlet-mapping&gt;" + nextLine +
                        "&lt;servlet-name&gt;RsaInfo&lt;/servlet-name&gt;" + nextLine +
                        "&lt;url-pattern&gt;/rsa/weaver.rsa.GetRsaInfo&lt;/url-pattern&gt;" + nextLine +
                        "&lt;/servlet-mapping&gt;" + nextLine +
                        "3)配置开启 在ecology\\WEB-INF\\prop\\openRSA.properties 配置" + nextLine +
                        "isrsaopen=1" + nextLine +
                        "4) 重启OA";
                file = new File(xssutil.getRootPath() + "/WEB-INF/prop/openRSA.properties");
                if (file.exists()) {

                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
                    String line1;

                    while ((line1 = bufferedReader.readLine()) != null) {
                        if (line1.contains("isrsaopen") && line1.contains("=") && line1.contains("1")) {
                            checkStatusMsg = pass;
                            checkMessage = "已开启登陆加密";
                            break;
                        }
                    }
                    try {
                        bufferedReader.close();
                    } catch (Exception e) {

                    }
                }
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>
    <tr>
        <td style="text-align:center;">检测是否已开404错误页面</td>
        <%
            SecurityCheckList scl = new SecurityCheckList();
            if (scl.is404PageConfig()) {
                checkStatusMsg = pass;
                checkMessage = "已配置404错误页面";
            } else {
                checkStatusMsg = refuse;
                checkMessage = "未配置404错误页面" + nextLine +
                        "在web.xml的的末尾&lt;/web-app&gt;上方添加如下代码即可\n" + nextLine +
                        "&lt;error-page&gt;\n" + nextLine +
                        "&lt;error-code&gt;404&lt;/error-code&gt;\n" + nextLine +
                        "&lt;location&gt;/errorpage/404.htm&lt;/location&gt;\n" + nextLine +
                        "&lt;/error-page&gt;\n" + nextLine +
                        "修改完成后请重启OA服务";
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>
    <tr>
        <td style="text-align:center;">检测是否已开500错误页面</td>
        <%
            if (scl.is500PageConfig()) {
                checkStatusMsg = pass;
                checkMessage = "已配置500错误页面";
            } else {
                checkStatusMsg = refuse;
                checkMessage = "未配置500错误页面" + nextLine +
                        "在web.xml的的末尾&lt;/web-app&gt;上方添加如下代码即可\n" + nextLine +
                        "&lt;error-page&gt;\n" + nextLine +
                        "&lt;error-code&gt;500&lt;/error-code&gt;\n" + nextLine +
                        "&lt;location&gt;/errorpage/500.htm&lt;/location&gt;\n" + nextLine +
                        "&lt;/error-page&gt;\n" + nextLine +
                        "修改完成后请重启OA服务";
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>
    <tr>
        <td style="text-align:center;">CommonCollection包版本检测</td>
        <%
            Integer checkJarStatus = 0;
            long jarVersion = 0l;

            String classPath = "/org/apache/commons/collections/CollectionUtils.class";
            String jarPath = this.getClass().getResource(classPath).getPath();

            try {
                jarVersion = getVersion(classPath);

                if (jarVersion >= 3002002000L) {
                    checkJarStatus = 1;
                    checkStatusMsg = pass;
                    checkMessage = "可靠的CommonCollection包版本";
                }

                if (checkJarStatus == 0) {
                    checkStatusMsg = refuse;
                    checkMessage = "当前的依赖路径为:" + jarPath.split("!")[0] + "</br> 请清理之后再手动更新官网最新安全补丁包 </br> " +
                            "ps:此处如果依赖路径中包含%[数字+字母]之类的乱码的情况证明该依赖中包含中文路径</br> 包含中文路径的依赖请直接删除";
                }
            } catch (Exception e) {
                checkStatusMsg = refuse;
                checkMessage = "当前的依赖路径为:" + jarPath.split("!")[0] + "</br> 请清理之后再手动更新官网最新安全补丁包 </br> " +
                        "ps:此处如果依赖路径中包含%[数字+字母]之类的乱码的情况证明该依赖中包含中文路径</br> 包含中文路径的依赖请直接删除";
            }

        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>

    <tr>
        <td style="text-align:center;">CommonFileUpload包版本检测</td>
        <%
            checkJarStatus = 0;
            classPath = "/org/apache/commons/fileupload/DiskFileUpload.class";
            jarPath = this.getClass().getResource(classPath).getPath();

            try {
                jarVersion = getVersion(classPath);

                if (jarVersion >= 1003003000L) {
                    checkJarStatus = 1;
                    checkStatusMsg = pass;
                    checkMessage = "可靠的CommonFileUpload包版本";
                }

                if (checkJarStatus == 0) {
                    checkStatusMsg = refuse;
                    checkMessage = "当前的依赖路径为:" + jarPath.split("!")[0] + "</br> 请清理之后再手动更新官网最新安全补丁包 </br> " +
                            "ps:此处如果依赖路径中包含%[数字+字母]之类的乱码的情况证明该依赖中包含中文路径</br> 包含中文路径的依赖请直接删除";
                }
            } catch (Exception e) {
                checkStatusMsg = refuse;
                checkMessage = "当前的依赖路径为:" + jarPath.split("!")[0] + "</br> 请清理之后再手动更新官网最新安全补丁包 </br> " +
                        "ps:此处如果依赖路径中包含%[数字+字母]之类的乱码的情况证明该依赖中包含中文路径</br> 包含中文路径的依赖请直接删除";
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>

    <tr>
        <td style="text-align:center;">XStream包版本检测</td>
        <%
            checkJarStatus = 0;
            classPath = "/com/thoughtworks/xstream/XStream.class";
            jarPath = this.getClass().getResource(classPath).getPath();

            try {
                jarVersion = getVersion(classPath);

                if (jarVersion >= 1004018000L) {
                    checkJarStatus = 1;
                    checkStatusMsg = pass;
                    checkMessage = "可靠的xstream包版本";
                }

                if (checkJarStatus == 0) {
                    checkStatusMsg = refuse;
                    checkMessage = "当前的依赖路径为:" + jarPath.split("!")[0] + "</br> 请清理之后再手动更新官网最新安全补丁包 </br> " +
                            "ps:此处如果依赖路径中包含%[数字+字母]之类的乱码的情况证明该依赖中包含中文路径</br> 包含中文路径的依赖请直接删除";
                }
            } catch (Exception e) {
                checkStatusMsg = refuse;
                checkMessage = "当前的依赖路径为:" + jarPath.split("!")[0] + "</br> 请清理之后再手动更新官网最新安全补丁包 </br> " +
                        "ps:此处如果依赖路径中包含%[数字+字母]之类的乱码的情况证明该依赖中包含中文路径</br> 包含中文路径的依赖请直接删除";
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>

    <tr>
        <td style="text-align:center;">FastJson包版本检测</td>
        <%
            checkJarStatus = 0;
            classPath = "/com/alibaba/fastjson/JSONObject.class";
            jarPath = this.getClass().getResource(classPath).getPath();
            String vPath = "META-INF/maven/com.alibaba/fastjson/pom.properties";
            String preStr = "version";
            String mark = "=";

            try {
                jarVersion = getSpecialJarVersion(classPath, vPath, preStr, mark);

                if (jarVersion >= 1002076000L) {
                    checkJarStatus = 1;
                    checkStatusMsg = pass;
                    checkMessage = "可靠的fastjson包版本";
                }

                if (checkJarStatus == 0) {
                    checkStatusMsg = refuse;
                    checkMessage = "当前的依赖路径为:" + jarPath.split("!")[0] + "</br> 请清理之后再手动更新官网最新安全补丁包 </br> " +
                            "ps:此处如果依赖路径中包含%[数字+字母]之类的乱码的情况证明该依赖中包含中文路径</br> 包含中文路径的依赖请直接删除";
                }
            } catch (Exception e) {
                checkStatusMsg = refuse;
                checkMessage = "当前的依赖路径为:" + jarPath.split("!")[0] + "</br> 请清理之后再手动更新官网最新安全补丁包 </br> " +
                        "ps:此处如果依赖路径中包含%[数字+字母]之类的乱码的情况证明该依赖中包含中文路径</br> 包含中文路径的依赖请直接删除";
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>

    <tr>
        <td style="text-align:center;">Jackson包版本检测</td>
        <%
            checkJarStatus = 0;
            classPath = "/com/fasterxml/jackson/databind/util/BeanUtil.class";
            jarPath = this.getClass().getResource(classPath).getPath();

            try {
                jarVersion = getVersion(classPath);
                if (jarVersion >= 2010005000L) {
                    checkJarStatus = 1;
                    checkStatusMsg = pass;
                    checkMessage = "可靠的Jackson包版本";
                }

                if (checkJarStatus == 0) {
                    checkStatusMsg = refuse;
                    checkMessage = "当前的依赖路径为:" + jarPath.split("!")[0] + "</br> 请清理之后再手动更新官网最新安全补丁包 </br> " +
                            "ps:此处如果依赖路径中包含%[数字+字母]之类的乱码的情况证明该依赖中包含中文路径</br> 包含中文路径的依赖请直接删除";
                }
            } catch (Exception e) {
                checkStatusMsg = refuse;
                checkMessage = "当前的依赖路径为:" + jarPath.split("!")[0] + "</br> 请清理之后再手动更新官网最新安全补丁包 </br> " +
                        "ps:此处如果依赖路径中包含%[数字+字母]之类的乱码的情况证明该依赖中包含中文路径</br> 包含中文路径的依赖请直接删除";
            }
        %>
        <td style="text-align:center;"><%=checkStatusMsg%>
        </td>
        <td><%=checkMessage%>
        </td>
    </tr>
    </tbody>
</table>

</body>
</html>

<%!
    private static final char[] DIGITS_LOWER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

    public char[] encodeHex(byte[] data, char... toDigits) {
        int l = data.length;
        char[] out = new char[l << 1];
        int i = 0;

        for (int var5 = 0; i < l; ++i) {
            out[var5++] = toDigits[(240 & data[i]) >>> 4];
            out[var5++] = toDigits[15 & data[i]];
        }

        return out;
    }

    public String md5Hex(String input) {
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.update(input.getBytes());
            byte[] md5bytes = digest.digest();
            return new String(encodeHex(md5bytes, DIGITS_LOWER));
        } catch (Throwable var4) {
            return null;
        }
    }

    final static String SPECIAL_CODE = "%@";


    private boolean fileWhiteListCheck(String path, List whiteList) {
        if (path == null || "".equals(path)) {
            return false;
        }

        path = path.substring(path.indexOf("ecology"));

        for (Object white : whiteList) {
            if (path.contains("/")) {
                path = path.replaceAll("/", File.pathSeparator);
            }
            if (path.contains("\\")) {
                path = path.replaceAll("\\\\", File.pathSeparator);
            }
            String whitePath = (String) white;
            if (path.toLowerCase().equals(whitePath)) {
                return true;
            }
        }

        return false;
    }


    public List getFiles(String filepath, String type, List whiteList) {
        List files = new Vector();
        listFiles(files, filepath, type, whiteList);
        return files;
    }

    public void listFiles(List files, String dirName, String type, List whiteList) {
        try {
            File dirFile = new File(dirName);
            if (!dirFile.exists() || (!dirFile.isDirectory())) {
            } else {
                File[] tmpfiles = dirFile.listFiles();
                for (int i = 0; i < tmpfiles.length; i++) {
                    File f = tmpfiles[i];
                    if (f.isFile()) {
                        if (f.getName().toLowerCase().contains(".jsp") || f.getName().toLowerCase().contains(".java")) {
                            if (checkFile(f, type, whiteList)) {
                                files.add(f.getAbsolutePath());
                            }
                        }
                    } else if (f.isDirectory()) {
                        if (!f.getPath().trim().endsWith("filesystem")) {
                            if (f.getPath().contains("WEB-INF")) {
                                if (f.getPath().trim().endsWith("WEB-INF") || f.getPath().trim().contains("WEB-INF" + File.separator + "work")) {
                                    listFiles(files, f.getAbsolutePath(), type, whiteList);
                                }
                            } else {
                                listFiles(files, f.getAbsolutePath(), type, whiteList);
                            }
                        }

                    }
                }
            }
        } catch (Exception e) {
        }
    }

    public static String getFileCharsetName(String fileName) throws IOException {
        InputStream inputStream = new FileInputStream(fileName);
        byte[] head = new byte[3];
        inputStream.read(head);

        String charsetName = "GBK";//或GB2312，即ANSI
        if (head[0] == -1 && head[1] == -2) //0xFFFE
            charsetName = "UTF-16";
        else if (head[0] == -2 && head[1] == -1) //0xFEFF
            charsetName = "Unicode";//包含两种编码格式：UCS2-Big-Endian和UCS2-Little-Endian
        else if (head[0] == -27 && head[1] == -101 && head[2] == -98)
            charsetName = "UTF-8"; //UTF-8(不含BOM)
        else if (head[0] == -17 && head[1] == -69 && head[2] == -65)
            charsetName = "UTF-8"; //UTF-8-BOM

        inputStream.close();
        //System.out.println(code);
        return charsetName;
    }

    public boolean checkCode(String code, String type) {
        if (code == null) return false;

        code = code.toLowerCase();
        if (code.contains("\\u0065") || code.contains("\\u0074")
                || code.contains("\\u0052") || code.contains("\\u006e") || code.contains("\\u0069") || code.contains("\\u006d")
                || code.contains("\\u0050") || code.contains("\\u0072") || code.contains("\\u006f") || code.contains("\\u0063") || code.contains("\\u0073")
                || code.contains("\\u0042") || code.contains("\\u006c") || code.contains("\\u0064") || code.contains("\\u0075")
                || code.contains("\\u0053") || code.contains("\\u006b") || code.contains("\\u0043") || code.contains("\\u0068") || code.contains("\\u0061")
                || code.contains("\\u0041") || code.contains("\\u0045") || code.contains("\\u0036") || code.contains("\\u0034") || code.contains("\\u002e")
                || code.contains("\\u0067") || code.contains("\\u004d") || code.contains("\\u0028") || code.contains("\\u0066") || code.contains("\\u004e")
                || code.contains("\\u003b")
        ) {
            return true;
        } else if (code.contains("getruntime")) {
            return true;
        } else if (code.contains("processbuilder")) {
            return true;
        } else if (code.contains("https://github.com/sensepost/regeorg")) {
            return true;
        } else if (code.contains("socketchannel")) {
            return true;
        } else if (code.contains("base64encoder") && "1".equals(type)) {
            return true;
        } else if (code.contains("base64decoder") && "1".equals(type)) {
            return true;
        } else if (code.contains("defineclass")) {
            return true;
        } else if (code.contains(".getmethod(") && "1".equals(type)) {
            return true;
        } else if (code.contains("@include") && !code.contains(".jsp\"")) {
            return true;
        } else {
            return false;
        }
    }

    private boolean checkFile(File file, String type, List whiteList) {
        if (fileWhiteListCheck(file.getPath(), whiteList)) {
            return false;
        } else {
            BufferedReader is = null;
            boolean isComment = false;
            String readline;
            try {
                is = new BufferedReader(new InputStreamReader(new FileInputStream(file), getFileCharsetName(file.getPath())));
                StringBuilder sb = null;
                while ((readline = is.readLine()) != null) {
                    sb = new StringBuilder();
                    sb.append(readline);
                    String tmp = readline.trim();

                    while (!tmp.trim().endsWith(">") && !tmp.trim().endsWith(";")) {
                        tmp = is.readLine();
                        if (tmp == null) break;
                        sb.append(tmp.trim());
                    }
                    if (sb.toString().contains(SPECIAL_CODE)) {
                        sb.toString().replaceAll("\\s+", "");
                    }
                    if (checkCode(sb.toString(), type)) {
                        return true;
                    }
                }
                return false;

            } catch (Exception e) {
            } finally {
                try {
                    is.close();
                } catch (Exception e) {
                }
            }
            return false;
        }
    }

    private long getVersion(String fileuploadPath) throws IOException {
        String path = this.getClass().getResource(fileuploadPath).getPath();
        if (path == null) {
            return -1;
        }

        Properties props = System.getProperties();
        String Osname = props.getProperty("os.name");
        weaver.filter.XssUtil util = new weaver.filter.XssUtil();
        File weblogicFile = new File(util.getRootPath() + "WEB-INF/weblogic.xml");
        if (!weblogicFile.exists()) {
            if (Osname.contains("Windows")) {
                path = path.substring("file:/".length(), path.indexOf("jar") + "jar".length());
            } else {
                path = path.substring("file:".length(), path.indexOf("jar") + "jar".length());
            }
        } else {
            path = path.substring(0,path.indexOf("jar") + "jar".length());
        }
        JarFile jarFileFileupload = new JarFile(path);
        long version = 0;
        Enumeration<JarEntry> enume = jarFileFileupload.entries();

        while (enume.hasMoreElements()) {
            JarEntry entry = enume.nextElement();
            if ("META-INF/MANIFEST.MF".equals(entry.getName())) {
                InputStream input = jarFileFileupload.getInputStream(entry);
                BufferedReader readerMF = new BufferedReader(new InputStreamReader(input));
                String line = readerMF.readLine();
                while (null != line) {
                    if (line.contains("Implementation-Version:")) {
                        String versionNow = line.substring(line.lastIndexOf("Implementation-Version:") + "Implementation-Version:".length());
                        long versionNowInt = 0;
                        String[] tmps = versionNow.trim().split("\\.");
                        if (1 == tmps.length) {

                            versionNowInt = Long.parseLong(tmps[0] + "000000000");
                        } else if (2 == tmps.length) {
                            int a = 3 - tmps[1].length();
                            while (0 < a) {
                                tmps[1] = "0" + tmps[1];
                                a--;
                            }
                            versionNowInt = Long.parseLong(tmps[0] + tmps[1] + "000000");
                        } else if (3 == tmps.length) {
                            int a = 3 - tmps[1].length();
                            while (0 < a) {
                                tmps[1] = "0" + tmps[1];
                                a--;
                            }

                            int c = 3 - tmps[2].length();
                            while (0 < c) {
                                tmps[2] = "0" + tmps[2];
                                c--;
                            }
                            versionNowInt = Long.parseLong(tmps[0] + tmps[1] + tmps[2] + "000");
                        } else if (4 == tmps.length) {

                            int a = 3 - tmps[1].length();
                            while (0 < a) {
                                tmps[1] = "0" + tmps[1];
                                a--;
                            }

                            int c = 3 - tmps[2].length();
                            while (0 < c) {
                                tmps[2] = "0" + tmps[2];
                                c--;
                            }

                            int d = 3 - tmps[3].length();
                            while (0 < d) {
                                tmps[3] = "0" + tmps[3];
                                d--;
                            }
                            versionNowInt = Long.parseLong(tmps[0] + tmps[1] + tmps[2] + tmps[3]);
                        }
                        return versionNowInt;
                    }
                    line = readerMF.readLine();
                }
                break;
            }
        }
        return 0;
    }

    private long getSpecialJarVersion(String fileuploadPath, String vPath, String preStr, String mark) throws IOException {
        String path = this.getClass().getResource(fileuploadPath).getPath();
        if (path == null) {
            return -1;
        }

        Properties props = System.getProperties();
        String Osname = props.getProperty("os.name");
        weaver.filter.XssUtil util = new weaver.filter.XssUtil();
        File weblogicFile = new File(util.getRootPath() + "WEB-INF/weblogic.xml");
        if (!weblogicFile.exists()) {
            if (Osname.contains("Windows")) {
                path = path.substring("file:/".length(), path.indexOf("jar") + "jar".length());
            } else {
                path = path.substring("file:".length(), path.indexOf("jar") + "jar".length());
            }
        } else {
            path = path.substring(0,path.indexOf("jar") + "jar".length());
        }
        JarFile jarFileFileupload = new JarFile(path);
        long version = 0;
        Enumeration<JarEntry> enume = jarFileFileupload.entries();

        while (enume.hasMoreElements()) {
            JarEntry entry = enume.nextElement();
            if (vPath.equals(entry.getName())) {
                InputStream input = jarFileFileupload.getInputStream(entry);
                BufferedReader readerMF = new BufferedReader(new InputStreamReader(input));
                String line = readerMF.readLine();
                while (null != line) {
                    if (line.contains(preStr)) {
                        String versionNow = line.split(mark)[1].trim();
                        long versionNowInt = 0;
                        String[] tmps = versionNow.trim().split("\\.");
                        if (1 == tmps.length) {

                            versionNowInt = Long.parseLong(tmps[0] + "000000000");
                        } else if (2 == tmps.length) {
                            int a = 3 - tmps[1].length();
                            while (0 < a) {
                                tmps[1] = "0" + tmps[1];
                                a--;
                            }
                            versionNowInt = Long.parseLong(tmps[0] + tmps[1] + "000000");
                        } else if (3 == tmps.length) {
                            int a = 3 - tmps[1].length();
                            while (0 < a) {
                                tmps[1] = "0" + tmps[1];
                                a--;
                            }

                            int c = 3 - tmps[2].length();
                            while (0 < c) {
                                tmps[2] = "0" + tmps[2];
                                c--;
                            }
                            versionNowInt = Long.parseLong(tmps[0] + tmps[1] + tmps[2] + "000");
                        } else if (4 == tmps.length) {

                            int a = 3 - tmps[1].length();
                            while (0 < a) {
                                tmps[1] = "0" + tmps[1];
                                a--;
                            }

                            int c = 3 - tmps[2].length();
                            while (0 < c) {
                                tmps[2] = "0" + tmps[2];
                                c--;
                            }

                            int d = 3 - tmps[3].length();
                            while (0 < d) {
                                tmps[3] = "0" + tmps[3];
                                d--;
                            }
                            versionNowInt = Long.parseLong(tmps[0] + tmps[1] + tmps[2] + tmps[3]);
                        }
                        return versionNowInt;
                    }
                    line = readerMF.readLine();
                }
                break;
            }
        }
        return 0;
    }

%>