Syntax Cleanup
This commit is contained in:
parent
406b47bf8c
commit
fb075c884b
|
@ -42,7 +42,12 @@ public class APKTool
|
||||||
|
|
||||||
File tempAPKPath = new File(TEMP_DIRECTORY + FS + MiscUtils.randomString(12));
|
File tempAPKPath = new File(TEMP_DIRECTORY + FS + MiscUtils.randomString(12));
|
||||||
tempAPKPath.mkdirs();
|
tempAPKPath.mkdirs();
|
||||||
brut.apktool.Main.main(new String[]{"r", "--frame-path", tempAPKPath.getAbsolutePath(), "d", input.getAbsolutePath(), "-o", dir.getAbsolutePath(), "-f"});
|
|
||||||
|
brut.apktool.Main.main(new String[]{"r",
|
||||||
|
"--frame-path", tempAPKPath.getAbsolutePath(),
|
||||||
|
"d", input.getAbsolutePath(),
|
||||||
|
"-o", dir.getAbsolutePath(),
|
||||||
|
"-f"});
|
||||||
|
|
||||||
File zip = new File(TEMP_DIRECTORY + FS + MiscUtils.randomString(12) + ".zip");
|
File zip = new File(TEMP_DIRECTORY + FS + MiscUtils.randomString(12) + ".zip");
|
||||||
ZipUtils.zipFolderAPKTool(dir.getAbsolutePath(), zip.getAbsolutePath());
|
ZipUtils.zipFolderAPKTool(dir.getAbsolutePath(), zip.getAbsolutePath());
|
||||||
|
@ -65,7 +70,6 @@ public class APKTool
|
||||||
File tempDir = new File(temp + FS + MiscUtils.getRandomizedName() + FS);
|
File tempDir = new File(temp + FS + MiscUtils.getRandomizedName() + FS);
|
||||||
tempDir.mkdirs();
|
tempDir.mkdirs();
|
||||||
|
|
||||||
|
|
||||||
File tempAPKPath = new File(TEMP_DIRECTORY + FS + MiscUtils.randomString(12));
|
File tempAPKPath = new File(TEMP_DIRECTORY + FS + MiscUtils.randomString(12));
|
||||||
tempAPKPath.mkdirs();
|
tempAPKPath.mkdirs();
|
||||||
|
|
||||||
|
@ -74,10 +78,13 @@ public class APKTool
|
||||||
File smaliFolder = new File(container.APKToolContents.getAbsolutePath() + FS + "smali");
|
File smaliFolder = new File(container.APKToolContents.getAbsolutePath() + FS + "smali");
|
||||||
FileUtils.deleteDirectory(smaliFolder);
|
FileUtils.deleteDirectory(smaliFolder);
|
||||||
|
|
||||||
|
|
||||||
//save entire jar as smali files
|
//save entire jar as smali files
|
||||||
System.out.println("Building!");
|
System.out.println("Building!");
|
||||||
brut.apktool.Main.main(new String[]{"b", container.APKToolContents.getAbsolutePath(), "--frame-path", tempAPKPath.getAbsolutePath(), "-o", output.getAbsolutePath()});
|
brut.apktool.Main.main(new String[]{"b", container.APKToolContents.getAbsolutePath(),
|
||||||
|
"--frame-path", tempAPKPath.getAbsolutePath(),
|
||||||
|
"-o", output.getAbsolutePath()});
|
||||||
|
|
||||||
|
//cleanup
|
||||||
tempAPKPath.delete();
|
tempAPKPath.delete();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -63,6 +63,7 @@ public class BootCheck implements Runnable
|
||||||
{
|
{
|
||||||
File libsDir = Boot.libsDir();
|
File libsDir = Boot.libsDir();
|
||||||
File[] listFiles = libsDir.listFiles();
|
File[] listFiles = libsDir.listFiles();
|
||||||
|
List<String> libsFileList = new ArrayList<>();
|
||||||
|
|
||||||
//first boot failed to download libraries
|
//first boot failed to download libraries
|
||||||
if (listFiles == null || listFiles.length <= 0)
|
if (listFiles == null || listFiles.length <= 0)
|
||||||
|
@ -74,7 +75,6 @@ public class BootCheck implements Runnable
|
||||||
Boot.setState("Bytecode Viewer Boot Screen (OFFLINE MODE) - Unable to connect to github, force booting...");
|
Boot.setState("Bytecode Viewer Boot Screen (OFFLINE MODE) - Unable to connect to github, force booting...");
|
||||||
System.out.println("Unable to connect to github, force booting...");
|
System.out.println("Unable to connect to github, force booting...");
|
||||||
|
|
||||||
List<String> libsFileList = new ArrayList<>();
|
|
||||||
for (File f : listFiles)
|
for (File f : listFiles)
|
||||||
libsFileList.add(f.getAbsolutePath());
|
libsFileList.add(f.getAbsolutePath());
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ public class BootCheck implements Runnable
|
||||||
if (s.endsWith(".jar"))
|
if (s.endsWith(".jar"))
|
||||||
{
|
{
|
||||||
File f = new File(s);
|
File f = new File(s);
|
||||||
|
|
||||||
if (f.exists())
|
if (f.exists())
|
||||||
{
|
{
|
||||||
Boot.setState("Bytecode Viewer Boot Screen (OFFLINE MODE) - Force Loading Library " + f.getName());
|
Boot.setState("Bytecode Viewer Boot Screen (OFFLINE MODE) - Force Loading Library " + f.getName());
|
||||||
|
|
|
@ -34,7 +34,8 @@ public class ClassFileUtils
|
||||||
*/
|
*/
|
||||||
public static byte[] getClassFileBytes(Class<?> clazz) throws IOException
|
public static byte[] getClassFileBytes(Class<?> clazz) throws IOException
|
||||||
{
|
{
|
||||||
try (InputStream is = clazz.getResourceAsStream("/" + clazz.getName().replace('.', '/') + ".class"); ByteArrayOutputStream baos = new ByteArrayOutputStream())
|
try (InputStream is = clazz.getResourceAsStream("/" + clazz.getName().replace('.', '/') + ".class");
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream())
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
|
|
|
@ -48,7 +48,9 @@ public class Dex2Jar
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dex2jar d2Jar = Dex2jar.from(input).computeFrames(true).withExceptionHandler(new DexExceptionHandler()
|
Dex2jar d2Jar = Dex2jar.from(input)
|
||||||
|
.computeFrames(true)
|
||||||
|
.withExceptionHandler(new DexExceptionHandler()
|
||||||
{
|
{
|
||||||
public void handleFileException(Exception e)
|
public void handleFileException(Exception e)
|
||||||
{
|
{
|
||||||
|
@ -60,6 +62,7 @@ public class Dex2Jar
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
d2Jar.to(output.toPath());
|
d2Jar.to(output.toPath());
|
||||||
}
|
}
|
||||||
catch (DexException e)
|
catch (DexException e)
|
||||||
|
@ -87,7 +90,10 @@ public class Dex2Jar
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Jar2Dex.main(input.getAbsolutePath(), "-f", "-o", output.getAbsolutePath(), "-s", BytecodeViewer.viewer.getMinSdkVersion() + "");
|
Jar2Dex.main(input.getAbsolutePath(), "-f",
|
||||||
|
"-o", output.getAbsolutePath(),
|
||||||
|
"-s", String.valueOf(BytecodeViewer.viewer.getMinSdkVersion()));
|
||||||
|
|
||||||
if (delete)
|
if (delete)
|
||||||
input.delete();
|
input.delete();
|
||||||
}
|
}
|
||||||
|
@ -96,5 +102,4 @@ public class Dex2Jar
|
||||||
BytecodeViewer.handleException(e);
|
BytecodeViewer.handleException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,6 @@ public class DialogUtils
|
||||||
int returnVal = fc.showOpenDialog(BytecodeViewer.viewer);
|
int returnVal = fc.showOpenDialog(BytecodeViewer.viewer);
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||||
{
|
{
|
||||||
|
|
||||||
File file = fc.getSelectedFile();
|
File file = fc.getSelectedFile();
|
||||||
onOpen.onOpen(file);
|
onOpen.onOpen(file);
|
||||||
return file;
|
return file;
|
||||||
|
|
|
@ -45,14 +45,17 @@ public class EncodeUtils
|
||||||
{
|
{
|
||||||
out.append("\\u");
|
out.append("\\u");
|
||||||
String str = Integer.toHexString(bytes[i + 1] & 0xff);
|
String str = Integer.toHexString(bytes[i + 1] & 0xff);
|
||||||
|
|
||||||
for (int j = str.length(); j < 2; j++)
|
for (int j = str.length(); j < 2; j++)
|
||||||
{
|
{
|
||||||
out.append("0");
|
out.append("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
String str1 = Integer.toHexString(bytes[i] & 0xff);
|
String str1 = Integer.toHexString(bytes[i] & 0xff);
|
||||||
out.append(str1);
|
out.append(str1);
|
||||||
out.append(str);
|
out.append(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return out.toString();
|
return out.toString();
|
||||||
}
|
}
|
||||||
catch (UnsupportedEncodingException e)
|
catch (UnsupportedEncodingException e)
|
||||||
|
@ -68,6 +71,7 @@ public class EncodeUtils
|
||||||
Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))");
|
Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))");
|
||||||
Matcher matcher = pattern.matcher(str);
|
Matcher matcher = pattern.matcher(str);
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
while (matcher.find())
|
while (matcher.find())
|
||||||
{
|
{
|
||||||
String group = matcher.group(2);
|
String group = matcher.group(2);
|
||||||
|
@ -75,15 +79,15 @@ public class EncodeUtils
|
||||||
String group1 = matcher.group(1);
|
String group1 = matcher.group(1);
|
||||||
str = str.replace(group1, ch + "");
|
str = str.replace(group1, ch + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String convertStringToUTF8(String s)
|
public static String convertStringToUTF8(String s)
|
||||||
{
|
{
|
||||||
if (s == null || StringUtils.EMPTY.equals(s))
|
if (s == null || StringUtils.EMPTY.equals(s))
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -91,14 +95,13 @@ public class EncodeUtils
|
||||||
for (int i = 0; i < s.length(); i++)
|
for (int i = 0; i < s.length(); i++)
|
||||||
{
|
{
|
||||||
c = s.charAt(i);
|
c = s.charAt(i);
|
||||||
|
|
||||||
if (c <= 255)
|
if (c <= 255)
|
||||||
{
|
|
||||||
sb.append(c);
|
sb.append(c);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
byte[] b;
|
byte[] b = Character.toString(c).getBytes(StandardCharsets.UTF_8);
|
||||||
b = Character.toString(c).getBytes(StandardCharsets.UTF_8);
|
|
||||||
for (int value : b)
|
for (int value : b)
|
||||||
{
|
{
|
||||||
int k = value;
|
int k = value;
|
||||||
|
@ -112,19 +115,21 @@ public class EncodeUtils
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String convertUTF8ToString(String s)
|
public static String convertUTF8ToString(String s)
|
||||||
{
|
{
|
||||||
if (s == null || StringUtils.EMPTY.equals(s))
|
if (s == null || StringUtils.EMPTY.equals(s))
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
s = s.toUpperCase();
|
s = s.toUpperCase();
|
||||||
|
|
||||||
int total = s.length() / 2;
|
int total = s.length() / 2;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
byte[] buffer = new byte[total];
|
byte[] buffer = new byte[total];
|
||||||
|
|
||||||
for (int i = 0; i < total; i++)
|
for (int i = 0; i < total; i++)
|
||||||
{
|
{
|
||||||
int start = i * 2;
|
int start = i * 2;
|
||||||
|
|
|
@ -72,9 +72,7 @@ public class JTextAreaUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentLine == startLine)
|
if (currentLine == startLine)
|
||||||
{
|
|
||||||
canSearch = true;
|
canSearch = true;
|
||||||
}
|
|
||||||
else if (s.contains(search))
|
else if (s.contains(search))
|
||||||
{
|
{
|
||||||
if (canSearch)
|
if (canSearch)
|
||||||
|
@ -93,13 +91,12 @@ public class JTextAreaUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found && firstPos != -1)
|
if (!found && firstPos != -1)
|
||||||
{
|
|
||||||
textArea.setCaretPosition(textArea.getDocument().getDefaultRootElement().getElement(firstPos - 1).getStartOffset());
|
textArea.setCaretPosition(textArea.getDocument().getDefaultRootElement().getElement(firstPos - 1).getStartOffset());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
canSearch = true;
|
canSearch = true;
|
||||||
|
|
||||||
for (String s : test)
|
for (String s : test)
|
||||||
{
|
{
|
||||||
if (!caseSensitiveSearch)
|
if (!caseSensitiveSearch)
|
||||||
|
@ -123,10 +120,8 @@ public class JTextAreaUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastGoodLine != -1 && textArea.getDocument().getDefaultRootElement().getElementIndex(textArea.getCaretPosition()) + 1 == startLine)
|
if (lastGoodLine != -1 && textArea.getDocument().getDefaultRootElement().getElementIndex(textArea.getCaretPosition()) + 1 == startLine)
|
||||||
{
|
|
||||||
textArea.setCaretPosition(textArea.getDocument().getDefaultRootElement().getElement(lastGoodLine - 1).getStartOffset());
|
textArea.setCaretPosition(textArea.getDocument().getDefaultRootElement().getElement(lastGoodLine - 1).getStartOffset());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
highlight(textArea, search, caseSensitiveSearch);
|
highlight(textArea, search, caseSensitiveSearch);
|
||||||
}
|
}
|
||||||
|
@ -161,8 +156,7 @@ public class JTextAreaUtils
|
||||||
// Search for pattern
|
// Search for pattern
|
||||||
while ((pos = text.indexOf(pattern, pos)) >= 0)
|
while ((pos = text.indexOf(pattern, pos)) >= 0)
|
||||||
{
|
{
|
||||||
// Create highlighter using private painter and apply around
|
// Create highlighter using private painter and apply around pattern
|
||||||
// pattern
|
|
||||||
highlighter.addHighlight(pos, pos + pattern.length(), PAINTER);
|
highlighter.addHighlight(pos, pos + pattern.length(), PAINTER);
|
||||||
pos += pattern.length();
|
pos += pattern.length();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,9 +51,7 @@ public class LazyNameUtil
|
||||||
return FilenameUtils.removeExtension(name) + "#" + seqAndCount.getSeq() + "." + FilenameUtils.getExtension(name);
|
return FilenameUtils.removeExtension(name) + "#" + seqAndCount.getSeq() + "." + FilenameUtils.getExtension(name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
NAME_MAP.put(name, SeqAndCount.init());
|
NAME_MAP.put(name, SeqAndCount.init());
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user