Artifacts Generated: Process Inject
Summary
Injects a screenshot capture assembly into a target process to capture desktop sessions from that process’s security context. Uses process injection, named pipes for IPC, and supports multiple screenshots with configurable intervals. Bypasses session isolation by executing in the context of the target process.- Needs Admin: False (depends on target process privileges)
- Version: 2
- Author: @reznok, @djhohnstein
Arguments
- pid (Number, Required) - Process ID to inject screenshot assembly into
- count (Number, Optional) - Number of screenshots to capture (default: 1)
- interval (Number, Optional) - Seconds between screenshots (default: 0)
Usage
Detailed Summary
Agent Execution Flow
1. Parameter Processing and Validation
- Deserializes injection parameters from JSON
- Validates required parameters (PID, pipe name, loader stub ID)
- Sets default values for optional parameters (count=1, interval=0)
- Generates unique named pipe identifier for IPC communication
2. Target Process Validation
- Verifies target process exists and is running
- Uses
Process.GetProcessById()for validation - Provides clear error message if process not found
- Prevents injection attempts into non-existent processes
3. Assembly Building and Shellcode Generation
- Builds standalone ScreenshotInject.exe using .NET compiler
- Uses Donut loader to convert executable to position-independent shellcode
- Embeds named pipe name as parameter for IPC communication
- Optimizes build for release (no debug symbols, x64 platform)
4. Process Injection Execution
- Downloads shellcode from Mythic file system
- Creates injection instance targeting specified PID
- Executes injection using Apollo’s injection manager
- Generates process injection artifact for logging
- Supports multiple injection techniques (configurable)
5. Named Pipe Communication Setup
- Establishes named pipe connection to injected process
- Uses 10-second connection timeout
- Sends configuration parameters (count, interval) to injected assembly
- Implements chunked message protocol for large data transfers
- Handles connection events asynchronously
6. Injected Assembly Screenshot Logic
- Executes in target process’s security context
- Captures all screens using
Screen.AllScreens - Uses
Graphics.CopyFromScreen()for pixel capture - Encodes screenshots as JPEG for smaller file size
- Sends data back through named pipe to parent process
7. Asynchronous Data Handling
- Implements producer-consumer pattern for data processing
- Uses concurrent queues for thread-safe operations
- Handles sending commands to injected process
- Manages file uploads to Mythic asynchronously
- Supports cancellation through cancellation tokens
8. Chunked Message Protocol
- Handles large screenshot data through chunked protocol
- Reconstructs messages from multiple chunks
- Uses message store to track incomplete messages
- Validates message types for security
- Processes screenshot data for file upload
9. Multi-Screenshot Coordination
- Supports multiple screenshot capture cycles
- Implements configurable intervals between captures
- Captures all monitors in each cycle
- Maintains timing accuracy across multiple screenshots
Donut Shellcode Integration
Position-Independent Code Generation
- Format 1: Raw shellcode output
- Parameter Passing: Named pipe name embedded in shellcode
- Architecture: x64 position-independent code
- Bypass: Avoids file-based detection
Shellcode Execution Flow
- Memory Allocation: Allocates RWX memory in target process
- Code Injection: Writes shellcode to allocated memory
- Execution: Creates thread to execute injected code
- Parameter Resolution: Resolves embedded pipe name at runtime
- Library Loading: Dynamically loads required .NET runtime
- Assembly Execution: Runs screenshot capture logic
Inter-Process Communication
Named Pipe Architecture
- Uses unique GUID-based pipe names
- Supports bidirectional communication
- Implements timeout mechanisms
- Handles connection failures gracefully
Message Protocol
- Supports large data transfers through chunking
- Uses Base64 encoding for binary data
- Implements message reconstruction logic
- Provides error detection and recovery
Security Context Considerations
Process Token Inheritance
- Desktop Access: Inherits target process’s desktop session
- User Context: Executes with target process’s user privileges
- Session Isolation: Bypasses session 0 isolation on Windows services
- Integrity Level: Maintains target process’s integrity level
Privilege Escalation Scenarios
Performance and Resource Management
Memory Usage Optimization
- Uses
usingstatements for automatic resource disposal - Processes screenshots sequentially to minimize memory footprint
- Implements JPEG compression to reduce data size
- Cleans up GDI+ resources immediately
Network and File Transfer
- Uploads screenshots asynchronously to prevent blocking
- Uses cancellation tokens for task management
- Implements error handling for failed uploads
- Provides progress feedback through intermediate responses
APIs Used
MITRE ATT&CK Mapping
- T1113 - Screen Capture
- T1055 - Process Injection
- T1055.001 - Process Injection: Dynamic-link Library Injection
- T1129 - Shared Modules
- T1559.001 - Inter-Process Communication: Component Object Model
Security Considerations
- Process Injection: Injects code into arbitrary processes
- Privilege Escalation: May gain higher privileges through target process
- Session Bypass: Circumvents session isolation mechanisms
- Memory Manipulation: Direct memory writing in target process
- Desktop Access: Captures sensitive information from target session
- Steganography: Screenshot data could hide additional payloads
- Forensic Evasion: Avoids file-based detection through in-memory execution
Defensive Detection
Process Injection Indicators
- Unusual Memory Patterns: RWX memory allocations in target process
- Cross-Process API Calls:
OpenProcess,VirtualAllocEx,WriteProcessMemory - Thread Creation:
CreateRemoteThreadin foreign process - Module Loading: Unexpected .NET runtime loading in non-.NET processes
Network and IPC Monitoring
- Named Pipe Creation: Unusual pipe names or patterns
- Large Data Transfers: Significant outbound data from screenshot uploads
- Process Communication: Unexpected IPC between processes
- Network Connections: HTTP/HTTPS uploads to suspicious destinations
Behavioral Analysis
- Graphics API Usage: Unusual
CopyFromScreenpatterns - Memory Usage Spikes: Temporary memory increases during capture
- Process Relationships: Parent-child process analysis
- File System Activity: Temporary file creation patterns
Limitations
- Process Architecture: Must match target process architecture (x86/x64)
- Injection Restrictions: Some processes protected by security software
- Session Requirements: Target process must have active desktop session
- Graphics Access: Requires target process to have graphics capabilities
- Memory Constraints: Large screenshots may cause memory pressure
- Network Dependencies: Requires reliable connection for file uploads
- Timing Accuracy: Intervals may drift under high system load
- Process Lifetime: Injection fails if target process terminates
Error Conditions
- Process Not Found: Target PID does not exist or has terminated
- Injection Failed: Cannot inject into target process (permissions, protection)
- Pipe Connection Failed: Named pipe communication establishment failure
- Assembly Load Failed: Cannot load screenshot assembly in target process
- Graphics Access Denied: Target process lacks desktop/graphics access
- Memory Allocation Failed: Insufficient memory for screenshot capture
- File Upload Failed: Network or file system errors during upload
- Timeout Expired: Operations exceed configured timeout values
- Cancellation Requested: User or system cancellation of operation