-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathghostvault_cli.py
More file actions
86 lines (72 loc) · 2.96 KB
/
ghostvault_cli.py
File metadata and controls
86 lines (72 loc) · 2.96 KB
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
#!/usr/bin/env python3
"""
GhostVault - Text-based Steganography Tool
Created by ACT91
GitHub: https://github.com/ACT91
"""
import click
import os
from steg.image_steg import hide_in_image, extract_from_image
from steg.audio_steg import hide_in_audio, extract_from_audio
from utils.validator import validate_file, check_capacity
@click.group()
def cli():
"""GhostVault - Text-based steganography tool by ACT91"""
pass
@cli.command()
@click.option('--file', '-f', required=True, help='Input file path')
@click.option('--message', '-m', required=True, help='Secret message to hide')
@click.option('--output', '-o', required=True, help='Output file path')
@click.option('--password', '-p', help='Password for encryption (optional)')
def hide(file, message, output, password):
"""Hide a secret message in an image or audio file."""
try:
if not validate_file(file):
click.echo(f"Error: Invalid or unsupported file: {file}")
return
if not check_capacity(file, message):
click.echo("Error: Message too long for the cover file")
return
file_ext = os.path.splitext(file)[1].lower()
if file_ext in ['.png', '.jpg', '.jpeg']:
hide_in_image(file, message, output, password)
elif file_ext in ['.wav']:
hide_in_audio(file, message, output, password)
else:
click.echo(f"Error: Unsupported file format: {file_ext}")
return
click.echo(f"Message successfully hidden in {output}")
except Exception as e:
click.echo(f"Error: {str(e)}")
@cli.command()
@click.option('--file', '-f', required=True, help='File to extract message from')
@click.option('--password', '-p', help='Password for decryption (optional)')
@click.option('--output', '-o', help='Save extracted message to file (optional)')
def extract(file, password, output):
"""Extract a hidden message from an image or audio file."""
try:
if not validate_file(file):
click.echo(f"Error: Invalid or unsupported file: {file}")
return
file_ext = os.path.splitext(file)[1].lower()
message = None
if file_ext in ['.png', '.jpg', '.jpeg']:
message = extract_from_image(file, password)
elif file_ext in ['.wav']:
message = extract_from_audio(file, password)
else:
click.echo(f"Error: Unsupported file format: {file_ext}")
return
if message:
if output:
with open(output, 'w', encoding='utf-8') as f:
f.write(message)
click.echo(f"Message extracted and saved to {output}")
else:
click.echo(f"Extracted message: {message}")
else:
click.echo("No hidden message found or incorrect password")
except Exception as e:
click.echo(f"Error: {str(e)}")
if __name__ == '__main__':
cli()