Skip to content

Commit

Permalink
Maintenance Bug Fixes
Browse files Browse the repository at this point in the history
-> Fix Audio and torrent metadata cleaning not working.
-> Better Cleaning of TIFF files implemented closes #13 .
-> Better Exception Handling.
  • Loading branch information
Anish-M-code committed Mar 19, 2023
1 parent 21c4a72 commit 02f7624
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 41 deletions.
103 changes: 75 additions & 28 deletions Source Code/C Source code/run.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

/* Metadata Removal Tool v3.2.8 for windows. Compile using gcc c complier mingw only*/
/* Metadata Removal Tool v3.5.0 for windows. Compile using gcc c complier mingw only*/
//[ THIS IS A STABLE RELEASE]

#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<stdbool.h>

char file[80],vfile[80],fil[50],vfil[50];

Expand All @@ -20,10 +22,11 @@ void pause()
void checker()
{
int check=0;
char eff[80];
char eff[80];
memcpy(eff,"exiftool ",10);eff[9]='\0';
strcat(eff,file);
strcat(eff,">output.txt");

check=system(eff);
if(check!=0)
{
Expand Down Expand Up @@ -55,41 +58,78 @@ void vchecker()
}

//Function to get input from user.
void input()
void input()
{
system("cls");
printf("\n\t|---------Image Sanitisation Tool ---------|\n");
printf("\n\n Enter Image name:");
scanf("%30s",fil);
memcpy(file,"Images\\",9);file[8]='\0';
memcpy(file,"Images\\",8);file[8]='\0';
strcat(file,fil);
}

bool endswith(const char str1[] , const char str2[] )
{
int i = 0;
int j = 0;
int str1_length = strlen(str1);
int str2_length = strlen(str2);
if(str1_length > str2_length)
{
for(i = str2_length-1,j=str1_length-1; i>=0;--j,--i)
{
if(tolower(str1[j])!= tolower(str2[i]))
{
return false;
}
}
return true;
}
return false;

}

//Function to sanitize the image selected using exiftool.
void sanitize()
{
int check=0;
int file_length = 0;
int visit = 0;
char eff[80];
memcpy(eff,"exiftool ",10);eff[9]='\0';
strcat(eff,file);
strcat(eff," -all=");
check=system(eff);
char tmp[80];
file_length = strlen(file);

if( endswith(file,"tiff") || endswith(file,"tif"))
{
memcpy(tmp,"exiftool -all= -CommonIFD0= ",28);tmp[28] = '\0';
strcat(tmp,file);
check=system(tmp);
visit = 1;
}

else if(visit == 0){
memcpy(eff,"exiftool ",10);eff[9]='\0';
strcat(eff,file);
strcat(eff," -all=");
check=system(eff);
}
if(check!=0)
{
printf("\n\nImage Sanitization failed maybe exiftool is missing!\nor Something went wrong like you entering a non image file!");
system("start https://exiftool.org");
pause();
exit(0);
}

}

//Function to generate and check generation of input log.
void ichecker()
void ichecker()
{
int check=0;
char eff[80];
memcpy(eff,"exiftool ",10);eff[9]='\0';
strcat(eff,file);
int check=0;
char eff[80];
memcpy(eff,"exiftool ",10);eff[9]='\0';
strcat(eff,file);
strcat(eff,">input.txt");
check=system(eff);
if(check!=0)
Expand All @@ -103,12 +143,12 @@ void sanitize()


//Function to generate and check generation of input log for videos.
void ivchecker()
void ivchecker()
{
int check=0;
char eff[200];
memcpy(eff,"exiftool ",10);eff[9]='\0';
strcat(eff,vfile);
int check=0;
char eff[200];
memcpy(eff,"exiftool ",10);eff[9]='\0';
strcat(eff,vfile);
strcat(eff,">video_input_metadata.txt");
check=system(eff);
if(check!=0)
Expand All @@ -121,18 +161,19 @@ void sanitize()
}

//Function to add support for * wildcards.
void detect()
void detect()
{
FILE *f;
char d;
int flag=0,len=0,i=0;
for( i=0;i<strlen(file);i++)
int file_length = strlen(file);
for( i=0;i<file_length;i++)
{
if((file[i]=='.')&&(i>0))
{
if(file[i-1]=='*')
{
if(((strlen(file)-i)==4)||((strlen(file)-i)==5))
if(((file_length-i)==4)||((file_length-i)==5))
{
flag=1;
}
Expand All @@ -151,7 +192,7 @@ void sanitize()
}}

//Function to check if image file was cleaned successfully by comparing size of input log and output log files generated by exiftool.
void compare()
void compare()
{
FILE *a,*b;
int w1=0,w2=0;
Expand Down Expand Up @@ -181,7 +222,8 @@ void sanitize()
}
fclose(a);fclose(b);
}
void run() // combine all functions .

void run() // combine all functions .
{
input();
detect();
Expand All @@ -191,16 +233,18 @@ fclose(a);fclose(b);
compare();
pause();
}
void vinput()

void vinput()
{
/* Gets input ( filename ) for removal of metadata from videos*/
system("cls");
printf("\n\t |----- Video sanitisation tool -----|\n");
printf("\n\n Enter Video name:");
scanf("%30s",vfil);
memcpy(vfile,"Videos\\",9);vfile[8]='\0';
memcpy(vfile,"Videos\\",8);vfile[8]='\0';
strcat(vfile,vfil);
}

void vdetect()
{
/* Detects if video file is present or not.*/
Expand Down Expand Up @@ -234,6 +278,7 @@ void vtool()
fclose(f);

}

void vsanitise()
{
/* Actual metadata removal process happens here.*/
Expand All @@ -252,6 +297,7 @@ void vsanitise()
}

}

void qrun()
{
/* Responsible for combining all video management functions.*/
Expand All @@ -263,7 +309,8 @@ void qrun()
vchecker();
pause();
}
void menu()

void menu()
{
int raw=0,backdoor=0;
printf("\n\t|----- Menu -----|\n\n");
Expand Down Expand Up @@ -292,9 +339,9 @@ void qrun()
}
}

void main()
void main()
{
system("title Metadata Removal Tool v3.2.2");
system("title Metadata Removal Tool v3.5.0");
menu();
}

Binary file modified Source Code/C Source code/run.c.sig
Binary file not shown.
2 changes: 1 addition & 1 deletion Source Code/Python Source Code/MRT/mat2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3


import os
import shutil
Expand Down
5 changes: 4 additions & 1 deletion Source Code/Python Source Code/MRT/mrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def autoexif():

# Function to remove metadata from image file.
def img(x):
if x.lower().endswith('.tiff') or x.lower().endswith('.tif'):
os.system("exiftool -all= -CommonIFD0= "+x)
return
os.system("exiftool "+x+" -all=")

# Function to remove metadata from video file.
Expand Down Expand Up @@ -70,7 +73,7 @@ def singly(x,y,mode='n'):

# should include function detect to detect exiftool [imp]
if y.lower()=='i':
v=('.jpg','.gif','.bmp','.tiff','.jpeg','.png')
v=('.jpg','.gif','.bmp','.tiff','.jpeg','.png','.tif')
for i in v:
if x.lower().endswith(i):
os.system("exiftool "+x+">input.txt")
Expand Down
43 changes: 32 additions & 11 deletions Source Code/Python Source Code/MRT/v9.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,34 @@

import os
from shutil import move,copy
import webbrowser as wb
from sys import exit
from time import sleep
try:
import mutagen
except:
os.system('pip install mutagen')
x = os.system('py -m pip install mutagen')
if(x != 0):
wb.open('https://pypi.org/project/mutagen/')
print('Please install mutagen from https://pypi.org/project/mutagen/ ')
sleep(5)
exit(1)
print('please close and restart this program!!!')
sleep(5)
exit(1)

# Function to display main menu()
def san():
cls()
print('\n |------ Metadata Removal Tool ------|\n')
print(' Please select an option from the following:')
print(' 1)Remove Metadata from a image.')
print(' 2)Remove Metadata from a video.')
print(' 3)Remove Metadata from a audio.')
print(' 4)Remove Metadata from a Torrent.')
print(' 5)Remove Metadata from all images in folder.')
print(' 6)Remove Metadata from all videos in folder.')
print(' 7)View Metadata in a file.')
print(' c)Close.')
x=input('\n Enter command(1,2,3,4,5,6,7 or c):')
x=input('\n Enter command(1,2,3,4,5,6 or 7):')
if x=='1':
file=input('\n Enter image name:')
singly(file,'i')
Expand All @@ -40,17 +49,28 @@ def san():
file=input('\n Enter Audio File:')
y=copy(file,'MRT')
os.chdir('MRT')
os.system('py mat2.py '+file)
y=move(file.split('.')[0]+'.cleaned.'+file.split('.')[1],'..')
os.remove(file)
z = os.system('py mat2.py '+file)
if( z!= 0):
print('Something went wrong , metadata was not cleaned!!!')
sleep(5)
else:
print('Metadata cleaned successfully !!!')
y=move(file.split('.')[0]+'.cleaned.'+file.split('.')[1],'..')
os.remove(file)
sleep(5)
os.chdir('..')
elif x == '4':
file=input('\n Enter Torrent File:')
y=copy(file,'MRT')
os.chdir('MRT')
os.system('py mat2.py '+file)
y=move(file.split('.')[0]+'.cleaned.'+file.split('.')[1],'..')
os.remove(file)
z = os.system('py mat2.py '+file)
if( z!= 0):
print('Something went wrong , metadata was not cleaned!!!')
else:
print('Metadata cleaned successfully !!!')
y=move(file.split('.')[0]+'.cleaned.'+file.split('.')[1],'..')
os.remove(file)
sleep(5)
os.chdir('..')
elif x=='5':
bulk()
Expand All @@ -68,6 +88,7 @@ def san():
wait()
elif x.lower()=='c' or x.lower()=='close':
exit()


while(True):
while True:
san()

0 comments on commit 02f7624

Please sign in to comment.