Skip to content

Bulk pack with Eronana's Packer

Alex edited this page Oct 1, 2022 · 1 revision

Here is the script that was used to generate the Amber samples using CLI automation:

#!/usr/bin/python3
from tinyscript import *

if __name__ == '__main__':
    initialize()
    l = [f for f in ts.Path("dataset-packed-pe", "not-packed").listdir()]
    random.shuffle(l)
    for i in range(145):
        f = l[i]
        h = hashlib.sha256_file(str(f))
        out, err = ts.execute("eronana-packer '%s'" % f)
        logger.debug(f)
        packed = f.dirname.joinpath(f.stem + ".packed" + f.extension)
        try:
            if b"[!]" in out or h == hashlib.sha256_file(str(packed)):
                logger.warning("Packing of %s failed" % f)
                packed.remove()
            else:
                packed.rename(f.dirname.parent.joinpath("packed", "Eronana Packer", "eronana_" + f.filename))
        except FileNotFoundError:
            continue