flat assembler
Message board for the users of flat assembler.

Index > Windows > encryptXOR

Author
Thread Post new topic Reply to topic
jochenvnltn



Joined: 15 Jul 2011
Posts: 96
jochenvnltn 27 Jul 2012, 01:34
Hello everyone,

I found an XOR encryption proc, but i can't get it to work..
Can someone please show me what is causing the error ?

Im still learning...

format pe GUI 4.0


include 'win32ax.inc'

section '.data' data readable writeable

Text db 'Unencrypted',0
Size = $ - Text
Key db '1234',0

section '.code' code readable executable

start:
invoke encryptXOR, Text,Size,Key
invoke MessageBoxA,0,Text,'test',0

exit:
invoke ExitProcess,0
.end start

;xor encryption
proc encryptXOR stdcall data_ptr:DWORD, data_size:DWORD, key_ptr:DWORD

local key_counter:DWORD

pushad
mov [key_counter],0
mov edi,[data_ptr]
encxor_loop:
;get key, data and xor it
mov eax,[key_ptr]
add eax,[key_counter]
mov bl,byte [eax]
mov bh,byte [edi]
xor bh,bl
mov [edi],bh
;increase counter variables
mov eax,[key_counter]
inc eax
cmp eax,KEY_SIZE
jne encxor_noreset_keycounter
sub eax,eax
encxor_noreset_keycounter:
mov [key_counter],eax
;increase data ptr
mov eax,[data_size]
dec eax
jz encxor_exit
mov [data_size],eax
inc edi
jmp encxor_loop

encxor_exit:
popad
ret
endp
Post 27 Jul 2012, 01:34
View user's profile Send private message MSN Messenger Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode 27 Jul 2012, 01:56
jochenvnltn wrote:
...what is causing the error ?
- invoke macro is generally for API like MessageBoxA.
- KEY_SIZE is not defined. presumably being 4 ?
Code:
  KEY_SIZE = 4
  stdcall encryptXOR, Text,Size,Key   <---- 
  invoke MessageBoxA,0,Text,'test',0
; ...
  cmp eax,KEY_SIZE  <--- 
; ...     
Cheers,

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 27 Jul 2012, 01:56
View user's profile Send private message Visit poster's website Reply with quote
jochenvnltn



Joined: 15 Jul 2011
Posts: 96
jochenvnltn 27 Jul 2012, 03:13
hopcode wrote:
jochenvnltn wrote:
...what is causing the error ?
- invoke macro is generally for API like MessageBoxA.
- KEY_SIZE is not defined. presumably being 4 ?
Code:
  KEY_SIZE = 4
  stdcall encryptXOR, Text,Size,Key   <---- 
  invoke MessageBoxA,0,Text,'test',0
; ...
  cmp eax,KEY_SIZE  <--- 
; ...     
Cheers,


Work's now ! thanks Wink
Post 27 Jul 2012, 03:13
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.