Skip to content

Commit

Permalink
Merge pull request #43 from tstromberg/main
Browse files Browse the repository at this point in the history
Make output more concise
  • Loading branch information
tstromberg authored Mar 9, 2024
2 parents 0450e12 + 905377e commit 6b60c7d
Show file tree
Hide file tree
Showing 25 changed files with 29 additions and 13 deletions.
15 changes: 9 additions & 6 deletions pkg/bincapz/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func forceWrap(s string, x int) string {
fw := []string{}
for _, w := range words {
if len(w) > x-2 {
klog.Infof("wrapping %s - longer than %d", w, x-2)
w = w[0:x-2] + ".."
}
fw = append(fw, w)
Expand Down Expand Up @@ -85,19 +86,21 @@ func RenderTable(fr *FileReport, w io.Writer) {
data = append(data, []string{"", "", "", ""})
}

valWidth := 24
width := terminalWidth()
if width > 110 {
valWidth += (width - 110)
valWidth := 8

if width > 90 {
valWidth = (width - 90)
}

if valWidth > 65 {
valWidth = 65
}

klog.Infof("terminal width: %d / val width: %d", width, valWidth)

for _, k := range kbs {
val := strings.Join(k.Behavior.Strings, "|||")
val := strings.Join(k.Behavior.Strings, "\n")
val = forceWrap(val, valWidth)
val = strings.ReplaceAll(val, "|||", "\n")

Expand All @@ -114,15 +117,15 @@ func RenderTable(fr *FileReport, w io.Writer) {
}
}

words, _ := tablewriter.WrapString(desc, 52)
words, _ := tablewriter.WrapString(desc, 40)
desc = strings.Join(words, "\n")

data = append(data, []string{fmt.Sprintf("%d/%s", k.Behavior.RiskScore, k.Behavior.RiskLevel), k.Key, val, desc})
}
table := tablewriter.NewWriter(os.Stdout)
table.SetAutoWrapText(false)
table.SetHeader([]string{"Risk", "Key", "Values", "Description"})
//table.SetBorder(false)
table.SetBorder(false)
for _, d := range data {
if strings.Contains(d[0], "LOW") {
table.Rich(d, []tablewriter.Colors{tablewriter.Colors{tablewriter.Normal, tablewriter.FgGreenColor}})
Expand Down
1 change: 1 addition & 0 deletions pkg/bincapz/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ var yaraForgeJunkWords = map[string]bool{
"encoded": true,
"forensicartifacts": true,
"lnx": true,
"linux": true,
}

var dateRe = regexp.MustCompile(`[a-z]{3}\d{1,2}`)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

rule system_log_references {
rule system_log_references : suspicious {
meta:
description = "Accesses multiple sensitive Linux logs"
strings:
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions rules/combo/worm/ssh.yara
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
rule generic_scan_tool : critical {
rule generic_scan_tool : suspicious {
meta:
description = "Probably an SSH worm, like SSH-Snake"
description = "possible SSH worm like SSH-Snake"
strings:
$s_dot_ssh = ".ssh"
$s_authorized_keys = "authorized_keys"
Expand Down
13 changes: 12 additions & 1 deletion rules/data/embedded-pem-private_key.yara
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rule begin_key {
rule begin_private_key : notable {
meta:
description = "Contains PRIVATE KEY directive"
strings:
Expand All @@ -7,4 +7,15 @@ rule begin_key {
any of them
}

rule rsa_private_key : notable {
meta:
description = "Contains RSA PRIVATE KEY directive"
strings:
$ref = "RSA PRIVATE KEY-----"
condition:
any of them
}




3 changes: 2 additions & 1 deletion rules/data/embedded-ssh-key.yara
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
rule ssh_pubilc_key : suspicious {
rule ssh_public_key : suspicious {
meta:
description = "contains SSH public key"
ref = "https://unfinished.bike/qubitstrike-and-diamorphine-linux-kernel-rootkits-go-mainstream"
strings:
$ssh_rsa = /ssh-[dr]sa [\w\+\/\=]{0,1024} [\w\-\.]{0,32}\@[\w\.\-]{1,64}/
Expand Down
2 changes: 1 addition & 1 deletion rules/ref/email.yara
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rule email_addr {
rule email_addr : harmless {
meta:
description = "Contains an email address"
strings:
Expand Down
1 change: 1 addition & 0 deletions rules/techniques/code_eval.yara
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ rule eval : suspicious {
condition:
any of them
}

0 comments on commit 6b60c7d

Please sign in to comment.