The Bytecode Club - Reverse Engineering Forum
ASM Save ArrayList ClassNode as Zip File - Printable Version

+- The Bytecode Club - Reverse Engineering Forum (https://the.bytecode.club)
+-- Forum: Lobby (https://the.bytecode.club/forumdisplay.php?fid=1)
+--- Forum: Programming (https://the.bytecode.club/forumdisplay.php?fid=86)
+--- Thread: ASM Save ArrayList ClassNode as Zip File (/showthread.php?tid=99)



ASM Save ArrayList ClassNode as Zip File - Konloch - 10-11-2014

Code:
    public static void saveAsJar(ArrayList<ClassNode> nodeList, String fileName) {
        try {
            JarOutputStream out = new JarOutputStream(new FileOutputStream(fileName));
            for (ClassNode cn : nodeList) {
                ClassWriter cw = new ClassWriter(0);
                cn.accept(cw);
                
                out.putNextEntry(new ZipEntry(cn.name + ".class"));
                out.write(cw.toByteArray());
                out.closeEntry();
            }
            
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }



RE: ASM Save ArrayList ClassNode as Zip File - Bibl - 10-12-2014

https://bitbucket.org/0xJAVA/byte-engineer/src


RE: ASM Save ArrayList ClassNode as Zip File - Konloch - 10-12-2014

(10-12-2014, 09:28 AM)Bibl Wrote:  https://bitbucket.org/0xJAVA/byte-engineer/src

Looks sexy, I'll have to take a better look at this later.

Is there any documentation on it?


RE: ASM Save ArrayList ClassNode as Zip File - Bibl - 10-12-2014

(10-12-2014, 09:55 AM)konloch Wrote:  
(10-12-2014, 09:28 AM)Bibl Wrote:  https://bitbucket.org/0xJAVA/byte-engineer/src

Looks sexy, I'll have to take a better look at this later.

Is there any documentation on it?

not really its not even done but when I need stuff I just add


RE: ASM Save ArrayList ClassNode as Zip File - Konloch - 10-12-2014

(10-12-2014, 09:58 AM)Bibl Wrote:  
(10-12-2014, 09:55 AM)konloch Wrote:  
(10-12-2014, 09:28 AM)Bibl Wrote:  https://bitbucket.org/0xJAVA/byte-engineer/src

Looks sexy, I'll have to take a better look at this later.

Is there any documentation on it?

not really its not even done but when I need stuff I just add

Interesting project non-the-less, favorited it for later.

What tools does it feature atm?


RE: ASM Save ArrayList ClassNode as Zip File - Bibl - 10-12-2014

load jars from file or url 
Code:
JarDownloader dl = new JarDownloader(new JarInfo(new File("jar.jar")));
boolean worked = dl.parse();
Map<String, ClassNode> nodes = dl.getContents();
Code:
JarDumper dumper = new JarDumper(contents);
dumper.dump(new File("out.jar"));


Add Analysers, store class, field and method data into HookMaps
A lot of filters

https://bitbucket.org/0xJAVA/byte-engineer/src/e18021ae51bd52f5ad742bcde4d8aac135f78b69/byteanalysis/src/main/java/eu/bibl/banalysis/asm/desc/?at=master

Code:
Refactorer refactorer = new Refactorer(hookMap, contents);
refactorer.run();
changes whole jars class, method and field names based on mapping data.

Code:
InstructionPrinter.consolePrint(methodName);
pretty prints

Code:
InstructionSearcher searcher = new InstructionSearcher(m.instructions, pattern);
boolean match = searcher.search();
List<AbstractInsnNode[]> matchedInsns = searched.getMatches();
find opcode/instruction patterns in code.


RE: ASM Save ArrayList ClassNode as Zip File - Konloch - 10-12-2014

(10-12-2014, 10:21 AM)Bibl Wrote:  load jars from file or url 

Code:
JarDownloader dl = new JarDownloader(new JarInfo(new File("jar.jar")));
boolean worked = dl.parse();
Map<String, ClassNode> nodes = dl.getContents();
Code:
JarDumper dumper = new JarDumper(contents);
dumper.dump(new File("out.jar"));


Add Analysers, store class, field and method data into HookMaps
A lot of filters

https://bitbucket.org/0xJAVA/byte-engineer/src/e18021ae51bd52f5ad742bcde4d8aac135f78b69/byteanalysis/src/main/java/eu/bibl/banalysis/asm/desc/?at=master


Code:
Refactorer refactorer = new Refactorer(hookMap, contents);
refactorer.run();
changes whole jars class, method and field names based on mapping data.


Code:
InstructionPrinter.consolePrint(methodName);
pretty prints


Code:
InstructionSearcher searcher = new InstructionSearcher(m.instructions, pattern);
boolean match = searcher.search();
List<AbstractInsnNode[]> matchedInsns = searched.getMatches();
find opcode/instruction patterns in code.

Sexy as fuck, I might start contributing to this once I'm done with Bytecode Viewer.


RE: ASM Save ArrayList ClassNode as Zip File - Explicit - 01-21-2015

Nice, mine differs slightly:

Code:
public static void dumpJar(List<ClassNode> classes, Manifest manifest, String absolutePath) {
   try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(new File(absolutePath)), manifest)) {
       for (ClassNode cn : classes) {
           ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);

           jos.putNextEntry(new JarEntry(cn.name + ".class"));
           cn.accept(writer);
           jos.write(writer.toByteArray());
       }
   } catch (IOException e) {
       e.printStackTrace();
   }
}

Gotta have a manifest to make it runnable xD


RE: ASM Save ArrayList ClassNode as Zip File - Konloch - 01-21-2015

(01-21-2015, 12:31 AM)Swizzbeat Wrote:  Nice, mine differs slightly:

Code:
public static void dumpJar(List<ClassNode> classes, Manifest manifest, String absolutePath) {
   try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(new File(absolutePath)), manifest)) {
       for (ClassNode cn : classes) {
           ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);

           jos.putNextEntry(new JarEntry(cn.name + ".class"));
           cn.accept(writer);
           jos.write(writer.toByteArray());
       }
   } catch (IOException e) {
       e.printStackTrace();
   }
}

Gotta have a manifest to make it runnable xD

Very true! Haha