Skip to content

Instantly share code, notes, and snippets.

@Maroc-OS
Forked from iamgreaser/gist:13989113cc9fc1e7c0ac
Created January 19, 2016 01:44
Show Gist options
  • Select an option

  • Save Maroc-OS/cdab9c863564919b169d to your computer and use it in GitHub Desktop.

Select an option

Save Maroc-OS/cdab9c863564919b169d to your computer and use it in GitHub Desktop.

Revisions

  1. @iamgreaser iamgreaser created this gist Aug 31, 2014.
    28 changes: 28 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    /* void rc4_apply(char *stream, int len, char *rc4buf); */
    rc4_apply:
    push {r4, r5, r6, lr}

    mov r3, #0
    mov r4, #0

    lp_rc4:
    add r3, r3, #1
    and r3, r3, #0xFF
    ldrb r5, [r2, r3]

    add r4, r4, r5
    and r4, r4, #0xFF
    ldrb r6, [r2, r4]
    strb r6, [r2, r3]
    strb r5, [r2, r4]

    add r5, r5, r6
    and r5, r5, #0xFF
    ldrb r6, [r0, r5]
    eor r6, r6, r5
    strb r6, [r0], #1

    subs r1, r1, #1
    bne lp_rc4

    pop {r4, r5, r6, pc}
    30 changes: 30 additions & 0 deletions gistfile2.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    /* void rc4_apply(char *stream, int len, char *rc4buf); */
    rc4_apply:
    push esi
    push edi
    push ebx

    mov edi, [esp + 0x04]
    mov ecx, [esp + 0x08]
    mov esi, [esp + 0x0C]

    xor eax, eax
    xor edx, edx

    lp_rc4:
    inc al
    mov bl, [esi+eax]
    add dl, bl
    mov bh, bl
    xchg [esi+eax], bl
    mov [esi+edx], bl
    add bh, bl
    xor [edi], bh
    inc edi
    loop lp_rc4

    pop ebx
    pop edi
    pop esi
    ret