[FASM] Ascii85 decode

Iniciado por Karcrack, Junio 16, 2013, 06:13:38 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Código: asm
include 'win32ax.inc'
entry main

section '.code' executable writeable readable
main:
        mov  esi, _enc
        mov  edi, esi
.m:     push 5
        pop  ecx
        xor  edx, edx
@@:     imul edx, 85
        xor  eax, eax
        lodsb
        sub  al, 33
        jl   @F
        add  edx, eax
        loop @B
        bswap edx
        mov  eax, edx
        stosd
        jmp  .m
@@:_enc:db "OH>QcOH>QcOH>QcOH>QcOH>QcOH>QcOH>QcOH>QcOH>QcOH>QcOH>QcOH>QcOH>QcOH?t2'*&$M",0   


Básicamente decodifica la cadena Ascii85 (AKA base85) y la ejecuta. Para generar la cadena en base85 uso este script en Python:
Código: python
import struct

def b85encode(arr):
    text = ''.join(map(chr,arr))
    l = len(text)
    r = l % 4
    if r:
        text += '\0' * (4 - r)
    longs = len(text) >> 2
    out = []
    words = struct.unpack('>' + 'L' * longs, text[0:longs*4])
    for word in words:
        rems = [0, 0, 0, 0, 0]
        for i in range(4, -1, -1):
            rems[i] = chr((word % 85)+33)
            word /= 85
        out.extend(rems)

    return ''.join(out)

print b85encode([0x90]*54 + [0xB8, 0x37, 0x13, 0x00, 0x00, 0xC3])


saludos
I code for $$$.

(PGP ID 0xCC050E77)
ASM, C, C++, VB6... skilled [malware] developer