Overview
Theupload action transfers files to remote systems using WMI class properties as a data channel. This provides file upload capabilities without requiring SMB access or file shares.
Syntax
Parameters
| Parameter | Required | Description |
|---|---|---|
action | Yes | Must be upload |
source | Yes | Local file path to upload |
dest | Yes | Destination path on remote system |
computername | No | Target host(s), comma-separated |
amsi | No | Set to disable to bypass AMSI during upload |
username | No | Username for authentication |
password | No | Password for authentication |
How It Works
1
Read Source File
Reads local file and converts to byte array
2
Create WMI Class
Creates temporary WMI class:
Win32_OSRecoveryConfigurationData3
Store in Property
Stores file bytes as comma-separated string in
DebugOptions property4
Remote Retrieval
Executes PowerShell on target to read from WMI class and write to disk
5
Verification
Queries
CIM_DataFile to verify file was created6
Cleanup
Removes temporary WMI class
Usage Examples
Basic File Upload
Example Output
Operational Scenarios
Scenario 1: Beacon Deployment
Scenario 2: Tool Staging
Scenario 3: Lateral Movement Chain
Scenario 4: Persistence Deployment
File Size Considerations
Recommendations:- Keep files under 10 MB when possible
- Test upload with small files first
- Use compression for larger payloads
- Consider staging larger files via other methods
Handling Large Files
Handling Large Files
For files larger than 10 MB:
- Compress the file before upload
- Upload compressed file via WMI
- Extract on target using PowerShell
- Clean up compressed file
Destination Path Guidelines
Writeable Locations
Recommended destination paths:
C:\Windows\temp\C:\temp\%APPDATA%\C:\ProgramData\
Avoid Protected Paths
Paths that may fail:
C:\Program Files\(requires admin)C:\Windows\System32\(protected)- Root of C:\ drive
- User profile without proper access
Remote vs Local Usage
- Local Upload
- Remote Upload
AMSI Evasion
Whenamsi=disable is specified, SharpWMI:
- Modifies registry to disable AMSI:
HKCU\Software\Microsoft\Windows Script\Settings\AmsiEnable = 0 - Executes PowerShell command to write file
- Restores original AMSI setting
Detection Considerations
WMI Class Creation
WMI Class Creation
- Creation of
Win32_OSRecoveryConfigurationDataclass - Unusual WMI class with large property values
- Temporary WMI class creation and deletion
- Event ID 5857-5861: WMI activity
PowerShell Execution
PowerShell Execution
- PowerShell spawned by
wmiprvse.exe - Command line with
[IO.File]::WriteAllBytes - WMI class property read operations
- Event ID 4104: PowerShell script block logging
File Creation
File Creation
- File written to temp directories
- File creation by PowerShell
- Suspicious file names (svchost.exe, system.exe in temp)
- Event ID 4663: File system access
Network Activity
Network Activity
- Large data transfer over WMI/DCOM
- Unusual WMI property queries
- Multiple WMI operations in sequence
- DCOM traffic on port 135
Best Practices
File Naming
- Use legitimate-sounding names
- Match existing system files
- Avoid obvious malware names
- Examples: svchost.exe, system.exe, update.exe
Path Selection
- Use temp directories
- Avoid monitored paths
- Match legitimate file locations
- Clean up after use
Operational Security
- Always use
amsi=disable - Test upload with small files first
- Verify upload success before execution
- Delete uploaded files after use
Error Handling
- Check for SUCCESS/FAILURE messages
- Verify file exists before execution
- Handle upload timeouts
- Monitor for AV detection
Troubleshooting
FAILURE: Could Not Confirm Upload
FAILURE: Could Not Confirm Upload
Cause: File not written to disk or verification failedSolution:
- Check destination path is writeable
- Verify sufficient disk space
- Ensure PowerShell is available
- Check AV didn’t quarantine file
- Try different destination path
Exception During Setting Evil Property
Exception During Setting Evil Property
Cause: WMI class creation failedSolution:
- Verify WMI service is running
- Check admin privileges
- Try smaller file size
- Ensure sufficient system resources
Access Denied
Access Denied
Cause: Insufficient privilegesSolution:
- Verify admin credentials
- Check UAC remote restrictions
- Ensure user can write to destination
- Try with domain admin account
File Upload Hangs
File Upload Hangs
Cause: Large file or network issueSolution:
- Reduce file size
- Check network connectivity
- Compress file before upload
- Increase timeout if possible
Cleanup
After successful operations, clean up uploaded files:Related Actions
exec
Execute uploaded files
executevbs
Alternative execution method
query
Verify file upload
ps
Check uploaded file execution
Alternative Methods
- WMI Upload (SharpWMI)
- SMB File Copy
- PowerShell Remoting
Advantages:
- No SMB required
- Works over WMI/RPC only
- Evades SMB monitoring
- Slower than SMB
- File size limitations
- More complex detection artifacts