Is malware abusing your infrastructure? Find out with VirusTotal!
Any organization’s infrastructure might inadvertently be abused by attackers as part of a malicious campaign. It is therefore important to monitor any suspicious activity. VirusTotal can help you identify these threats and improve your threat detection and protection capabilities. In this post we will first analyze different available search modifiers and then we will provide different templates to quickly deploy infrastructure monitoring rules.
Hunting for infrastructure abuses
- Specific IP addresses: entity:ip (ip:34.125.68.133 OR ip: 34.125.118.189 ) p:20-
- IP range: entity:ip ip:34.120.0.0/13 p:13+
Search modifier | Description |
---|---|
detected_communicating_files_count | # of detected files contacting the given domain or IP address when executed in a sandbox |
communicating_files_max_detections | maximum # of detected files communicating with a given domain or IP address |
detected_downloaded_files_count | # of detected files downloaded by VirusTotal from a URL hosted under a given domain or an IP address |
downloaded_files_max_detections | maximum # of detected files downloaded by VirusTotal from a URL hosted under a given domain or an IP address |
detected_referring_files_count | # of detected files containing the given domain or IP address in their strings |
referring_files_max_detections | maximum # of detected files containing the given domain or IP address in their strings |
detected_urls_count | # of detected URLs hosted under a given domain or IP address |
urls_max_detections | maximum # of detected URLs hosted under a given domain or IP address |
Files
- Communicating to a domain. Eg: entity: file behaviour_network: google.com
- Communicating to a url. Eg: entity: file behaviour_network: www.virustotal.com/gui/
- Communicating to an IP address. Eg: entity: file behaviour_network: 8.8.8.8
- Specific IP address communication. Eg: entity: file contacted_ip: 8.8.8.8
- Range communication. Eg: entity: file contacted_ip: 173.194.0.0/16
Do it yourself!
Automated monitoring
1. Using the VT API
QUERY = “entity:file behaviour_network:file.io (contacted_ip:107.23.246.142 or contacted_ip:34.197.10.85) p:10+ fs:2022-12-01+”
with vt.Client(API_KEY) as client:
it = client.iterator(‘/intelligence/search’, params={“query”: QUERY })
for file_obj in it:
print(f'{file_obj.id}’)
2. Using YARA
rule infrastructure_monitoring {
meta:
description = “Description of the logic of the use case and its goal.”
author = “VT Team”
strings:
// assets
$ip1 = “X.X.X.X”
$ip2 = “Y.Y.Y.Y”
$url1 = “companyexampledomain.com/url?p=5”
$url2 = “companyexampledomain.es/url2”
$domain1 = “companyexampledomain.com”
$domain2 = “companyexampledomain.es”
condition:
any of ($ip*,$domain*,$url*)
}
- vt.behaviour.dns_lookups: this field is a list of DNS resolutions performed by the sample. For each item or resolution in the list, it provides the hostname and the resolved IP address (resolved_ips). We could use this to detect if a sample dynamically tries to contact with a given domain, for example:
dns_lookup.hostname contains “companyexampledomain.com”
- vt.behaviour.ip_traffic: this field is a list of established IP connections and it provides the destination IP address, the port and the transport layer protocol (destination_ip, destination_port, transport_layer_protocol) for each connection.
ip_traffic.destination_ip == “X.X.X.X”
- vt.behaviour.http_conversations: this field is a list of HTTP requests performed by the sample. Every item in the list provides context information such as request URL, method and headers (url, request_method, request_headers), and response headers, status code and body filetype (response_headers, status_code, response_body_filetype).
http_conversations.url contains “companyexampledomain.com/url?p=5”
- vt.behaviour.smtp_conversations: this field is a list of SMTP requests. It provides many features for every item in the list such as the recipient and the sender (message_from, message_to, message_cc, message_bcc), email’s subject and body (subject, html_body, txt_body), and SMTP server related information such as the host name, IP address and port (hostname, destination_ip, destination_port) among others.
smtp_conversations.hostname contains “companyexampledomain.com”
rule infrastructure_monitoring {
meta:
description = “Description of the logic of the use case and its goal.“
author = “VT Team”
// assets
ip1 = “34.197.10.85”
ip2 = “107.23.246.142”
condition:
// Match only samples detected as malicious by more than 9 AVs
vt.metadata.analysis_stats.malicious > 9 and (
// Check the list of established IP connections
for any ip_traffic in vt.behaviour.ip_traffic : (
// Match samples communicating to any of my IP addresses
ip_traffic.destination_ip == “34.197.10.85” or
ip_traffic.destination_ip == “107.23.246.142”
)
)
}
Conclusions
rule infrastructure_monitoring {
meta:
description = “Description of the logic of the use case and its goal.”
author = “VT Team”
strings:
// assets
$ip1 = “X.X.X.X”
$ip2 = “Y.Y.Y.Y”
$url1 = “companyexampledomain.com/url?p=5”
$url2 = “companyexampledomain.es/url2”
$domain1 = “companyexampledomain.com”
$domain2 = “companyexampledomain.es”
condition:
// First it checks for strings in sample content
// This can be potentially noisy, you can consider comment this line
any of them or
// Match only samples detected as malicious by more than 10 AVs
vt.metadata.analysis_stats.malicious > 10 and (
// Check the list of DNS resolutions performed by the sample
for any dns_lookup in vt.behaviour.dns_lookups : (
// Match samples that perform DNS requests for any of my domains
dns_lookup.hostname contains “companyexampledomain.com” or
dns_lookup.hostname contains “companyexampledomain.es” or
// Match samples that resolve to any of my IP addresses
for any ip in dns_lookup.resolved_ips: (
ip == “X.X.X.X” or
ip == “Y.Y.Y.Y”
)
) or
// Check the list of established IP connections
for any ip_traffic in vt.behaviour.ip_traffic : (
// Match samples communicating to any of my IP addresses
ip_traffic.destination_ip == “X.X.X.X” or
ip_traffic.destination_ip == “Y.Y.Y.Y”
) or
// Check the list of HTTP requests performed
for any http_conversations in vt.behaviour.http_conversations : (
// Match samples communicating to any of my IP addresses
http_conversations.url contains “companyexampledomain.com/url?p=5” or
http_conversations.url contains “companyexampledomain.es/url2”
)
)
}
Continue reading Is malware abusing your infrastructure? Find out with VirusTotal!