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

mapping hashes/hash to individual hashes #57

Closed
wmetcalf opened this issue Apr 3, 2023 · 5 comments
Closed

mapping hashes/hash to individual hashes #57

wmetcalf opened this issue Apr 3, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@wmetcalf
Copy link

wmetcalf commented Apr 3, 2023

Not sure if here is a more proper fix. I was looking at the 3cx sigma rules

https://github.com/SigmaHQ/sigma/blob/master/rules/windows/image_load/image_load_malware_3cx_compromise_susp_dll.yml

which look both in the hashes field or for a hash in a field associated with the algo i.e. sha256,md5,etc. The converted query causes Zircolite not to match because of the OR statement. This patch maps the individual hashes and allows these rules to fire.

index da24233..92bc36a 100755
--- a/zircolite.py
+++ b/zircolite.py
@@ -582,6 +582,22 @@ class JSONFlattener:
                             key = "".join(
                                 e for e in name[:-1].split(".")[-1] if e.isalnum()
                             )
+
+                        #Event 15 uses "Hash" instead of "Hashes". Hashing algo gets lower cased in rules
+                        if key == "Hashes" or key == "Hash":
+                            try:
+                                hashes = value.split(',')
+                                for fhash in hashes:
+                                    k,v = fhash.split('=')
+                                    kl = k.lower()
+                                    JSONLine[kl] = v
+                                    if kl not in self.keyDict:
+                                        self.keyDict[kl] = kl
+                                        fieldStmt += f"'{kl}' TEXT COLLATE NOCASE,\n"
+                            except Exception as e:
+                                self.logger.info(f"[+] Couldn't normalize out Hash list into individual hashes {e}")
+                                pass
+
                         JSONLine[key] = value
                         # Creating the CREATE TABLE SQL statement
                         if key.lower() not in self.keyDict:

python3 zircolite.py --evtx /opt/out//sysmon --debug --ruleset
[+] Cleaning unused objects
[+] Loading ruleset from : rules/rules_windows_sysmon_full.json
[+] Executing ruleset - 2083 rules
- Malicious DLL Load By Compromised 3CXDesktopApp [critical] : 9 events
- Potential Compromised 3CXDesktopApp Execution [high] : 9 events
- Potential Configuration And Service Reconnaissance Via Reg.EXE [medium] : 1 events
- Suspicious Msiexec Quiet Install [medium] : 1 events
- CurrentVersion Autorun Keys Modification [medium] : 1 events
- Remote Thread Creation in Suspicious Targets [high] : 1 events

@wagga40
Copy link
Owner

wagga40 commented Apr 5, 2023

Hi thanks.
Sorry for delay I didn't have access to my computer.

Zircolite is supposed to be as much as possible agnostic to rules/format/... Your patch introduce a modification for 1 field, in my opinion it should be handled elsewhere. I can look into it to provide an other solution, Can you provide the matching sample ? even if it is only one event ?

NB :
about that

#Event 15 uses "Hash" instead of "Hashes".

Zircolite has its own field mapping if you need it (here).

@wagga40
Copy link
Owner

wagga40 commented May 3, 2023

Implemented in : 0dfaa7a

@wagga40 wagga40 added the enhancement New feature or request label May 3, 2023
@wmetcalf
Copy link
Author

wmetcalf commented May 3, 2023

Somehow I missed your initial response. Thank you for implementing this!

@wagga40
Copy link
Owner

wagga40 commented May 3, 2023

All thanks to you for the idea.
It is implemented in a different branch for now, I will merge after some tests

@wagga40
Copy link
Owner

wagga40 commented May 5, 2023

Merged in #58

@wagga40 wagga40 closed this as completed May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants