Skip to content

Commit

Permalink
various signature improvements and bugfixes
Browse files Browse the repository at this point in the history
Rename the mark() function to be more distinct - mark_call().
There is no longer an add_match() function, just match().
One of the on_ functions has to return True for the signature to really
match.
Forgot to filter API names in the recon_systeminfo signature.
  • Loading branch information
jbremer committed Aug 23, 2015
1 parent 3f934eb commit 73a132e
Show file tree
Hide file tree
Showing 32 changed files with 47 additions and 45 deletions.
2 changes: 1 addition & 1 deletion modules/signatures/windows/antidbg_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ def on_call(self, call, process):
class_name = call["arguments"].get("class_name", "").lower()

if indicator == window_name or indicator == class_name:
self.mark()
self.mark_call()
return True
2 changes: 1 addition & 1 deletion modules/signatures/windows/antisandbox_mouse_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ class HookMouse(Signature):
def on_call(self, call, process):
if call["arguments"]["hook_identifier"] in [7, 14]:
if not call["arguments"]["thread_identifier"]:
self.mark()
self.mark_call()
return True
2 changes: 1 addition & 1 deletion modules/signatures/windows/antisandbox_productid.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ class GetProductID(Signature):
def on_call(self, call, process):
regkey = call["arguments"].get("regkey", "").lower()
if regkey.endswith("productid"):
self.mark()
self.mark_call()
return True
2 changes: 1 addition & 1 deletion modules/signatures/windows/antisandbox_unhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ class Unhook(Signature):
filter_apinames = "__anomaly__",

def on_call(self, call, process):
self.mark()
self.mark_call()
return True
3 changes: 2 additions & 1 deletion modules/signatures/windows/antivm_generic_bios.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ class AntiVMBios(Signature):
def on_call(self, call, process):
regkey = call["arguments"].get("regkey", "").lower()
if regkey.endswith(("systembiosversion", "videobiosversion")):
self.mark()
self.mark_call()
return True
4 changes: 2 additions & 2 deletions modules/signatures/windows/antivm_generic_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def on_call(self, call, process):
if call["api"] == "NtCreateFile":
filepath = call["arguments"]["filepath"].lower()
if "scsi0" in filepath or "physicaldrive0" in filepath:
self.mark()
self.mark_call()

if call["api"] in ["DeviceIoControl", "NtDeviceIoControlFile"]:
if self.marked and call["arguments"]["control_code"] in self.ioctls:
self.mark()
self.mark_call()
return True
2 changes: 1 addition & 1 deletion modules/signatures/windows/antivm_generic_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AntiVMServices(Signature):
filter_apinames = "EnumServicesStatusA", "EnumServicesStatusW"

def on_call(self, call, process):
self.mark()
self.mark_call()
return True

def on_complete(self):
Expand Down
2 changes: 1 addition & 1 deletion modules/signatures/windows/antivm_vbox_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ def on_complete(self):
for indicator in self.indicators:
filepath = self.check_file(pattern=indicator, regex=True)
if filepath:
self.add_match(None, "file", filepath=filepath)
self.match(None, "file", filepath=filepath)
2 changes: 1 addition & 1 deletion modules/signatures/windows/antivm_vbox_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ class VBoxDetectKeys(Signature):
def on_complete(self):
regkey = self.check_key(pattern=self.indicator, regex=True)
if regkey:
self.add_match(None, "registry", regkey=regkey)
self.match(None, "registry", regkey=regkey)
2 changes: 1 addition & 1 deletion modules/signatures/windows/antivm_vbox_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ def on_call(self, call, process):
class_name = call["arguments"].get("class_name", "").lower()

if indicator == window_name or indicator == class_name:
self.mark()
self.mark_call()
return True
2 changes: 1 addition & 1 deletion modules/signatures/windows/apt_turlacarbon.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def on_call(self, call, process):
break
else:
self.wrote = True
self.mark()
self.mark_call()
return True

