Giter Club home page Giter Club logo

lsbtools's Introduction

lsbtools

While experimenting with LSB steganography I wrote several scripts to play with. Eventually this scripts become quite useful so i decided to convert them into a node.js module.

You can also use online version.

NOTE: this is more a playground than a real steganography.

I also made short article about all stuff used in this library. Read it if you interested.

А ещё есть вариант этой же заметки на русском.

Installing

Install with npm:

npm install lsbtools

If you want to use this tools in browser include lsbtools.min.js into your page. Module will be available as lsbTools.

Usage

As any node.js module lsbtools should be requirde before use

var lsbTools = require('lsbtools');

Thi lib operated on an array of pixels byte data. Each pixel must be presented by for bytes: R, G, B and Alpha. This is because it was at first targeted for pixeldata returned from canvas element with getImageData. In node you can use pngjs it also returns image pixels in this 4 byte format.

If applicable, pixels data will be changed in-place. If you want to preserve original pixel data, make a copy before calling lsbTools methods.

lsbTools exposes this methods:

lsbTools.read(pixels, options)

pixels is an array of pixel. options is an object what can contain following properties (shown with defaults)

{
  shuffle: true, // spread data across image instead of writing sequentially
  matrix: true, // use matrix encoding to minimize changes
  mask: true, // mask data with stream of random bytes
  key: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], // array of bytes used as key for shuffling and masking
  pm1code: true  // use ±1 encoding instead of LSB flip
}

Returns Uint8Array with bytes extracted from image.

lsbTools.write(pixels, data, options)

Opposite to read, writes data bytes into image. Accepts same options object.

Returns object with writing stats. Like this:

{
  bitsWrited: 17234,  // total bits writed
  bitsChanged: 1725,  // how many bits in image was changed
  n: 10,  // bit per codeword
  k: 1023 // length of codewords (without matrix coding both n and k will be 1)
}

lsbTools.fill(pixels, value)

Fill LSB plane of image with provided value. 0 or 1.

lsbTools.enhance(pixels)

Change color components to 255 if LSB was set and to 0 if not.

lsbTools.chiAttack(pixels, width, enhance)

Performs chi-squared attack as described in "Attacks on Steganographic Systems. Breaking the Steganographic Utilities EzStego, Jsteg,Steganos, and S-Toolsand Some Lessons Learned" by Andreas Westfeld and Andreas Pfitzmann

URL to pdf with original paper: https://web.archive.org/web/20151123010933/http://users.ece.cmu.edu/~adrian/487-s06/westfeld-pfitzmann-ihw99.pdf

Needs pixels array and width of image. Blends image with a map of test results. Red color for zones with data embedded. Green color for clean zones. If enhance parameter evaluates to true then pixels will be enhanced according to their LSB value.

Returns estimated length of embedded message (in bits).

lsbTools.rsDetect(pixels, width, mask, bw, bh)

Performs "RS Steganalysis" attack as described in "Reliable Detection of LSB Steganography in Color and Grayscale Images" by Jessica Fridrich et al.

URL to pdf with original paper: http://www.ws.binghamton.edu/fridrich/Research/acm_2001_03.pdf

Needs pixels array and width of image. You also can provide mask in a form of an array, like [1, 0, 1, 0] and width and height (bw and bh) of block what is analyzed with that matrix.

Returns estimated capacity usage (usually from 0 to 1, but can be negative).

lsbTools.rc4(key)

Return RC4 cipher initialized from key (array of bytes) as object with following methods:

rc4.rc4Rnd()

Return next byte from RC4 keystream.

rc4.rc4RndFloat()

Reads four bytes from RC4 keystream and returns real value derived from them. Value in [0,1] range.

CLI tool

If lsbtools module installed globally with npm, then you can use it from command line. Only png images are supported as input.

Here is help output of this tool:

  usage:

    embed:   lsbtools -eb -p password -d message.txt -o secret.png clean.png
    extract: lsbtools -xb -p password -d hidden.txt secret.png

  options:

    -p, --password   password for shuffle.
    -e, --embed      hidde data in image.
    -x, --extract    extract hidden data from image.
    -s, --shuffle    embed with shuffle.
    -k, --mask       mask data.
    -m, --matrix     use matrix coding.
    -1, --plusminus1 use +-1 code instead of bit flip.
    -b, --best       best settings. Equals to -smM1.
    -d, --data       data for embedding.
    -o, --output     file for output.
    -t, --test       extract data but do not write it to disc.
    -C, --chitest    perform chi-squared test.
    -R, --rstest     perform RS Steganalysis.
    -a, --enhance    enhance LSB plane.
    -f, --fill       fill LSB plane with 0 or 1.
    -h, --help       show usage information.

License

This code released under MIT license.

lsbtools's People

Contributors

desudesutalk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.