Android reverse learning (part one) smali2java part of the file can not be decompiled bug and repair method

Android reverse learning (part one) smali2java part of the file can not be decompiled bug and repair method

I. Introduction

Yesterday, I was preparing the android reverse (4) blog as usual, and found that smali2java cannot reverse some files. I don’t know if windows will cause this bug, but ubuntu has this situation. As a person who likes to know more People, I explored this bug and found the reason and gave a repair method. At present, I have contacted the original author and hope that smali2java can update this as soon as possible.

Below I will briefly introduce the cause of this bug and the repair method. If you are in a hurry, you can directly see the repair method

2. Introduction of bugs

I am reversing some smali files with $$ filenames and this bug occurs

20230905125635

This is very strange. The $$ file is a smali code generated by using java lambda expressions. Although this kind of code is generally very simple, you don’t need to reverse reverse the smali code directly, but as a vegetable dog with great ambitions , I can't see the computer reporting an error the most, so I plan to fix this bug directly

Next, we will start to analyze how this bug is generated and how to fix it. By checking the error report, we found that a line of commands did not run correctly. Let’s run this command directly on the command line and find that the error report is as follows

20230905130122

The file was not found, and then I found out that the name of the file did not match up and down. Could it be that there is no escaping? Let’s try again with the escaping symbol

20230905125749

Sure enough, this is the reason. Since we already know the cause of the bug, we can simply fix it.

3. Repair method

We first need to find the location of this plug-in. This vscode plug-in is written in javascript or typescript. I have written and published javascript scripts, so it is not difficult for me to modify the script. Generally speaking, vscode configuration files They are all in the .vscode directory under the main directory, we can just find them directly, remember to open the hidden directory

20230905125846

This is how we found the script directory of smali2java

Then open the folder, we only need to modify two files

There is a decompiler folder under the out folder inside, and there are two JadxDecompiler.js files in it, one in the decompiler and one in the impl folder inside, and then we modify the two folders as follows

20230905163734

20230905163529

Just add the following code at the specified location. This is replaced by a regular expression.

.replace(/\$/g,"\\\$")

The meaning of this code is that when running the command, add escape to the file name, so that it can run correctly.

By the way, after you modify it, your vscode still has no way to run. At this time, ctrl+shift+p opens the vscode command panel, and then reloads the window to reload the plug-in, and then you find that the program can run correctly

20230905130016

In the end, it was Tiger Town Building

20230905130334

Guess you like

Origin blog.csdn.net/qq_52380836/article/details/132689737