Skip to content

Commit bf5362c

Browse files
committed
2.9.7 preview 2
1 parent fc32f6c commit bf5362c

23 files changed

+314
-72
lines changed

BytecodeViewer 2.9.7-preview.jar

-250 KB
Binary file not shown.

src/krakatau.zip

-280 KB
Binary file not shown.

src/org/objectweb/asm/commons/util/JarArchive.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ public JarArchive(File file) {
3232
public Map<String, ClassNode> build() {
3333
if (!nodes.isEmpty())
3434
return nodes;
35+
JarFile jar = null;
3536
try {
36-
JarFile jar = new JarFile(file);
37+
jar = new JarFile(file);
3738
manifest = jar.getManifest();
3839
Enumeration<JarEntry> entries = jar.entries();
3940
while (entries.hasMoreElements()) {
@@ -48,6 +49,12 @@ public Map<String, ClassNode> build() {
4849
}
4950
} catch (IOException e) {
5051
throw new RuntimeException("Error building classes (" + file.getName() + "): ", e.getCause());
52+
} finally {
53+
try {
54+
if(jar != null)
55+
jar.close();
56+
} catch (IOException e) {
57+
}
5158
}
5259
return nodes;
5360
}

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

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@
4343
import the.bytecode.club.bytecodeviewer.plugin.PluginManager;
4444

4545
/**
46-
* A lightweight Java Reverse Engineering suite, developed by Konloch -
47-
* http://konloch.me
46+
* A lightweight Java Reverse Engineering suite, developed by Konloch - http://konloch.me
4847
*
49-
* Are you a Java Reverse Engineer? Or maybe you want to learn Java Reverse
50-
* Engineering? Join The Bytecode Club, we're noob friendly, and censorship
51-
* free.
48+
* Are you a Java Reverse Engineer? Or maybe you want to learn Java Reverse Engineering?
49+
* Join The Bytecode Club, we're noob friendly, and censorship free.
5250
*
5351
* http://the.bytecode.club
5452
*
@@ -91,13 +89,17 @@
9189
* refresh appears under panes that are non refreshable
9290
* make ez-injection plugin console show all sys.out calls
9391
* edit then save issues?
94-
* Search open doesnt append .class to tab name
92+
* Search open doesn't append .class to tab name
9593
*
9694
* -----2.9.7-----:
9795
* 07/02/2015 - Added ajustable font size.
9896
* 07/05/2015 - Started working on the new Boot Screen.
9997
* 07/06/2015 - Moved the font size to be under the view menu.
10098
* 07/06/2015 - Fixed a bug with plugins not being able to grab the currently viewed class.
99+
* 07/07/2015 - Started adding enjarify as an optional APK converter instead of Dex2Jar.
100+
* 07/07/2015 - Finished the new Boot Screen
101+
* 07/09/2015 - Fixed a process leak with krakatau decompiler.
102+
* 07/09/2015 - Finished adding enjarify.
101103
*
102104
* @author Konloch
103105
*
@@ -107,14 +109,15 @@ public class BytecodeViewer {
107109

108110
/*per version*/
109111
public static String version = "2.9.7";
110-
public static String krakatauVersion = "2";
112+
public static boolean previewCopy = true;
111113
/*the rest*/
112114
public static MainViewerGUI viewer = null;
113115
public static ClassNodeLoader loader = new ClassNodeLoader(); //might be insecure due to assholes targeting BCV, however that's highly unlikely.
114116
public static String python = "";
117+
public static String python3 = "";
115118
public static String rt = "";
116119
public static String library = "";
117-
public static SecurityMan sm = new SecurityMan();
120+
public static SecurityMan sm = new SecurityMan(); //might be insecure due to assholes targeting BCV, however that's highly unlikely.
118121
public static HashMap<String, ClassNode> loadedClasses = new HashMap<String, ClassNode>();
119122
public static HashMap<String, byte[]> loadedResources = new HashMap<String, byte[]>();
120123
private static int maxRecentFiles = 25;
@@ -126,13 +129,17 @@ public class BytecodeViewer {
126129
public static String settingsName = getBCVDirectory() + fs + "settings.bcv";
127130
public static String tempDirectory = getBCVDirectory() + fs + "bcv_temp" + fs;
128131
public static String libsDirectory = getBCVDirectory() + fs + "libs" + fs;
129-
public static String krakatauWorkingDirectory = getBCVDirectory() + fs + "krakatau_" + krakatauVersion + fs + "Krakatau-master";
132+
public static String krakatauWorkingDirectory = "";
133+
public static String krakatauVersion = "";
134+
public static String enjarifyWorkingDirectory = "";
135+
public static String enjarifyVersion = "";
130136
private static ArrayList<String> recentFiles = DiskReader.loadArrayList(filesName, false);
131137
private static ArrayList<String> recentPlugins = DiskReader.loadArrayList(pluginsName, false);
132138
public static boolean runningObfuscation = false;
133139
private static long start = System.currentTimeMillis();
134140
public static String lastDirectory = "";
135141
public static ArrayList<Process> krakatau = new ArrayList<Process>();
142+
public static ArrayList<Process> enjarify = new ArrayList<Process>();
136143
public static Refactorer refactorer = new Refactorer();
137144
public static boolean pingback = false;
138145
public static boolean deleteForiegnLibraries = true;
@@ -303,7 +310,7 @@ public void run() {
303310
try {
304311
new HTTPRequest(new URL("https://bytecodeviewer.com/add.php")).read();
305312
} catch(Exception e) {
306-
//ignore
313+
pingback = false;
307314
}
308315
}
309316
};
@@ -356,21 +363,25 @@ public static void main(String[] args) {
356363
System.setSecurityManager(sm);
357364
try {
358365
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
366+
if(previewCopy)
367+
showMessage("WARNING: This is a preview/dev copy, you WON'T be alerted when 2.9.7 is actually out if you use this."+nl+
368+
"Make sure to watch the repo: https://github.com/Konloch/bytecode-viewer for 2.9.7's release");
359369
new BootScreen().DO_FIRST_BOOT(args);
360370
} catch (Exception e) {
361371
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
362372
}
363373
}
364374

365375
public static void BOOT(String[] args) {
366-
checkKrakatau();
367376
System.out.println("https://the.bytecode.club - Created by @Konloch - Bytecode Viewer " + version);
368377
cleanup();
369378
Runtime.getRuntime().addShutdownHook(new Thread() {
370379
@Override
371380
public void run() {
372381
for(Process krakatau : krakatau)
373382
krakatau.destroy();
383+
for(Process enjarify : enjarify)
384+
enjarify.destroy();
374385
Settings.saveGUI();
375386
cleanup();
376387
}
@@ -558,33 +569,6 @@ public static boolean compile(boolean message) {
558569

559570
return true;
560571
}
561-
562-
/**
563-
* Drops the latest krakatau safely
564-
*/
565-
public static void checkKrakatau() {
566-
File krakatauDirectory = new File(getBCVDirectory() + fs + "krakatau_" + krakatauVersion);
567-
if(!krakatauDirectory.exists()) {
568-
try {
569-
File temp = new File(getBCVDirectory() + fs + "krakatau_" + krakatauVersion + ".zip");
570-
while(temp.exists())
571-
temp.delete();
572-
InputStream is = BytecodeViewer.class.getClassLoader().getResourceAsStream("krakatau.zip");
573-
FileOutputStream baos = new FileOutputStream(temp);
574-
int r = 0;
575-
byte[] buffer = new byte[8192];
576-
while((r=is.read(buffer))>=0) {
577-
baos.write(buffer, 0, r);
578-
}
579-
baos.close();
580-
ZipUtils.unzipFilesToPath(temp.getAbsolutePath(), krakatauDirectory.getAbsolutePath());
581-
temp.delete();
582-
} catch(Exception e) {
583-
showMessage("ERROR: There was an issue unzipping Krakatau decompiler, please contact @Konloch with your stacktrace.");
584-
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
585-
}
586-
}
587-
}
588572

589573
private static boolean update = true;
590574

@@ -653,7 +637,12 @@ public void run() {
653637

654638
String name = getRandomizedName()+".jar";
655639
File output = new File(tempDirectory + fs + name);
656-
Dex2Jar.dex2Jar(f, output);
640+
641+
if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
642+
Dex2Jar.dex2Jar(f, output);
643+
else if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel()))
644+
Enjarify.apk2Jar(f, output);
645+
657646
BytecodeViewer.viewer.setIcon(false);
658647
openFiles(new File[]{output}, false);
659648
} catch (final Exception e) {
@@ -664,7 +653,12 @@ public void run() {
664653
try {
665654
String name = getRandomizedName()+".jar";
666655
File output = new File(tempDirectory + fs + name);
667-
Dex2Jar.dex2Jar(f, output);
656+
657+
if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
658+
Dex2Jar.dex2Jar(f, output);
659+
else if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel()))
660+
Enjarify.apk2Jar(f, output);
661+
668662
BytecodeViewer.viewer.setIcon(false);
669663
openFiles(new File[]{output}, false);
670664
} catch (final Exception e) {
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
package the.bytecode.club.bytecodeviewer;
2+
3+
import java.io.BufferedReader;
4+
import java.io.File;
5+
import java.io.InputStream;
6+
import java.io.InputStreamReader;
7+
8+
/**
9+
* A simple wrapper for Enjarify.
10+
*
11+
* @author Konloch
12+
*
13+
*/
14+
15+
public class Enjarify {
16+
17+
/**
18+
* Converts a .apk or .dex to .jar
19+
* @param input the input .apk or .dex file
20+
* @param output the output .jar file
21+
*/
22+
public static synchronized void apk2Jar(File input, File output) {
23+
if(BytecodeViewer.python3.equals("")) {
24+
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 3.x executable path.");
25+
BytecodeViewer.viewer.pythonC3();
26+
}
27+
28+
BytecodeViewer.sm.blocking = false;
29+
try {
30+
ProcessBuilder pb = new ProcessBuilder(
31+
BytecodeViewer.python3,
32+
"-O",
33+
"-m",
34+
"enjarify.main",
35+
input.getAbsolutePath(),
36+
"-o",
37+
output.getAbsolutePath()
38+
);
39+
40+
pb.directory(new File(BytecodeViewer.enjarifyWorkingDirectory));
41+
42+
Process process = pb.start();
43+
BytecodeViewer.enjarify.add(process);
44+
45+
//Read out dir output
46+
InputStream is = process.getInputStream();
47+
InputStreamReader isr = new InputStreamReader(is);
48+
BufferedReader br = new BufferedReader(isr);
49+
String line;
50+
while ((line = br.readLine()) != null) {
51+
System.out.println(line);
52+
}
53+
br.close();
54+
55+
is = process.getErrorStream();
56+
isr = new InputStreamReader(is);
57+
br = new BufferedReader(isr);
58+
while ((line = br.readLine()) != null) {
59+
System.out.println(line);
60+
}
61+
br.close();
62+
63+
int exitValue = process.waitFor();
64+
System.out.println("Exit Value is " + exitValue);
65+
66+
} catch(Exception e) {
67+
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
68+
}
69+
70+
BytecodeViewer.sm.blocking = true;
71+
}
72+
73+
/**
74+
* Converts a .jar to .dex
75+
* @param input the input .jar file
76+
* @param output the output .dex file
77+
*/
78+
public static synchronized void saveAsAPK(File input, File output) {
79+
if(BytecodeViewer.python3.equals("")) {
80+
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 3.x executable path.");
81+
BytecodeViewer.viewer.pythonC3();
82+
}
83+
84+
BytecodeViewer.sm.blocking = false;
85+
try {
86+
ProcessBuilder pb = new ProcessBuilder(
87+
BytecodeViewer.python3,
88+
"-O",
89+
"-m",
90+
"enjarify.main",
91+
input.getAbsolutePath(),
92+
"-o",
93+
output.getAbsolutePath()
94+
);
95+
pb.directory(new File(BytecodeViewer.enjarifyWorkingDirectory));
96+
97+
98+
Process process = pb.start();
99+
BytecodeViewer.enjarify.add(process);
100+
101+
//Read out dir output
102+
InputStream is = process.getInputStream();
103+
InputStreamReader isr = new InputStreamReader(is);
104+
BufferedReader br = new BufferedReader(isr);
105+
String line;
106+
while ((line = br.readLine()) != null) {
107+
System.out.println(line);
108+
}
109+
br.close();
110+
111+
is = process.getErrorStream();
112+
isr = new InputStreamReader(is);
113+
br = new BufferedReader(isr);
114+
while ((line = br.readLine()) != null) {
115+
System.out.println(line);
116+
}
117+
br.close();
118+
119+
int exitValue = process.waitFor();
120+
System.out.println("Exit Value is " + exitValue);
121+
122+
} catch(Exception e) {
123+
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
124+
}
125+
126+
BytecodeViewer.sm.blocking = true;
127+
}
128+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ else if(BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.panel
194194
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "0", false);
195195
else if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel()))
196196
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "1", false);
197+
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.python3, false);
197198
} catch(Exception e) {
198199
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
199200
}
@@ -387,6 +388,7 @@ else if(decompiler == 9)
387388
BytecodeViewer.viewer.apkConversionGroup.setSelected(BytecodeViewer.viewer.apkConversionDex.getModel(), true);
388389
else if(decompiler == 1)
389390
BytecodeViewer.viewer.apkConversionGroup.setSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel(), true);
391+
BytecodeViewer.python3 = DiskReader.loadString(BytecodeViewer.settingsName, 115, false);
390392
} catch(Exception e) {
391393
//ignore because errors are expected, first start up and outdated settings.
392394
//e.printStackTrace();

src/the/bytecode/club/bytecodeviewer/api/ASMUtil_OLD.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public static void renameMethodNode(String originalParentName,
9393
}
9494
}
9595