def on_complete(self):
Expand Down
2 changes: 1 addition & 1 deletion modules/signatures/windows/banker_prinimalka.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ class Prinimalka(Signature):
def on_call(self, call, process):
regkey = call["arguments"]["regkey"].lower()
if regkey.endswith("_opt_server1"):
self.mark(c2=call["arguments"]["value"])
self.mark_call(c2=call["arguments"]["value"])
return True
2 changes: 1 addition & 1 deletion modules/signatures/windows/banker_spyeye_mutex.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ def on_complete(self):
for indicator in self.indicators:
mutex = self.check_mutex(pattern=indicator, regex=True)
if mutex:
self.add_match(None, "mutex", mutex=mutex)
self.match(None, "mutex", mutex=mutex)
2 changes: 1 addition & 1 deletion modules/signatures/windows/banker_zeus_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ def on_complete(self):
for indicator in self.indicators:
url = self.check_url(pattern=indicator, regex=True)
if url:
self.add_match(None, "url", url=url)
self.match(None, "url", url=url)
2 changes: 1 addition & 1 deletion modules/signatures/windows/bitcoin_opencl.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ class BitcoinOpenCL(Signature):
def on_complete(self):
filepath = self.check_file(pattern=".*OpenCL\.dll$", regex=True)
if filepath:
self.add_match(None, "file", filepath=filepath)
self.match(None, "file", filepath=filepath)
2 changes: 1 addition & 1 deletion modules/signatures/windows/bot_russkill.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ class Ruskill(Signature):
def on_complete(self):
mutex = self.check_mutex(pattern="FvLQ49IlzIyLjj6m")
if mutex:
self.add_match(None, "mutex", mutex=mutex)
self.match(None, "mutex", mutex=mutex)
3 changes: 1 addition & 2 deletions modules/signatures/windows/downloader_cabby.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ def on_complete(self):
else:
return False

self.add_match(None, 'cabby_ioc', signs)
return True
self.match(None, 'cabby_ioc', signs)
3 changes: 2 additions & 1 deletion modules/signatures/windows/exec_crash.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ class Crash(Signature):

def on_call(self, call, process):
if "faultrep.dll" in call["arguments"]["module_name"].lower():
self.mark()
self.mark_call()
return True
2 changes: 1 addition & 1 deletion modules/signatures/windows/infostealer_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ def on_complete(self):
for indicator in self.indicators:
filepath = self.check_file(pattern=indicator, regex=True)
if filepath:
self.add_match(None, "file", filepath=filepath)
self.match(None, "file", filepath=filepath)
2 changes: 1 addition & 1 deletion modules/signatures/windows/infostealer_keylogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ class Keylogger(Signature):
def on_call(self, call, process):
if call["arguments"]["hook_identifier"] in [2, 13]:
if not call["arguments"]["thread_identifier"]:
self.mark()
self.mark_call()
return True
6 changes: 2 additions & 4 deletions modules/signatures/windows/injection_runpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@ def on_process(self, process):

def on_call(self, call, process):
self.functions[process["pid"]].add(call["api"])
self.mark()
self.mark_call()

def on_complete(self):
# Only mark this signature if one or more of the following matches.
self.marked = False

for pid, functions in self.functions.items():
if len(functions) >= len(self.filter_apinames)-2:
self.match(None, "injection", pid=pid)
return True
6 changes: 2 additions & 4 deletions modules/signatures/windows/injection_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ def on_process(self, process):

def on_call(self, call, process):
self.functions[process["pid"]].add(call["api"])
self.mark()
self.mark_call()

def on_complete(self):
# Only mark this signature if one or more of the following matches.
self.marked = False

for pid, functions in self.functions.items():
if len(functions) >= len(self.filter_apinames)-2:
self.match(None, "injection", pid=pid)
return True
4 changes: 3 additions & 1 deletion modules/signatures/windows/network_tor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ def on_call(self, call, process):

if service_name == "Tor Win32 Service" or \
display_name == "Tor Win32 Service":
self.mark()
self.mark_call()
return True

def on_complete(self):
for indicator in self.indicators:
filepath = self.check_file(pattern=indicator, regex=True)
if filepath:
self.match(None, "file", filepath=filepath)
return True
2 changes: 1 addition & 1 deletion modules/signatures/windows/packer_entropy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def on_complete(self):
total_pe_data += int(section["size_of_data"], 16)

