; The last part of the Cyber Security Challenge is a 500-byte encoded cipher ; which can be decoded into plaintext by rotating each byte to the right by ; 5 bits. Compile the following code as a console application with masm32. .386 .model flat,stdcall option casemap:none include windows.inc include kernel32.inc .data szConsoleTitle db "Cyber Security Challenge", 0 szFileName db "c:\bin", 0 ; 500-byte encoded cipher .data? hStdOut HANDLE ? .code DecodeFile proc uses ebx esi dwSize, lpMem: DWORD LOCAL b[2]:BYTE ; b[1] = 0 xor eax, eax lea ecx, b inc ecx mov byte ptr[ecx], al mov esi, lpMem mov ebx, dwSize @df_l: ; rotate right by 5 bits mov al, byte ptr[esi] ror al, 5 mov b, al ; print a char every 100ms invoke WriteConsole, hStdOut, addr b, 1, 0, 0 invoke Sleep, 100 inc esi dec ebx jnz @df_l @df_r: ret DecodeFile endp MapFile proc uses ebx lpFileName: DWORD LOCAL hFile, dwSize: DWORD invoke CreateFile, lpFileName, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0 mov hFile, eax inc eax jz @mp_r invoke GetFileSize, hFile, 0 mov dwSize, eax inc eax jz @mp_c invoke CreateFileMapping, hFile, 0, PAGE_READONLY, 0, 0, 0 .IF eax mov ebx, eax invoke MapViewOfFile, ebx, FILE_MAP_READ, 0, 0, 0 .IF eax push eax invoke DecodeFile, dwSize, eax call UnmapViewOfFile .ENDIF invoke CloseHandle, ebx .ENDIF @mp_c: invoke CloseHandle, hFile @mp_r: ret MapFile endp ; entry point WinMain proc invoke SetConsoleTitle, offset szConsoleTitle invoke GetStdHandle, STD_OUTPUT_HANDLE mov hStdOut, eax invoke MapFile, offset szFileName invoke ExitProcess, 0 WinMain endp end WinMain