javassist
javassist copied to clipboard
insert code failed: java.lang.VerifyError
## insert following code before a method: try {com.baidu.openrasp.ModuleLoader.loadClass("com.baidu.openrasp.HookHandler").getMethod("onInputStreamRead",new Class[]{java.lang.int.class,Object.class}).invoke(null,new Object[]{$_,$0});} catch (Exception e) {if(e.getClass().getName().equals("com.baidu.openrasp.exception.SecurityException")){throw e;}}
## The following error occurred at runtime:
java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
org/apache/catalina/connector/InputBuffer.readByte()I @70: aastore
Reason:
Type integer (current frame, stack[5]) is not assignable to 'java/lang/Object'
Current Frame:
bci: @70
flags: { }
locals: { 'org/apache/catalina/connector/InputBuffer', top, integer }
stack: { 'java/lang/reflect/Method', null, '[Ljava/lang/Object;', '[Ljava/lang/Object;', integer, integer }
Bytecode:
0x0000000: 2ab4 0008 9900 13bb 0028 59b2 0029 122a
0x0000010: b600 2bb7 002c bf2a b400 11b6 002d a700
0x0000020: 033d 1301 49b8 014f 1301 5105 bd01 5359
0x0000030: 03b2 0159 5359 0413 015b 53b6 015f 0105
0x0000040: bd01 5b59 031c 5359 042a 53b6 0165 57a7
0x0000050: 0019 4e2d b601 6bb6 016e 1301 70b6 0176
0x0000060: 9900 052d bfa7 0003 1cac
Exception Handler Table:
bci [34, 79] => handler: 82
Stackmap Table:
same_frame(@23)
same_locals_1_stack_item_frame(@33,Integer)
full_frame(@82,{Object[#80],Top,Integer},{Object[#359]})
append_frame(@101,Object[#359])
chop_frame(@104,1)
at org.apache.catalina.connector.Request.<init>(Request.java:252)
at org.apache.catalina.connector.Connector.createRequest(Connector.java:882)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:416)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
It looks like wrapper class error,how to fix it
$_ is available only with insertAfter(). Maybe that's a problem.
I really use the insertAfter() method.
I have fixed it wither $_
Javassist can not automatically convet the primitive type to wrapper type.
I also got this problem, @chibash @tangyouyi1513 how to solve this
You guys can try with ($w)$_.
$w represents a wrapper type. It must be used as the cast type in a cast expression. ($w) converts from a primitive type to the corresponding wrapper type.
Surely autoboxing is better.
You guys can try with ($w)$_.
$w represents a wrapper type. It must be used as the cast type in a cast expression. ($w) converts from a primitive type to the corresponding wrapper type.
Surely autoboxing is better.
yes, I also solve it by using $w, but i think autoboxing support is a batter way.