---
title: "14. Attacking thick applications"
date: 2025-01-18
draft: false
---

Thick client apps are apps installed locally on our computers. Unlike client apps that run on a remote server that can be accessed through web browsers, these apps do not require internet to run and perform better in processing power / memory / storage capacity. 

Thick clients are usually applications used in enterprise environments created to serve specific purposes. 
- Project mgmt systems
- Customer relationship mgmt systems
- Inventory management tools
- Productivity software 

Critical security measure that for example Java has is `sandbox` 
- Virtual env allowing untrusted code like code from internet to run safely on a user's system without posing a security risk. 
- Isolates untrusted code - preventing it from accessing or modifying system resources / other apps without proper auth

Aside from these are Java API restrictions and code signing that help security

In `.NET` 
- Thick => `rich` or `fat` client 
- Performs significant amount of processing on client side rather than relying solely on a server for all processing tasks. 
- As a result - thick has better perf, features, UX compared to thin - which rely heavily on servers

Examples of thick clients: 
- Web browsers
- Media players
- Chatting software
- Video games 

Some thick client applications are usually available to purchase or download for free through official website or 3p - some other custom apps have been created for a specific company and can be delivered from it dept 
Maintaining and deploying thick clients more difficult than thin - updates must be done locally to user's computer. 
- Independent software
- Working without internet access
- Store data locally
- Less secure
- Consume more resources
- More expensive 

**Two tier** thick clients:
- app installed locally on computer + communicates directly with database 

**Three tier** thick clients: 
- also installed locally
- In order to interact with backend DB - first communicate with application server usually via http/https protocol 

App server / DB may be located in same network or over internet. 
This helps three-tier thick apps more secure since attackers wouldn't communicate directly with db. 

Large portion of thick apps are downloaded from internet - no sufficient way to ensure all users download the official application 
Web specific vulns do not apply to thick apps. 
Although, thick considered less secure than webapps with many attacks being applicable: 
- Improper error handling
- Hardcoded sensitive data
- DLL Hijacking
- Buffer overflows
- SQL injections
- Insecure storage
- Session management 

----
## Thick application - penetration testing steps
Attack surface can be large. 
Both automated and manual steps to leverage

**Information gathering**
- ID app architecture
- Proglang and frameworks used - understand app and infra 
- ID tech used on client and serverside to find entry points and user inputs. 
- ID common vulns 

Tools: 
https://ntcore.com/?page_id=388 - `CFF Explorer`
https://github.com/horsicq/Detect-It-Easy - `Detect It Easy` 
https://learn.microsoft.com/en-us/sysinternals/downloads/procmon - `Process Monitor`
https://learn.microsoft.com/en-us/sysinternals/downloads/strings - `strings` 

**Clientside attacks**
Thick clients perform significant processing + data storage on clientside, but still comm with servers (synchronization, shared resources)
This interaction exposes thick to vulns found in webapps like cmd inj, weak access control, sqli 
Sensitive info like users, passwords, token or strings for communication with other services may be stored in application's local files. 
Hardcoded credentials and other sensitive information can also be found in application source code. Static analysis is a necessary step while testing the application. Using proper tools, rev-eng and examine a .net / java app using EXE, DLL, JAR, CLASS, WAR / other formats. Dynamic analysis should also be performed, thick clients store sensitive info in memory as well 

