jipegit / OSXAuditor

OS X Auditor is a free Mac OS X computer forensics tool
Other
3.13k stars 280 forks source link

NSRangeException index 0 beyond bounds for SessionWindow #13

Open brodjieski opened 10 years ago

brodjieski commented 10 years ago

When running OSXAuditor on a system in which a user does not have any saved Session data from Safari, an error is generated. The error is:

IndexError: NSRangeException - -[__NSCFArray objectAtIndex:]: index (0) beyond bounds (0)

The contents of the LastSession.plist are:

{ SessionVersion = "1.0"; SessionWindows = ( ); }

From what I can gather, this section (line 713) is not validating there are objects within the SessionWindows key of the plist.

if "SessionWindows" in LastSessionPlist:
    LastSession = LastSessionPlist["SessionWindows"][0]["TabStates"][0]
    PrintAndLog(LastSession["TabURL"].decode("utf-8") + u" - " + binascii.hexlify(LastSession["SessionState"]).decode("hex").decode("utf-8", "ignore"), "INFO")

Once I open some tabs in Safari and quit, the LastSession.plist file contains data in the SessionWindows key, and the osxauditor.py script runs without issue.

ActionScripted commented 10 years ago

Had the same error and this fixed things if that helps in any way. Perhaps check the length of SessionWindows?

jipegit commented 9 years ago

Can't reproduce.