HTB | Find The Easy Pass | Write-Up

Summary:
We navigate the Hack The Box CTF platform, preparing for a challenge by preparing challenge files and testing the executable. We then perform static analysis using Ghidra and dynamic analysis with OllyDbg to gain insight into its behavior.
Next, we run the executable with test data and track where it stores this data in memory, checking the surrounding environment to better understand the context. With this knowledge, we extract the password and verify it by running the executable again with the password as input. Finally, we submit the flag as
HTB{<password>}and declare Challenge Completed.
Challenge Name: Find The Easy Pass | Difficulty: Easy | Category: Reversing
Outlining the attack path demonstrated in this writeup is much easier through a picture rather than a description, since a picture is worth a thousand words.

The aim of this walkthrough is to provide help with the Find The Easy Pass challenge on the Hack The Box website. Please note that no flags are directly provided here. Moreover, be aware that this is only one of the many ways to solve the challenges.
It belongs to a series of tutorials that aim to help out with finishing the Beginner-Track challenges.
Preparation
After reading the challenge description
Find the password (say PASS) and enter the flag in the form HTB{PASS}
we set out and download the provided challenge files. There is only one this time: - Find The Easy Pass.zip -.

Once downloaded, we make sure to copy the provided sha256 checksum and use it for integrity check.

Once nice way to do this is to use the -c option with the sha256sum command.
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$ ll
total 208K
-rw-r--r-- 1 htb-bluewalle htb-bluewalle 206K May 26 22:02 'Find The Easy Pass.zip'
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$ echo "0c48ca8a4a3ab2f73f76b0e6535c2feb510c1caf16b8bcc41c74b392c945e4db Find The Easy Pass.zip" | sha256sum -c
Find The Easy Pass.zip: OK
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$
Looks like the file was not tampered with so we decompress it.
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$ unzip -P hackthebox Find\ The\ Easy\ Pass.zip
Archive: Find The Easy Pass.zip
inflating: EasyPass.exe
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$ ll
total 604K
-rw-r--r-- 1 htb-bluewalle htb-bluewalle 393K Jul 3 2017 EasyPass.exe
-rw-r--r-- 1 htb-bluewalle htb-bluewalle 206K May 26 22:02 'Find The Easy Pass.zip'
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$
Search for Strings
After determining the file type as a 32-bit windows portable executable,
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$ file EasyPass.exe
EasyPass.exe: PE32 executable (GUI) Intel 80386, for MS Windows
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$
we try and store all the printable strings in a separate file. This way, we can easily sort through them. For example, searching for all words starting with pass (case insensitive) does provide us with some ideas about where to look.
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$ strings EasyPass.exe > easypass_strings.txt
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$ cat easypass_strings.txt | grep -i -n pass*
1960:PasswordChar
3795:Wrong Password!
5158:Enter Password
5171:Check Password
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$
Looks like some login text. Let's use vim and take a better look at the environment where those words are mentioned. Maybe we get lucky and the password is located near one of them.

No luck this time. Moreover, since the generated strings file alone contains more than 5000 entries,
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$ wc -l easypass_strings.txt
5174 easypass_strings.txt
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$
Running the Executable
it is time to take an other approach. How about simply running it (which could be very dangerous if it were a malware) and see what happens? But there is an other issue with this. Namely, running native windows 32-bit apps on linux (pwnbox - parrot os, debian based) does not work right out of the box.
After doing some quick online research we end up with the wine tool. It comes already installed on the pwnbox, so all that's left for us is to run it.
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$ wine EasyPass.exe
it looks like wine32 is missing, you should install it.
multiarch needs to be enabled first. as root, please
execute "dpkg --add-architecture i386 && apt-get update &&
apt-get install wine32:i386"
wine: created the configuration directory '/home/htb-bluewalle/.wine'
0050:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hr 0x80004002
0050:err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, hr 0x80004002
0050:err:ole:apartment_get_local_server_stream Failed: 0x80004002
0048:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hr 0x80004002
0048:err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, hr 0x80004002
0048:err:ole:apartment_get_local_server_stream Failed: 0x80004002
0050:err:ole:start_rpcss Failed to open RpcSs service
it looks like wine32 is missing, you should install it.
multiarch needs to be enabled first. as root, please
execute "dpkg --add-architecture i386 && apt-get update &&
apt-get install wine32:i386"
wine: failed to open L"C:\\windows\\syswow64\\rundll32.exe": c0000135
wine: configuration in L"/home/htb-bluewalle/.wine" has been updated.
it looks like wine32 is missing, you should install it.
multiarch needs to be enabled first. as root, please
execute "dpkg --add-architecture i386 && apt-get update &&
apt-get install wine32:i386"
00f8:err:module:load_wow64_ntdll failed to load L"\\??\\C:\\windows\\syswow64\\ntdll.dll" error c0000135
00f8:err:virtual:virtual_setup_exception stack overflow 1488 bytes in thread 00f8 addr 0x7f3288b160b0 stack 0x470a30 (0x470000-0x471000-0x56fd20)
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$
It does not work, but we get some nice hints about the follow up instructions.
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$ sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install wine32:i386
Ign:1 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 InRelease
...
...
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
wine32:i386 : Depends: libwine:i386 (= 5.0.3-3) but it is not going to be installed
Recommends: wine:i386 (= 5.0.3-3)
E: Unable to correct problems, you have held broken packages.
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$
But sadly, nor does this one. Running them separately seems to be working.
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$ sudo dpkg --add-architecture i386
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$ sudo apt-get update
Hit:1 https://debian.neo4j.com stable InRelease
Hit:2 https://repos.insights.digitalocean.com/apt/do-agent main InRelease
Hit:3 https://download.docker.com/linux/debian bullseye InRelease
Hit:4 https://packages.microsoft.com/debian/10/prod buster InRelease
Ign:5 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 InRelease
Hit:6 https://deb.parrot.sh/parrot parrot InRelease
Hit:7 https://deb.parrot.sh/direct/parrot parrot-security InRelease
Hit:8 https://deb.parrot.sh/parrot parrot-backports InRelease
Hit:9 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 Release
Reading package lists... Done
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [★]$
All that's left now is to find a way to install the wine32 module. One quick (and dirty) fix we find online is the following:
┌─[eu-dedivip-2]─[10.10.14.25]─[htb-bluewalle@htb-xh9th8t7hj]─[~/find-the-easy-pass]
└──╼ [