stego-lsb


Namestego-lsb JSON
Version 1.6.3 PyPI version JSON
download
home_pagehttps://github.com/ragibson/Steganography
SummaryLeast Significant Bit Steganography for bitmap images (.bmp and .png), WAV sound files, and byte sequences. Simple LSB Steganalysis (LSB extraction) for bitmap images.
upload_time2024-10-09 01:35:59
maintainerNone
docs_urlNone
authorRyan Gibson
requires_python>=3.8
licenseMIT
keywords steganography steganalysis
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Steganography

![Steganography illustration](readme_illustration.png)

# Table of Contents

* [Installation](#installation)
* [Byte Sequence Manipulation](#byte-sequence-manipulation)
* [WavSteg](#wavsteg)
* [LSBSteg](#lsbsteg)
* [StegDetect](#stegdetect)

If you are unfamiliar with steganography techniques, I have also written a
basic overview of the field in
[Steganography: Hiding Data Inside Data](https://ryanagibson.com/posts/steganography-intro/).

## Installation

This project is on [PyPI](https://pypi.org/project/stego-lsb/) and can be
installed with

    pip install stego-lsb

Alternatively, you can install it from this repository directly:

    git clone https://github.com/ragibson/Steganography
    cd Steganography
    python3 setup.py install

After installation, use the `stegolsb` command in the terminal or import
functions from `stego_lsb` in your code.

## Byte Sequence Manipulation

bit_manipulation provides the ability to (quickly) interleave the bytes of a
payload directly in the least significant bits of a carrier byte sequence.

Specifically, it contains four primary functions:

    # Interleave the bytes of payload into the num_lsb LSBs of carrier.
    lsb_interleave_bytes(carrier, payload, num_lsb, truncate=False)

    # Deinterleave num_bits bits from the num_lsb LSBs of carrier.
    lsb_deinterleave_bytes(carrier, num_bits, num_lsb)

    # Runs lsb_interleave_bytes with a List[uint8] carrier.
    lsb_interleave_list(carrier, payload, num_lsb)

    # Runs lsb_deinterleave_bytes with a List[uint8] carrier.
    lsb_deinterleave_list(carrier, num_bits, num_lsb)

Running `bit_manipulation.py`, calling its `test()` function directly, or
running `stegolsb test` should produce output similar to

    Testing 1.0 MB payload -> 10.0 MB carrier...
    Progress: [################################]
    ----------------------------------------
    | # LSBs | Encode Rate  | Decode rate  |
    | 1      | 60.6   MB/s  | 95.9   MB/s  |
    | 2      | 56.6   MB/s  | 52.7   MB/s  |
    | 3      | 82.5   MB/s  | 77.4   MB/s  |
    | 4      | 112.4  MB/s  | 105.9  MB/s  |
    | 5      | 135.9  MB/s  | 129.8  MB/s  |
    | 6      | 159.9  MB/s  | 152.4  MB/s  |
    | 7      | 181.7  MB/s  | 174.6  MB/s  |
    | 8      | 372.8  MB/s  | 1121.8 MB/s  |
    ----------------------------------------

## WavSteg

WavSteg uses least significant bit steganography to hide a file in the samples
of a .wav file.

For each sample in the audio file, we overwrite the least significant bits with
the data from our file.

### How to use

WavSteg requires Python 3

Run WavSteg with the following command line arguments:

    Command Line Arguments:
     -h, --hide               To hide data in a sound file
     -r, --recover            To recover data from a sound file
     -i, --input TEXT         Path to a .wav file
     -s, --secret TEXT        Path to a file to hide in the sound file
     -o, --output TEXT        Path to an output file
     -n, --lsb-count INTEGER  How many LSBs to use  [default: 2]
     -b, --bytes INTEGER      How many bytes to recover from the sound file
     --help                   Show this message and exit.

Example:

    $ stegolsb wavsteg -h -i sound.wav -s file.txt -o sound_steg.wav -n 1
    # OR
    $ stegolsb wavsteg -r -i sound_steg.wav -o output.txt -n 1 -b 1000

### Hiding Data

Hiding data uses the arguments -h, -i, -s, -o, and -n.

The following command would hide the contents of file.txt into sound.wav and
save the result as sound_steg.wav. The command also outputs how many bytes have
been used out of a theoretical maximum.

Example:

    $ stegolsb wavsteg -h -i sound.wav -s file.txt -o sound_steg.wav -n 2
    Using 2 LSBs, we can hide 6551441 bytes
    Files read                     in 0.01s
    5589889 bytes hidden           in 0.24s
    Output wav written             in 0.03s

If you attempt to hide too much data, WavSteg will print the minimum number of
LSBs required to hide your data.

### Recovering Data

Recovering data uses the arguments -r, -i, -o, -n, and -b

The following command would recover the hidden data from sound_steg.wav and
save it as output.txt. This requires the size in bytes of the hidden data to
be accurate or the result may be too short or contain extraneous data.

Example:

    $ stegolsb wavsteg -r -i sound_steg.wav -o output.txt -n 2 -b 5589889
    Files read                     in 0.02s
    Recovered 5589889 bytes        in 0.18s
    Written output file            in 0.00s

## LSBSteg

LSBSteg uses least significant bit steganography to hide a file in the color
information of an RGB image (.bmp or .png).

For each color channel (e.g., R, G, and B) in each pixel of the image, we
overwrite the least significant bits of the color value with the data from our
file. In order to make recovering this data easier, we also hide the file size
of our input file in the first few color channels of the image.

### How to use

You need Python 3 and Pillow, a fork of the Python Imaging Library (PIL).

Run LSBSteg with the following command line arguments:

    Command Line Arguments:
     -h, --hide                      To hide data in an image file
     -r, --recover                   To recover data from an image file
     -a, --analyze                   Print how much data can be hidden within an image   [default: False]
     -i, --input TEXT                Path to an bitmap (.bmp or .png) image
     -s, --secret TEXT               Path to a file to hide in the image
     -o, --output TEXT               Path to an output file
     -n, --lsb-count INTEGER         How many LSBs to use  [default: 2]
     -c, --compression INTEGER RANGE
                                     1 (best speed) to 9 (smallest file size)  [default: 1]
     --help                          Show this message and exit.

Example:

    $ stegolsb steglsb -a -i input_image.png -s input_file.zip -n 2
    # OR
    $ stegolsb steglsb -h -i input_image.png -s input_file.zip -o steg.png -n 2 -c 1
    # OR
    $ stegolsb steglsb -r -i steg.png -o output_file.zip -n 2

### Analyzing

Before hiding data in an image, it can be useful to see how much data can be
hidden. The following command will achieve this, producing output similar to

    $ stegolsb steglsb -a -i input_image.png -s input_file.zip -n 2
    Image resolution: (2000, 1100, 3)
    Using 2 LSBs, we can hide:     1650000 B
    Size of input file:            1566763 B
    File size tag:                 3 B

### Hiding Data

The following command will hide data in the input image and write the result to
the steganographed image, producing output similar to

    $ stegolsb steglsb -h -i input_image.png -s input_file.zip -o steg.png -n 2 -c 1
    Files read                     in 0.26s
    1566763 bytes hidden           in 0.31s
    Image overwritten              in 0.27s

### Recovering Data

The following command will recover data from the steganographed image and write
the result to the output file, producing output similar to

    $ stegolsb steglsb -r -i steg.png -o output_file.zip -n 2
    Files read                     in 0.30s
    1566763 bytes recovered        in 0.28s
    Output file written            in 0.00s

## StegDetect

StegDetect provides one method for detecting simple steganography in images.

### How to Use

You need Python 3 and Pillow, a fork of the Python Imaging Library (PIL).

Run StegDetect with the following command line arguments:

    Command Line Arguments:
     -i, --input TEXT         Path to an image
     -n, --lsb-count INTEGER  How many LSBs to display  [default: 2]
     --help                   Show this message and exit.

### Showing the Least Significant Bits of an Image

We sum the least significant n bits of the RGB color channels for each pixel
and normalize the result to the range 0-255. This value is then applied to each
color channel for the pixel. Where n is the number of least significant bits to
show, the following command will save the resulting image, appending "_nLSBs"
to the file name, and will produce output similar to the following:

    $ stegolsb stegdetect -i input_image.png -n 2
    Runtime: 0.63s

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ragibson/Steganography",
    "name": "stego-lsb",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "steganography steganalysis",
    "author": "Ryan Gibson",
    "author_email": "ryan.alex.gibson@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/51/8f/56949e3fbc0d744f30a60f369b66addb38e4a59c8283b7fdfb70b35b5846/stego_lsb-1.6.3.tar.gz",
    "platform": null,
    "description": "# Steganography\n\n![Steganography illustration](readme_illustration.png)\n\n# Table of Contents\n\n* [Installation](#installation)\n* [Byte Sequence Manipulation](#byte-sequence-manipulation)\n* [WavSteg](#wavsteg)\n* [LSBSteg](#lsbsteg)\n* [StegDetect](#stegdetect)\n\nIf you are unfamiliar with steganography techniques, I have also written a\nbasic overview of the field in\n[Steganography: Hiding Data Inside Data](https://ryanagibson.com/posts/steganography-intro/).\n\n## Installation\n\nThis project is on [PyPI](https://pypi.org/project/stego-lsb/) and can be\ninstalled with\n\n    pip install stego-lsb\n\nAlternatively, you can install it from this repository directly:\n\n    git clone https://github.com/ragibson/Steganography\n    cd Steganography\n    python3 setup.py install\n\nAfter installation, use the `stegolsb` command in the terminal or import\nfunctions from `stego_lsb` in your code.\n\n## Byte Sequence Manipulation\n\nbit_manipulation provides the ability to (quickly) interleave the bytes of a\npayload directly in the least significant bits of a carrier byte sequence.\n\nSpecifically, it contains four primary functions:\n\n    # Interleave the bytes of payload into the num_lsb LSBs of carrier.\n    lsb_interleave_bytes(carrier, payload, num_lsb, truncate=False)\n\n    # Deinterleave num_bits bits from the num_lsb LSBs of carrier.\n    lsb_deinterleave_bytes(carrier, num_bits, num_lsb)\n\n    # Runs lsb_interleave_bytes with a List[uint8] carrier.\n    lsb_interleave_list(carrier, payload, num_lsb)\n\n    # Runs lsb_deinterleave_bytes with a List[uint8] carrier.\n    lsb_deinterleave_list(carrier, num_bits, num_lsb)\n\nRunning `bit_manipulation.py`, calling its `test()` function directly, or\nrunning `stegolsb test` should produce output similar to\n\n    Testing 1.0 MB payload -> 10.0 MB carrier...\n    Progress: [################################]\n    ----------------------------------------\n    | # LSBs | Encode Rate  | Decode rate  |\n    | 1      | 60.6   MB/s  | 95.9   MB/s  |\n    | 2      | 56.6   MB/s  | 52.7   MB/s  |\n    | 3      | 82.5   MB/s  | 77.4   MB/s  |\n    | 4      | 112.4  MB/s  | 105.9  MB/s  |\n    | 5      | 135.9  MB/s  | 129.8  MB/s  |\n    | 6      | 159.9  MB/s  | 152.4  MB/s  |\n    | 7      | 181.7  MB/s  | 174.6  MB/s  |\n    | 8      | 372.8  MB/s  | 1121.8 MB/s  |\n    ----------------------------------------\n\n## WavSteg\n\nWavSteg uses least significant bit steganography to hide a file in the samples\nof a .wav file.\n\nFor each sample in the audio file, we overwrite the least significant bits with\nthe data from our file.\n\n### How to use\n\nWavSteg requires Python 3\n\nRun WavSteg with the following command line arguments:\n\n    Command Line Arguments:\n     -h, --hide               To hide data in a sound file\n     -r, --recover            To recover data from a sound file\n     -i, --input TEXT         Path to a .wav file\n     -s, --secret TEXT        Path to a file to hide in the sound file\n     -o, --output TEXT        Path to an output file\n     -n, --lsb-count INTEGER  How many LSBs to use  [default: 2]\n     -b, --bytes INTEGER      How many bytes to recover from the sound file\n     --help                   Show this message and exit.\n\nExample:\n\n    $ stegolsb wavsteg -h -i sound.wav -s file.txt -o sound_steg.wav -n 1\n    # OR\n    $ stegolsb wavsteg -r -i sound_steg.wav -o output.txt -n 1 -b 1000\n\n### Hiding Data\n\nHiding data uses the arguments -h, -i, -s, -o, and -n.\n\nThe following command would hide the contents of file.txt into sound.wav and\nsave the result as sound_steg.wav. The command also outputs how many bytes have\nbeen used out of a theoretical maximum.\n\nExample:\n\n    $ stegolsb wavsteg -h -i sound.wav -s file.txt -o sound_steg.wav -n 2\n    Using 2 LSBs, we can hide 6551441 bytes\n    Files read                     in 0.01s\n    5589889 bytes hidden           in 0.24s\n    Output wav written             in 0.03s\n\nIf you attempt to hide too much data, WavSteg will print the minimum number of\nLSBs required to hide your data.\n\n### Recovering Data\n\nRecovering data uses the arguments -r, -i, -o, -n, and -b\n\nThe following command would recover the hidden data from sound_steg.wav and\nsave it as output.txt. This requires the size in bytes of the hidden data to\nbe accurate or the result may be too short or contain extraneous data.\n\nExample:\n\n    $ stegolsb wavsteg -r -i sound_steg.wav -o output.txt -n 2 -b 5589889\n    Files read                     in 0.02s\n    Recovered 5589889 bytes        in 0.18s\n    Written output file            in 0.00s\n\n## LSBSteg\n\nLSBSteg uses least significant bit steganography to hide a file in the color\ninformation of an RGB image (.bmp or .png).\n\nFor each color channel (e.g., R, G, and B) in each pixel of the image, we\noverwrite the least significant bits of the color value with the data from our\nfile. In order to make recovering this data easier, we also hide the file size\nof our input file in the first few color channels of the image.\n\n### How to use\n\nYou need Python 3 and Pillow, a fork of the Python Imaging Library (PIL).\n\nRun LSBSteg with the following command line arguments:\n\n    Command Line Arguments:\n     -h, --hide                      To hide data in an image file\n     -r, --recover                   To recover data from an image file\n     -a, --analyze                   Print how much data can be hidden within an image   [default: False]\n     -i, --input TEXT                Path to an bitmap (.bmp or .png) image\n     -s, --secret TEXT               Path to a file to hide in the image\n     -o, --output TEXT               Path to an output file\n     -n, --lsb-count INTEGER         How many LSBs to use  [default: 2]\n     -c, --compression INTEGER RANGE\n                                     1 (best speed) to 9 (smallest file size)  [default: 1]\n     --help                          Show this message and exit.\n\nExample:\n\n    $ stegolsb steglsb -a -i input_image.png -s input_file.zip -n 2\n    # OR\n    $ stegolsb steglsb -h -i input_image.png -s input_file.zip -o steg.png -n 2 -c 1\n    # OR\n    $ stegolsb steglsb -r -i steg.png -o output_file.zip -n 2\n\n### Analyzing\n\nBefore hiding data in an image, it can be useful to see how much data can be\nhidden. The following command will achieve this, producing output similar to\n\n    $ stegolsb steglsb -a -i input_image.png -s input_file.zip -n 2\n    Image resolution: (2000, 1100, 3)\n    Using 2 LSBs, we can hide:     1650000 B\n    Size of input file:            1566763 B\n    File size tag:                 3 B\n\n### Hiding Data\n\nThe following command will hide data in the input image and write the result to\nthe steganographed image, producing output similar to\n\n    $ stegolsb steglsb -h -i input_image.png -s input_file.zip -o steg.png -n 2 -c 1\n    Files read                     in 0.26s\n    1566763 bytes hidden           in 0.31s\n    Image overwritten              in 0.27s\n\n### Recovering Data\n\nThe following command will recover data from the steganographed image and write\nthe result to the output file, producing output similar to\n\n    $ stegolsb steglsb -r -i steg.png -o output_file.zip -n 2\n    Files read                     in 0.30s\n    1566763 bytes recovered        in 0.28s\n    Output file written            in 0.00s\n\n## StegDetect\n\nStegDetect provides one method for detecting simple steganography in images.\n\n### How to Use\n\nYou need Python 3 and Pillow, a fork of the Python Imaging Library (PIL).\n\nRun StegDetect with the following command line arguments:\n\n    Command Line Arguments:\n     -i, --input TEXT         Path to an image\n     -n, --lsb-count INTEGER  How many LSBs to display  [default: 2]\n     --help                   Show this message and exit.\n\n### Showing the Least Significant Bits of an Image\n\nWe sum the least significant n bits of the RGB color channels for each pixel\nand normalize the result to the range 0-255. This value is then applied to each\ncolor channel for the pixel. Where n is the number of least significant bits to\nshow, the following command will save the resulting image, appending \"_nLSBs\"\nto the file name, and will produce output similar to the following:\n\n    $ stegolsb stegdetect -i input_image.png -n 2\n    Runtime: 0.63s\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Least Significant Bit Steganography for bitmap images (.bmp and .png), WAV sound files, and byte sequences. Simple LSB Steganalysis (LSB extraction) for bitmap images.",
    "version": "1.6.3",
    "project_urls": {
        "Homepage": "https://github.com/ragibson/Steganography"
    },
    "split_keywords": [
        "steganography",
        "steganalysis"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "32d2e536164ff469d844d89e836944705cd7de92964976682222422865074517",
                "md5": "0d9c9da49c1cd3207596547be4d8bb0f",
                "sha256": "3b0a6636be08fa0b34bfef17c56bd08d14716d5717199bc9183f450cf1194684"
            },
            "downloads": -1,
            "filename": "stego_lsb-1.6.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0d9c9da49c1cd3207596547be4d8bb0f",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.8",
            "size": 13873,
            "upload_time": "2024-10-09T01:35:56",
            "upload_time_iso_8601": "2024-10-09T01:35:56.727303Z",
            "url": "https://files.pythonhosted.org/packages/32/d2/e536164ff469d844d89e836944705cd7de92964976682222422865074517/stego_lsb-1.6.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "518f56949e3fbc0d744f30a60f369b66addb38e4a59c8283b7fdfb70b35b5846",
                "md5": "c28cad929944c3e76436cf0fd24441f6",
                "sha256": "bd1a426ef2484e05cd226804ce1a464d3a781036eeadfb5e6c6d85496462b3f8"
            },
            "downloads": -1,
            "filename": "stego_lsb-1.6.3.tar.gz",
            "has_sig": false,
            "md5_digest": "c28cad929944c3e76436cf0fd24441f6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 16397,
            "upload_time": "2024-10-09T01:35:59",
            "upload_time_iso_8601": "2024-10-09T01:35:59.133647Z",
            "url": "https://files.pythonhosted.org/packages/51/8f/56949e3fbc0d744f30a60f369b66addb38e4a59c8283b7fdfb70b35b5846/stego_lsb-1.6.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-09 01:35:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ragibson",
    "github_project": "Steganography",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "stego-lsb"
}
        
Elapsed time: 0.46462s