-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.py
190 lines (166 loc) · 7.44 KB
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import platform
import os
import time
from PIL import Image, PngImagePlugin
import piexif
import banners
import cores as c
from pystyle import Colorate, Colors
VERSION = "2.0.2"
def loading_mobile():
os.system('clear')
print(Colorate.Vertical(Colors.yellow_to_red, banners.banner3))
print(f'Starting {c.byellow}Stark{c.white} on your cell phone...')
time.sleep(2)
def loading_pc():
os.system('clear')
print(Colorate.Vertical(Colors.yellow_to_red, banners.banner3))
print(f'Starting {c.byellow}Stark{c.white} on your PC...')
time.sleep(2)
def hide_message(caminho_da_imagem, mensagem):
try:
if caminho_da_imagem.endswith(".png"):
img = Image.open(caminho_da_imagem)
metadata = PngImagePlugin.PngInfo()
metadata.add_text("Mensagem Oculta", mensagem)
img.save(caminho_da_imagem, pnginfo=metadata)
elif caminho_da_imagem.endswith((".jpg", ".jpeg")):
exif_dict = {"0th": {piexif.ImageIFD.Software: mensagem}}
exif_bytes = piexif.dump(exif_dict)
piexif.insert(exif_bytes, caminho_da_imagem)
elif caminho_da_imagem.endswith(".webp"):
img = Image.open(caminho_da_imagem)
metadata = PngImagePlugin.PngInfo()
metadata.add_text("Mensagem Oculta", mensagem)
img.save(caminho_da_imagem, "WEBP", pnginfo=metadata)
else:
print(f"\n{c.red}[!] Invalid file format")
input(f"\n{c.white}Press {c.bwhite}[ENTER]{c.white} to continue")
return
print(f'\n{c.green}Hidden message successfully added to {caminho_da_imagem}!')
input(f"\n{c.white}Press {c.bwhite}[ENTER]{c.white} to continue")
except FileNotFoundError:
print(f"\n{c.red}[!] File not found")
input(f"\n{c.white}Press {c.bwhite}[ENTER]{c.white} to continue")
except Exception as e:
print(f"\n{c.red}[!] An error occurred (report this error to the creator): {e}")
input(f"\n{c.white}Press {c.bwhite}[ENTER]{c.white} to continue")
def decode_exif(exif_bytes):
exif_data = piexif.load(exif_bytes)
exif_info = {}
for ifd in exif_data:
if exif_data[ifd] is not None:
for tag in exif_data[ifd]:
tag_name = piexif.TAGS[ifd][tag]["name"]
value = exif_data[ifd][tag]
if isinstance(value, bytes):
try:
value = value.decode("utf-8", errors="ignore")
except UnicodeDecodeError:
value = value.decode("latin1", errors="ignore")
exif_info[tag_name] = value
return exif_info
def scan_image_metadata(caminho_da_imagem):
if not os.path.isfile(caminho_da_imagem):
print(f"\n{c.red}[!] The path provided is not a file.")
input(f"\n{c.white}Press {c.bwhite}[ENTER]{c.white} to continue")
return
if not caminho_da_imagem.lower().endswith((".jpg", ".jpeg", ".png", ".webp")):
print(f"\n{c.red}[!] Unsupported file format")
input(f"\n{c.white}Press {c.bwhite}[ENTER]{c.white} to continue")
return
try:
file_info = os.stat(caminho_da_imagem)
file_size = file_info.st_size
last_modified = time.ctime(file_info.st_mtime)
absolute_path = os.path.abspath(caminho_da_imagem)
print(f"\n{c.yellow}File Information:")
print(f"{c.white}Path: {absolute_path}")
print(f"Size: {file_size} bytes")
print(f"Last Modified: {last_modified}")
img = Image.open(caminho_da_imagem)
width, height = img.size
color_mode = img.mode
print(f"Dimensions: {width} x {height} pixels")
print(f"Color Mode: {color_mode}")
if caminho_da_imagem.endswith(".png"):
metadata = img.info
print(f"\n{c.yellow}Metadata:")
for key, value in metadata.items():
print(f"{c.white}{key}: {value}")
if "Mensagem Oculta" in metadata:
print(f"\n{c.green}Message found: {metadata['Mensagem Oculta']}")
else:
print(f"\n{c.red}Message not found.")
elif caminho_da_imagem.endswith((".jpg", ".jpeg")):
exif_data = img.info.get("exif")
if exif_data:
exif_dict = piexif.load(exif_data)
print(f"\n{c.yellow}EXIF Data:")
for ifd in exif_dict:
if exif_dict[ifd] is not None:
for tag in exif_dict[ifd]:
tag_name = piexif.TAGS[ifd].get(tag, {"name": tag})["name"]
value = exif_dict[ifd][tag]
if isinstance(value, bytes):
try:
value = value.decode("utf-8", errors="ignore")
except UnicodeDecodeError:
value = value.decode("latin1", errors="ignore")
print(f"{c.white}{tag_name}: {value}")
if "0th" in exif_dict and piexif.ImageIFD.Software in exif_dict["0th"]:
mensagem_bytes = exif_dict["0th"][piexif.ImageIFD.Software]
if isinstance(mensagem_bytes, bytes):
mensagem_decodificada = mensagem_bytes.decode("utf-8", errors="ignore")
else:
mensagem_decodificada = mensagem_bytes
print(f"\n{c.green}Message found: {mensagem_decodificada}")
else:
print(f"\n{c.red}Message not found.")
else:
print(f"\n{c.red}No EXIF data found.")
elif caminho_da_imagem.endswith(".webp"):
metadata = img.info
print(f"\n{c.yellow}Metadata:")
for key, value in metadata.items():
if key == "exif":
exif_info = decode_exif(value)
for tag_name, tag_value in exif_info.items():
print(f"{c.white}{tag_name}: {tag_value}")
else:
print(f"{c.white}{key}: {value}")
if "Mensagem Oculta" in metadata:
print(f"\n{c.green}Message found: {metadata['Mensagem Oculta']}")
else:
print(f"\n{c.red}Message not found.")
else:
print(f"\n{c.red}[!] Invalid file format")
input(f"\n{c.white}Press {c.bwhite}[ENTER]{c.white} to continue")
return
input(f"\n{c.white}Press {c.bwhite}[ENTER]{c.white} to continue")
except FileNotFoundError:
print(f"\n{c.red}[!] File not found")
input(f"\n{c.white}Press {c.bwhite}[ENTER]{c.white} to continue")
except Exception as e:
print(f"\n{c.red}[!] An error occurred (report this error to the creator): {e}")
input(f"\n{c.white}Press {c.bwhite}[ENTER]{c.white} to continue")
def plataform():
try:
with open("save.txt", "r") as arquivo:
conteudo = arquivo.read().strip()
except FileNotFoundError:
conteudo = None
if conteudo not in ["1", "2"]:
os_name = platform.system().lower()
if "TERMUX_VERSION" in os.environ or "android" in os_name or "ios" in os_name:
escolha = "2"
else:
escolha = "1"
with open("save.txt", "w") as arquivo:
arquivo.write(escolha)
else:
escolha = conteudo
if escolha == "2":
os.system('python3 mobile.py')
else:
os.system('python3 pc.py')