Skip to content

Commit 02f7624

Browse files
committed
Maintenance Bug Fixes
-> Fix Audio and torrent metadata cleaning not working. -> Better Cleaning of TIFF files implemented closes #13 . -> Better Exception Handling.
1 parent 21c4a72 commit 02f7624

File tree

5 files changed

+112
-41
lines changed

5 files changed

+112
-41
lines changed

Source Code/C Source code/run.c

Lines changed: 75 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11

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

55
#include<string.h>
66
#include<stdio.h>
77
#include<stdlib.h>
8+
#include<ctype.h>
9+
#include<stdbool.h>
810

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

@@ -20,10 +22,11 @@ void pause()
2022
void checker()
2123
{
2224
int check=0;
23-
char eff[80];
25+
char eff[80];
2426
memcpy(eff,"exiftool ",10);eff[9]='\0';
2527
strcat(eff,file);
2628
strcat(eff,">output.txt");
29+
2730
check=system(eff);
2831
if(check!=0)
2932
{
@@ -55,41 +58,78 @@ void vchecker()
5558
}
5659

5760
//Function to get input from user.
58-
void input()
61+
void input()
5962
{
6063
system("cls");
6164
printf("\n\t|---------Image Sanitisation Tool ---------|\n");
6265
printf("\n\n Enter Image name:");
6366
scanf("%30s",fil);
64-
memcpy(file,"Images\\",9);file[8]='\0';
67+
memcpy(file,"Images\\",8);file[8]='\0';
6568
strcat(file,fil);
6669
}
6770

71+
bool endswith(const char str1[] , const char str2[] )
72+
{
73+
int i = 0;
74+
int j = 0;
75+
int str1_length = strlen(str1);
76+
int str2_length = strlen(str2);
77+
if(str1_length > str2_length)
78+
{
79+
for(i = str2_length-1,j=str1_length-1; i>=0;--j,--i)
80+
{
81+
if(tolower(str1[j])!= tolower(str2[i]))
82+
{
83+
return false;
84+
}
85+
}
86+
return true;
87+
}
88+
return false;
89+
90+
}
91+
6892
//Function to sanitize the image selected using exiftool.
6993
void sanitize()
7094
{
7195
int check=0;
96+
int file_length = 0;
97+
int visit = 0;
7298
char eff[80];
73-
memcpy(eff,"exiftool ",10);eff[9]='\0';
74-
strcat(eff,file);
75-
strcat(eff," -all=");
76-
check=system(eff);
99+
char tmp[80];
100+
file_length = strlen(file);
101+
102+
if( endswith(file,"tiff") || endswith(file,"tif"))
103+
{
104+
memcpy(tmp,"exiftool -all= -CommonIFD0= ",28);tmp[28] = '\0';
105+
strcat(tmp,file);
106+
check=system(tmp);
107+
visit = 1;
108+
}
109+
110+
else if(visit == 0){
111+
memcpy(eff,"exiftool ",10);eff[9]='\0';
112+
strcat(eff,file);
113+
strcat(eff," -all=");
114+
check=system(eff);
115+
}
77116
if(check!=0)
78117
{
79118
printf("\n\nImage Sanitization failed maybe exiftool is missing!\nor Something went wrong like you entering a non image file!");
80119
system("start https://exiftool.org");
81120
pause();
82121
exit(0);
83122
}
123+
84124
}
85125

86126
//Function to generate and check generation of input log.
87-
void ichecker()
127+
void ichecker()
88128
{
89-
int check=0;
90-
char eff[80];
91-
memcpy(eff,"exiftool ",10);eff[9]='\0';
92-
strcat(eff,file);
129+
int check=0;
130+
char eff[80];
131+
memcpy(eff,"exiftool ",10);eff[9]='\0';
132+
strcat(eff,file);
93133
strcat(eff,">input.txt");
94134
check=system(eff);
95135
if(check!=0)
@@ -103,12 +143,12 @@ void sanitize()
103143

104144

105145
//Function to generate and check generation of input log for videos.
106-
void ivchecker()
146+
void ivchecker()
107147
{
108-
int check=0;
109-
char eff[200];
110-
memcpy(eff,"exiftool ",10);eff[9]='\0';
111-
strcat(eff,vfile);
148+
int check=0;
149+
char eff[200];
150+
memcpy(eff,"exiftool ",10);eff[9]='\0';
151+
strcat(eff,vfile);
112152
strcat(eff,">video_input_metadata.txt");
113153
check=system(eff);
114154
if(check!=0)
@@ -121,18 +161,19 @@ void sanitize()
121161
}
122162

123163
//Function to add support for * wildcards.
124-
void detect()
164+
void detect()
125165
{
126166
FILE *f;
127167
char d;
128168
int flag=0,len=0,i=0;
129-
for( i=0;i<strlen(file);i++)
169+
int file_length = strlen(file);
170+
for( i=0;i<file_length;i++)
130171
{
131172
if((file[i]=='.')&&(i>0))
132173
{
133174
if(file[i-1]=='*')
134175
{
135-
if(((strlen(file)-i)==4)||((strlen(file)-i)==5))
176+
if(((file_length-i)==4)||((file_length-i)==5))
136177
{
137178
flag=1;
138179
}
@@ -151,7 +192,7 @@ void sanitize()
151192
}}
152193

153194
//Function to check if image file was cleaned successfully by comparing size of input log and output log files generated by exiftool.
154-
void compare()
195+
void compare()
155196
{
156197
FILE *a,*b;
157198
int w1=0,w2=0;
@@ -181,7 +222,8 @@ void sanitize()
181222
}
182223
fclose(a);fclose(b);
183224
}
184-
void run() // combine all functions .
225+
226+
void run() // combine all functions .
185227
{
186228
input();
187229
detect();
@@ -191,16 +233,18 @@ fclose(a);fclose(b);
191233
compare();
192234
pause();
193235
}
194-
void vinput()
236+
237+
void vinput()
195238
{
196239
/* Gets input ( filename ) for removal of metadata from videos*/
197240
system("cls");
198241
printf("\n\t |----- Video sanitisation tool -----|\n");
199242
printf("\n\n Enter Video name:");
200243
scanf("%30s",vfil);
201-
memcpy(vfile,"Videos\\",9);vfile[8]='\0';
244+
memcpy(vfile,"Videos\\",8);vfile[8]='\0';
202245
strcat(vfile,vfil);
203246
}
247+
204248
void vdetect()
205249
{
206250
/* Detects if video file is present or not.*/
@@ -234,6 +278,7 @@ void vtool()
234278
fclose(f);
235279

236280
}
281+
237282
void vsanitise()
238283
{
239284
/* Actual metadata removal process happens here.*/
@@ -252,6 +297,7 @@ void vsanitise()
252297
}
253298

254299
}
300+
255301
void qrun()
256302
{
257303
/* Responsible for combining all video management functions.*/
@@ -263,7 +309,8 @@ void qrun()
263309
vchecker();
264310
pause();
265311
}
266-
void menu()
312+
313+
void menu()
267314
{
268315
int raw=0,backdoor=0;
269316
printf("\n\t|----- Menu -----|\n\n");
@@ -292,9 +339,9 @@ void qrun()
292339
}
293340
}
294341

295-
void main()
342+
void main()
296343
{
297-
system("title Metadata Removal Tool v3.2.2");
344+
system("title Metadata Removal Tool v3.5.0");
298345
menu();
299346
}
300347

0 Bytes
Binary file not shown.

Source Code/Python Source Code/MRT/mat2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
22

33
import os
44
import shutil

Source Code/Python Source Code/MRT/mrt.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ def autoexif():
3535

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

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

7174
# should include function detect to detect exiftool [imp]
7275
if y.lower()=='i':
73-
v=('.jpg','.gif','.bmp','.tiff','.jpeg','.png')
76+
v=('.jpg','.gif','.bmp','.tiff','.jpeg','.png','.tif')
7477
for i in v:
7578
if x.lower().endswith(i):
7679
os.system("exiftool "+x+">input.txt")

Source Code/Python Source Code/MRT/v9.py

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,34 @@
1111

1212
import os
1313
from shutil import move,copy
14+
import webbrowser as wb
15+
from sys import exit
16+
from time import sleep
1417
try:
1518
import mutagen
1619
except:
17-
os.system('pip install mutagen')
20+
x = os.system('py -m pip install mutagen')
21+
if(x != 0):
22+
wb.open('https://pypi.org/project/mutagen/')
23+
print('Please install mutagen from https://pypi.org/project/mutagen/ ')
24+
sleep(5)
25+
exit(1)
26+
print('please close and restart this program!!!')
27+
sleep(5)
28+
exit(1)
1829

1930
# Function to display main menu()
2031
def san():
2132
cls()
2233
print('\n |------ Metadata Removal Tool ------|\n')
23-
print(' Please select an option from the following:')
2434
print(' 1)Remove Metadata from a image.')
2535
print(' 2)Remove Metadata from a video.')
2636
print(' 3)Remove Metadata from a audio.')
2737
print(' 4)Remove Metadata from a Torrent.')
2838
print(' 5)Remove Metadata from all images in folder.')
2939
print(' 6)Remove Metadata from all videos in folder.')
3040
print(' 7)View Metadata in a file.')
31-
print(' c)Close.')
32-
x=input('\n Enter command(1,2,3,4,5,6,7 or c):')
41+
x=input('\n Enter command(1,2,3,4,5,6 or 7):')
3342
if x=='1':
3443
file=input('\n Enter image name:')
3544
singly(file,'i')
@@ -40,17 +49,28 @@ def san():
4049
file=input('\n Enter Audio File:')
4150
y=copy(file,'MRT')
4251
os.chdir('MRT')
43-
os.system('py mat2.py '+file)
44-
y=move(file.split('.')[0]+'.cleaned.'+file.split('.')[1],'..')
45-
os.remove(file)
52+
z = os.system('py mat2.py '+file)
53+
if( z!= 0):
54+
print('Something went wrong , metadata was not cleaned!!!')
55+
sleep(5)
56+
else:
57+
print('Metadata cleaned successfully !!!')
58+
y=move(file.split('.')[0]+'.cleaned.'+file.split('.')[1],'..')
59+
os.remove(file)
60+
sleep(5)
4661
os.chdir('..')
4762
elif x == '4':
4863
file=input('\n Enter Torrent File:')
4964
y=copy(file,'MRT')
5065
os.chdir('MRT')
51-
os.system('py mat2.py '+file)
52-
y=move(file.split('.')[0]+'.cleaned.'+file.split('.')[1],'..')
53-
os.remove(file)
66+
z = os.system('py mat2.py '+file)
67+
if( z!= 0):
68+
print('Something went wrong , metadata was not cleaned!!!')
69+
else:
70+
print('Metadata cleaned successfully !!!')
71+
y=move(file.split('.')[0]+'.cleaned.'+file.split('.')[1],'..')
72+
os.remove(file)
73+
sleep(5)
5474
os.chdir('..')
5575
elif x=='5':
5676
bulk()
@@ -68,6 +88,7 @@ def san():
6888
wait()
6989
elif x.lower()=='c' or x.lower()=='close':
7090
exit()
91+
7192

72-
while(True):
93+
while True:
7394
san()

0 commit comments

Comments
 (0)