96-
@SuppressWarnings("unchecked")
9796
public static void renameClassNode(final String oldName,
9897
final String newName) {
9998
for (ClassNode c : BytecodeViewer.getLoadedClasses()) {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import me.konloch.kontainer.io.DiskWriter;
66
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
77
import the.bytecode.club.bytecodeviewer.Dex2Jar;
8+
import the.bytecode.club.bytecodeviewer.Enjarify;
89
import the.bytecode.club.bytecodeviewer.MiscUtils;
910
import the.bytecode.club.bytecodeviewer.ZipUtils;
1011

@@ -43,7 +44,10 @@ public byte[] compile(String contents, String name) {
4344
}
4445

4546

46-
Dex2Jar.dex2Jar(tempDex, tempJar);
47+
if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
48+
Dex2Jar.dex2Jar(tempDex, tempJar);
49+
else if(BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel()))
50+
Enjarify.apk2Jar(tempDex, tempJar);
4751

4852
try {
4953
ZipUtils.unzipFilesToPath(tempJar.getAbsolutePath(), tempJarFolder.getAbsolutePath());

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
package the.bytecode.club.bytecodeviewer.decompilers;
22

3-
import java.io.BufferedReader;
43
import java.io.File;
54
import java.io.FileOutputStream;
65
import java.io.IOException;
7-
import java.io.InputStream;
8-
import java.io.InputStreamReader;
96
import java.io.PrintStream;
107
import java.io.PrintWriter;
118
import java.io.StringWriter;
129

1310
import jd.cli.loader.DirectoryLoader;
14-
import jd.cli.loader.JarLoader;
1511
import jd.cli.preferences.CommonPreferences;
1612
import jd.cli.util.ClassFileUtil;
17-
import jd.core.loader.Loader;
1813
import jd.core.process.DecompilerImpl;
1914
import me.konloch.kontainer.io.DiskReader;
2015
import me.konloch.kontainer.io.DiskWriter;
@@ -23,9 +18,7 @@
2318
import org.objectweb.asm.tree.ClassNode;
2419

2520
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
26-
import the.bytecode.club.bytecodeviewer.JarUtils;
2721
import the.bytecode.club.bytecodeviewer.MiscUtils;
28-
import the.bytecode.club.bytecodeviewer.ZipUtils;
2922
import jd.cli.printer.text.PlainTextPrinter;
3023

3124
/**

0 commit comments

Comments
 (0)