Questions tagged [bytecode-manipulation]

Low level Virtual Machine bytecode manipulations. Including creating/modifying/optimizing/etc bytecode for various VMs. For example JVM, Python VM, Lua VM, etc.

Why?

Using some VM based programming languages for period of time usually leads to realising that some parts of the code aren't translated into bytecode efficiently, might be optimized for the specific VM even more or we just need some functionality which isn't implemented into standard bytecode compiler/interpreter/etc, like:

  • bytecode encryption
  • bytecode linkage
  • etc.

Links:

More about bytecode:

383 questions
0
votes
1 answer

Transforming FieldInsnNode's names and information

I'm attempting to deobfuscate a .jar's code. I've created a module that successfully renames the methods (including return type), the class and its superclass, and its fields. My issue now is in the actual bytecode. I'm attempting to modify the…
0
votes
1 answer

How to add an extra instruction to method in ByteCode using ClassVisitor / Java Bytecode (ASM)

I'm writing a gradle plugin for my lib. https://github.com/shehabic/sherlock, I need to inject a network interceptor at compilation time in the byte code of OkHttp Client…
Shehabic
  • 6,787
  • 9
  • 52
  • 93
0
votes
0 answers

JVMTI Encrypt&Decrypt Java class file

I'm doing something to encrypt java .class file, and using jvmti agentlib to decrypt the source data. there always an Exception. Error: A JNI error has occurred, please check your installation and try again Exception in thread "main"…
xufeng
  • 55
  • 1
  • 7
0
votes
1 answer

Why is this simple bit of code outputting a corrupted class file?

ClassReader classReader = new ClassReader(new FileInputStream(new File("input.class"))); ClassWriter classWriter = new ClassWriter(classReader, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); Files.write(Paths.get("output.class"),…
vaps
  • 57
  • 5
0
votes
1 answer

ASM skips Classes if COMPUTE_FRAMES is set in ClassWriter

I have been working on a Java Agent which is run together with the maven-surfire-plugin. The agent should be able to inject method calls using the ASM library into loaded methods at three different points: 1) In the beginning of each method; 2) At…
0
votes
0 answers

Javassist - Why I can't replace a method body after being intercepted during the execution?

I'm trying to replace a method declared in my main class using instrument. This piece of code will intercept all the method calls during the execution but it won't replace the method body for a certain method (change in my…
0
votes
1 answer

byte-buddy (byte code manipulation) interceptor dont work: None of

I have to add annotation XmlElementWrapper and XmlElement to field of list type, but these annotation required name. I would to set property name to field name. I do: new ByteBuddy() .redefine(className) …
robyp7
  • 481
  • 2
  • 7
  • 25
0
votes
2 answers

Java - instrumenting the Garbage Collector?

Is it possible to inject bytecode into the Garbage Collector? I have a hunch the answer will be "no", but I can't seem to find anything about it online.
0
votes
2 answers

How does the JVM actually read and run the bytecode? A giant switch-case statement?

Or, what actually goes on in the inner loop of the JVM? I suppose this is a rather implementation-specific question, but how actually does the JVM run bytecodes? The most naive method might consist of a giant switch case - using C…
oink
  • 1,443
  • 2
  • 14
  • 23
0
votes
2 answers

Remember JVM state before executing a specific instruction

I am working on a testing project using mutating technique. My project requires to manipulate a Java classfile and re-execute the classfile multiple times for testing. My implementation need to re-execute the whole system again after one…
Anh Cuong
  • 131
  • 1
  • 3
0
votes
1 answer

dirtyJoe to manipulate java byte code

I'm using Dirty Joe to manipulate this code bellow SetAttribute localSetAttribute = new SetAttribute(140, "B", beeperVolume.getValue(), 0); So I use Dirty Joe to change number to push. On code editor I only found edit opcode which only edit the…
Yohanim
  • 3,319
  • 9
  • 52
  • 92
0
votes
0 answers

turn off asmtools class file version check

So I have a classes containing bytecode I need to debug ... Using asmtools' jdis gives me editable bytecode that I then can reassemble using jasm. Or at least I can MOST of the time. For this particular class, though, I can disassemble it just fine.…
0
votes
0 answers

How are ``getfield`` instructions resolved?

Alright so I have an instance of Foo that has an Object field obj, say, and a bunch of other fields. I now create a class Bar and give it all the fields that Foo has and a few extra. In particular, Bar has obj as well. I instrument my classes to…
User1291
  • 7,664
  • 8
  • 51
  • 108
0
votes
2 answers

How does scalac mark compiled files?

Look at this question. When you open .class file with scala plugin enabled (Intellij Idea) it shows you scala code, bu when it is turned off java decompile plugin shows you a decompiled java code. Note that .class files which are compiled by javac…
Cherry
  • 31,309
  • 66
  • 224
  • 364
0
votes
1 answer

ASM - Inconsistent stackmap frames at branch target

I am trying to do a simple Java bytecode obfuscator which works by replacing GOTO instructions with simple conditional jumps, say, if 10 != 15 GOTO else throw IllegalStateException. My current code is: final AbstractInsnNode[] insns =…