-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rule to alert on known cryptomining ports in VPC flow logs (#972)
* Add rule to alert on known cryptomining ports in VPC flow logs * Lower severity; turn off by default * Add to pack * Remove SMTP; add reference * fmt * Add monero ports
- Loading branch information
Evan Gibler
authored
Nov 28, 2023
1 parent
d201e9e
commit 28e3bd7
Showing
4 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from ipaddress import ip_network | ||
|
||
from panther_base_helpers import aws_rule_context | ||
from panther_iocs import CRYPTO_MINING_PORTS | ||
|
||
# List of allowed destination addresses | ||
# with more commonly-used ports (e.g., 8080) | ||
ALLOWED_DST_ADDRESSES = {} | ||
|
||
|
||
def rule(event): | ||
# Only alert on traffic originating from a private address | ||
# and destined for a public address | ||
if any( | ||
[ | ||
not ip_network(event.get("srcaddr", "0.0.0.0/0")).is_private, | ||
ip_network(event.get("dstaddr", "0.0.0.0/0")).is_private, | ||
] | ||
): | ||
return False | ||
|
||
return all( | ||
[ | ||
event.get("dstport") in CRYPTO_MINING_PORTS, | ||
event.get("dstaddr") not in ALLOWED_DST_ADDRESSES, | ||
] | ||
) | ||
|
||
|
||
def alert_context(event): | ||
return aws_rule_context(event) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
AnalysisType: rule | ||
Filename: aws_vpc_crypto_ports.py | ||
RuleID: "AWS.VPC.CryptoPorts" | ||
DisplayName: "VPC Flow Logs Known Cryotomining Ports" | ||
Enabled: false | ||
LogTypes: | ||
- AWS.VPCFlow | ||
Tags: | ||
- AWS | ||
- Configuration Required | ||
- Security Control | ||
- Command and Control:Application Layer Protocol | ||
Reports: | ||
MITRE ATT&CK: | ||
- TA0040:T1496 | ||
Severity: Low | ||
Description: > | ||
Alerts if a known cryptomining port is detected in outbound traffic. | ||
Runbook: > | ||
Investigate the host sending traffic over the known cryptomining ports for activity or signs of compromise or other malicious activity. Update network configurations appropriately. | ||
Reference: https://unit42.paloaltonetworks.com/malicious-operations-of-exposed-iam-keys-cryptojacking/ | ||
SummaryAttributes: | ||
- srcaddr | ||
- dstaddr | ||
- dstport | ||
Tests: | ||
- | ||
Name: DstPortInKnownList-true | ||
ExpectedResult: true | ||
Log: | ||
{ | ||
"dstport": 6641, | ||
"dstaddr": "106.58.92.8", | ||
"srcaddr": "10.0.0.1" | ||
} | ||
- | ||
Name: DstPortTwoInKnownList-true | ||
ExpectedResult: true | ||
Log: | ||
{ | ||
"dstport": 9332, | ||
"dstaddr": "106.58.92.8", | ||
"srcaddr": "10.0.0.1" | ||
} | ||
- | ||
Name: DstPortNotInKnownList-true | ||
ExpectedResult: false | ||
Log: | ||
{ | ||
"dstport": 443, | ||
"dstaddr": "100.100.100.100", | ||
"srcaddr": "10.0.0.1" | ||
} |