Browse Source

changement de nom & readme

master
Astequ 2 years ago
parent
commit
5cecb401fe
  1. 4
      CMakeLists.txt
  2. 6
      bench.sh
  3. 93
      readme.md
  4. 2
      src/extract.c
  5. 1
      src/hide.c
  6. 2
      src/main.c

4
CMakeLists.txt

@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.17)
project(lsd C)
project(dip C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR})
add_executable(lsd src/main.c src/lodepng.c src/hide.c src/extract.c src/utils.c)
add_executable(dip src/main.c src/lodepng.c src/hide.c src/extract.c src/utils.c)
include_directories(include)

6
bench.sh

@ -1,12 +1,10 @@
#!/bin/bash
gcc src/* -I include -O2 -o lsd
for ((i = 0; i < $1; i++)); do
head -c 267K </dev/urandom >rdata
original_hash=$(sha1sum rdata | cut -d " " -f 1)
./lsd -h giedre.png rdata hdata.png
./lsd -e hdata.png odata
./dip -h giedre.png rdata hdata.png
./dip -e hdata.png odata
extracted_hash=$(sha1sum odata | cut -d " " -f 1)
if [[ "$original_hash" == "$extracted_hash" ]]; then
echo hash ok

93
readme.md

@ -0,0 +1,93 @@
# DIP - Data In Picture
## A tool to hide binary stuff into PNG pictures using LSB
### Presentation
This tool allow to hide any type of file in a PNG pictures, provided that the following conditions are respected :
- the picture is a 8-bits depth RGB PNG
- the data is small enough to fit in the picture (maximum ~21 bits/pixel)
The data will be hidden in the bits having the least importance in the picture in order to make the modification as
imperceptible as possible.
#### Details
##### Header
A header is embedded in the picture alongside the data. He is split in two main parts :
- **LSB header *(3 bits)* :** hidden in the 3 last bits of the R component of the first pixel, it contains the number of
bits from the right reserved for the data in all the following components/pixels *(**L**east **S**ignificant **B**its)*. Its value is greater than 0 and lower than 8.
- **Main header *(40 bits)* :**
- **Size header *(32 bits)* :** stored like regular data accordingly to the lsb value found in the first header.
Contains the size of the hidden data in bytes.
- **Reserved space *(8 bits)* :** useless for now. Maybe forever. Consider it a wasted byte.
Reading this header needs to be done in two steps, as the first part is needed to retrieve the second one.
#### Storage capacity
For a picture of width `x` and height `y`, the maximum payload which can be hidden is given (in bits) by the formula
```python
21 * x * y - 47
```
This capacity is only reachable by pretty much destroying the original picture, only leaving it one out of 8 bits in
each channel (the LSB value as described in the header section will be 7). If you're not into deepfry aesthetics, you
will want to keep this value below 5. For a target maximum LSB of 4, the formula is
```python
12 * x * y - 44
```
Or, for a maximum LSB of v :
```python
(x * y * 3 - 1) * v - 40
```
Please note that theses formulas describes the way the program is supposed to act, but my incompetence and a certain lack of tests may lead its real behavior to slightly differ from this values.
### Usage
#### hiding
```
./dip -h <picture.png> <data> <output.png>
```
Hides `data` in `picture.png` and saves the resulting picture in `output.png`.
#### extracting
```
./dip -e <picture.png> <output.data>
```
Extracts data hidden in `picture.png` and saves it in `output.data`. Using it on a picture which wasn't generated by DIP
or has been altered is undefined behavior.
#### cleaning
```
./dip -c <picture.png> <output.png>
```
Strips hidden data from `picture.png` and saves the resulting picture in `output.png`. Using it on a picture which
wasn't generated by DIP or has been altered is undefined behavior.
### Return Codes
- **0 :** everything's fine
- **1 :** small issue, like incorrect input
- **2 :** the data doesn't fit in the picture
- **3 :** a system call failed
- **4 :** PNG loading/saving-related error
### External libs
PNG manipulation : [LodePNG by Lode Vandevenne](https://github.com/lvandeve/lodepng) ([zlib licensed](https://raw.githubusercontent.com/lvandeve/lodepng/master/LICENSE)).

2
src/extract.c

@ -95,7 +95,7 @@ void get_info(byte *lsb, u32 *length, string picture_path) {
if (read_bytes < LEN_HEADER_SIZE) { // si on est en train de lire le header
real_length = (real_length << 8) | data;
if (read_bytes == 3) {
*length = real_length + EMBEDDED_HEADER_SIZE;
*length = real_length;
free(image);
return;
}

1
src/hide.c

@ -1,4 +1,3 @@
#include <time.h>
#include "hide.h"
void hide(string picture_path, string file_path, string output_path) {

2
src/main.c

@ -53,7 +53,7 @@ int main(int argc, char *argv[]) {
}
}
printf("lsd - a tool to hide things in PNG pictures\nwritten by astequ\n\nUsage :\n\t- hiding :"
printf("DIP - a tool to hide things in PNG pictures\nwritten by astequ\n\nUsage :\n\t- hiding :"
" %s -h <picture.png> <data> <output.png>\n\t- extracting : %s -e <picture.png> <output.data>\n\t- cleaning"
" : %s -c <picture.png> <output.png>\n", argv[0], argv[0], argv[0]);

Loading…
Cancel
Save