mirror of
https://github.com/elisspace/autopsy.git
synced 2026-10-09 10:30:59 +00:00
395 lines
19 KiB
Python
395 lines
19 KiB
Python
"""
|
|
Autopsy Forensic Browser
|
|
|
|
Copyright 2019-2020 Basis Technology Corp.
|
|
Contact: carrier <at> sleuthkit <dot> org
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
"""
|
|
from java.io import File
|
|
from java.lang import Class
|
|
from java.lang import ClassNotFoundException
|
|
from java.lang import Long
|
|
from java.lang import String
|
|
from java.sql import ResultSet
|
|
from java.sql import SQLException
|
|
from java.sql import Statement
|
|
from java.util.logging import Level
|
|
from java.util import ArrayList
|
|
from org.apache.commons.codec.binary import Base64
|
|
from org.sleuthkit.autopsy.casemodule import Case
|
|
from org.sleuthkit.autopsy.coreutils import Logger
|
|
from org.sleuthkit.autopsy.coreutils import MessageNotifyUtil
|
|
from org.sleuthkit.autopsy.coreutils import AppSQLiteDB
|
|
|
|
from org.sleuthkit.autopsy.datamodel import ContentUtils
|
|
from org.sleuthkit.autopsy.ingest import IngestJobContext
|
|
from org.sleuthkit.datamodel import AbstractFile
|
|
from org.sleuthkit.datamodel import BlackboardArtifact
|
|
from org.sleuthkit.datamodel import BlackboardAttribute
|
|
from org.sleuthkit.datamodel import Content
|
|
from org.sleuthkit.datamodel import TskCoreException
|
|
from org.sleuthkit.datamodel.Blackboard import BlackboardException
|
|
from org.sleuthkit.autopsy.casemodule import NoCurrentCaseException
|
|
from org.sleuthkit.datamodel import Account
|
|
from org.sleuthkit.datamodel.blackboardutils import CommunicationArtifactsHelper
|
|
from org.sleuthkit.datamodel.blackboardutils.attributes import MessageAttachments
|
|
from org.sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments import FileAttachment
|
|
from org.sleuthkit.datamodel.blackboardutils.CommunicationArtifactsHelper import MessageReadStatus
|
|
from org.sleuthkit.datamodel.blackboardutils.CommunicationArtifactsHelper import CommunicationDirection
|
|
from TskMessagesParser import TskMessagesParser
|
|
from TskContactsParser import TskContactsParser
|
|
from TskCallLogsParser import TskCallLogsParser
|
|
|
|
import traceback
|
|
import general
|
|
|
|
class ViberAnalyzer(general.AndroidComponentAnalyzer):
|
|
"""
|
|
Parses the Viber App databases for TSK contacts, message
|
|
and calllog artifacts.
|
|
|
|
The Viber v11.5.0 database structure is as follows:
|
|
- People can take part in N conversation(s). A conversation can have M
|
|
members and messages are exchanged in a conversation.
|
|
- Viber has a conversation table, a participant table (the people/members in the above
|
|
analogy) and a messages table.
|
|
- Each row of the participants table maps a person to a conversation_id
|
|
- Each row in the messages table has a from participant id and a conversation id.
|
|
"""
|
|
|
|
def __init__(self):
|
|
self._logger = Logger.getLogger(self.__class__.__name__)
|
|
self._VIBER_PACKAGE_NAME = "com.viber.voip"
|
|
self._PARSER_NAME = "Viber Parser"
|
|
self._VERSION = "11.5.0"
|
|
|
|
def analyze(self, dataSource, fileManager, context):
|
|
"""
|
|
Extract, Transform and Load all messages, contacts and
|
|
calllogs from the Viber databases.
|
|
"""
|
|
|
|
try:
|
|
contact_and_calllog_dbs = AppSQLiteDB.findAppDatabases(dataSource,
|
|
"viber_data", True, self._VIBER_PACKAGE_NAME)
|
|
message_dbs = AppSQLiteDB.findAppDatabases(dataSource,
|
|
"viber_messages", True, self._VIBER_PACKAGE_NAME)
|
|
|
|
#Extract TSK_CONTACT and TSK_CALLLOG information
|
|
for contact_and_calllog_db in contact_and_calllog_dbs:
|
|
current_case = Case.getCurrentCaseThrows()
|
|
helper = CommunicationArtifactsHelper(
|
|
current_case.getSleuthkitCase(), self._PARSER_NAME,
|
|
contact_and_calllog_db.getDBFile(), Account.Type.VIBER)
|
|
self.parse_contacts(contact_and_calllog_db, helper)
|
|
self.parse_calllogs(contact_and_calllog_db, helper)
|
|
|
|
#Extract TSK_MESSAGE information
|
|
for message_db in message_dbs:
|
|
current_case = Case.getCurrentCaseThrows()
|
|
helper = CommunicationArtifactsHelper(
|
|
current_case.getSleuthkitCase(), self._PARSER_NAME,
|
|
message_db.getDBFile(), Account.Type.VIBER)
|
|
self.parse_messages(message_db, helper, current_case)
|
|
|
|
except NoCurrentCaseException as ex:
|
|
self._logger.log(Level.WARNING, "No case currently open.", ex)
|
|
self._logger.log(Level.WARNING, traceback.format_exc())
|
|
|
|
for message_db in message_dbs:
|
|
message_db.close()
|
|
|
|
for contact_and_calllog_db in contact_and_calllog_dbs:
|
|
contact_and_calllog_db.close()
|
|
|
|
def parse_contacts(self, contacts_db, helper):
|
|
try:
|
|
contacts_parser = ViberContactsParser(contacts_db)
|
|
while contacts_parser.next():
|
|
if (not(not contacts_parser.get_phone() or contacts_parser.get_phone().isspace |