Exemple #1
0
def aplib_compdecsingle(data):
    import aplib
    c = aplib.compress(data)
    compressed = c.do()
    d = aplib.decompress(compressed)
    decompressed , consumed = d.do()
    return compressed, decompressed
# Minimalist compressor

import mypacklib, pefile
from aplib import compress, decompress

pe, oep, ib, start, size = mypacklib.load()

# read the first section
sect = pe.get_data(start)
# compress it
compressed_data = compress(sect).do()

# blank the original uncompressed data
pe.set_bytes_at_rva(start, "\x00" * size)

# we will inject our code and compressed data at the end of the last section
section = pe.sections[-1]
start, size = section.VirtualAddress, section.SizeOfRawData

my_stub = """
bits 32
section .text valign=1 vstart=0%(start_va)08xh
; http://www.ibsensoftware.com/files/aPLib-1.01.zip, /src/32bit/depack.asm
    mov    esi, compressed_data
    mov    edi, 0%(oep_va)08xh

    cld
    mov    dl, 80h
    xor    ebx,ebx

literal:
# Minimalist compressor

import mypacklib, pefile
from aplib import compress, decompress

pe, oep, ib, start, size = mypacklib.load()


# read the first section
sect = pe.get_data(start)
# compress it
compressed_data = compress(sect).do()

# blank the original uncompressed data
pe.set_bytes_at_rva(start, "\x00" * size)

# we will inject our code and compressed data at the end of the last section
section = pe.sections[-1]
start, size = section.VirtualAddress, section.SizeOfRawData

my_stub = """
bits 32
section .text valign=1 vstart=0%(start_va)08xh
; http://www.ibsensoftware.com/files/aPLib-1.01.zip, /src/32bit/depack.asm
    mov    esi, compressed_data
    mov    edi, 0%(oep_va)08xh

    cld
    mov    dl, 80h
    xor    ebx,ebx