Skip to content

Commit f76b31d

Browse files
committed
v2.9.20
1 parent 9f3302f commit f76b31d

File tree

12 files changed

+398
-55
lines changed

12 files changed

+398
-55
lines changed

src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@
1616
import java.nio.file.Files;
1717
import java.nio.file.Paths;
1818
import java.util.ArrayList;
19-
import java.util.Enumeration;
2019
import java.util.HashMap;
2120
import java.util.List;
22-
import java.util.jar.JarEntry;
23-
import java.util.jar.JarFile;
24-
import java.util.jar.JarOutputStream;
2521

2622
import javax.swing.JDialog;
2723
import javax.swing.JFileChooser;
@@ -118,7 +114,7 @@
118114
public class BytecodeViewer
119115
{
120116
/*per version*/
121-
public static final String VERSION = "2.9.19";
117+
public static final String VERSION = "2.9.20";
122118
public static String krakatauVersion = "12";
123119
public static String enjarifyVersion = "4";
124120
public static final boolean BLOCK_TAB_MENU = true;
@@ -145,12 +141,13 @@ public class BytecodeViewer
145141
public static boolean currentlyDumping = false;
146142
public static boolean needsReDump = true;
147143
public static boolean warnForEditing = false;
148-
public static ArrayList<FileContainer> files = new ArrayList<FileContainer>(); //all of BCV's loaded files/classes/etc
144+
public static List<FileContainer> files = new ArrayList<FileContainer>(); //all of BCV's loaded files/classes/etc
149145
private static int maxRecentFiles = 25;
150146
public static String fs = System.getProperty("file.separator");
151147
public static String nl = System.getProperty("line.separator");
152148
private static File BCVDir = new File(System.getProperty("user.home") + fs + ".Bytecode-Viewer");
153-
public static File RJ_JAR = new File(System.getProperty("java.home") + fs + "lib" + fs + "rt.jar");
149+
public static File RT_JAR = new File(System.getProperty("java.home") + fs + "lib" + fs + "rt.jar");
150+
public static File RT_JAR_DUMPED = new File(getBCVDirectory() + fs + "rt.jar");
154151
private static String filesName = getBCVDirectory() + fs + "recentfiles.json";
155152
private static String pluginsName = getBCVDirectory() + fs + "recentplugins.json";
156153
public static String settingsName = getBCVDirectory() + fs + "settings.bcv";
@@ -161,15 +158,15 @@ public class BytecodeViewer
161158
public static boolean runningObfuscation = false;
162159
private static long start = System.currentTimeMillis();
163160
public static String lastDirectory = ".";
164-
public static ArrayList<Process> createdProcesses = new ArrayList<Process>();
161+
public static List<Process> createdProcesses = new ArrayList<Process>();
165162
public static Refactorer refactorer = new Refactorer();
166163
public static boolean pingback = false;
167164
public static boolean deleteForeignLibraries = true;
168165
public static boolean canExit = false;
169166
public static Gson gson;
170167

171-
private static ArrayList<String> recentPlugins;
172-
private static ArrayList<String> recentFiles;
168+
private static List<String> recentPlugins;
169+
private static List<String> recentFiles;
173170

174171
static
175172
{
@@ -669,6 +666,10 @@ public static FileContainer getFileContainer(String name) {
669666
return null;
670667
}
671668

669+
public static List<FileContainer> getFiles() {
670+
return files;
671+
}
672+
672673
public static ClassNode getClassNode(FileContainer container, String name) {
673674
for (ClassNode c : container.classes)
674675
if (c.name.equals(name))
@@ -943,7 +944,7 @@ public void run() {
943944

944945
if (viewer.decodeAPKResources.isSelected()) {
945946
File decodedResources = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk");
946-
APKTool.decodeResources(tempCopy, decodedResources);
947+
APKTool.decodeResources(tempCopy, decodedResources, container);
947948
container.files = JarUtils.loadResources(decodedResources);
948949
}
949950

@@ -1080,7 +1081,7 @@ public static void resetWorkSpace(boolean ask)
10801081
the.bytecode.club.bytecodeviewer.api.BytecodeViewer.getClassNodeLoader().clear();
10811082
}
10821083

1083-
private static ArrayList<String> killList = new ArrayList<String>();
1084+
private static List<String> killList = new ArrayList<String>();
10841085

10851086
/**
10861087
* Add the recent file
@@ -1109,7 +1110,7 @@ public static void addRecentFile(File f) {
11091110
resetRecentFilesMenu();
11101111
}
11111112

1112-
private static ArrayList<String> killList2 = new ArrayList<String>();
1113+
private static List<String> killList2 = new ArrayList<String>();
11131114

11141115
/**
11151116
* Add to the recent plugin list
@@ -1187,7 +1188,7 @@ public static void cleanup() {
11871188
tempF.mkdir();
11881189
}
11891190

1190-
public static ArrayList<String> createdRandomizedNames = new ArrayList<String>();
1191+
public static List<String> createdRandomizedNames = new ArrayList<String>();
11911192

11921193
/**
11931194
* Ensures it will only return a uniquely generated names, contains a dupe checker to be sure
@@ -1254,7 +1255,7 @@ private static void hideFile(File f) {
12541255
* @param a array
12551256
* @return string with newline per array object
12561257
*/
1257-
private static String quickConvert(ArrayList<String> a) {
1258+
private static String quickConvert(List<String> a) {
12581259
return gson.toJson(a);
12591260
}
12601261

@@ -1471,11 +1472,30 @@ else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.pane
14711472
return files;
14721473
}
14731474

1474-
public static void rtCheck()
1475+
public synchronized static void rtCheck()
14751476
{
1476-
if(rt.equals("") && RJ_JAR.exists())
1477+
if(rt.equals(""))
14771478
{
1478-
rt = RJ_JAR.getAbsolutePath();
1479+
if(RT_JAR.exists())
1480+
{
1481+
rt = RT_JAR.getAbsolutePath();
1482+
}
1483+
else if(RT_JAR_DUMPED.exists())
1484+
{
1485+
rt = RT_JAR_DUMPED.getAbsolutePath();
1486+
}
1487+
else
1488+
{
1489+
try
1490+
{
1491+
JRTExtractor.extractRT(RT_JAR_DUMPED.getAbsolutePath());
1492+
rt = RT_JAR_DUMPED.getAbsolutePath();
1493+
}
1494+
catch (Throwable t)
1495+
{
1496+
t.printStackTrace();
1497+
}
1498+
}
14791499
}
14801500
}
14811501

src/the/bytecode/club/bytecodeviewer/Resources.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.ByteArrayInputStream;
55
import java.io.File;
66
import java.util.ArrayList;
7+
import java.util.List;
78

89
import javax.imageio.ImageIO;
910
import javax.swing.ImageIcon;
@@ -37,7 +38,7 @@
3738

3839
public class Resources {
3940

40-
public static ArrayList<BufferedImage> iconList;
41+
public static List<BufferedImage> iconList;
4142
public static BufferedImage icon;
4243
public static ImageIcon nextIcon;
4344
public static ImageIcon prevIcon;

src/the/bytecode/club/bytecodeviewer/SecurityMan.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public void stopBlocking() { //slightly safer security system than just a public
4444
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.JDGUIDecompiler") ||
4545
executedClass.equals("the.bytecode.club.bytecodeviewer.compilers.KrakatauAssembler") ||
4646
executedClass.equals("the.bytecode.club.bytecodeviewer.util.Enjarify") ||
47+
executedClass.equals("the.bytecode.club.bytecodeviewer.util.APKTool") ||
4748
executedClass.equals("the.bytecode.club.bytecodeviewer.BytecodeViewer") ||
4849
executedClass.equals("the.bytecode.club.bytecodeviewer.compilers.JavaCompiler")) {
4950
blocking = false;
@@ -60,7 +61,8 @@ public void checkExec(String cmd) {
6061
"attrib",
6162
"python",
6263
"pypy",
63-
"java"
64+
"java",
65+
"brut_util",
6466
};
6567
boolean allow = false;
6668

@@ -71,7 +73,7 @@ public void checkExec(String cmd) {
7173

7274
if (allow && !blocking) {
7375
System.out.println("Allowing exec:" + cmd);
74-
} else throw new SecurityException("BCV is awesome, blocking " + cmd);
76+
} else throw new SecurityException("BCV is awesome, blocking("+blocking+") exec " + cmd);
7577
}
7678

7779
@Override

src/the/bytecode/club/bytecodeviewer/compilers/SmaliAssembler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public byte[] compile(String contents, String name) {
4444
tempSmaliFolder.mkdir();
4545

4646
File tempSmali = new File(tempSmaliFolder.getAbsolutePath() + BytecodeViewer.fs + fileNumber + ".smali");
47-
File tempDex = new File(fileStart + fileNumber + ".dex");
47+
File tempDex = new File("./out.dex");
4848
File tempJar = new File(fileStart + fileNumber + ".jar");
4949
File tempJarFolder = new File(fileStart + fileNumber + "-jar" + BytecodeViewer.fs);
5050

@@ -68,6 +68,7 @@ else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.view
6868
Enjarify.apk2Jar(tempDex, tempJar);
6969

7070
try {
71+
System.out.println("Unzipping to " + tempJarFolder.getAbsolutePath());
7172
ZipUtils.unzipFilesToPath(tempJar.getAbsolutePath(), tempJarFolder.getAbsolutePath());
7273

7374
File outputClass = null;

src/the/bytecode/club/bytecodeviewer/decompilers/SmaliDisassembler.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ public class SmaliDisassembler extends Decompiler {
4141

4242
public String decompileClassNode(FileContainer container, ClassNode cn, byte[] b) {
4343
String exception = "";
44-
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs
45-
+ "temp";
44+
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp";
4645

4746
String start = MiscUtils.getUniqueName(fileStart, ".class");
4847

@@ -62,9 +61,7 @@ public String decompileClassNode(FileContainer container, ClassNode cn, byte[] b
6261

6362
//ZipUtils.zipFile(tempClass, tempZip);
6463

65-
Dex2Jar.saveAsDex(container.file, tempDex, false);
66-
67-
System.out.println("FOR SHOW: " + tempDex.getName().replaceFirst("\\.dex", "-out")); //tempSmali.getAbsolutePath()
64+
Dex2Jar.saveAsDex(tempClass, tempDex, true);
6865

6966
try
7067
{
@@ -94,9 +91,6 @@ public String decompileClassNode(FileContainer container, ClassNode cn, byte[] b
9491
exception += "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw.toString();
9592
}
9693

97-
System.out.println("FOR SHOW1: " + rename.getAbsolutePath());
98-
System.out.println("FOR SHOW2: " + tempSmali.getAbsolutePath());
99-
10094
File outputSmali = null;
10195

10296
boolean found = false;

0 commit comments

Comments
 (0)