List of usage examples for org.objectweb.asm Opcodes ACONST_NULL
int ACONST_NULL
To view the source code for org.objectweb.asm Opcodes ACONST_NULL.
Click Source Link
From source file:scouter.agent.asm.asyncsupport.CallRunnableASM.java
License:Apache License
@Override public void visitMaxs(int maxStack, int maxLocals) { Label endFinally = new Label(); mv.visitTryCatchBlock(startFinally, endFinally, endFinally, null); mv.visitLabel(endFinally);// w ww . ja v a2s . c o m mv.visitInsn(DUP); int errIdx = newLocal(Type.getType(Throwable.class)); mv.visitVarInsn(Opcodes.ASTORE, errIdx); mv.visitInsn(Opcodes.ACONST_NULL);// return mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitVarInsn(Opcodes.ALOAD, errIdx); mv.visitMethodInsn(Opcodes.INVOKESTATIC, TARGET, END_METHOD, END_METHOD_DESC, false); mv.visitInsn(ATHROW); mv.visitMaxs(maxStack + 8, maxLocals + 2); }
From source file:scouter.agent.asm.HttpServiceASM.java
License:Apache License
@Override public void visitInsn(int opcode) { if ((opcode >= IRETURN && opcode <= RETURN)) { mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitInsn(Opcodes.ACONST_NULL); mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, END_METHOD, END_SIGNATURE, false); }/* w ww. j av a 2s.c om*/ mv.visitInsn(opcode); }
From source file:scouter.agent.asm.jdbc.PsExecuteMV.java
License:Apache License
@Override public void visitInsn(int opcode) { if ((opcode >= IRETURN && opcode <= RETURN)) { int lvPosReturn; switch (returnType.getSort()) { case Type.ARRAY: if (returnType.getElementType().getSort() == Type.INT) { lvPosReturn = newLocal(returnType); mv.visitVarInsn(Opcodes.ASTORE, lvPosReturn); mv.visitVarInsn(Opcodes.ALOAD, lvPosReturn); mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitInsn(Opcodes.ACONST_NULL); mv.visitVarInsn(Opcodes.ALOAD, lvPosReturn); mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, "getIntArraySum", "([I)I", false); } else { mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitInsn(Opcodes.ACONST_NULL); AsmUtil.PUSH(mv, -1);// ww w.j av a2 s.co m } break; case Type.BOOLEAN: case Type.INT: lvPosReturn = newLocal(returnType); mv.visitVarInsn(Opcodes.ISTORE, lvPosReturn); mv.visitVarInsn(Opcodes.ILOAD, lvPosReturn); mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitInsn(Opcodes.ACONST_NULL); mv.visitVarInsn(Opcodes.ILOAD, lvPosReturn); if (returnType.getSort() == Type.BOOLEAN) { mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, "toInt", "(Z)I", false); } break; default: mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitInsn(Opcodes.ACONST_NULL); AsmUtil.PUSH(mv, -1); } mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, END_METHOD, END_SIGNATURE, false); } mv.visitInsn(opcode); }
From source file:scouter.agent.asm.jdbc.StExecuteMV.java
License:Apache License
@Override public void visitInsn(int opcode) { if ((opcode >= IRETURN && opcode <= RETURN)) { int lvPosReturn; switch (returnType.getSort()) { case Type.ARRAY: if (returnType.getElementType().getSort() == Type.INT) { lvPosReturn = newLocal(returnType); mv.visitVarInsn(Opcodes.ASTORE, lvPosReturn); mv.visitVarInsn(Opcodes.ALOAD, lvPosReturn); mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitInsn(Opcodes.ACONST_NULL); mv.visitVarInsn(Opcodes.ALOAD, lvPosReturn); mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, "getIntArraySum", "([I)I", false); } else { mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitInsn(Opcodes.ACONST_NULL); AsmUtil.PUSH(mv, -1);/* w w w . j ava 2s . c om*/ } break; case Type.BOOLEAN: case Type.INT: int i = newLocal(returnType); mv.visitVarInsn(Opcodes.ISTORE, i); mv.visitVarInsn(Opcodes.ILOAD, i); mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitInsn(Opcodes.ACONST_NULL); mv.visitVarInsn(Opcodes.ILOAD, i); if (returnType.getSort() == Type.BOOLEAN) { mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, "toInt", "(Z)I", false); } break; default: mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitInsn(Opcodes.ACONST_NULL); AsmUtil.PUSH(mv, -1); } mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, END_METHOD, END_SIGNATURE, false); } mv.visitInsn(opcode); }
From source file:scouter.agent.asm.redis.JedisProtocolASM.java
License:Apache License
@Override public void visitInsn(int opcode) { if ((opcode >= IRETURN && opcode <= RETURN)) { mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitVarInsn(Opcodes.ALOAD, 2); mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitInsn(Opcodes.ACONST_NULL); mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, END_METHOD, END_SIGNATURE, false); }/* w w w. j a v a 2s .co m*/ mv.visitInsn(opcode); }
From source file:scouter.agent.asm.ServiceASM.java
License:Apache License
private void capReturn() { Type tp = returnType;//from w w w. j av a2s . com if (tp == null || tp.equals(Type.VOID_TYPE)) { mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitInsn(Opcodes.ACONST_NULL); mv.visitInsn(Opcodes.ACONST_NULL); mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, END_METHOD, END_SIGNATURE, false); return; } int i = newLocal(tp); switch (tp.getSort()) { case Type.BOOLEAN: mv.visitVarInsn(Opcodes.ISTORE, i); mv.visitVarInsn(Opcodes.ILOAD, i); mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat mv.visitVarInsn(Opcodes.ILOAD, i); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;", false); mv.visitInsn(Opcodes.ACONST_NULL);// throwable break; case Type.BYTE: mv.visitVarInsn(Opcodes.ISTORE, i); mv.visitVarInsn(Opcodes.ILOAD, i); mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat mv.visitVarInsn(Opcodes.ILOAD, i); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false); mv.visitInsn(Opcodes.ACONST_NULL);// throwable break; case Type.CHAR: mv.visitVarInsn(Opcodes.ISTORE, i); mv.visitVarInsn(Opcodes.ILOAD, i); mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat mv.visitVarInsn(Opcodes.ILOAD, i); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;", false); mv.visitInsn(Opcodes.ACONST_NULL);// throwable break; case Type.SHORT: mv.visitVarInsn(Opcodes.ISTORE, i); mv.visitVarInsn(Opcodes.ILOAD, i); mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat mv.visitVarInsn(Opcodes.ILOAD, i); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;", false); mv.visitInsn(Opcodes.ACONST_NULL);// throwable break; case Type.INT: mv.visitVarInsn(Opcodes.ISTORE, i); mv.visitVarInsn(Opcodes.ILOAD, i); mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat mv.visitVarInsn(Opcodes.ILOAD, i); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false); mv.visitInsn(Opcodes.ACONST_NULL);// throwable break; case Type.LONG: mv.visitVarInsn(Opcodes.LSTORE, i); mv.visitVarInsn(Opcodes.LLOAD, i); mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat mv.visitVarInsn(Opcodes.LLOAD, i); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false); mv.visitInsn(Opcodes.ACONST_NULL);// throwable break; case Type.FLOAT: mv.visitVarInsn(Opcodes.FSTORE, i); mv.visitVarInsn(Opcodes.FLOAD, i); mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat mv.visitVarInsn(Opcodes.FLOAD, i); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;", false); mv.visitInsn(Opcodes.ACONST_NULL);// throwable break; case Type.DOUBLE: mv.visitVarInsn(Opcodes.DSTORE, i); mv.visitVarInsn(Opcodes.DLOAD, i); mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat mv.visitVarInsn(Opcodes.DLOAD, i); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;", false); mv.visitInsn(Opcodes.ACONST_NULL);// throwable break; default: mv.visitVarInsn(Opcodes.ASTORE, i); mv.visitVarInsn(Opcodes.ALOAD, i); mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat mv.visitVarInsn(Opcodes.ALOAD, i);// return mv.visitInsn(Opcodes.ACONST_NULL);// throwable } mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, END_METHOD, END_SIGNATURE, false); }
From source file:scouter.agent.asm.ServiceASM.java
License:Apache License
@Override public void visitMaxs(int maxStack, int maxLocals) { Label endFinally = new Label(); mv.visitTryCatchBlock(startFinally, endFinally, endFinally, null); mv.visitLabel(endFinally);//from w ww.ja va2 s . co m mv.visitInsn(DUP); int errIdx = newLocal(Type.getType(Throwable.class)); mv.visitVarInsn(Opcodes.ASTORE, errIdx); mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitInsn(Opcodes.ACONST_NULL);// return mv.visitVarInsn(Opcodes.ALOAD, errIdx); mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, END_METHOD, END_SIGNATURE, false); mv.visitInsn(ATHROW); mv.visitMaxs(maxStack + 8, maxLocals + 2); }
From source file:scouter.agent.asm.SocketASM.java
License:Apache License
@Override public void visitInsn(int opcode) { if ((opcode >= IRETURN && opcode <= RETURN)) { mv.visitVarInsn(Opcodes.ALOAD, statIdx); mv.visitInsn(Opcodes.ACONST_NULL); mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEAPICALL, END_METHOD, END_SIGNATURE, false); }/*www . j a va 2 s .c o m*/ mv.visitInsn(opcode); }
From source file:serianalyzer.JVMImpl.java
License:Open Source License
/** * @param opcode//from w ww . jav a 2 s.co m * @param s */ static void handleJVMInsn(int opcode, JVMStackState s) { BaseType o1; BaseType o2; BaseType o3; List<BaseType> l1; List<BaseType> l2; switch (opcode) { case Opcodes.NOP: break; case Opcodes.ARRAYLENGTH: o1 = s.pop(); s.push(new BasicConstant(Type.INT_TYPE, 0, !(o1 != null && !o1.isTainted()))); break; case Opcodes.ACONST_NULL: s.push(new BasicConstant(Type.VOID_TYPE, "<null>")); //$NON-NLS-1$ break; case Opcodes.ICONST_M1: case Opcodes.ICONST_0: case Opcodes.ICONST_1: case Opcodes.ICONST_2: case Opcodes.ICONST_3: case Opcodes.ICONST_4: case Opcodes.ICONST_5: s.push(new BasicConstant(Type.INT_TYPE, opcode - 3)); break; case Opcodes.LCONST_0: case Opcodes.LCONST_1: s.push(new BasicConstant(Type.LONG_TYPE, opcode - 9L)); break; case Opcodes.FCONST_0: case Opcodes.FCONST_1: case Opcodes.FCONST_2: s.push(new BasicConstant(Type.FLOAT_TYPE, opcode - 11f)); break; case Opcodes.DCONST_0: case Opcodes.DCONST_1: s.push(new BasicConstant(Type.DOUBLE_TYPE, opcode - 14d)); break; case Opcodes.IALOAD: case Opcodes.LALOAD: case Opcodes.FALOAD: case Opcodes.DALOAD: case Opcodes.BALOAD: case Opcodes.CALOAD: case Opcodes.SALOAD: o1 = s.pop(); o2 = s.pop(); s.push(new BasicVariable(toType(opcode), "primitive array elem", //$NON-NLS-1$ (o1 == null || o1.isTainted()) | (o2 == null || o2.isTainted()))); break; case Opcodes.AALOAD: o1 = s.pop(); o2 = s.pop(); if (o1 != null && o2 instanceof SimpleType && ((SimpleType) o2).getType().toString().startsWith("[")) { //$NON-NLS-1$ Type atype = Type.getType(((SimpleType) o2).getType().toString().substring(1)); if (o2.getAlternativeTypes() != null && !o2.getAlternativeTypes().isEmpty()) { s.clear(); break; } s.push(new BasicVariable(atype, "array elem " + atype, o1.isTainted() | o2.isTainted())); //$NON-NLS-1$ } else { s.clear(); } break; case Opcodes.IASTORE: case Opcodes.LASTORE: case Opcodes.FASTORE: case Opcodes.DASTORE: case Opcodes.AASTORE: case Opcodes.BASTORE: case Opcodes.CASTORE: case Opcodes.SASTORE: s.pop(3); break; case Opcodes.POP2: s.pop(); case Opcodes.MONITORENTER: case Opcodes.MONITOREXIT: case Opcodes.POP: s.pop(); break; case Opcodes.DUP: if (!s.isEmpty()) { o1 = s.pop(); s.push(o1); s.push(o1); } break; case Opcodes.DUP_X1: o1 = s.pop(); o2 = s.pop(); s.push(o1); s.push(o2); s.push(o1); break; case Opcodes.DUP_X2: o1 = s.pop(); o2 = s.pop(); o3 = s.pop(); s.push(o1); s.push(o3); s.push(o2); s.push(o1); break; case Opcodes.DUP2: l1 = s.popWord(); if (l1.isEmpty()) { log.trace("DUP2 with unknown operand"); //$NON-NLS-1$ s.clear(); } else { s.pushWord(l1); s.pushWord(l1); } break; case Opcodes.DUP2_X1: l1 = s.popWord(); o1 = s.pop(); if (l1.isEmpty()) { log.trace("DUP2 with unknown operand"); //$NON-NLS-1$ s.clear(); } else { s.pushWord(l1); s.push(o1); s.pushWord(l1); } break; case Opcodes.DUP2_X2: l1 = s.popWord(); l2 = s.popWord(); if (l1.isEmpty() || l2.isEmpty()) { log.trace("DUP2 with unknown operand"); //$NON-NLS-1$ s.clear(); } else { s.pushWord(l1); s.pushWord(l2); s.pushWord(l1); } break; case Opcodes.SWAP: o1 = s.pop(); o2 = s.pop(); s.push(o1); s.push(o2); break; case Opcodes.IADD: case Opcodes.LADD: case Opcodes.FADD: case Opcodes.DADD: case Opcodes.ISUB: case Opcodes.LSUB: case Opcodes.FSUB: case Opcodes.DSUB: case Opcodes.IMUL: case Opcodes.LMUL: case Opcodes.FMUL: case Opcodes.DMUL: case Opcodes.IDIV: case Opcodes.LDIV: case Opcodes.FDIV: case Opcodes.DDIV: case Opcodes.IREM: case Opcodes.LREM: case Opcodes.FREM: case Opcodes.DREM: case Opcodes.IAND: case Opcodes.LAND: case Opcodes.IOR: case Opcodes.LOR: case Opcodes.IXOR: case Opcodes.LXOR: case Opcodes.LCMP: case Opcodes.FCMPL: case Opcodes.FCMPG: case Opcodes.DCMPL: case Opcodes.DCMPG: s.merge(2); break; case Opcodes.ISHL: case Opcodes.LSHL: case Opcodes.ISHR: case Opcodes.LSHR: case Opcodes.IUSHR: case Opcodes.LUSHR: s.pop(); // amount // ignore value break; case Opcodes.INEG: case Opcodes.F2I: case Opcodes.D2I: case Opcodes.L2I: s.push(cast(s.pop(), Type.INT_TYPE)); break; case Opcodes.LNEG: case Opcodes.I2L: case Opcodes.F2L: case Opcodes.D2L: s.push(cast(s.pop(), Type.LONG_TYPE)); break; case Opcodes.FNEG: case Opcodes.I2F: case Opcodes.L2F: case Opcodes.D2F: s.push(cast(s.pop(), Type.FLOAT_TYPE)); case Opcodes.DNEG: case Opcodes.I2D: case Opcodes.L2D: case Opcodes.F2D: s.push(cast(s.pop(), Type.DOUBLE_TYPE)); case Opcodes.I2B: s.push(cast(s.pop(), Type.BYTE_TYPE)); break; case Opcodes.I2C: s.push(cast(s.pop(), Type.CHAR_TYPE)); break; case Opcodes.I2S: s.push(cast(s.pop(), Type.SHORT_TYPE)); break; case Opcodes.ARETURN: s.clear(); break; case Opcodes.IRETURN: case Opcodes.LRETURN: case Opcodes.FRETURN: case Opcodes.DRETURN: case Opcodes.RETURN: if (log.isTraceEnabled()) { log.trace("Found return " + s.pop()); //$NON-NLS-1$ } s.clear(); break; case Opcodes.ATHROW: Object thrw = s.pop(); log.trace("Found throw " + thrw); //$NON-NLS-1$ s.clear(); break; default: log.warn("Unsupported instruction code " + opcode); //$NON-NLS-1$ } }
From source file:the.bytecode.club.bytecodeviewer.plugin.preinstalled.MaliciousCodeScanner.java
License:Open Source License
@Override public void execute(ArrayList<ClassNode> classNodeList) { PluginConsole frame = new PluginConsole("Malicious Code Scanner"); StringBuilder sb = new StringBuilder(); for (ClassNode classNode : classNodeList) { for (Object o : classNode.fields.toArray()) { FieldNode f = (FieldNode) o; Object v = f.value;/*from w w w . java 2 s . c o m*/ if (v instanceof String) { String s = (String) v; if ((LWW && s.contains("www.")) || (LHT && s.contains("http://")) || (LHS && s.contains("https://")) || (ORE && s.contains("java/lang/Runtime")) || (ORE && s.contains("java.lang.Runtime")) || (ROB && s.contains("java.awt.Robot")) || (ROB && s.contains("java/awt/Robot")) || (LIP && s.matches("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b"))) sb.append("Found LDC \"" + s + "\" at field " + classNode.name + "." + f.name + "(" + f.desc + ")" + BytecodeViewer.nl); } if (v instanceof String[]) { for (int i = 0; i < ((String[]) v).length; i++) { String s = ((String[]) v)[i]; if ((LWW && s.contains("www.")) || (LHT && s.contains("http://")) || (LHS && s.contains("https://")) || (ORE && s.contains("java/lang/Runtime")) || (ORE && s.contains("java.lang.Runtime")) || (ROB && s.contains("java.awt.Robot")) || (ROB && s.contains("java/awt/Robot")) || (LIP && s.matches("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b"))) sb.append("Found LDC \"" + s + "\" at field " + classNode.name + "." + f.name + "(" + f.desc + ")" + BytecodeViewer.nl); } } } boolean prevInsn_aconst_null = false; for (Object o : classNode.methods.toArray()) { MethodNode m = (MethodNode) o; InsnList iList = m.instructions; for (AbstractInsnNode a : iList.toArray()) { if (a instanceof MethodInsnNode) { final MethodInsnNode min = (MethodInsnNode) a; if ((ORE && min.owner.startsWith("java/lang/reflect")) || (ONE && min.owner.startsWith("java/net")) || (ORU && min.owner.equals("java/lang/Runtime")) || (ROB && min.owner.equals("java/awt/Robot")) || (OIO && min.owner.startsWith("java/io"))) { sb.append("Found Method call to " + min.owner + "." + min.name + "(" + min.desc + ") at " + classNode.name + "." + m.name + "(" + m.desc + ")" + BytecodeViewer.nl); } } if (a instanceof LdcInsnNode) { if (((LdcInsnNode) a).cst instanceof String) { final String s = (String) ((LdcInsnNode) a).cst; if ((LWW && s.contains("www.")) || (LHT && s.contains("http://")) || (LHS && s.contains("https://")) || (ORE && s.contains("java/lang/Runtime")) || (ORE && s.contains("java.lang.Runtime")) || (ROB && s.contains("java.awt.Robot")) || (ROB && s.contains("java/awt/Robot")) || (LIP && s.matches("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b"))) { sb.append("Found LDC \"" + s + "\" at method " + classNode.name + "." + m.name + "(" + m.desc + ")" + BytecodeViewer.nl); } } } // Check if the security manager is getting set to null if ((a instanceof InsnNode) && (a.opcode() == Opcodes.ACONST_NULL)) { prevInsn_aconst_null = true; } else if ((a instanceof MethodInsnNode) && (a.opcode() == Opcodes.INVOKESTATIC)) { final String owner = ((MethodInsnNode) a).owner; final String name = ((MethodInsnNode) a).name; if ((NSM && prevInsn_aconst_null && owner.equals("java/lang/System") && name.equals("setSecurityManager"))) { sb.append("Found Security Manager set to null at method " + classNode.name + "." + m.name + "(" + m.desc + ")" + BytecodeViewer.nl); prevInsn_aconst_null = false; } } else { prevInsn_aconst_null = false; } } } } frame.appendText(sb.toString()); frame.setVisible(true); }