Storyyeller / Krakatau

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

try-catch class name causing UnicodeEncodeError: 'ascii' codec can't encode character u'\u200b' in position 0: ordinal not in range(128) #180

Closed Janmm14 closed 2 years ago

Janmm14 commented 2 years ago

On Windows 10. Latest helios despite the hash in path suggesting otherwise.

    // Traceback (most recent call last):
    //   File "C:\Users\Jan\.helios\Krakatau\3eff49fe480efeca8a728936f6452ec6853cdc88\Krakatau\java\javaclass.py", line 38, in _getMethod
    //     graph = cb(method) if method.code is not None else None
    //   File "H:\C\pypy2.7-v7.3.4-win64\lib_pypy\_functools.py", line 45, in __call__
    //     return self._func(*(self._args + fargs), **fkeywords)
    //   File "decompile.py", line 49, in makeGraph
    //     s = Krakatau.ssa.ssaFromVerified(m.code, v, opts)
    //   File "C:\Users\**\.helios\Krakatau\3eff49fe480efeca8a728936f6452ec6853cdc88\Krakatau\ssa\graph.py", line 718, in ssaFromVerified
    //     data = blockmaker.BlockMaker(parent, iNodes, inputTypes, returnTypes, code.except_raw, opts=opts)
    //   File "C:\Users\**\.helios\Krakatau\3eff49fe480efeca8a728936f6452ec6853cdc88\Krakatau\ssa\blockmaker.py", line 141, in __init__
    //     self._startNewBlock(node.key)
    //   File "C:\Users\**\.helios\Krakatau\3eff49fe480efeca8a728936f6452ec6853cdc88\Krakatau\ssa\blockmaker.py", line 204, in _startNewBlock
    //     self._addOnException(block, self.blockd[key], curslots)
    //   File "C:\Users\**\.helios\Krakatau\3eff49fe480efeca8a728936f6452ec6853cdc88\Krakatau\ssa\blockmaker.py", line 244, in _addOnException
    //     block.jump = ssa_jumps.OnException(parent, ephi.outException, block.chpairs, fallthrough)
    //   File "C:\Users\**\.helios\Krakatau\3eff49fe480efeca8a728936f6452ec6853cdc88\Krakatau\ssa\ssa_jumps\onexception.py", line 12, in __init__
    //     self.cs = CatchSetManager.new(parent.env, chpairs)
    //   File "C:\Users\**\.helios\Krakatau\3eff49fe480efeca8a728936f6452ec6853cdc88\Krakatau\ssa\exceptionset.py", line 19, in new
    //     sets[handler] = old | (new - sofar)
    //   File "C:\Users\**\.helios\Krakatau\3eff49fe480efeca8a728936f6452ec6853cdc88\Krakatau\ssa\exceptionset.py", line 89, in __sub__
    //     pairs = itertools.chain(*[ExceptionSet.diffPair(subtest, pair1, pair2) for pair1 in pairs])
    //   File "C:\Users\Jan\.helios\Krakatau\3eff49fe480efeca8a728936f6452ec6853cdc88\Krakatau\ssa\exceptionset.py", line 129, in diffPair
    //     elif subtest(t2,t1): # t2 < t1
    //   File "C:\Users\**\.helios\Krakatau\3eff49fe480efeca8a728936f6452ec6853cdc88\Krakatau\environment.py", line 37, in isSubclass
    //     name1 = self._getSuper(name1)
    //   File "C:\Users\**\.helios\Krakatau\3eff49fe480efeca8a728936f6452ec6853cdc88\Krakatau\environment.py", line 19, in _getSuper
    //     return self.getClass(name).supername
    //   File "C:\Users\**\.helios\Krakatau\3eff49fe480efeca8a728936f6452ec6853cdc88\Krakatau\environment.py", line 25, in getClass
    //     result = self._loadClass(name)
    //   File "C:\Users\**\.helios\Krakatau\3eff49fe480efeca8a728936f6452ec6853cdc88\Krakatau\environment.py", line 87, in _loadClass
    //     print("Loading", name[:70])
    // UnicodeEncodeError: 'ascii' codec can't encode character u'\u200b' in position 0: ordinal not in range(128)
    static {/*error*/throw null;}

This specific sample is from BDNkq6u7y96Yx7sh.BDNkq6u7y96Yx7sh.BDNkq6u7y96Yx7sh.BDNkq6u7y96Yx7sh.VQT3KUN9BKLtQ8nA$VQT3KUN9BKLtQ8nA, however nearly every method errors with that stack trace, always complaining about u'\u200b' for this sample.

Seems to be related to try-catch of the class \u200b\u2004

File: https://drive.google.com/file/d/1KC5lZCvhKCIJ-Fb2J7rH_yGAM2GjVot0/view?usp=sharing Original issue: https://github.com/java-deobfuscator/deobfuscator/issues/785

Storyyeller commented 2 years ago

Unfortunately my old windows laptop is in the closet and barely works, so this will be hard to test. I'd recommend just commenting out the print statement and see if that works.

Janmm14 commented 2 years ago

That fixes it.