fix(extractor): read registration literals from raw bytes first
Analyzer-typed string data can split short or overlapping literals; the operand points at the literal start, so trust the bytes and require a terminator within the bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ce44e30c60
commit
bddb5949a6
@@ -96,21 +96,26 @@ def _read_cstring(program, addr, maxlen=64):
|
||||
except: # noqa: E722 - Java MemoryAccessException isn't a Python Exception under Jython
|
||||
return None
|
||||
if b == 0:
|
||||
break
|
||||
return "".join(chars) if chars else None
|
||||
if b < 0x20 or b > 0x7e:
|
||||
return None # not a clean type-name literal
|
||||
chars.append(chr(b))
|
||||
i += 1
|
||||
return "".join(chars) if chars else None
|
||||
return None # the bound was reached without a terminator
|
||||
|
||||
|
||||
def _string_at(program, addr):
|
||||
if addr is None or not addr.isMemoryAddress():
|
||||
return None # skip stack/register/constant refs (e.g. inline CXString stack buffers)
|
||||
# Registration operands point to literal bytes. Prefer them over an analyzer's
|
||||
# typed string boundary (which can split short/overlapping literals).
|
||||
raw = _read_cstring(program, addr)
|
||||
if raw is not None:
|
||||
return raw
|
||||
d = program.getListing().getDataAt(addr)
|
||||
if d is not None and d.hasStringValue():
|
||||
return str(d.getValue())
|
||||
return _read_cstring(program, addr) # fall back to raw memory for undefined literals
|
||||
return None
|
||||
|
||||
|
||||
def lookback_string(program, recent):
|
||||
|
||||
Reference in New Issue
Block a user