Skip to content

Commit

Permalink
add check for pointer to string
Browse files Browse the repository at this point in the history
Check if memory referenced is a pointer to a string. Fixes mimikatz
string test.
  • Loading branch information
jcrussell committed Oct 30, 2020
1 parent 74b2c18 commit 8f6a46e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions capa/features/extractors/smda/insn.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import string
import struct

from smda.common.SmdaReport import SmdaReport

Expand Down Expand Up @@ -172,6 +173,18 @@ def extract_insn_string_features(f, bb, insn):
string_read = read_string(f.smda_report, data_ref)
if string_read:
yield String(string_read.rstrip("\x00")), insn.offset
continue

# test to see if we're referencing a pointer and that points to a string
bytes_ = read_bytes(insn.smda_function.smda_report, data_ref, num_bytes=4)
val = struct.unpack("I", bytes_)[0]
if val and insn.smda_function.smda_report.isAddrWithinMemoryImage(val):
# it is a pointer, check if it points to a string
string_read = read_string(f.smda_report, val)
if string_read:
yield String(string_read.rstrip("\x00")), insn.offset
continue



def extract_insn_offset_features(f, bb, insn):
Expand Down

0 comments on commit 8f6a46e

Please sign in to comment.