-
Notifications
You must be signed in to change notification settings - Fork 1
/
StegGenie.py
85 lines (67 loc) · 3.64 KB
/
StegGenie.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
import os
from stegano import lsb
import pyfiglet as fig
from colorama import Fore
# from lib import hide_text_in_image, extract_text_from_image
def hide_text_in_image(image_path, text):
# Hide the text within the image
secret_image = lsb.hide(image_path, text)
# Get the directory and file name without extension
directory, filename = os.path.split(image_path)
filename_without_extension, extension = os.path.splitext(filename)
# Save the image with the hidden text
secret_image_path = os.path.join(directory, f"{filename_without_extension}_hidden{extension}")
secret_image.save(secret_image_path)
print("Text hidden successfully in the image:", secret_image_path)
return secret_image_path
def extract_text_from_image(image_path):
# Extract the text from the image
try:
# Extract the text from the image
extracted_text = lsb.reveal(image_path)
print("Extracted text from the image:", extracted_text)
except IndexError:
print("No hidden message found in the image.")
def main():
while True:
# Print the ASCII art text using pyfiglet
for i in fig.figlet_format(' StegGenie ', font='big', width=200).split('\n\n'):
print(Fore.LIGHTMAGENTA_EX + i.center(120) + Fore.RESET)
# Print some information about steganography
print(Fore.GREEN + "StegGenie is a steganography tool that conceals messages or data within images. Users can hide text or files within images and extract hidden information from them. With an intuitive interface and ASCII art banners, StegGenie enables covert communication and secure data concealment.".center(120) + Fore.LIGHTCYAN_EX)
# Ask for the user's choice
choice = input("Choose an option:\n1. Hide text in an image\n2. Extract text from an image\n3. Go back to main page\n4. Exit\nEnter your choice (1/2/3/4): ")
if choice == '1':
# Ask for the user's choice for hiding text
hide_choice = input("Choose what you want to hide:\n1. Message\n2. File\n3. Back to main menu\nEnter your choice (1/2/3): ")
if hide_choice == '1':
# Ask for the message to hide
message = input("Enter the message you want to hide: ")
image_path = input("Enter the path to the image: ")
secret_image_path = hide_text_in_image(image_path, message)
elif hide_choice == '2':
# Ask for the file to hide
file_path = input("Enter the path to the file: ")
with open(file_path, 'r') as file:
file_content = file.read()
image_path = input("Enter the path to the image: ")
secret_image_path = hide_text_in_image(image_path, file_content)
elif hide_choice == '3':
continue
else:
print("Invalid choice.")
elif choice == '2':
# Ask for the image to extract text from
image_path = input("Enter the path to the image: ")
extract_text_from_image(image_path)
elif choice == '3':
os.system('cls' if os.name == 'nt' else 'clear')
os.system('python main.py')
break
elif choice == '4':
print("Exiting..." + Fore.RESET)
break
else:
print("Invalid choice.")
if __name__ == "__main__":
main()