if float(section["entropy"]) > 6.8:
self.add_match(None, "section", section)
self.match(None, "section", section)
total_compressed += int(section["size_of_data"], 16)

if total_pe_data and float(total_compressed) / total_pe_data > .2:
Expand Down
4 changes: 2 additions & 2 deletions modules/signatures/windows/persistence_autorun.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def on_complete(self):
for indicator in self.indicators:
regkey = self.check_key(pattern=indicator, regex=True)
if regkey:
self.add_match(None, "autorun", regkey=regkey)
self.match(None, "autorun", regkey=regkey)

for indicator in self.indicators2:
filepath = self.check_file(pattern=indicator, regex=True)
if filepath:
self.add_match(None, "autorun", filepath=filepath)
self.match(None, "autorun", filepath=filepath)
6 changes: 3 additions & 3 deletions modules/signatures/windows/rat_comRAT.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ def on_call(self, call, process):
subject=oldfilepath,
regex=True):
self.move_count += 1
self.mark()
self.mark_call()

if call["api"] == "CreateProcessInternalW":
# start rundll32.exe Install?
if "rundll32.exe" in call["arguments"]["command_line"] and \
"Install" in call["arguments"]["command_line"]:
self.created_process = True
self.mark()
self.mark_call()

if call["api"] == "NtWriteFile" and \
call["arguments"]["buffer"][:2] == "MZ":
self.wrote_pe_file = True
self.mark()
self.mark_call()

def on_complete(self):
if not self.check_key(pattern=registry_indicator, regex=True):
Expand Down
2 changes: 1 addition & 1 deletion modules/signatures/windows/rat_fynloski_mutex.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ def on_complete(self):
for indicator in self.indicators:
mutex = self.check_mutex(pattern=indicator, regex=True)
if mutex:
self.add_match(None, "mutex", mutex=mutex)
self.match(None, "mutex", mutex=mutex)
4 changes: 2 additions & 2 deletions modules/signatures/windows/rat_pcclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def on_complete(self):
for indicator in self.indicators:
mutex = self.check_mutex(pattern=indicator, regex=True)
if mutex:
self.add_match(None, "mutex", mutex=mutex)
self.match(None, "mutex", mutex=mutex)

for indicator in self.indicators2:
filepath = self.check_file(pattern=indicator, regex=True)
if filepath:
self.add_match(None, "file", filepath=filepath)
self.match(None, "file", filepath=filepath)
4 changes: 2 additions & 2 deletions modules/signatures/windows/rat_spynet.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def on_complete(self):
for indicator in self.indicators:
mutex = self.check_mutex(pattern=indicator, regex=True)
if mutex:
self.add_match(None, "mutex", mutex=mutex)
self.match(None, "mutex", mutex=mutex)

for indicator in self.indicators2:
regkey = self.check_key(pattern=indicator, regex=True)
if regkey:
self.add_match(None, "registry", regkey)
self.match(None, "registry", regkey)
2 changes: 1 addition & 1 deletion modules/signatures/windows/rat_xtreme_mutex.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ def on_complete(self):
for indicator in self.indicators:
mutex = self.check_mutex(pattern=indicator, regex=True)
if mutex:
self.add_match(None, "mutex", mutex=mutex)
self.match(None, "mutex", mutex=mutex)
2 changes: 1 addition & 1 deletion modules/signatures/windows/recon_checkip.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ def on_complete(self):
for indicator in self.indicators:
domain = self.check_domain(pattern=indicator)
if domain:
self.add_match(None, "domain", domain=domain)
self.match(None, "domain", domain=domain)
5 changes: 4 additions & 1 deletion modules/signatures/windows/recon_systeminfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ class SystemInfo(Signature):
authors = ["nex"]
minimum = "2.0"

filter_apinames = "CreateProcessInternalW",

def on_call(self, call, process):
if self._check_value(pattern="^cmd\.exe.*(systeminfo|ipconfig|netstat)",
subject=call["arguments"]["command_line"],
regex=True):
self.mark()
self.mark_call()
return True

0 comments on commit 73a132e

Please sign in to comment.