Krakatau | Java decompiler, assembler, and disassembler
kandi X-RAY | Krakatau Summary
kandi X-RAY | Krakatau Summary
Krakatau provides an assembler and disassembler for Java bytecode, which allows you to convert binary classfiles to a human readable text format, make changes, and convert it back to a classfile, even for obfuscated code. You can also create your own classfiles from scratch by writing bytecode manually, and can examine and compare low level details of Java binaries. Unlike javap, the Krakatau disassembler can handle even highly obfuscated code, and the disassembled output can be reassembled into a classfile. Krakatau's assembler syntax is mostly a superset of Jasmin syntax with some minor incompatibilities, but unlike Jasmin, Krakatau has full support for all Java 14 features and even supports some undocumented features found in old versions of the JVM. Krakatau also provides a decompiler for converting Java binaries to readable source code. Unlike other decompilers, the Krakatau decompiler was specifically designed for working with obfuscated code and can easily handle tricks that break other decompilers. However, the Krakatau decompiler does not support some Java 8+ features such as lambdas, so it works best on older code.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create a SSA graph from the given code
- Parse a method descriptor
- Returns the root of the tree
- Parse unbound MethodDescriptor
- Parse a fmimref
- Log an error
- Format a list
- Check that all of the expected types match
- Reference target
- Creates the Ternary of the given item
- Parse target info
- Prints the method definition
- Handle constant data
- Print this block
- Parse an XML element
- Start a new block
- Assemble a NoCP packet
- Update the node s successor state
- Decompile a Java class
- Return a dictionary of used local variables
- Precompute the values for each instruction
- Append an instruction
- Handle the constant pool
- Disassembles target files
- Propagate constraints
- Writes the contents of the module to disk
Krakatau Key Features
Krakatau Examples and Code Snippets
value compute block slots $a,$b,$c {
loadslot $a
loadslot $b
add
loadslot $c
mul
}
value main block {
push number 5
dup
push number 4
load compute
exec
}
#include
#include
uint64_t compute(uint64_t a, uint64_t b, uint64_t c)
build$ cmake ..
[...]
-- Build files have been written to: /home/egranata/krakatau/build
$ make -j
[...]
build$ ls
assembler CMakeCache.txt cmake_install.cmake googletest-download lexer.cpp libstuff.so runner
bin CMakeFiles googlete
Community Discussions
Trending Discussions on Krakatau
QUESTION
I'm using Krakatau to generate bytecodes from Jasmin syntax. My Jasmin code is created from a direct translation of a intermediate code in the form of Three Address Code(TAC). My problem is that I can't tell for sure, only
looking at the TAC, where I should position my stack
directives when translating jump statements.
Krakatau documentation on its assembler says the following:
The content of a StackMapTable attribute is automatically filled in based on the stack directives in the enclosing code attribute. If this attribute’s contents are nonempty and the attribute isn’t specified explicitly, one will be added implicitly.
But it also says:
Krakatau will not calculate a new stack map for you from bytecode that does not have any stack information. If you want to do this, you should try using ASM.
I'm confused about which kind of directives, and where should I add them to my translation so the assembler knows how to add the attributes implicitly. Any help on this would be appreciated.
For instance, I have this code written in a syntax similar to Java(but not the same, so I need to use another compiler for it):
What I get from the front end of my compiler is the TAC on the left and my translator generate the Jasmin code on the right(I'm removing the headers and footers and only leaving the bytecode itself, missing the return instruction):
When I try to run it, I get something like:
...ANSWER
Answered 2017-Nov-12 at 15:49The easiest approach is to avoid the need for stack maps entirely. Stack maps are only required if you want to use version 51.0+ features (i.e. invokedynamic). If you aren't using invokedynamic, you can just set the classfile version to 50 or lower, and you don't need a stack map at all. In fact, Krakatau defaults the version to 49.0 if you don't explicitly specify one, so you don't need to do anything there.
If you are using invokedynamic, things get much tricker, because you have to generate stack maps. The basic rule is that you need a stack map entry whenever an instruction is reachable from anywhere other than the preceding instruction. (I think you also need entries for dead code, but I haven't checked).
As for actually generating the entries, there are several different types of stack frames, but you don't have to worry about that. The easiest approach is to just use a full
frame every time. This involves listing out the current type for every live value in the local variable ("register") slots and on the operand stack, so you'll have to track those.
Yes, it is a pain to calculate and generate all that type information, but you'll have to blame Oracle for that, not me. Alternatively, you could try to use ASM to generate the stack maps for you, as suggested in the documentation.
QUESTION
I'm trying to use Krakatau to assemble a native Java bytecode, acquired with javap -c
, but I'm getting a weird error:
ANSWER
Answered 2017-Nov-11 at 07:35Nothing in the Krakatau documentation says that it is designed to convert the output of javap -c
.
If you want to use Krakatau to convert bytecode files, you should use Krakatau for the disassembly step not javap -c
.
The Krakatua README.txt file explains how to do that.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Krakatau
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page