Autopsy  4.13.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
XRYContactsFileParser.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.datasourceprocessors.xry;
20 
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.Optional;
26 import java.util.logging.Level;
28 import org.sleuthkit.datamodel.BlackboardAttribute;
29 import org.sleuthkit.datamodel.BlackboardArtifact;
30 import org.sleuthkit.datamodel.Content;
31 import org.sleuthkit.datamodel.TskCoreException;
32 
36 final class XRYContactsFileParser extends AbstractSingleEntityParser {
37 
38  private static final Logger logger = Logger.getLogger(XRYContactsFileParser.class.getName());
39 
40  //All of the known XRY keys for contacts.
41  private static final Map<String, BlackboardAttribute.ATTRIBUTE_TYPE> XRY_KEYS =
42  new HashMap<String, BlackboardAttribute.ATTRIBUTE_TYPE>() {{
43  put("name", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
44  put("tel", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER);
45  put("mobile", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_MOBILE);
46  put("home", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_HOME);
47  put("related application", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME);
48  put("address home", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_LOCATION);
49  put("email home", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_HOME);
50  put("deleted", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ISDELETED);
51 
52  //Ignoring or need more information to decide.
53  put("storage", null);
54  put("other", null);
55  put("picture", null);
56  put("index", null);
57  put("account name", null);
58 
59  }};
60 
61  @Override
62  boolean canProcess(XRYKeyValuePair pair) {
63  String normalizedKey = pair.getKey().toLowerCase();
64  return XRY_KEYS.containsKey(normalizedKey);
65  }
66 
67  @Override
68  boolean isNamespace(String nameSpace) {
69  //No namespaces are currently known for this report type.
70  return false;
71  }
72 
77  private Optional<BlackboardAttribute> getBlackboardAttribute(XRYKeyValuePair pair) {
78  String normalizedKey = pair.getKey().toLowerCase();
79  BlackboardAttribute.ATTRIBUTE_TYPE attrType = XRY_KEYS.get(normalizedKey);
80  if(attrType != null) {
81  return Optional.of(new BlackboardAttribute(attrType, PARSER_NAME, pair.getValue()));
82  }
83 
84  logger.log(Level.INFO, String.format("[XRY DSP] Key value pair "
85  + "(in brackets) [ %s ] was recognized but we need "
86  + "more data or time to finish implementation. Discarding... ",
87  pair));
88  return Optional.empty();
89  }
90 
91  @Override
92  void makeArtifact(List<XRYKeyValuePair> keyValuePairs, Content parent) throws TskCoreException {
93  List<BlackboardAttribute> attributes = new ArrayList<>();
94  for(XRYKeyValuePair pair : keyValuePairs) {
95  Optional<BlackboardAttribute> attribute = getBlackboardAttribute(pair);
96  if(attribute.isPresent()) {
97  attributes.add(attribute.get());
98  }
99  }
100  if(!attributes.isEmpty()) {
101  BlackboardArtifact artifact = parent.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT);
102  artifact.addAttributes(attributes);
103  }
104  }
105 }

Copyright © 2012-2019 Basis Technology. Generated on: Tue Jan 7 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.