Skip to content

Commit 7b38a36

Browse files
morriscodeID Generatorzoomequipdalex-herold
authored
Create link_multiple_http_protocols_in_single_url.yml (#3027)
Co-authored-by: ID Generator <[email protected]> Co-authored-by: Brandon Murphy <[email protected]> Co-authored-by: Alex Herold <[email protected]>
1 parent ba1788e commit 7b38a36

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: "Link: Multiple HTTP protocols in single URL"
2+
description: "Detects messages containing links with 5 or more HTTP protocol declarations within a single URL, indicating potential URL manipulation or obfuscation techniques."
3+
type: "rule"
4+
severity: "medium"
5+
source: |
6+
type.inbound
7+
and 0 < length(body.current_thread.links) < 10
8+
and any(body.current_thread.links,
9+
.visible
10+
// no ability to loop query_params_decoded, so create the non-decoded equivlent
11+
and not strings.icontains(.href_url.url, 'unsubscribe')
12+
and not strings.icontains(.display_text, 'unsubscribe')
13+
and any(regex.extract(.href_url.query_params,
14+
'[?&](?P<name>[^=&]+)(?:=(?P<value>[^&]*))?'
15+
),
16+
17+
// filter down to query params that start with a url
18+
regex.contains(.named_groups['value'],
19+
'^(?:https?(?:%253[Aa]|%3[Aa]|:))?(?:%252[Ff]|%2[Ff]|/)(?:%252[Ff]|%2[Ff]|/)'
20+
)
21+
// the number of unique domains in the URL query param is greater or equal to three
22+
and length(distinct(map(filter(regex.iextract(.named_groups['value'],
23+
'(?:https?(?:%253[Aa]|%3[Aa]|:))?(?:%252[Ff]|%2[Ff]|/)(?:%252[Ff]|%2[Ff]|/)(?P<domain>[^/\s&%]+)'
24+
),
25+
// sometimes URLs have // and produce entries we want to skip
26+
// so ensure it's a valid domain first
27+
strings.parse_domain(.named_groups['domain']).error is null
28+
and strings.parse_domain(.named_groups['domain']).valid
29+
// remove domain that are the same as the sender root domain
30+
and strings.parse_domain(.named_groups['domain']).root_domain != sender.email.domain.root_domain
31+
),
32+
// return just the root domian
33+
strings.parse_domain(.named_groups['domain']).root_domain
34+
), .)
35+
) >= 3
36+
37+
// there are three or more total URLs in that query param
38+
and regex.count(.named_groups['value'],
39+
'(?:https?(?:%253[Aa]|%3[Aa]|:))?(?:%252[Ff]|%2[Ff]|/)(?:%252[Ff]|%2[Ff]|/)'
40+
) >= 3
41+
)
42+
)
43+
44+
tags:
45+
- "Attack surface reduction"
46+
attack_types:
47+
- "Credential Phishing"
48+
- "Malware/Ransomware"
49+
tactics_and_techniques:
50+
- "Evasion"
51+
detection_methods:
52+
- "Content analysis"
53+
- "URL analysis"
54+
id: "92f9d241-ebd2-53b8-9c67-6f9ec3e263b8"

0 commit comments

Comments
 (0)