def _parse_google_photo_location(database, result_path): """Parse Google photo location. Args: database (SQLite3): target SQLite3 database. result_path (str): result path. """ try: cursor = database.cursor() cursor.execute("PRAGMA database_list") # for database file name rows = cursor.fetchall() db_name = rows[0][2][rows[0][2].rfind(os.path.sep) + 1:] cursor.execute(location_query) results = cursor.fetchall() num_of_results = len(results) except Exception as e: #print(str(e)) return False data = {} header = ('package_name', 'timestamp', 'longitude', 'latitude', 'contents', 'source', 'is_visited') data['number_of_data_headers'] = len(header) data['number_of_data'] = num_of_results data['data_header'] = header data['title'] = "geodata" data_list = [] if num_of_results >0: for row in results: data_list.append(("com.google.android.apps.photos", row['timestamp'], row['longitude'], row['latitude'], row['contents'], "DB:"+db_name+"|Table:local_media", "Yes")) data['data'] = data_list else: logger.info('Not found location data!') return data
def _parse_yogiyo_location(database, result_path): """Parse Yogiyo location. Args: database (SQLite3): target SQLite3 database. result_path (str): result path. """ cursor = database.cursor() cursor.execute("PRAGMA database_list") # for database file name rows = cursor.fetchall() db_name = rows[0][2][rows[0][2].rfind(os.path.sep) + 1:] cursor.execute(location_query) results = cursor.fetchall() num_of_results = len(results) data = {} header = ('package_name', 'timestamp', 'longitude', 'latitude', 'contents', 'source', 'is_visited') data['number_of_data_headers'] = len(header) data['number_of_data'] = num_of_results data['data_header'] = header data['title'] = "geodata" data_list = [] if num_of_results > 0: for row in results: data_list.append( ("com.fineapp.yogiyo", row['timestamp'], row['longitude'], row['latitude'], row['contents'], "DB:" + db_name + "|Table:locationSearch", "No")) data['data'] = data_list else: logger.info('Not found location data!') return data
def main(input=None, debug_mode=False, quiet_mode=False): #TODO: print program infromation. if not input: argument_parser = argparse.ArgumentParser(description='Android User Apps Parser.') argument_parser.add_argument('-i', '--input_path', required=True, action='store', help='Path to input file/directory') argument_parser.add_argument('-o', '--output_path', required=True, action='store', help='Output path') argument_parser.add_argument('-d', '--debug', default=False ,action='store', help='set debug mode') argument_parser.add_argument('-q', '--quiet', default=False, action='store', help='set quiet mode') args = argument_parser.parse_args() input_path = args.input_path output_path = os.path.abspath(args.output_path) _debug_mode = args.debug _quiet_mode = args.quiet else: input_path = input output_path = input _debug_mode = debug_mode _quiet_mode = quiet_mode if len(input_path) == 0: print('invalid input file or directory.') return if len(output_path) == 0: print('invalid output file or directory.') return # set output directory and logfile local_date_time = datetime.datetime.now() _result_path = ('{0:s}AU2A_Results-{1:04d}{2:02d}{3:02d}T{4:02d}{5:02d}{6:02d}').format( output_path + os.sep, local_date_time.year, local_date_time.month, local_date_time.day, local_date_time.hour, local_date_time.minute, local_date_time.second) _log_file = ( '{0:s}{1:s}-{2:04d}{3:02d}{4:02d}T{5:02d}{6:02d}{7:02d}.log.gz').format( _result_path, os.sep + 'AU2A', local_date_time.year, local_date_time.month, local_date_time.day, local_date_time.hour, local_date_time.minute, local_date_time.second) loggers.ConfigureLogging(debug_output=_debug_mode, filename=_log_file, quiet_mode=_quiet_mode) results = [] for key, val in SUPPORTED_USER_APPS.items(): search_results = search(input_path, val[0]) if not search_results: logger.info(f'No results: {key}:{val[0]}') else: result = process(search_results, val[1], _result_path) if result: for ret in result: results.append(ret) return results
def parse_google_photo(target_files, result_path): """Parse Google photo databases. Args: target_files (list): target files. result_path (str): result path. """ logger.info('Parse Google photo databases.') results = [] for file in target_files: if str(file).find('com.google.android.apps.photos'+os.path.sep+'databases'+os.path.sep+'gphotos'): database = sqlite3.connect(str(file)) database.row_factory = sqlite3.Row location_data = _parse_google_photo_location(database, result_path) if location_data: results.append(location_data) return results
def parse_yogiyo(target_files, result_path): """Parse Yogiyo databases. Args: target_files (list): target files. result_path (str): result path. """ logger.info('Parse Yogiyo databases.') results = [] for file in target_files: if str(file).endswith('ygy-database'): database = sqlite3.connect(str(file)) database.row_factory = sqlite3.Row location_data = _parse_yogiyo_location(database, result_path) if location_data: results.append(location_data) return results
def parse_media(target_files, result_path): """Parse media databases. Args: target_files (list): target files. result_path (str): result path. """ logger.info('Parse media databases.') results = [] for file in target_files: if str(file).endswith('external.db') or str(file).endswith( 'internal.db'): database = sqlite3.connect(str(file)) database.row_factory = sqlite3.Row location_data = _parse_media_location(database, result_path) if location_data: results.append(location_data) return results