cuckoosandbox/community/modules/signatures

cuckoosandbox/community/data/yara

支持

导入YARA规则作为子检测条件

community/modules/signatures/extractor/dde.py

  1. # Copyright (C) 2017 Cuckoo Foundation.
  2. # This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
  3. # See the file 'docs/LICENSE' for copying permission.
  4. import xml.etree.ElementTree as ET
  5. from cuckoo.common.abstracts import Extractor
  6. ns = {
  7. "w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
  8. }
  9. def push_command_line(self, cmdline):
  10. if cmdline.startswith(("DDE ", "DDEAUTO ")):
  11. cmdline = cmdline.split(None, 1)[1]
  12. self.push_command_line(cmdline)
  13. class OfficeDDE1(Extractor):
  14. yara_rules = "OfficeDDE1"
  15. minimum = "2.0.5"
  16. def handle_yara(self, filepath, match):
  17. root = ET.parse(filepath)
  18. elements = []
  19. for element in root.findall(".//w:instrText", ns):
  20. element.text and elements.append(element.text)
  21. push_command_line(self, "".join(elements).strip())
  22. class OfficeDDE2(Extractor):
  23. yara_rules = "OfficeDDE2"
  24. minimum = "2.0.5"
  25. def handle_yara(self, filepath, match):
  26. root = ET.parse(filepath)
  27. for element in root.findall(".//w:fldSimple", ns):
  28. cmdline = element.get("{%s}instr" % ns["w"], "").strip()
  29. cmdline and push_command_line(self, cmdline)

上文规则包括YARA规则:

rule OfficeDDE1 { strings: $s1 = “w:instrText”

  1. condition:
  2. filename matches /word\/document.xml/ and $s1

}

rule OfficeDDE2 { strings: $s1 = “w:fldSimple” $s2 = “w:instr”

  1. condition:
  2. filename matches /word\/document.xml/ and $s1 and $s2

} ```

How to configure yara rules in cuckoo