private static void usage(Options options) { HelpFormatter formatter = new HelpFormatter(); int consoleWidth = ConsoleUtil.getConsoleWidth(); if (consoleWidth <= 0) { consoleWidth = 80; } formatter.setWidth(consoleWidth); formatter.printHelp("java -jar simplify.jar <input> [options]", "deobfuscates a dalvik executable", options, ""); }
private static int attemptStty() { String output = attemptCommand(new String[]{"sh", "-c", "stty size < /dev/tty"}); if (output == null) { return 80; } String[] vals = output.split(" "); if (vals.length < 2) { return 80; } return Integer.parseInt(vals[1]); }
/** * Attempt to find the width of the console. If it can't get the width, return a default of 80 * @return */ public static int getConsoleWidth() { if (System.getProperty("os.name").toLowerCase().contains("windows")) { try { return attemptMode(); } catch (Exception ex) { } } else { try { return attemptStty(); } catch (Exception ex) { } } return 80; }
/** * Writes an annotated hex dump of the given dex file to output. * * @param dexFile The dex file to dump * @param output An OutputStream to write the annotated hex dump to. The caller is responsible for closing this * when needed. * * @throws IOException */ public static void dump(@Nonnull DexBackedDexFile dexFile, @Nonnull OutputStream output) throws IOException { Writer writer = new BufferedWriter(new OutputStreamWriter(output)); try { int consoleWidth = ConsoleUtil.getConsoleWidth(); if (consoleWidth <= 0) { consoleWidth = 120; } RawDexFile rawDexFile = new RawDexFile(dexFile.getOpcodes(), dexFile); DexAnnotator annotator = new DexAnnotator(rawDexFile, consoleWidth); annotator.writeAnnotations(writer); } finally { writer.close(); } } }
/** * Attempt to find the width of the console. If it can't get the width, return a default of 80 * @return */ public static int getConsoleWidth() { if (System.getProperty("os.name").toLowerCase().contains("windows")) { try { return attemptMode(); } catch (Exception ex) { } } else { try { return attemptStty(); } catch (Exception ex) { } } return 80; }
private static int attemptMode() { String output = attemptCommand(new String[]{"mode", "con"}); if (output == null) { return 80; } Pattern pattern = Pattern.compile("Columns:[ \t]*(\\d+)"); Matcher m = pattern.matcher(output); if (!m.find()) { return 80; } return Integer.parseInt(m.group(1)); }
/** * Prints the usage message. */ private static void usage() { int consoleWidth = ConsoleUtil.getConsoleWidth(); if (consoleWidth <= 0) { consoleWidth = 80; } System.out.println("java -cp baksmali.jar org.jf.dexlib2.analysis.DumpFields -d path/to/framework/jar/files <dex-file>"); }
/** * Attempt to find the width of the console. If it can't get the width, return a default of 80 * @return The current console width */ public static int getConsoleWidth() { if (System.getProperty("os.name").toLowerCase().contains("windows")) { try { return attemptMode(); } catch (Exception ex) { } } else { try { return attemptStty(); } catch (Exception ex) { } } return 80; }
private static int attemptStty() { String output = attemptCommand(new String[]{"sh", "-c", "stty size < /dev/tty"}); if (output == null) { return 80; } String[] vals = output.split(" "); if (vals.length < 2) { return 80; } return Integer.parseInt(vals[1]); }
/** * Prints the usage message. */ private static void usage() { int consoleWidth = ConsoleUtil.getConsoleWidth(); if (consoleWidth <= 0) { consoleWidth = 80; } System.out.println("java -cp baksmali.jar org.jf.dexlib2.analysis.DumpVtables -d path/to/framework/jar/files <dex-file>"); }
private static int attemptStty() { String output = attemptCommand(new String[]{"sh", "-c", "stty size < /dev/tty"}); if (output == null) { return 80; } String[] vals = output.split(" "); if (vals.length < 2) { return 80; } return Integer.parseInt(vals[1]); }
/** * Writes an annotated hex dump of the given dex file to output. * * @param dexFile The dex file to dump * @param output An OutputStream to write the annotated hex dump to. The caller is responsible for closing this * when needed. * * @throws IOException */ public static void dump(@Nonnull DexBackedDexFile dexFile, @Nonnull OutputStream output) throws IOException { Writer writer = new BufferedWriter(new OutputStreamWriter(output)); try { int consoleWidth = ConsoleUtil.getConsoleWidth(); if (consoleWidth <= 0) { consoleWidth = 120; } RawDexFile rawDexFile = new RawDexFile(dexFile.getOpcodes(), dexFile); DexAnnotator annotator = new DexAnnotator(rawDexFile, consoleWidth); annotator.writeAnnotations(writer); } finally { writer.close(); } } }
private static int attemptMode() { String output = attemptCommand(new String[]{"mode", "con"}); if (output == null) { return 80; } Pattern pattern = Pattern.compile("Columns:[ \t]*(\\d+)"); Matcher m = pattern.matcher(output); if (!m.find()) { return 80; } return Integer.parseInt(m.group(1)); }
public void usage() { System.out.println(new HelpFormatter() .width(ConsoleUtil.getConsoleWidth()) .format(getCommandHierarchy())); }
private static int attemptMode() { String output = attemptCommand(new String[]{"mode", "con"}); if (output == null) { return 80; } Pattern pattern = Pattern.compile("Columns:[ \t]*(\\d+)"); Matcher m = pattern.matcher(output); if (!m.find()) { return 80; } return Integer.parseInt(m.group(1)); }
writer = new BufferedWriter(new FileWriter(dumpFileName)); int consoleWidth = ConsoleUtil.getConsoleWidth(); if (consoleWidth <= 0) { consoleWidth = 120;
"Warning: You are disassembling an odex/oat file without deodexing it. You won't be able to " + "re-assemble the results unless you deodex it. See \"baksmali help deodex\"", ConsoleUtil.getConsoleWidth());
/** * Prints the usage message. */ private static void usage(boolean printDebugOptions) { SmaliHelpFormatter formatter = new SmaliHelpFormatter(); int consoleWidth = ConsoleUtil.getConsoleWidth(); if (consoleWidth <= 0) { consoleWidth = 80; } formatter.setWidth(consoleWidth); formatter.printHelp("java -jar smali.jar [options] [--] [<smali-file>|folder]*", "assembles a set of smali files into a dex file", basicOptions, printDebugOptions?debugOptions:null); }
"Warning: You are disassembling an odex/oat file without deodexing it. You won't be able to " + "re-assemble the results unless you deodex it. See \"baksmali help deodex\"", ConsoleUtil.getConsoleWidth());
/** * Prints the usage message. */ private static void usage(boolean printDebugOptions) { SmaliHelpFormatter formatter = new SmaliHelpFormatter(); int consoleWidth = ConsoleUtil.getConsoleWidth(); if (consoleWidth <= 0) { consoleWidth = 80; } formatter.setWidth(consoleWidth); formatter.printHelp("java -jar baksmali.jar [options] <dex-file>", "disassembles and/or dumps a dex file", basicOptions, printDebugOptions?debugOptions:null); }