Skip to content

Commit d42cc8d

Browse files
committed
Fix up tests
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
1 parent 76da51e commit d42cc8d

13 files changed

Lines changed: 50 additions & 39 deletions

pkg/programkind/programkind_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestPath(t *testing.T) {
4949
{"/etc/systemd/system/launcher.service", &FileType{MIME: "text/x-systemd", Ext: "service"}},
5050
{"yarn-package.json", &FileType{MIME: "application/json", Ext: "json"}},
5151
{"/home/yeti/.hidden/package.json", &FileType{MIME: "application/json", Ext: "json"}},
52-
{"unknown.json", nil},
52+
{"unknown.json", &FileType{MIME: "application/json", Ext: "json"}},
5353
}
5454
for _, tt := range tests {
5555
t.Run(tt.in, func(t *testing.T) {

pkg/report/report.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func TrimPrefixes(path string, prefixes []string) string {
365365
return path
366366
}
367367

368-
// fileMatchesRules checks the scanned file's type against a rule's defined filetypes
368+
// fileMatchesRules checks the scanned file's type against a rule's defined filetypes.
369369
func fileMatchesRule(meta []yarax.Metadata, mime string) bool {
370370
for _, m := range meta {
371371
if m.Identifier() == "filetypes" {

rules/c2/tool_transfer/download.yara

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ rule download_sites: high {
2626
$not_manual = "manually upload"
2727
$not_paste_go = "paste.go"
2828
$not_netlify = "netlify.app"
29+
$not_misp_galaxy = "misp-galaxy:"
2930
3031
condition:
3132
any of ($d_*) and none of ($not*)
@@ -56,8 +57,10 @@ rule pastebin: medium {
5657
strings:
5758
$d_pastebin = /[\w\.]{1,128}astebin[\w\.\/]{1,128}/
5859
60+
$not_misp_galaxy = "misp-galaxy:"
61+
5962
condition:
60-
any of ($d_*)
63+
any of ($d_*) and none of ($not*)
6164
}
6265

6366
rule program_dropper_url: medium {

rules/c2/tool_transfer/exe_url.yara

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ rule http_url_with_exe: high {
55
strings:
66
$exe_url = /https*:\/\/[\w\.]{0,160}[:\/\w\_\-\?\@=]{6,160}\.exe/
77
$not_mongodb_404 = "https://docs.mongodb.com/manual/reference/method/Bulk.exe"
8+
$not_elastic = "\"license\": \"Elastic License v2\""
89
910
condition:
1011
any of ($exe*) and none of ($not*)
@@ -17,8 +18,10 @@ rule http_ip_url_with_exe: critical {
1718
strings:
1819
$exe_url = /https*:\/\/[\d\.\:\[\]]{8,64}[:\/\w\_\-\?\@=]{6,160}\.exe/
1920
21+
$not_elastic = "\"license\": \"Elastic License v2\""
22+
2023
condition:
21-
any of ($exe*)
24+
any of ($exe*) and none of ($not*)
2225
}
2326

2427
rule http_url_with_msi: high {
@@ -28,8 +31,10 @@ rule http_url_with_msi: high {
2831
strings:
2932
$exe_url = /https*:\/\/[\w\.]{0,160}[:\/\w\_\-\?\@=]{6,160}\.msi/
3033
34+
$not_elastic = "\"license\": \"Elastic License v2\""
35+
3136
condition:
32-
any of ($exe*)
37+
any of ($exe*) and none of ($not*)
3338
}
3439

3540
rule http_ip_url_with_msi: critical {
@@ -39,8 +44,10 @@ rule http_ip_url_with_msi: critical {
3944
strings:
4045
$exe_url = /https*:\/\/[\d\.\:\[\]]{8,64}[:\/\w\_\-\?\@=]{6,160}\.msi/
4146
47+
$not_elastic = "\"license\": \"Elastic License v2\""
48+
4249
condition:
43-
any of ($exe*)
50+
any of ($exe*) and none of ($not*)
4451
}
4552

4653
rule http_url_with_powershell: high {
@@ -50,8 +57,10 @@ rule http_url_with_powershell: high {
5057
strings:
5158
$exe_url = /https*:\/\/[\w\.]{0,160}[:\/\w\_\-\?\@=]{6,160}\.ps1/
5259
60+
$not_elastic = "\"license\": \"Elastic License v2\""
61+
5362
condition:
54-
any of ($exe*)
63+
any of ($exe*) and none of ($not*)
5564
}
5665

5766
rule http_ip_url_with_powershell: critical {
@@ -61,6 +70,8 @@ rule http_ip_url_with_powershell: critical {
6170
strings:
6271
$exe_url = /https*:\/\/[\d\.\:\[\]]{8,64}[:\/\w\_\-\?\@=]{6,160}\.ps1/
6372
73+
$not_elastic = "\"license\": \"Elastic License v2\""
74+
6475
condition:
65-
any of ($exe*)
76+
any of ($exe*) and none of ($not*)
6677
}

rules/exfil/discord.yara

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ rule discord_bot: high {
33
description = "Uses the Discord webhooks API"
44

55
strings:
6-
$webhook_endpoint = /discordapp.com\/api\/webhooks[\/\d]{0,32}/
6+
$webhook_endpoint = /discordapp.com\/api\/webhooks[\/\d]{0,32}/
77
$webhook_endpoint2 = /discord.com\/api\/webhooks[\/\d]{0,32}/
8-
$l_discordjs = "discord.js"
9-
$l_discord4j = "discord4j"
10-
$l_discordgo = "discordgo"
11-
$l_discord = "import discord"
12-
$l_disnake = "import disnake"
13-
$l_hikari = "import hikari"
14-
$l_interactions = "import interactions"
15-
$l_nextcord = "import nextcord"
16-
$l_jda = "net.dv8tion:JDA"
17-
$l_discordia = "discordia"
18-
$l_eris = /require\(("|')eris("|')\);/
19-
$l_oceanic = /require\(("|')oceanic.js("|')\);/
20-
$l_discordphp = "use Discord\\Discord;"
8+
$l_discordjs = "discord.js"
9+
$l_discord4j = "discord4j"
10+
$l_discordgo = "discordgo"
11+
$l_discord = "import discord"
12+
$l_disnake = "import disnake"
13+
$l_hikari = "import hikari"
14+
$l_interactions = "import interactions"
15+
$l_nextcord = "import nextcord"
16+
$l_jda = "net.dv8tion:JDA"
17+
$l_discordia = "discordia"
18+
$l_eris = /require\(("|')eris("|')\);/
19+
$l_oceanic = /require\(("|')oceanic.js("|')\);/
20+
$l_discordphp = "use Discord\\Discord;"
2121
22-
$not_pypi_index = /\"index_date\":\"\d{4}-\d{2}\d{2}\"/
22+
$not_pypi_index = /\"index_date\":\"\d{4}-\d{2}\d{2}\"/
2323
$not_pypi_index2 = "\"package_names\""
2424
2525
condition:

rules/impact/remote_access/botnet.yara

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ rule botnet_high: high {
2828
description = "References a 'botnet'"
2929

3030
strings:
31-
$bot_deployed = "bot deployed"
32-
$botnet = "Botnet"
33-
$not_phishing = "phishing"
34-
$not_keylogger = "keylogger"
31+
$bot_deployed = "bot deployed"
32+
$botnet = "Botnet"
33+
$not_phishing = "phishing"
34+
$not_keylogger = "keylogger"
35+
$not_wikiticker_contribution = "Undid revision 680586363 by"
3536
3637
condition:
3738
filesize < 20MB and any of ($bot*) and none of ($not*)

rules/impact/remote_access/reverse_shell.yara

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ rule reverse_shell: high {
99
$r_reverse_space_shell = "reverse shell" nocase fullword
1010
$r_revshell = "revshell"
1111
$r_stdin_redir = "0>&1" fullword
12+
$not_elastic = "\"license\": \"Elastic License v2\""
1213
$not_ref_1 = "reverse shellConf"
1314
$not_ref_2 = "reverse shellshare"
1415
$not_pypi_index = "testpack-id-lb001"
@@ -27,6 +28,7 @@ rule possible_reverse_shell: medium {
2728
$sh_bash = "/bin/bash"
2829
$sh = "/bin/sh"
2930
31+
$not_elastic = "\"license\": \"Elastic License v2\""
3032
$not_uc2 = "ucs2reverse"
3133
$not_pypi_index = "testpack-id-lb001"
3234

tests/linux/clean/kibana/2e29e96a-b67c-455a-afe4-de6183431d0d_111.json.simple

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# linux/clean/kibana/2e29e96a-b67c-455a-afe4-de6183431d0d_111.json: high
1+
# linux/clean/kibana/2e29e96a-b67c-455a-afe4-de6183431d0d_111.json: medium
22
3P/sig_base/hacktool_strings_p0wnedshell: low
3-
c2/tool_transfer/exe_url: high
43
c2/tool_transfer/os: low
54
exec/shell/power: medium
65
impact/infection/infected: medium

tests/linux/clean/kibana/951779c2-82ad-4a6c-82b8-296c1f691449_2.json.simple

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# linux/clean/kibana/951779c2-82ad-4a6c-82b8-296c1f691449_2.json: high
1+
# linux/clean/kibana/951779c2-82ad-4a6c-82b8-296c1f691449_2.json: medium
22
3P/sig_base/p0wnedpotato: low
3-
c2/tool_transfer/exe_url: high
43
c2/tool_transfer/os: low
54
exec/shell/power: medium
65
net/download: medium

tests/linux/clean/kibana/ac96ceb8-4399-4191-af1d-4feeac1f1f46_108.json.simple

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# linux/clean/kibana/ac96ceb8-4399-4191-af1d-4feeac1f1f46_108.json: high
1+
# linux/clean/kibana/ac96ceb8-4399-4191-af1d-4feeac1f1f46_108.json: medium
22
3P/sig_base/hacktool_strings_p0wnedshell: low
33
c2/addr/url: medium
4-
c2/tool_transfer/exe_url: high
54
c2/tool_transfer/os: low
65
credential/password: low
76
exec/shell/power: medium

0 commit comments

Comments
 (0)