Function at 0x401698
Capabilities:
Read file on windows
Write file on windows

Disassembly:
push edi
push esi
push ebp
push ebx
sub esp, 0x68
mov ebx, edx
cmp eax, 3
jg 0x4016b3
mov eax, 1
add esp, 0x68
pop ebx
pop ebp
pop esi
pop edi
ret
xor ebp, ebp
push ebp
push ebp
push dword [0x406018]
push ebp
push 7
push dword [0x406014]
push dword [ebx + 8]
call dword [sym.imp.KERNEL32.dll_CreateFileA]
mov edi, eax
cmp edi, 0xffffffff
je 0x4016da
test edi, edi
jne 0x4016e7
mov eax, 2
add esp, 0x68
pop ebx
pop ebp
pop esi
pop edi
ret
push ebp
push ebp
push 3
push ebp
push 7
push dword [0x406010]
push dword [ebx + 0xc]
call dword [sym.imp.KERNEL32.dll_CreateFileA]
mov esi, eax
cmp esi, 0xffffffff
je 0x401708
test esi, esi
jne 0x401715
mov eax, 3
add esp, 0x68
pop ebx
pop ebp
pop esi
pop edi
ret
mov dword [esp + 0x3c], ebp
mov dword [esp + 0x40], ebp
lea eax, [esp + 0x40]
push 1
push eax
push ebp
push esi
call dword [sym.imp.KERNEL32.dll_SetFilePointer]
mov ecx, eax
mov edx, dword [esp + 0x40]
mov dword [esp + 0x3c], ecx
mov dword [esp], edx
mov dword [esp + 0x44], ebp
mov dword [esp + 0x48], ebp
lea ebx, [esp + 0x48]
push 2
push ebx
push ebp
push esi
mov dword [esp + 0x14], ecx
call dword [sym.imp.KERNEL32.dll_SetFilePointer]
mov ecx, dword [esp + 4]
mov ebx, eax
mov edx, dword [esp + 0x48]
mov eax, dword [esp]
mov dword [esp + 0x44], ebx
mov dword [esp + 0x4c], ecx
mov dword [esp + 0x50], eax
lea eax, [esp + 0x50]
push 0
push eax
push ecx
push esi
mov dword [esp + 0x14], edx
call dword [sym.imp.KERNEL32.dll_SetFilePointer]
mov edx, dword [esp + 4]
mov dword [esp], eax
mov dword [0x431100], ebx
mov ecx, ebx
mov dword [0x431104], edx
mov dword [0x431108], ebp
mov eax, 0x10000000
sub ecx, eax
sbb edx, ebp
jb 0x4017b3
mov eax, 4
add esp, 0x68
pop ebx
pop ebp
pop esi
pop edi
ret
mov eax, dword [esp]
mov dword [esp + 0x4c], eax
inc ebx
push ebx
call sub.MSVCRT.dll_void____cdecl_operator_new_unsigned_int_
pop ecx
mov dword [0x431108], eax
test eax, eax
je 0x4017a6
mov dword [esp + 0x54], ebp
lea edx, [esp + 0x54]
push ebp
push edx
push dword [0x431100]
push eax
push esi
call dword [sym.imp.KERNEL32.dll_ReadFile]
mov edx, dword [esp + 0x54]
sub edx, dword [0x431100]
mov eax, ebp
sub eax, dword [0x431104]
or edx, eax
je 0x401806
mov eax, 4
add esp, 0x68
pop ebx
pop ebp
pop esi
pop edi
ret
push esi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
mov ecx, dword [0x431100]
mov dword [0x43110c], 0
mov ebx, ebp
mov edx, ebx
mov eax, edx
cmp edx, ecx
je 0x40183b
mov esi, dword [0x431108]
movzx esi, byte [esi + edx]
cmp esi, 0xa
je 0x40183b
cmp esi, 0xd
jne 0x40184b
cmp edx, eax
jbe 0x401846
inc ebx
mov dword [0x43110c], ebx
inc edx
mov eax, edx
jmp 0x40184c
inc edx
cmp edx, ecx
jbe 0x401823
push ebx
push ecx
push str.flbufsize_i_flcount_i_n
call dword [sym.imp.MSVCRT.dll_printf]
lea eax, [ebx*4]
shl ebx, 5
sub ebx, eax
push ebx
call sub.MSVCRT.dll_void____cdecl_operator_new_unsigned_int_
add esp, 0x10
mov dword [0x431110], eax
test eax, eax
jne 0x401888
mov eax, 5
add esp, 0x68
pop ebx
pop ebp
pop esi
pop edi
ret
mov ecx, dword [0x431100]
mov dword [esp + 0x5c], edi
mov esi, ebp
mov ebx, esi
mov eax, ebx
mov edx, eax
mov ebp, ecx
cmp esi, ebp
jne 0x4018a7
mov ecx, 0xa
jmp 0x4018b1
mov edi, dword [0x431108]
movzx ecx, byte [edi + esi]
cmp ecx, 0x20
jae 0x4018ec
mov edi, 1
shl edi, cl
test edi, 0x2401
je 0x4018ec
mov edi, dword [0x431108]
mov byte [edi + esi], 0
cmp esi, ebx
jbe 0x4018e7
add ebx, dword [0x431108]
mov edi, dword [0x431110]
inc eax
mov dword [edi + edx + 0x18], ebx
add edx, 0x1c
inc esi
mov ebx, esi
jmp 0x4018ed
inc esi
cmp esi, ebp
jbe 0x40189c
mov edi, dword [esp + 0x5c]
mov ebx, dword [0x431110]
mov dword [0x431114], eax
xor ebp, ebp
mov esi, ebp
mov dword [0x41000c], ebp
mov dword [0x410008], ebp
mov dword [0x410004], ebp
mov dword [0x410000], ebp
test eax, eax
mov dword [0x410010], 0x421000
mov dword [0x410014], 0x421000
mov dword [0x410018], 0x431000
jbe 0x4019c5
mov dword [esp + 0x28], esi
mov edx, ebp
mov dword [esp + 0x5c], edi
mov eax, edx
mov ecx, eax
mov esi, eax
mov dword [esp + 8], ecx
xor ecx, ecx
push ecx
push ecx
push 3
push ecx
push 7
push dword [0x406010]
push dword [ebx + esi + 0x18]
call dword [sym.imp.KERNEL32.dll_CreateFileA]
mov edi, eax
push dword [ebx + esi + 0x18]
push str.__s_:
cmp edi, 0xffffffff
jne 0x401984
mov edi, 0
call dword [sym.imp.MSVCRT.dll_printf]
add esp, 8
test edi, edi
jne 0x401b0c
push str.Error_n
call dword [sym.imp.MSVCRT.dll_printf]
pop ecx
add esi, 0x1c
inc ebp
cmp ebp, dword [0x431114]
jae 0x4019b5
mov ebx, dword [0x431110]
jmp 0x401956
mov esi, dword [esp + 0x28]
mov edi, dword [esp + 0x5c]
mov ebx, dword [0x431110]
xor ebp, ebp
mov dword [0x431114], esi
push esi
push str.n_seg_i_n
call dword [sym.imp.MSVCRT.dll_printf]
add esp, 8
mov edx, dword [0x431108]
mov eax, edx
test esi, esi
jbe 0x401a46
mov ebx, ebp
mov ecx, ebx
mov ebp, dword [0x431110]
mov ebp, dword [ebp + ecx + 0x18]
movzx edx, byte [ebp]
cmp edx, 0x2e
je 0x401d56
movzx edx, byte [ebp]
inc ebp
cmp edx, 0x3a
je 0x401b03
cmp edx, 0x2f
je 0x401b03
cmp edx, 0x5c
je 0x401b03
mov byte [eax], dl
inc eax
test edx, edx
jne 0x401a01
mov esi, esi
mov esi, dword [0x431114]
add ecx, 0x1c
inc ebx
cmp ebx, esi
jb 0x4019ea
mov edx, dword [0x431108]
mov ebx, dword [0x431110]
xor ebp, ebp
sub eax, edx
cdq
mov dword [0x431100], eax
mov dword [0x431104], edx
test esi, esi
jbe 0x401a91
mov dword [esp + 0x5c], edi
mov ecx, ebp
mov edx, ecx
mov ebp, dword [edx + ebx]
mov edi, dword [edx + ebx + 4]
mov eax, ecx
shl eax, 4
inc ecx
mov dword [ebx + eax], ebp
mov dword [ebx + eax + 4], edi
mov ebp, dword [edx + ebx + 8]
mov edi, dword [edx + ebx + 0xc]
mov dword [ebx + eax + 8], ebp
mov dword [ebx + eax + 0xc], edi
add edx, 0x1c
cmp ecx, esi
jb 0x401a60
mov edi, dword [esp + 0x5c]
xor ebp, ebp
mov dword [esp], ebp
lea eax, [esp]
push ebp
shl esi, 4
push eax
push esi
push ebx
push edi
call dword [sym.imp.KERNEL32.dll_WriteFile]
mov dword [esp + 4], ebp
lea eax, [esp + 4]
push ebp
push eax
push dword [0x431100]
push dword [0x431108]
push edi
call dword [sym.imp.KERNEL32.dll_WriteFile]
mov dword [esp + 8], ebp
lea eax, [esp + 8]
push ebp
push eax
push 4
push 0x431114
push edi
call dword [sym.imp.KERNEL32.dll_WriteFile]
mov dword [esp + 0xc], ebp
lea eax, [esp + 0xc]
push ebp
push eax
push 4
push 0x431100
push edi
call dword [sym.imp.KERNEL32.dll_WriteFile]
push edi
call dword [sym.imp.KERNEL32.dll_CloseHandle]
xor eax, eax
add esp, 0x68
pop ebx
pop ebp
pop esi
pop edi
ret
mov byte [eax], 0x5f
inc eax
jmp 0x401a01
lea ecx, [esp + 0x14]
xor eax, eax
mov dword [esp + 0x10], eax
mov dword [esp + 0x14], eax
push 1
push ecx
push eax
push edi
call dword [sym.imp.KERNEL32.dll_SetFilePointer]
mov edx, eax
mov ecx, dword [esp + 0x14]
mov dword [esp + 0x10], edx
mov dword [esp + 0x2c], ecx
xor eax, eax
mov dword [esp + 0x18], eax
mov dword [esp + 0x1c], eax
lea ecx, [esp + 0x1c]
push 2
push ecx
push eax
push edi
mov dword [esp + 0x48], edx
call dword [sym.imp.KERNEL32.dll_SetFilePointer]
mov edx, dword [esp + 0x38]
mov dword [esp + 0x34], eax
mov ecx, eax
mov dword [esp + 0x18], ecx
mov ecx, dword [esp + 0x1c]
mov dword [esp + 0x30], ecx
mov ecx, dword [esp + 0x2c]
mov dword [esp + 0x20], edx
mov dword [esp + 0x24], ecx
lea ecx, [esp + 0x24]
push 0
push ecx
push edx
push edi
call dword [sym.imp.KERNEL32.dll_SetFilePointer]
mov dword [esp + 0x20], eax
push dword [esp + 0x30]
push dword [esp + 0x38]
push str._I64i_n
call dword [sym.imp.MSVCRT.dll_printf]
add esp, 0xc
mov ecx, dword [esp + 0x34]
mov eax, dword [esp + 0x30]
mov dword [esp + 0x64], edi
mov dword [ebx + esi], ecx
xor edx, edx
mov dword [ebx + esi + 4], eax
mov dword [ebx + esi + 8], edx
mov dword [ebx + esi + 0xc], edx
mov dword [0x410048], ecx
mov dword [0x41004c], eax
mov dword [0x41001c], edx
lea ecx, [esp + 0x58]
mov dword [esp + 0xc], ebx
mov dword [esp + 4], esi
mov dword [esp], ebp
mov eax, 0x410020
xchg esp, eax
add esp, 4
call 0x401be6
add dword [esp], 0xb
mov dword [esp + 4], eax
xchg esp, eax
xor eax, eax
test eax, eax
jne 0x401c0d
mov eax, dword [0x410000]
test eax, eax
jne 0x401d73
mov ecx, 0x410000
push ecx
call fcn.00401580
mov ebx, dword [0x410000]
cmp ebx, 3
jb 0x401c1f
xor ebx, ebx
jmp 0x401ca0
cmp ebx, 1
jne 0x401c93
mov ebp, dword [0x410048]
mov ebx, 0x10000
mov ecx, dword [0x41004c]
mov eax, ebp
xor edx, edx
sub eax, ebx
sbb ecx, edx
jb 0x401c41
mov ebp, ebx
lea edx, [esp + 0x60]
xor eax, eax
mov dword [esp + 0x60], eax
push eax
push edx
push ebp
push 0x411000
push dword [esp + 0x74]
call dword [sym.imp.KERNEL32.dll_ReadFile]
mov eax, dword [esp + 0x60]
test eax, eax
jne 0x401c6f
mov dword [0x41001c], 1
mov dword [0x410004], 0x411000
lea eax, [eax + 0x411000]
mov dword [0x41000c], eax
mov dword [0x410008], 0x411000
jmp 0x401bd8
test ebx, ebx
je 0x401ca0
cmp ebx, 2
jne 0x401bd8
mov ebp, dword [0x410010]
mov eax, 0x421000
sub ebp, eax
xor edx, edx
mov dword [esp + 0x58], edx
push edx
lea ecx, [esp + 0x5c]
push ecx
push ebp
push 0x421000
push dword [esp + 0x6c]
call dword [sym.imp.KERNEL32.dll_WriteFile]
mov dword [0x410010], 0x421000
test ebx, ebx
mov dword [0x410014], 0x421000
mov dword [0x410018], 0x431000
jne 0x401bd8
mov edi, dword [esp + 0x64]
mov ebx, dword [esp + 0xc]
mov esi, dword [esp + 4]
mov ecx, dword [ebx + esi]
mov ebp, dword [ebx + esi + 4]
mov edx, dword [0x431110]
mov eax, dword [esp + 8]
inc dword [esp + 0x28]
mov dword [edx + eax], ecx
mov dword [edx + eax + 4], ebp
mov ecx, dword [ebx + esi + 8]
mov ebp, dword [ebx + esi + 0xc]
mov dword [edx + eax + 8], ecx
mov dword [edx + eax + 0xc], ebp
mov ecx, dword [ebx + esi + 0x10]
mov ebp, dword [ebx + esi + 0x14]
mov dword [edx + eax + 0x10], ecx
mov dword [edx + eax + 0x14], ebp
mov ebx, dword [ebx + esi + 0x18]
mov dword [edx + eax + 0x18], ebx
add eax, 0x1c
mov dword [esp + 8], eax
push edi
mov ebp, dword [esp + 4]
call dword [sym.imp.KERNEL32.dll_CloseHandle]
jmp 0x4019a1
movzx edx, byte [ebp + 1]
cmp edx, 0x2e
jne 0x401a01
mov edx, 0x5f
mov byte [ebp + 1], dl
mov byte [ebp], dl
jmp 0x401a01
mov ebx, 0x410040
mov esp, dword [ebx + 4]
mov eax, 1
jmp dword [ebx]