Function at 0x140051420
Capabilities:
Encrypt data using rc4 ksa

Disassembly:
mov qword [rsp + 0x20], rbx
push rbp
push rsi
push rdi
push r12
push r13
push r14
push r15
sub rsp, 0x80
mov rax, qword [0x1400f6f40]
xor rax, rsp
mov qword [rsp + 0x78], rax
mov rax, qword [rcx + 0xc0]
mov rbx, rcx
mov qword [rsp + 0x48], r8
mov qword [rsp + 0x60], rdx
cmp rax, qword [rcx + 0xc8]
jae 0x140051472
movzx edx, byte [rax]
inc rax
mov qword [rcx + 0xc0], rax
jmp 0x140051495
cmp dword [rcx + 0x30], 0
je 0x140051493
call fcn.140046040
mov rax, qword [rbx + 0xc0]
movzx edx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x140051495
xor dl, dl
mov ecx, 0x30
mov r8, rbx
lea rsi, [rcx + rbx]
movzx ecx, dl
mov dword [rsp + 0x34], ecx
cmp rax, qword [rbx + 0xc8]
jae 0x1400514c4
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
mov byte [rsp + 0x30], cl
jmp 0x1400514f0
cmp dword [rsi], 0
je 0x1400514eb
mov rcx, rbx
call fcn.140046040
mov rax, qword [rbx + 0xc0]
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
mov byte [rsp + 0x30], cl
jmp 0x1400514f0
mov byte [rsp + 0x30], 0
cmp rax, qword [rbx + 0xc8]
jae 0x140051508
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x14005152d
cmp dword [rsi], 0
je 0x14005152b
mov rcx, rbx
call fcn.140046040
mov rax, qword [rbx + 0xc0]
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x14005152d
xor cl, cl
movzx eax, cl
mov rcx, rbx
mov dword [rsp + 0x44], eax
mov ebp, eax
mov dword [rsp + 0x3c], eax
call fcn.140046250
mov rcx, rbx
movsxd r12, eax
call fcn.140046250
mov rcx, qword [rbx + 0xc0]
mov dword [rsp + 0x58], eax
cmp rcx, qword [rbx + 0xc8]
jae 0x140051570
movzx edx, byte [rcx]
inc rcx
mov qword [rbx + 0xc0], rcx
jmp 0x140051595
cmp dword [rsi], 0
je 0x140051593
mov rcx, rbx
call fcn.140046040
mov rax, qword [rbx + 0xc0]
movzx edx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x140051595
xor dl, dl
mov rcx, rbx
movzx edi, dl
call fcn.140046250
mov rcx, rbx
call fcn.140046250
mov rcx, rbx
call fcn.140046250
mov rcx, rbx
mov dword [rsp + 0x40], eax
call fcn.140046250
mov dword [rsp + 0x38], eax
mov rax, qword [rbx + 0xc0]
cmp rax, qword [rbx + 0xc8]
jae 0x1400515df
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x140051604
cmp dword [rsi], 0
je 0x140051602
mov rcx, rbx
call fcn.140046040
mov rax, qword [rbx + 0xc0]
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x140051604
xor cl, cl
movzx edx, cl
mov dword [rsp + 0x6c], edx
cmp rax, qword [rbx + 0xc8]
jae 0x140051623
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x14005164c
cmp dword [rsi], 0
je 0x14005164a
mov rcx, rbx
call fcn.140046040
mov rax, qword [rbx + 0xc0]
mov edx, dword [rsp + 0x6c]
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x14005164c
xor cl, cl
mov esi, dword [rsp + 0x38]
xor r14d, r14d
movzx eax, cl
mov r15d, r14d
mov qword [rsp + 0x50], r14
mov dword [rsp + 0x74], r14d
mov dword [rsp + 0x68], r14d
lea r13d, [r14 + 1]
cmp esi, 0x1000000
jg 0x140051e01
mov r8d, dword [rsp + 0x40]
cmp r8d, 0x1000000
jg 0x140051e01
cmp ebp, 8
jb 0x140051696
sub ebp, 8
mov dword [rsp + 0x3c], ebp
shr eax, 5
mov ecx, r13d
and eax, r13d
mov ebp, r14d
sub ecx, eax
mov dword [rsp + 0x70], ecx
cmp byte [rsp + 0x30], r14b
je 0x1400516d1
mov ecx, edi
sub ecx, 8
je 0x1400516cc
sub ecx, 7
je 0x14005171b
sub ecx, r13d
je 0x14005171b
sub ecx, 8
je 0x1400516ee
cmp ecx, 8
jne 0x1400516f5
jmp 0x1400516ee
mov edi, r13d
jmp 0x1400516f1
mov ecx, edx
sub ecx, 8
je 0x140051725
sub ecx, 7
je 0x14005171b
sub ecx, r13d
je 0x14005170d
sub ecx, 8
je 0x1400516ec
cmp ecx, 8
jne 0x1400516f5
mov edi, edx
shr edi, 3
test edi, edi
jne 0x140051728
mov rax, qword gs:[0x58]
mov rcx, qword [rax]
lea rax, str.bad_format
jmp 0x140051e14
cmp dword [rsp + 0x3c], 3
jne 0x14005171b
mov edi, 2
jmp 0x140051728
mov ebp, r13d
mov edi, 3
jmp 0x140051728
mov edi, r13d
mov rax, qword [rsp + 0x60]
mov dword [rax], r8d
mov rax, qword [rsp + 0x48]
mov dword [rax], esi
test r8d, r8d
js 0x140051e01
test esi, esi
js 0x140051e01
je 0x14005175b
mov eax, 0x7fffffff
cdq
idiv esi
cmp r8d, eax
jg 0x140051e01
mov ecx, esi
imul ecx, r8d
test ecx, ecx
js 0x140051e01
xor edx, edx
mov eax, 0x7fffffff
div edi
cmp ecx, eax
jg 0x140051e01
test esi, esi
je 0x14005178f
mov eax, 0x7fffffff
cdq
idiv esi
cmp r8d, eax
jg 0x140051dec
mov eax, esi
imul eax, edi
imul eax, r8d
movsxd rcx, eax
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_malloc]
mov qword [rsp + 0x48], rax
mov r8, rax
test rax, rax
je 0x140051dec
movsxd rdx, dword [rsp + 0x34]
test edx, edx
je 0x1400517f6
cmp qword [rbx + 0x10], r14
je 0x1400517ef
mov ecx, dword [rbx + 0xc8]
sub ecx, dword [rbx + 0xc0]
cmp ecx, edx
jge 0x1400517ef
mov rax, qword [rbx + 0xc8]
sub edx, ecx
mov rcx, qword [rbx + 0x28]
mov qword [rbx + 0xc0], rax
call qword [rbx + 0x18]
mov r8, qword [rsp + 0x48]
jmp 0x1400517f6
add qword [rbx + 0xc0], rdx
cmp byte [rsp + 0x30], r14b
jne 0x1400518b3
mov edx, dword [rsp + 0x44]
mov r12d, edi
mov dword [rsp + 0x3c], ebp
mov dword [rsp + 0x34], edi
cmp edx, 8
jae 0x140051a67
mov dword [rsp + 0x3c], ebp
mov dword [rsp + 0x34], edi
test ebp, ebp
jne 0x140051a67
mov r13d, ebp
test esi, esi
jle 0x140051d73
mov r15d, edi
imul r15d, dword [rsp + 0x40]
cmp dword [rsp + 0x70], r14d
mov r14d, dword [rsp + 0x38]
je 0x140051885
mov eax, r15d
neg eax
movsxd r12, eax
lea eax, [rsi - 1]
imul eax, edi
imul eax, dword [rsp + 0x40]
movsxd rsi, eax
add rsi, r8
mov r8d, r15d
mov rdx, rsi
mov rcx, rbx
call fcn.1400460c0
add rsi, r12
sub r14, 1
jne 0x140051862
mov esi, dword [rsp + 0x38]
mov r12d, edi
jmp 0x140051d73
movsxd r12, r15d
mov rsi, r8
nop dword [rax + rax]
mov r8d, r15d
mov rdx, rsi
mov rcx, rbx
call fcn.1400460c0
add rsi, r12
sub r14, 1
jne 0x140051890
mov esi, dword [rsp + 0x38]
mov r12d, edi
jmp 0x140051d73
cmp dword [rsp + 0x58], r14d
jne 0x1400518db
mov rcx, r8
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
mov rax, qword gs:[0x58]
mov rcx, qword [rax]
lea rax, str.bad_palette
jmp 0x140051e14
test r12d, r12d
je 0x14005192d
jns 0x1400518f2
mov rax, qword [rbx + 0xc8]
mov qword [rbx + 0xc0], rax
jmp 0x14005192d
cmp qword [rbx + 0x10], r14
je 0x140051926
mov ecx, dword [rbx + 0xc8]
sub ecx, dword [rbx + 0xc0]
cmp ecx, r12d
jge 0x140051926
mov rax, qword [rbx + 0xc8]
sub r12d, ecx
mov rcx, qword [rbx + 0x28]
mov edx, r12d
mov qword [rbx + 0xc0], rax
call qword [rbx + 0x18]
jmp 0x14005192d
add qword [rbx + 0xc0], r12
mov r12d, dword [rsp + 0x58]
test r12d, r12d
js 0x140051de1
xor edx, edx
mov eax, 0x7fffffff
div edi
cmp r12d, eax
jg 0x140051de1
mov esi, edi
imul esi, r12d
movsxd rcx, esi
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_malloc]
mov qword [rsp + 0x50], rax
test rax, rax
je 0x140051de1
mov dword [rsp + 0x3c], ebp
mov dword [rsp + 0x34], edi
test ebp, ebp
je 0x140051a32
mov rsi, rax
test r12d, r12d
jle 0x140051a22
mov eax, edi
mov qword [rsp + 0x60], rax
nop dword [rax]
mov rcx, rbx
call fcn.140046250
movzx r8d, ax
mov eax, r8d
shr eax, 0xa
and eax, 0x1f
imul ecx, eax, 0xff
mov eax, 0x84210843
imul ecx
add edx, ecx
sar edx, 4
mov eax, edx
shr eax, 0x1f
add edx, eax
mov eax, r8d
shr eax, 5
and r8d, 0x1f
and eax, 0x1f
mov byte [rsi], dl
imul ecx, eax, 0xff
mov eax, 0x84210843
imul ecx
add edx, ecx
imul ecx, r8d, 0xff
sar edx, 4
mov eax, edx
shr eax, 0x1f
add edx, eax
mov eax, 0x84210843
mov byte [rsi + 1], dl
imul ecx
add edx, ecx
sar edx, 4
mov eax, edx
shr eax, 0x1f
add edx, eax
mov byte [rsi + 2], dl
add rsi, rdi
sub r12, r13
jne 0x140051990
mov r12d, dword [rsp + 0x34]
mov esi, dword [rsp + 0x38]
mov rdi, qword [rsp + 0x50]
mov edx, dword [rsp + 0x44]
jmp 0x140051a6a
mov esi, dword [rsp + 0x38]
mov r12d, edi
mov edx, dword [rsp + 0x44]
mov rdi, rax
jmp 0x140051a6a
mov r12d, edi
mov r8d, esi
mov rdx, rax
mov rcx, rbx
mov rdi, rax
call fcn.1400460c0
test eax, eax
jne 0x140051a5d
mov rcx, qword [rsp + 0x48]
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
mov rcx, rdi
jmp 0x1400518bd
mov esi, dword [rsp + 0x38]
mov edx, dword [rsp + 0x44]
jmp 0x140051a6a
mov rdi, r14
mov ecx, dword [rsp + 0x40]
mov eax, esi
imul eax, ecx
mov esi, r12d
test eax, eax
je 0x140051ce2
mov rbp, qword [rsp + 0x48]
lea r8, [rsp + 0x74]
sub rbp, r8
movsxd rcx, r12d
mov qword [rsp + 0x60], rax
cmp edx, 8
jb 0x140051b08
test r15d, r15d
jne 0x140051af8
mov rax, qword [rbx + 0xc0]
cmp rax, qword [rbx + 0xc8]
jae 0x140051abc
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x140051ae2
cmp dword [rbx + 0x30], r14d
je 0x140051ae0
mov rcx, rbx
call fcn.140046040
mov rax, qword [rbx + 0xc0]
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x140051ae2
xor cl, cl
movzx eax, cl
mov r15d, eax
and r15d, 0x7f
inc r15d
shr eax, 7
mov dword [rsp + 0x68], eax
jmp 0x140051b08
cmp dword [rsp + 0x68], r14d
je 0x140051b08
test r13d, r13d
je 0x140051c8c
cmp byte [rsp + 0x30], r14b
je 0x140051ba1
cmp dword [rsp + 0x6c], 8
jne 0x140051b6a
mov rax, qword [rbx + 0xc0]
cmp rax, qword [rbx + 0xc8]
jae 0x140051b3c
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
movzx eax, cl
jmp 0x140051b72
cmp dword [rbx + 0x30], r14d
je 0x140051b63
mov rcx, rbx
call fcn.140046040
mov rax, qword [rbx + 0xc0]
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
movzx eax, cl
jmp 0x140051b72
xor cl, cl
movzx eax, cl
jmp 0x140051b72
mov rcx, rbx
call fcn.140046250
test r12d, r12d
je 0x140051c81
cmp eax, dword [rsp + 0x58]
mov ecx, r14d
mov r8, rsi
cmovl ecx, eax
imul ecx, r12d
movsxd rdx, ecx
lea rcx, [rsp + 0x74]
add rdx, rdi
call sub.VCRUNTIME140.dll_memcpy
jmp 0x140051c81
cmp dword [rsp + 0x3c], r14d
je 0x140051c24
mov rcx, rbx
call fcn.140046250
movzx r8d, ax
mov eax, r8d
shr eax, 0xa
and eax, 0x1f
imul ecx, eax, 0xff
mov eax, 0x84210843
imul ecx
add edx, ecx
sar edx, 4
mov eax, edx
shr eax, 0x1f
add edx, eax
mov eax, r8d
shr eax, 5
and r8d, 0x1f
and eax, 0x1f
mov byte [rsp + 0x74], dl
imul ecx, eax, 0xff
mov eax, 0x84210843
imul ecx
add edx, ecx
imul ecx, r8d, 0xff
sar edx, 4
mov eax, edx
shr eax, 0x1f
add edx, eax
mov eax, 0x84210843
mov byte [rsp + 0x75], dl
imul ecx
add edx, ecx
sar edx, 4
mov eax, edx
shr eax, 0x1f
add edx, eax
mov byte [rsp + 0x76], dl
jmp 0x140051c81
mov rdi, r14
test r12d, r12d
je 0x140051c81
nop dword [rax]
mov rax, qword [rbx + 0xc0]
cmp rax, qword [rbx + 0xc8]
jae 0x140051c4f
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x140051c75
cmp dword [rbx + 0x30], r14d
je 0x140051c73
mov rcx, rbx
call fcn.140046040
mov rax, qword [rbx + 0xc0]
movzx ecx, byte [rax]
inc rax
mov qword [rbx + 0xc0], rax
jmp 0x140051c75
xor cl, cl
mov byte [rsp + rdi + 0x74], cl
inc rdi
cmp rdi, rsi
jl 0x140051c30
mov rax, qword [rsp + 0x60]
mov r13d, r14d
movsxd rcx, r12d
mov rdi, r14
test r12d, r12d
je 0x140051cc0
lea rcx, [rsp + 0x74]
mov r8, rsi
add rcx, rbp
lea rdx, [rsp + 0x74]
call sub.VCRUNTIME140.dll_memcpy
nop dword [rax]
inc rdi
cmp rdi, rsi
jl 0x140051cb0
mov rax, qword [rsp + 0x60]
movsxd rcx, r12d
mov rdi, qword [rsp + 0x50]
dec r15d
mov edx, dword [rsp + 0x44]
add rbp, rcx
sub rax, 1
mov qword [rsp + 0x60], rax
jne 0x140051a93
mov ecx, dword [rsp + 0x40]
mov esi, dword [rsp + 0x38]
cmp dword [rsp + 0x70], r14d
je 0x140051d5e
test esi, esi
jle 0x140051d5e
mov r11d, r12d
lea r10d, [rsi - 1]
imul r10d, r12d
mov ebx, r14d
mov r12, qword [rsp + 0x48]
imul r11d, ecx
imul r10d, ecx
nop dword [rax]
mov r8d, r11d
test r11d, r11d
jle 0x140051d4a
movsxd rax, ebx
movsxd r9, r10d
sub r9, rax
lea rdx, [rax + r12]
nop word [rax + rax]
movzx eax, byte [r9 + rdx]
dec r8d
movzx ecx, byte [rdx]
mov byte [rdx], al
mov byte [r9 + rdx], cl
lea rdx, [rdx + 1]
test r8d, r8d
jg 0x140051d30
add ebx, r11d
sub r10d, r11d
add r14d, 2
cmp r14d, esi
jl 0x140051d10
mov r12d, dword [rsp + 0x34]
mov rcx, qword [rsp + 0x50]
test rcx, rcx
je 0x140051d6e
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
mov r13d, dword [rsp + 0x3c]
mov rcx, qword [rsp + 0x48]
mov edx, dword [rsp + 0x40]
cmp r12d, 3
jb 0x140051dbe
test r13d, r13d
jne 0x140051dbe
mov eax, esi
mov r8, rcx
imul eax, edx
test eax, eax
je 0x140051dbe
mov r11d, r12d
mov r10d, eax
nop dword [rax]
movzx ecx, byte [r8]
movzx eax, byte [r8 + 2]
mov byte [r8], al
mov byte [r8 + 2], cl
add r8, r11
sub r10, 1
jne 0x140051da0
mov rcx, qword [rsp + 0x48]
cmp r12d, 4
je 0x140051ddc
mov r9d, edx
mov dword [rsp + 0x20], esi
mov edx, r12d
mov r8d, 4
call fcn.140046310
mov rcx, rax
mov rax, rcx
jmp 0x140051e1f
mov rcx, qword [rsp + 0x48]
call qword [sym.imp.api_ms_win_crt_heap_l1_1_0.dll_free]
mov rax, qword gs:[0x58]
mov rcx, qword [rax]
lea rax, str.outofmem
jmp 0x140051e14
mov rax, qword gs:[0x58]
mov rcx, qword [rax]
lea rax, str.too_large
mov edx, 0x18
mov qword [rdx + rcx], rax
xor eax, eax
mov rcx, qword [rsp + 0x78]
xor rcx, rsp
call fcn.14009ab60
mov rbx, qword [rsp + 0xd8]
add rsp, 0x80
pop r15
pop r14
pop r13
pop r12
pop rdi
pop rsi
pop rbp
ret