|[Ghidra](https://www.ghidra-sre.org/)|[IDA](https://hex-rays.com/ida-pro/)|[OllyDbg](http://www.ollydbg.de/)|[Radare2](https://www.radare.org/r/index.html)|
|[dnSpy](https://github.com/dnSpy/dnSpy)|[x64dbg](https://x64dbg.com/)|[JADX](https://github.com/skylot/jadx)|[Frida](https://frida.re/)|

**Network side attacks**
If app communicates with a local or remote server, network traffic analysis can help us capture sensitive information that might be transferred through HTTP/HTTPS or TCP/UDP connections and give us a better understanding of how the application is working. Pentesters that perform traffic analysis on thick client apps should be familiar with tools like: |[Wireshark](https://www.wireshark.org/)|[tcpdump](https://www.tcpdump.org/)|[TCPView](https://learn.microsoft.com/en-us/sysinternals/downloads/tcpview)|[Burp Suite](https://portswigger.net/burp)|

**Server-side**
Similar to web app attacks - OWASP top ten. 

----

## Retrieving hardcoded credentials from a thick application 

Take given scenario. Exploring NETLOGON share of SMB svc reveals `RestartOracle-Service.exe` among other filers. Downloading the executable locally and running it through command line, seems like it does not run or runs something hidden 

Taking a look through ProcMon64 from sysinternals and monitoring the process reveals the executable creates a temp file 
for example: C:\Users\Matt\AppData\Local\Temp

![](/img/Pasted image 20250118144722.png)

In order to capture the files it's required to change the permissions of `Temp` to disallow file deletions. 
`Properties -> Security -> Advanced -> [username] -> Disable Inheritance -> Convert inherited permissions into explicit permissions on this object -> Edit -> Show advanced permissions -> de-select Delete subfolders and files, -> and Delete checkboxes` 

Re-run EXE and nav to the temp location. 

Example generated file:

```batch
@shift /0
@echo off

if %username% == matt goto correcto
if %username% == frankytech goto correcto
if %username% == ev4si0n goto correcto
goto error

:correcto
echo TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA > c:\programdata\oracle.txt
echo AAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4g >> c:\programdata\oracle.txt
<SNIP>
echo AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA >> c:\programdata\oracle.txt

echo $salida = $null; $fichero = (Get-Content C:\ProgramData\oracle.txt) ; foreach ($linea in $fichero) {$salida += $linea }; $salida = $salida.Replace(" ",""); [System.IO.File]::WriteAllBytes("c:\programdata\restart-service.exe", [System.Convert]::FromBase64String($salida)) > c:\programdata\monta.ps1
powershell.exe -exec bypass -file c:\programdata\monta.ps1
del c:\programdata\monta.ps1
del c:\programdata\oracle.txt
c:\programdata\restart-service.exe
del c:\programdata\restart-service.exe
```

content of file reveals:
- two files dropped by batch
- deleted before anyone can access
- retrieve content of 2 files by modifying batch script and removing the deletion 

basically 
make dir readonly (script doesnt cleanup)
follow what is created by the script, manually create executable by running powershell script it creates from above `correcto:` function (its essentially dropping b64 encoded payload into a .txt file and the ps1 script uses that .txt to create another .exe)
then we open that .exe in x64dbg to inspect what its doing. `options -> preferences -> exit breakpoint` as only options checked 
- unchecking all other options, debugging will start directly from application exit point (aviod going through any dll files that are loaded before the app actually starts) 

![](/img/Pasted image 20250118151144.png)

rightclick inside cpu view and select 'follow in memory map'

![](/img/Pasted image 20250118151243.png)

checking memory maps at this stage of exec 

Checking the memory maps at this stage of the execution, of particular interest is the map with a size of `0000000000003000` with a type of `MAP` and protection set to `-RW--`.

memory-mapped files allow applications to access large files without having to read or write entire file into memory at once. instead file is mapped to region of memory that the application can r/w as if it were regular buffer of memory. this is a place to look for potentially hardcoded credentials. following this memory map we see magic bytes MZ in ascii columns indicating the file is a DOS MZ executable 

![](/img/Pasted image 20250118151858.png)

![](/img/Pasted image 20250118151913.png)

why this particular memory map? how to find it yourself? not sure! maybe outside scope of the module itself. 

- Return to memory map pane, and export newly discovered mapped item from memory to a dump file by rightclicking the address and selecting the option. Run `strings` on the exported file 

![](/img/Pasted image 20250118152047.png)

![](/img/Pasted image 20250118152237.png)

![](/img/Pasted image 20250118152314.png)

that sure looks like a password

Reading output reveals the dump contains a .NET executable
![](/img/Pasted image 20250118152359.png)

We can use de4dot to reverse the .NET back into source code by dragging our bin file onto the `de4dot` executable

![](/img/Pasted image 20250118152516.png)

now we can read teh source code of the exported application by dragging/dropping this cleaned bin onto DnSpy

![](/img/Pasted image 20250118152617.png)
![](/img/Pasted image 20250118152700.png)

---

## Attacking web vulnerabilities in a thick client application 
Three-tier architectures have security advantage over two tiers since it prevents the end user from communicating directly with the database server - but these can still be susceptible to webspecific attacks like sqli and path traversal 

Common to encounter thick client apps that connect to a server to communicate with a database. Assume you've found the below files enumerating an FTP server that provides anonymous user access: 
- fatty-client.jar
- note.txt
- note2.txt
- note3.txt

Content of these reveal: 

- A server has been reconfigured to run on port `1337` instead of `8000`.
- This might be a thick/thin client architecture where the client application still needs to be updated to use the new port.
- The client application relies on `Java 8`.
- The login credentials for login in the client application are `qtc / clarabibi`.

fatty-client.jar 

![](/img/Pasted image 20250118171203.png)
connection fails. probably due to `port 1337` instead of 8000 above. extract jar file and search strings for 8000

![](/img/Pasted image 20250118171231.png)

when we modify the xml file you need to make sure the sha-256 digest matches. if you try to simply modify and re-run it will fail because the JAR is signed. (every files sha-256 hash is validated before running)

remove all hashes and delete 1.rsa and 1.sf from `meta-inf`. manifest.mf should end with a newline 

update and run the jar: 
```powershell-session
C:\> cd .\fatty-client
C:\> jar -cmf .\META-INF\MANIFEST.MF ..\fatty-client-new.jar *
```

![](/img/Pasted image 20250118171815.png)
now we can communicate with the backend

**Recompiling a JAR after making changes**
![](/img/Pasted image 20250118194328.png)
open in decompiler
file -> save all sources 
this gives us access to source Java files 

make some changes

recompile files: 

![](/img/Pasted image 20250118195412.png)


This generates several class files. Let's create a new folder and extract the contents of `fatty-client-new.jar` into it.

![](/img/Pasted image 20250118200038.png)

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.

```powershell-session
mv -Force fatty-client-new.jar.src\htb\fatty\client\gui\*.class raw\htb\fatty\client\gui\
```

![](/img/Pasted image 20250118200555.png)


Build new JAR file: 
```bash
jar -cmf META-INF\MANIFEST.MF traverse.jar .
```

https://0xdf.gitlab.io/2020/08/08/htb-fatty.html

this section blows. read the writeup above and if you EVER need to decompile/recompile java classes to fuck with and reverse engineer a thick client, use this post for the love of fucking god: 
https://0xdf.gitlab.io/2020/08/08/jar-files-analysis-and-modifications.html#modifying-compiled-classes
