jipegit/OSXAuditor

NSRangeException index 0 beyond bounds for SessionWindow

Opened this issue · 2 comments

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.

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

Can't reproduce.