Thick Client Pentest
Thick Client Pentesting
CheckList
Linux Binaries
Change encoding
Pre Compiled Tools

Information Gathering
CFF Explorer
Detect It Easy
Process Monitor
Strings
MSI Files
Look inside Install files, etc
MSI FilesCOM Files
DLL Files Analysis
ILSpy - .NET Decompiler
Decompile the DLL files, then you can search strings, check the code, etc.

DLL Hijacking
DLL HijackingClient Side attacks
Code AnalysisGhidra
IDA
OllyDBG
Radare2
dnSpy - .NET C#
x64dbg
JADX
JD-GUI - Java
Scavenger - Java
Retdec - C++
Frida
API Monitor
Network Side Attacks
Miscellaneous TechniquesWireshark
TCPDump
TCPView
Burp
Server Side Attacks
OWASP Top 10Retriving sensitive information from processes
Windows ProcessesRetrieving hardcoded Credentials
ProcMon - monitoring the process reveals that the executable indeed creates a temp file


In order to capture the files, it is required to change the permissions of the Temp folder to disallow file deletions
To do this, we right-click the folder C:\Users\Matt\AppData\Local\Temp and under Properties -> Security -> Advanced -> cybervaca -> Disable inheritance -> Convert inherited permissions into explicit permissions on this object -> Edit -> Show advanced permissions, we deselect the Delete subfolders and files, and Delete checkboxes.
Run the app again
bat file
Two files are being dropped by the batch file and being deleted. Try to retrieve the content of the 2 files, by modifying the batch script and removing the deletion
Remove user part and del part. Also change echo $salida
Write the files on Desktop

echo $salida = $null; $fichero = (Get-Content C:\Users\cybervaca\Desktop\oracle.txt) ; foreach ($linea in $fichero) {$salida += $linea }; $salida = $salida.Replace(" ",""); [System.IO.File]::WriteAllBytes("C:\Users\cybervaca\Desktop\restart-service.exe", [System.Convert]::FromBase64String($salida)) > C:\Users\cybervaca\Desktop\monta.ps1
run ps1 to create exe
Banner
procmon

x64dbg, navigate to Options -> Preferences, and uncheck everything except Exit Breakpoint

file -> open and select the restart-service.exe to import it and start the debugging. Once imported, we right click inside the CPU view and Follow in Memory Map

MAP and protection set to -RW--

double-click on it

Return to the Memory Map pane, then export the newly discovered mapped item from memory to a dump file by right-clicking on the address and selecting Dump Memory to File. Running strings on the exported file
use De4Dot to reverse .NET executables

Read the source code of the exported application by dragging and dropping it onto the DnSpy executable

Web Vulnerabilities
Based on HTB Fatty Walkthrough:
FTP server find some info:
A server has been reconfigured to run on port
1337instead of8000.The login credentials for login in the client application are ****/*


The client attempts to connect to the server.fatty.htb subdomain

fatty-client.jar is a Java Archive file, and its content can be extracted by right-clicking on it and selecting Extract files
set the port to 1337
secret is clarabibiclarabibiclarabibi.
Running the edited application will fail due to an SHA-256 digest mismatch. The JAR is signed, validating every file's SHA-256 hashes before running. These hashes are present in the file META-INF/MANIFEST.MF.
remove the hashes from META-INF/MANIFEST.MF and delete the 1.RSA and 1.SF files from the META-INF directory. The modified MANIFEST.MF should end with a new line.
Update and run the fatty-client.jar file by issuing the following commands.

Foothold
Profile -> Whoami


Path Traversal

Decompile the application using JD-GUI, by dragging and dropping the fatty-client-new.jar onto the jd-gui

Save the source code by pressing the Save All Sources option in jdgui. Decompress the fatty-client-new.jar.src.zip by right-clicking and selecting Extract files.
The file fatty-client-new.jar.src/htb/fatty/client/methods/Invoker.java handles the application features
showFiles function takes in one argument for the folder name and then sends the data to the server using the sendAndRecv() call. The file fatty-client-new.jar.src/htb/fatty/client/gui/ClientGuiTest.java sets the folder option
Replace the configs folder name with ..
Compile the ClientGuiTest.Java file
This generates several class files. Let's create a new folder and extract the contents of fatty-client.jar into it.
Navigate to the raw directory and decompress fatty-client-new-2.jar by right-clicking and selecting Extract Here
Navigate to the raw directory and decompress fatty-client-new-2.jar by right-clicking and selecting Extract Here. Overwrite any existing htb/fatty/client/gui/*.class files with updated class files.
Exploiting Web Vulnerabilities in Thick-Client Applications
Finally, we build the new JAR file.
Log in to the application and navigate to FileBrowser -> Config option

Listing the content of the start.sh file reveals that fatty-server.jar is running inside an Alpine Docker container.
Modify the open function in fatty-client-new.jar.src/htb/fatty/client/methods/Invoker.java to download the file fatty-server.jar
Rebuild the JAR file by following the same steps and log in again to the application. Then, navigate to FileBrowser -> Config, add the fatty-server.jar name in the input field, and click the Open button.

SQL Injection
Decompiling the fatty-server.jar using JD-GUI reveals the file htb/fatty/server/database/FattyDbSession.class that contains a checkLogin() function that handles the login functionality
The login button creates the new object ClientGuiTest.this.user for the User class. It then calls the setUsername() and setPassword() functions with the respective username and password values.

htb/fatty/shared/resources/user.java
Username isn't sanitized and is directly used in the SQL query, making it vulnerable to SQL injection.
The checkLogin function in htb/fatty/server/database/FattyDbSession.class writes the SQL exception to a log file.
To see the error, we need to edit the code in the fatty-client-new.jar.src/htb/fatty/client/gui/ClientGuiTest.java file as follows
error-log.txt

username in the login form is ' or '1'='1
The injection in the username field can be leveraged to create a fake user entry.
Modify the code in htb/fatty/shared/resources/User.java to submit the password as it is from the client application.


Copy the .class files to raw directory

Create jar file

Attempt to log in using the payload abc' UNION SELECT 1,'abc','a@b.com','abc','admin in the username field and the random text abc in the password field.


Resources
Support this Gitbook
I hope it helps you as much as it has helped me. If you can support me in any way, I would deeply appreciate it.
Last updated



