• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

ASM FASM base64 encode

Status
Not open for further replies.

DDoSer

The Real DDoSer
User
Joined
Oct 9, 2013
Messages
352
Reputation
0
Reaction score
4,578
Points
243
Credits
0
‎11 Years of Service‎
51%
[HIDE-THANKS]

Code:
>format   PE GUI 4.0
 entry    start
 include  'win32a.inc'

 section  '.text' code executable readable

 start:

        lea        ebx,[base64log]
        lea        eax,[text]
        mov        [pszlog],eax
        invoke     lstrlen,[pszlog]
        stdcall    Base64Encode,dword [pszlog],ebx,eax
        invoke     MessageBoxA,0,base64log,0,0
        ret

;--------------------------------------------------
; [base64Encode]
;--------------------------------------------------

  proc Base64Encode lpSrc,lpDst,dwstrlen
          push       esi edi edx ebx

          mov        esi,[lpSrc]
          mov        edi,[lpDst]
          mov        ebx,dword [dwstrlen]
          call       b64.encode

          pop        ebx edx edi esi
          ret        
  endp    

; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; base64 encoder without dictionary by RT Fishel
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  b64:       
    .newline:  
          call       b64.store_crlf

    .encode:   ; ebp = length, esi -> src buffer, edi -> dst buffer
          push       (76 shr 2) + 1
          pop        edx

    .outer:    
          dec        edx
          je         b64.newline
          lodsd      
          dec        esi
          inc        ebx
          bswap      eax
          mov        ecx,4

    .inner:    
          rol        eax,6
          and        al,3Fh
          cmp        al,3Eh
          jb         b64.testchar
          shl        al,2
          sub        al,((3Eh shl 2)+'A'-'+') and 0FFh

    .testchar: 
          sub        al,4
          cmp        al,'0'
          jnl        b64.store
          add        al,'A'+4
          cmp        al,'Z'
          jbe        b64.store
          add        al,'a'-'Z'-1

    .store:    
          stosb      
          dec        ebx
          loopne     b64.inner
          jne        b64.outer
          mov        al,'='
          rep        stosb
          xor        al,al
          stosb      
          ret        

    .store_crlf: 
          mov        ax,0a0dh
          stosw      

          ret        

 section  '.data' data writeable readable

          text                 db '1234',0
          pszlog               dd ?
          base64log            db 200 dup (?)

 section  '.idata' import data readable

 library  kernel32,'KERNEL32.DLL',\
          user32,  'USER32.DLL'

  include 'api/kernel32.inc'
  include 'api/user32.inc'
[/HIDE-THANKS]

 
Status
Not open for further replies.
Back
Top