Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_strings(vw):
'''
enumerate the strings in the given vivisect workspace.
Args:
vw (vivisect.Workspace): the workspace.
Yields:
Tuple[int, str]: the address, string pair.
'''
for loc in vw.getLocations(ltype=vivisect.const.LOC_STRING):
va = loc[vivisect.const.L_VA]
size = loc[vivisect.const.L_SIZE]
yield va, vw.readMemory(va, size).decode('ascii')
for loc in vw.getLocations(ltype=vivisect.const.LOC_UNI):
va = loc[vivisect.const.L_VA]
size = loc[vivisect.const.L_SIZE]
try:
yield va, vw.readMemory(va, size).decode('utf-16le')
except UnicodeDecodeError:
continue