2023-11-15 15:45:25 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
"""
|
|
|
|
The Exif Module
|
|
|
|
======================
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
##################################
|
|
|
|
# Import External packages
|
|
|
|
##################################
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from PIL import Image, ExifTags
|
|
|
|
|
|
|
|
sys.path.append(os.environ['AIL_BIN'])
|
|
|
|
##################################
|
|
|
|
# Import Project packages
|
|
|
|
##################################
|
|
|
|
from modules.abstract_module import AbstractModule
|
|
|
|
|
|
|
|
|
|
|
|
class Exif(AbstractModule):
|
|
|
|
"""
|
|
|
|
CveModule for AIL framework
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(Exif, self).__init__()
|
|
|
|
|
|
|
|
# Waiting time in seconds between to message processed
|
|
|
|
self.pending_seconds = 1
|
|
|
|
|
|
|
|
# Send module state to logs
|
|
|
|
self.logger.info(f'Module {self.module_name} initialized')
|
|
|
|
|
|
|
|
def compute(self, message):
|
|
|
|
image = self.get_obj()
|
|
|
|
print(image)
|
|
|
|
img = Image.open(image.get_filepath())
|
|
|
|
img_exif = img.getexif()
|
|
|
|
print(img_exif)
|
|
|
|
if img_exif:
|
2024-02-07 10:32:18 +01:00
|
|
|
self.logger.critical(f'Exif: {self.get_obj().id}')
|
2023-11-24 15:05:19 +01:00
|
|
|
gps = img_exif.get(34853)
|
|
|
|
print(gps)
|
2024-02-07 10:32:18 +01:00
|
|
|
self.logger.critical(f'gps: {gps}')
|
2023-11-15 15:45:25 +01:00
|
|
|
for key, val in img_exif.items():
|
|
|
|
if key in ExifTags.TAGS:
|
|
|
|
print(f'{ExifTags.TAGS[key]}:{val}')
|
2024-02-07 10:32:18 +01:00
|
|
|
self.logger.critical(f'{ExifTags.TAGS[key]}:{val}')
|
2023-11-15 15:45:25 +01:00
|
|
|
else:
|
|
|
|
print(f'{key}:{val}')
|
2024-02-07 10:32:18 +01:00
|
|
|
self.logger.critical(f'{key}:{val}')
|
2023-11-15 15:45:25 +01:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
# tag = 'infoleak:automatic-detection="cve"'
|
|
|
|
# Send to Tags Queue
|
|
|
|
# self.add_message_to_queue(message=tag, queue='Tags')
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
module = Exif()
|
|
|
|
module.run()
|