Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Progress Bar for long operations #11

Open
wants to merge 23 commits into
base: progress-bar
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [ajmwagar]
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name = "stego"
description = "A steganographic swiss army knife"
repository = "https://github.com/ajmwagar/stego"
version = "0.1.3"
readme = "README.md"
version = "0.1.4"
authors = ["Avery Wagar <[email protected]>"]
edition = "2018"
license = "MIT"
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Avery Wagar and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
47 changes: 32 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@
[![stego](https://docs.rs/stego/badge.svg)](https://docs.rs/stego)
[![Build Status](https://travis-ci.org/ajmwagar/stego.svg?branch=master)](https://travis-ci.org/ajmwagar/stego)
[![dependency status](https://deps.rs/repo/github/ajmwagar/stego/status.svg)](https://deps.rs/repo/github/ajmwagar/stego)
[![License](https://img.shields.io/crates/l/pbr.svg)](https://github.com/ajmwagar/stego/blob/master/LICENSE.md)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fajmwagar%2Fstego.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fajmwagar%2Fstego?ref=badge_shield)



*stego* is a steganographic swiss army knife.

## Features


<!--- Encoding and decoding of images/text/binary files into audio/photo/movie files-->
- Cross platform (MacOS, Windows, Linux)
- Encoding and decoding of images/text/binary files into audio/photo/movie files
- Fast and nearly undetectable encoding.
- Smart `stdin`/`stdout` detection (try piping to `stego` instead of using `--txt`)
- Encoding and decoding of images/text/binary files into photos (audio/video coming soon)
- Fast and nearly undetectable encoding (to the human eye).
- Smart `stdin`/`stdout` detection (try piping to `stego` instead of using `--payload`)
- lossless decoding of data
- Simple, stateless CLI
- Zero system-dependencies (standalone binary)
Expand All @@ -23,26 +27,24 @@

```bash

# Simple encoding
# Text encoding/decoding

# Encodes the message "Hello, Stego!" into the provided image
stego encode text --input image.png --output encoded-image.png --txt "Hello, Stego\!"

# Simple decoding
stego encode text --input image.png --output encoded-image.png --payload "Hello, Stego\!"

# decodes and prints out the encoded message ("Hello, Stego!") hidden in the provided image
# Decodes and prints out the encoded message ("Hello, Stego!") hidden in the provided image
stego decode text --input encoded-image.png

# Stdin detection
echo "Hello, Stego\!" | stego encode text --input image.png --output encoded-image.png
# File encoding/decoding

# Example
# Encodes the file hidden.docx into the provided image
stego encode file --input image.png --output encoded-image.png --payload hidden.docx

# encodes contents of "secret" into hostimage.png and saves as output.png
cat secret | stego encode text -i hostimage.png -o output.png
# Decodes and saves the content to decoded.docx from the provided image
stego decode file --input encoded-image.png --output decoded.docx

# decodes and prints contents of "secret"
stego decode text -i output.png
# Stdin detection (for text-encoding)
echo "Hello, Stego\!" | stego encode text --input image.png --output encoded-image.png

# Help
stego --help
Expand Down Expand Up @@ -83,3 +85,18 @@ cargo install --path ./ --force
- [ ] Jurassic Park
- [ ] Another mass extinction
- [ ] ???

## 🤝 Acknowledgments & Contributors

`stego` wouldn't be possible without:

- Nathan Laha ([@TheDekuTree](https://github.com/TheDekuTree))
- Avery Wagar ([@ajmwagar](https://github.com/ajmwagar))

`stego` was inspired by:
- [`xsv`](https://github.com/BurntSushi/xsv)
- [`LSBPython`](https://github.com/RobinDavid/LSB-Steganography)


## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fajmwagar%2Fstego.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fajmwagar%2Fstego?ref=badge_large)
18 changes: 14 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ impl LSBStego {
for h in 0..height{
for w in 0..width {
for chan in 0..channels {
let val = im.get_pixel(w, h)[chan as usize];
// println!("Chan: {}/{}, Val: {}", chan, channels, val);
self.put_binary_value(self.byte_value(val as usize));
let val = im.get_pixel(w, h);
self.put_binary_value(self.byte_value(val[chan as usize] as usize));
println!("Chan: {}/{}, Val: {}", chan, channels, val[chan as usize]);
}

}
Expand All @@ -250,14 +250,24 @@ impl LSBStego {

let width = u32::from_str_radix(&self.read_bits(16), 2).unwrap();
let height = u32::from_str_radix(&self.read_bits(16), 2).unwrap();

let mut unhideimg = image::RgbaImage::new(width, height);

for h in 0..height {
for w in 0..width {
for chan in 0..channels {
let val = unhideimg.get_pixel_mut(w,h);
// let color = match chan {
// 0 => 0, // Red
// 1 => 1, // Green
// 2 => 2, // Blue
// 3 => 3, // Alpha
// _ => continue

// };

val[chan as usize] = u8::from_str_radix(&self.read_byte(), 2).unwrap();
// println!("Chan: {}/{}, Val: {}", chan, channels, val[chan as usize]);
println!("Chan: {}/{}, Val: {}", chan, channels, val[chan as usize]);
}
}
}
Expand Down
37 changes: 19 additions & 18 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[macro_use] extern crate structopt;
#[macro_use] extern crate log;

use log::{LevelFilter};
use atty::Stream;

Expand All @@ -18,14 +18,15 @@ use image::{DynamicImage};
arg_enum! {
#[derive(Debug)]
enum DataType {
Image,
// Image,
Text,
File
}
}

#[derive(StructOpt, Debug)]
#[structopt(name = "stego", about = "Stegnography at it's finest")]
#[structopt(name = "stego")]
/// a steganographic swiss army knife
struct Opt {
// The number of occurrences of the `v/verbose` flag
/// Verbose mode (-v, -vv, -vvv, etc.)
Expand Down Expand Up @@ -129,18 +130,18 @@ fn main() -> Result<(), Box<dyn Error>> {
im2 = stego.encode_binary(bytes);

},
DataType::Image => {
let path = payload.unwrap();
info!("Loading hidden image {}", &path);
// DataType::Image => {
// let path = payload.unwrap();
// info!("Loading hidden image {}", &path);

let pim: DynamicImage = image::open(&Path::new(&path))?;
// let pim: DynamicImage = image::open(&Path::new(&path))?;


info!("Encoding to host image...");
// info!("Encoding to host image...");

im2 = stego.encode_image(pim);
// im2 = stego.encode_image(pim);

},
// },
DataType::Text => {
if payload != None {
info!("Encoding text paylod to host image...");
Expand Down Expand Up @@ -185,19 +186,19 @@ fn main() -> Result<(), Box<dyn Error>> {
Ok(())

},
DataType::Image => {
// TODO: Fix this
warn!("Image decoding is currently broken (see https://github.com/ajmwagar/stego/issues/5)");
// DataType::Image => {
// // TODO: Fix this
// warn!("Image decoding is currently broken (see https://github.com/ajmwagar/stego/issues/5)");

let im2 = stego.decode_image();
// let im2 = stego.decode_image();

info!("Saving file to {:?}", output);
// info!("Saving file to {:?}", output);

im2.save(&Path::new(&output.unwrap()))?;
// im2.save(&Path::new(&output.unwrap()))?;

Ok(())
// Ok(())

},
// },
DataType::Text => {
// TODO Support hidden image / hiddenfile
print!("{}",stego.decode_text());
Expand Down
8 changes: 4 additions & 4 deletions tests/common.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::fs::File;
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use std::path::{Path};
use stego::*;
use image::{DynamicImage, ImageBgra8};
use image::DynamicImage;

fn setup() -> LSBStego {
let im: DynamicImage = image::open(&Path::new(&"./tests/img/test.png")).unwrap();
let mut stego = LSBStego::new(im.clone());
let stego = LSBStego::new(im.clone());
stego
}

Expand All @@ -31,7 +31,7 @@ fn encode_decode_binary(){

let mut bytes = Vec::new();
let mut file = File::open(&Path::new(&"./tests/img/beemoviescript")).unwrap();
file.read_to_end(&mut bytes);
assert!(file.read_to_end(&mut bytes).is_ok());

let im2 = stego.encode_binary(bytes.clone());

Expand Down
Binary file removed tests/img/bee.png
Binary file not shown.