Storyyeller / Krakatau

Java decompiler, assembler, and disassembler
GNU General Public License v3.0
1.95k stars 219 forks source link

AssertionError: assert bytestream.size() == 0 #155

Closed spaceone closed 5 years ago

spaceone commented 5 years ago

Hi, the decompiler crashes for my file: Executed Krakatau/decompile.py qmine-o.jar:

Loading qmine/MainApplet
Traceback (most recent call last):
  File "Krakatau/decompile.py", line 158, in <module>
    decompileClass(path, targets, args.out, args.skip, magic_throw=args.xmagicthrow)
  File "Krakatau/decompile.py", line 101, in decompileClass
    c = e.getClass(target.decode('utf8'))
  File "Krakatau/Krakatau/environment.py", line 24, in getClass
    result = self._loadClass(name)
  File "Krakatau/Krakatau/environment.py", line 93, in _loadClass
    new = ClassFile(stream)
  File "Krakatau/Krakatau/classfile.py", line 85, in __init__
    assert bytestream.size() == 0
AssertionError

The following .jar file is used: www.wechall.net/challenge/quangntenemy/QMine/qmine-o.jar

Storyyeller commented 5 years ago

Are you sure the classfile is valid? That error will occur if you try to parse an invalid classfile.

A good way to test it is to run the disassembler on the jar. That should tell you if there are any invalid classfiles in there and which ones.

spaceone commented 5 years ago

I think so, as the java applet is normally running. I am no java expert. You can test it yourself just download the jar file.

spaceone commented 5 years ago

The error might happen because the java file is obfuscated(?). When i decompile it with another decompiler it creates invalid variables:

  95   public void actionPerformed(ActionEvent paramActionEvent)
  96   {
  97     if ((paramActionEvent = paramActionEvent.getActionCommand()).equals("samegame"))

It assigns a string to the paramActionEvent variable which is type ActionEvent.

Storyyeller commented 5 years ago

Did you try disassembling it like I suggested?

Unfortunately, I won't be able to test it myself until next week as I am on vacation.

spaceone commented 5 years ago

Ah yes, ofc I dissassembled it and that just works fine! Happy holidays ! :)

Janmm14 commented 5 years ago

@spaceone I would not trust other decompilers. For example fernflower can very easily get exploited and produce such invalid code.

spaceone commented 5 years ago

@Janmm14 I don't understand? I didn't use another decompiler than the one which is part of Krakatau.

Janmm14 commented 5 years ago

@spaceone you posted code of decompilation with "another decompiler".

spaceone commented 5 years ago

@Janmm14 oh yes, but this was from http://javadecompilers.com/

Janmm14 commented 5 years ago

@spaceone and which one did you choose?

Storyyeller commented 5 years ago

I just tried it and it decompiled without error. Are you sure you are using the latest version of Krakatau?

spaceone commented 5 years ago

I used the latest git checkout from that day. I would be okay with closing this issue as I solved my problem.