2024-05-03 10:00:17 +00:00
|
|
|
format COFF
|
|
|
|
use32
|
|
|
|
|
|
|
|
section '.text' code
|
|
|
|
|
|
|
|
;; Function: rc4_init
|
|
|
|
;;
|
|
|
|
;; Parameters:
|
|
|
|
;;
|
|
|
|
;; [esp+8] - state
|
|
|
|
;; [esp+12] - key
|
|
|
|
;; [esp+16] - key length
|
|
|
|
;;
|
|
|
|
rc4_init:
|
|
|
|
push ebp
|
|
|
|
mov ebp, esp
|
|
|
|
|
|
|
|
mov eax, [ebp+8]
|
2024-07-14 13:11:28 +00:00
|
|
|
xor cx, cx
|
2024-05-03 10:00:17 +00:00
|
|
|
|
2024-07-14 13:11:28 +00:00
|
|
|
@@:
|
|
|
|
mov byte [eax], byte cx
|
|
|
|
inc cx
|
|
|
|
inc eax
|
|
|
|
cmp cx, 255
|
|
|
|
jne @b
|
|
|
|
|
|
|
|
xor cx, cx
|
|
|
|
mov eax, [ebp+8]
|
|
|
|
@@:
|
2024-05-03 10:00:17 +00:00
|
|
|
|
2024-07-14 13:11:28 +00:00
|
|
|
|
|
|
|
|
2024-05-03 10:00:17 +00:00
|
|
|
.end:
|
|
|
|
leave
|
|
|
|
ret
|
|
|
|
|
|
|
|
;; Function: rc4
|
|
|
|
;;
|
|
|
|
;; Parameters:
|
|
|
|
;;
|
|
|
|
;; [esp+8] - state
|
|
|
|
;; [esp+12] - out buffer
|
|
|
|
;; [esp+16] - input buffer
|
|
|
|
;; [esp+20] - intput buffer size
|
|
|
|
rc4:
|
|
|
|
push ebp
|
|
|
|
mov ebp, esp
|
|
|
|
|
|
|
|
push esi
|
|
|
|
push edi
|
|
|
|
push ebx
|
|
|
|
|
|
|
|
xor esi, esi
|
|
|
|
xor edi, edi
|
|
|
|
xor ecx, ecx
|
|
|
|
|
|
|
|
.loop:
|
|
|
|
cmp ecx, [esp+20]
|
|
|
|
je .end
|
|
|
|
|
|
|
|
inc esi
|
|
|
|
mov eax, esi
|
|
|
|
movzx esi, al
|
|
|
|
|
|
|
|
add edi, esi
|
|
|
|
mov eax, edi
|
|
|
|
movzx edi, al
|
|
|
|
|
|
|
|
mov edx, [esp+8]
|
|
|
|
|
|
|
|
mov al, byte [edx+esi]
|
|
|
|
mov bl, byte [edx+edi]
|
|
|
|
|
|
|
|
mov byte [edx+esi], bl
|
|
|
|
mov byte [edx+edi], al
|
|
|
|
|
|
|
|
inc ecx
|
|
|
|
jmp .loop
|
|
|
|
.end:
|
|
|
|
|
|
|
|
pop ebx
|
|
|
|
pop edi
|
|
|
|
pop esi
|
|
|
|
|
|
|
|
leave
|
|
|
|
ret
|