mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-20 20:38:32 +02:00
Compare commits
224 commits
Author | SHA1 | Date | |
---|---|---|---|
|
bd3238acfa | ||
|
eb28c60d27 | ||
|
7ba387ecdc | ||
|
ac66655ad8 | ||
|
2e8b0fdec9 | ||
|
7849955cdb | ||
|
d6015157bf | ||
|
43f02702f9 | ||
|
9c69075d34 | ||
|
10256ba28b | ||
|
70572bf047 | ||
|
8ebd760f7e | ||
|
0d0d328230 | ||
|
5a6e08232f | ||
|
6fac279580 | ||
|
a6140fef36 | ||
|
80d7e6c88a | ||
|
d078b7a734 | ||
|
b4114bca00 | ||
|
ada72ecb47 | ||
|
d8685270ff | ||
|
924d8e4979 | ||
|
40c0e83c88 | ||
|
20bb3dc6fc | ||
|
68b56779b1 | ||
|
e41c5b7cb0 | ||
|
00415e364d | ||
|
bd1a82f397 | ||
|
dfce98008c | ||
|
e0360062b5 | ||
|
a660ff8628 | ||
|
53d897b808 | ||
|
fd2a784df3 | ||
|
136ce42ae9 | ||
|
c66a54875c | ||
|
b1133d8e35 | ||
|
a78c520058 | ||
|
b592ce4bcb | ||
|
0054c89b7d | ||
|
ab046d24f2 | ||
|
1de253dd0a | ||
|
a70b552cb8 | ||
|
eae8ab29fc | ||
|
0d20be7d82 | ||
|
33c9cd55b1 | ||
|
d02f8b8b14 | ||
|
d0ca9322cc | ||
|
91fef6a178 | ||
|
178347f61f | ||
|
ed66aaa159 | ||
|
1293a3575b | ||
|
1ef59ac80b | ||
|
0ca92d1d3a | ||
|
46da77ef1c | ||
|
5c94a790bc | ||
|
220501adbc | ||
|
e253929ad6 | ||
|
d863dbfddb | ||
|
0f550178ff | ||
|
a3dd6be618 | ||
|
29322e759a | ||
|
c6437af0d1 | ||
|
25447f88e9 | ||
|
ad916563da | ||
|
88ce965e7c | ||
|
25a7105487 | ||
|
29d427afef | ||
|
7434ed9a1e | ||
|
e3c1312d14 | ||
|
166d9d1291 | ||
|
556473c81d | ||
|
84b1855130 | ||
|
11348dda9a | ||
|
c2168422df | ||
|
bd2835d7d0 | ||
|
116e011d37 | ||
|
84a34d0bfa | ||
|
8c14555adb | ||
|
e33bebad46 | ||
|
2a3b92e62a | ||
|
0537c13a08 | ||
|
e490e32791 | ||
|
91789f065e | ||
|
bc9b91e983 | ||
|
c12b371e7d | ||
|
3fd55e2e79 | ||
|
7abce7d5d9 | ||
|
6d87ba2921 | ||
|
eb639510ce | ||
|
d10805427a | ||
|
bfc5d332be | ||
|
e2fe642e3d | ||
|
92d3e0697d | ||
|
4575319307 | ||
|
0080ec06f7 | ||
|
d6a18a71e4 | ||
|
fa741328f3 | ||
|
2abe01660d | ||
|
3dd5dd2be3 | ||
|
857d311a79 | ||
|
0daa5208c7 | ||
|
ea2f1a6eda | ||
|
03ebf467a2 | ||
|
7f9c34c6da | ||
|
dd16c1cb61 | ||
|
257fa03c9f | ||
|
e68404176a | ||
|
e988e9e02a | ||
|
fb4b596726 | ||
|
0f8b0cef1f | ||
|
3b619afa17 | ||
|
4c37a41e77 | ||
|
a67793e7a2 | ||
|
298acb7d57 | ||
|
3eaa93e36c | ||
|
18d1176ae8 | ||
|
2e4f1629fd | ||
|
bee5f819d9 | ||
|
1f684966cc | ||
|
a610da148e | ||
|
cf40cb26b0 | ||
|
e290d1260e | ||
|
fc53f2a6b9 | ||
|
e6e0f4f80f | ||
|
053c27ad4f | ||
|
43b963d4f1 | ||
|
076a5d447f | ||
|
82b59f73db | ||
|
54938159d4 | ||
|
f6aa2207f4 | ||
|
eed1f08526 | ||
|
3103a3ae9b | ||
|
0d98e1834c | ||
|
58dbb94c5e | ||
|
257d2c2f68 | ||
|
cf7209f94c | ||
|
ee1044e627 | ||
|
afb095c5ae | ||
|
12410c2548 | ||
|
ce472f9dd9 | ||
|
fea529d84d | ||
|
cc255e2e55 | ||
|
35a4c20d8d | ||
|
1c53b1d01b | ||
|
a18efe6ab8 | ||
|
1b8d8042b7 | ||
|
0a17b29121 | ||
|
9c981005e4 | ||
|
555cf1acc2 | ||
|
d7ea51eed7 | ||
|
b6c8cc3d35 | ||
|
871f1f60b4 | ||
|
0460acd7f3 | ||
|
27083934d0 | ||
|
1033933f85 | ||
|
c25cdc09f7 | ||
|
a1213a9163 | ||
|
891051f77b | ||
|
a5912ba3f1 | ||
|
4a657625f5 | ||
|
c774e9e91c | ||
|
8ea1553538 | ||
|
b00dc73fd4 | ||
|
4aac55ec77 | ||
|
b64d039389 | ||
|
be3e32ef6c | ||
|
415afc3ac8 | ||
|
7681cee3d3 | ||
|
b9e01071f0 | ||
|
0602d8328a | ||
|
44fb07ab69 | ||
|
317eb0d889 | ||
|
b7d26d15ee | ||
|
16e12e8edf | ||
|
96ff4ae620 | ||
|
d29d42509e | ||
|
3ef0239b8c | ||
|
ff09bfb267 | ||
|
d765fee7cf | ||
|
99971ff14f | ||
|
d030b8db7d | ||
|
b7ca9a9704 | ||
|
0290b2836b | ||
|
183daf3155 | ||
|
50320b0cd2 | ||
|
048322532b | ||
|
0fac8cb22c | ||
|
1b484563f5 | ||
|
6d3818ceca | ||
|
c1ec5b9ab1 | ||
|
e9a7721ccc | ||
|
45de0524d6 | ||
|
c2047f569e | ||
|
ecc858b9c3 | ||
|
3aeb032623 | ||
|
e5c7e003d6 | ||
|
6e24ec6374 | ||
|
e9605589b6 | ||
|
3dfebda205 | ||
|
13693ab3b5 | ||
|
8260dd6444 | ||
|
d160c4f1cf | ||
|
f72afd2f12 | ||
|
04531488ca | ||
|
71f6c08c28 | ||
|
9b216d9d59 | ||
|
a61a7916a3 | ||
|
c0abda31bc | ||
|
e5cfceb261 | ||
|
5f2dd1dad8 | ||
|
0f5a251398 | ||
|
13b06ee04a | ||
|
6e5a0a3523 | ||
|
9acc9afa99 | ||
|
a03c59db5c | ||
|
481b315605 | ||
|
cc626f8954 | ||
|
15b62a8034 | ||
|
6e9dff3c79 | ||
|
cfe3a1325c | ||
|
213531f63d | ||
|
23ad27f267 | ||
|
3c4042ac91 | ||
|
37a0bc2fa2 |
57 changed files with 3699 additions and 1954 deletions
|
@ -1,19 +0,0 @@
|
|||
image: debian/sid
|
||||
sources:
|
||||
- https://git.sr.ht/~cedric/Stegano
|
||||
packages:
|
||||
- python3
|
||||
- python3-dev
|
||||
- python3-pip
|
||||
tasks:
|
||||
- test: |
|
||||
pip3 install pipenv
|
||||
PATH=$PATH:/home/build/.local/bin
|
||||
cd Stegano
|
||||
pipenv install
|
||||
pipenv install --dev
|
||||
pipenv run nosetests --with-coverage --cover-package=stegano
|
||||
- typecheck: |
|
||||
PATH=$PATH:/home/build/.local/bin
|
||||
cd Stegano
|
||||
pipenv run python tools/run_mypy.py
|
16
.editorconfig
Normal file
16
.editorconfig
Normal file
|
@ -0,0 +1,16 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
max_line_length = 88
|
||||
|
||||
[*.{yml,yaml,json,js,css,html}]
|
||||
indent_size = 2
|
||||
|
||||
[*.{md,rst}]
|
||||
trim_trailing_whitespace = false
|
42
.github/workflows/pythonapp.yaml
vendored
Normal file
42
.github/workflows/pythonapp.yaml
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
name: Python application
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.10", "3.11", "3.12"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install poetry
|
||||
poetry install --with dev
|
||||
|
||||
- name: Lint with flake8
|
||||
run: |
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
poetry run flake8 stegano --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||
poetry run flake8 stegano --count --max-complexity=15 --max-line-length=127 --statistics
|
||||
|
||||
- name: Test with pytest
|
||||
run: |
|
||||
poetry run nose2 -v --pretty-assert
|
||||
env:
|
||||
testing: actions
|
||||
|
||||
# - name: Type check with mypy
|
||||
# run: |
|
||||
# poetry run mypy .
|
27
.github/workflows/release.yml
vendored
Normal file
27
.github/workflows/release.yml
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
||||
name: release
|
||||
|
||||
jobs:
|
||||
pypi-publish:
|
||||
name: Upload release to PyPI
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: pypi
|
||||
url: https://pypi.org/p/Stegano
|
||||
|
||||
permissions:
|
||||
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install Poetry
|
||||
run: python -m pip install --upgrade pip poetry
|
||||
- name: Build artifacts
|
||||
run: poetry build
|
||||
- name: Publish package distributions to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -12,7 +12,7 @@ build
|
|||
|
||||
# setuptools
|
||||
build/*
|
||||
Stegano.egg-info/*
|
||||
stegano.egg-info/
|
||||
dist/*
|
||||
|
||||
# tests
|
||||
|
|
36
.pre-commit-config.yaml
Normal file
36
.pre-commit-config.yaml
Normal file
|
@ -0,0 +1,36 @@
|
|||
ci:
|
||||
autoupdate_schedule: monthly
|
||||
repos:
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.3.1
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: ["--py37-plus"]
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.12.0
|
||||
hooks:
|
||||
- id: isort
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.3.0
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/PyCQA/flake8
|
||||
rev: 6.1.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
additional_dependencies:
|
||||
- flake8-bugbear
|
||||
- flake8-implicit-str-concat
|
||||
args: ["--max-line-length=125"]
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.1.0
|
||||
hooks:
|
||||
- id: fix-byte-order-marker
|
||||
- id: trailing-whitespace
|
||||
exclude: .md
|
||||
- id: end-of-file-fixer
|
||||
exclude: tests/.*
|
||||
- repo: https://github.com/pypa/pip-audit
|
||||
rev: v2.7.3
|
||||
hooks:
|
||||
- id: pip-audit
|
22
.readthedocs.yaml
Normal file
22
.readthedocs.yaml
Normal file
|
@ -0,0 +1,22 @@
|
|||
# .readthedocs.yaml
|
||||
# Read the Docs configuration file
|
||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||
|
||||
# Required
|
||||
version: 2
|
||||
|
||||
# Set the version of Python and other tools you might need
|
||||
build:
|
||||
os: ubuntu-22.04
|
||||
tools:
|
||||
python: "3.11"
|
||||
|
||||
# Build documentation in the docs/ directory with Sphinx
|
||||
sphinx:
|
||||
configuration: docs/conf.py
|
||||
|
||||
# We recommend specifying your dependencies to enable reproducible builds:
|
||||
# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
|
||||
python:
|
||||
install:
|
||||
- requirements: docs/requirements.txt
|
20
.travis.yml
20
.travis.yml
|
@ -1,20 +0,0 @@
|
|||
language: python
|
||||
python:
|
||||
- 3.6
|
||||
|
||||
env:
|
||||
- PIPENV_VENV_IN_PROJECT=1
|
||||
|
||||
install:
|
||||
- "pip install pipenv"
|
||||
- "pipenv install"
|
||||
- "pipenv install --dev"
|
||||
|
||||
script:
|
||||
# Run the test suit
|
||||
- nosetests --with-coverage --cover-package=stegano
|
||||
# Run the type checker
|
||||
- python tools/run_mypy.py
|
||||
|
||||
after_success:
|
||||
- coveralls
|
299
CHANGELOG.md
299
CHANGELOG.md
|
@ -1,236 +1,321 @@
|
|||
# Release History
|
||||
## Release History
|
||||
|
||||
### 1.0.1 (2025-05-03)
|
||||
|
||||
- Improved the packaging configuration for the command line (stegano.console).
|
||||
|
||||
|
||||
## 0.9.5 (2019-10-27)
|
||||
### 1.0.0 (2025-04-26)
|
||||
|
||||
* updated dependencies;
|
||||
* home page of the project is now: https://git.sr.ht/~cedric/Stegano
|
||||
- Updated dependencies.
|
||||
- Improved the packaging configuration.
|
||||
- Fixed typing errors.
|
||||
|
||||
|
||||
## 0.9.4 (2019-06-05)
|
||||
### 0.11.5 (2025-02-13)
|
||||
|
||||
* new: Implemented LFSR generator (with tests and CLI)
|
||||
- Updated dependencies.
|
||||
- Aligned pyproject.toml with the standard specification.
|
||||
- Publishing to PyPI using a Trusted Publisher.
|
||||
|
||||
|
||||
### 0.11.4 (2024-09-07)
|
||||
|
||||
- Added a parameter, close_file, to lsb.reveal in order to
|
||||
specify if the file must be closed at the end of the processing.
|
||||
|
||||
|
||||
### 0.11.3 (2024-01-02)
|
||||
|
||||
- Stegano now supports Python 3.12. Support of Python 3.8 has been removed.
|
||||
|
||||
|
||||
### 0.11.2 (2023-05-23)
|
||||
|
||||
- improved typing of various functions;
|
||||
- updated dependencies.
|
||||
|
||||
|
||||
### 0.11.1 (2022-11-20)
|
||||
|
||||
- Fixed a bug in the command line when no sub-command is specified.
|
||||
|
||||
|
||||
### 0.11.0 (2022-11-20)
|
||||
|
||||
- Reduced memory footprint and processing speed,
|
||||
the modules ``lsb`` and ``lsbset`` have been merged
|
||||
([PR #34](https://github.com/cedricbonhomme/Stegano/pull/34)).
|
||||
|
||||
|
||||
### 0.10.2 (2022-01-13)
|
||||
|
||||
- Stegano now uses Pillow 9.0.0 (CVE-2022-22815).
|
||||
|
||||
|
||||
### 0.10.1 (2021-11-30)
|
||||
|
||||
- Stegano now uses OpenCV Python 4.5.4 abd Numpy 1.21.4.
|
||||
|
||||
|
||||
### 0.10.0 (2021-11-29)
|
||||
|
||||
- new: Implemented Shi-Tomashi corner generator
|
||||
([PR #32](https://github.com/cedricbonhomme/Stegano/pull/32)).
|
||||
Implemented by thundersparkf (see CONTRIBUTORS.md file).
|
||||
|
||||
|
||||
### 0.9.9 (2021-07-02)
|
||||
|
||||
- Stegano now uses Pillow 8.3.0.
|
||||
|
||||
|
||||
### 0.9.8 (2019-12-20)
|
||||
|
||||
- Stegano is now using poetry;
|
||||
- minor improvements to the command line.
|
||||
|
||||
|
||||
### 0.9.7 (2019-10-27)
|
||||
|
||||
- fixed markdown of the previous release.
|
||||
|
||||
|
||||
### 0.9.6 (2019-10-27)
|
||||
|
||||
- fixed markdown of the previous release;
|
||||
|
||||
|
||||
### 0.9.5 (2019-10-27)
|
||||
|
||||
- updated dependencies;
|
||||
- home page of the project is now: https://github.com/cedricbonhomme/Stegano
|
||||
|
||||
|
||||
### 0.9.4 (2019-06-05)
|
||||
|
||||
- new: Implemented LFSR generator (with tests and CLI)
|
||||
([PR #27](https://github.com/cedricbonhomme/Stegano/pull/27))
|
||||
* new: Implemented Ackermann generators CLI interface
|
||||
- new: Implemented Ackermann generators CLI interface
|
||||
([PR #26](https://github.com/cedricbonhomme/Stegano/pull/26))
|
||||
* new: The Ackermann functions are not actual generators
|
||||
- new: The Ackermann functions are not actual generators
|
||||
([#24](https://github.com/cedricbonhomme/Stegano/issues/24))
|
||||
* new: add a shift parameter for the lsbmodule
|
||||
- new: add a shift parameter for the lsbmodule
|
||||
([#25](https://github.com/cedricbonhomme/Stegano/issues/25))
|
||||
* fix: lsbset.hide cause .png transparent area lost
|
||||
- fix: lsbset.hide cause .png transparent area lost
|
||||
([#23](https://github.com/cedricbonhomme/Stegano/issues/23))
|
||||
|
||||
|
||||
## 0.9.3 (2019-04-10)
|
||||
### 0.9.3 (2019-04-10)
|
||||
|
||||
* it is now possible to either pass the location of an image or directly pass
|
||||
- it is now possible to either pass the location of an image or directly pass
|
||||
an already opened Image.Image to the hide and reveal methods;
|
||||
* code re-formatted a bit with black.
|
||||
- code re-formatted a bit with black.
|
||||
|
||||
|
||||
## 0.9.2 (2019-04-04)
|
||||
### 0.9.2 (2019-04-04)
|
||||
|
||||
* updated Pillow dependency to version 6.0.0 in order to fix a bug when opening
|
||||
- updated Pillow dependency to version 6.0.0 in order to fix a bug when opening
|
||||
some PNG files (https://github.com/python-pillow/Pillow/issues/3557).
|
||||
|
||||
|
||||
## 0.9.1 (2019-03-06)
|
||||
### 0.9.1 (2019-03-06)
|
||||
|
||||
* updated Pillow dependency in order to fix a bug when opening some PNG files.
|
||||
- updated Pillow dependency in order to fix a bug when opening some PNG files.
|
||||
|
||||
|
||||
## 0.9.0 (2018-12-18)
|
||||
### 0.9.0 (2018-12-18)
|
||||
|
||||
* added the possibility to shift the encoded bits when using the lsbset module.
|
||||
- added the possibility to shift the encoded bits when using the lsbset module.
|
||||
|
||||
|
||||
## 0.8.6 (2018-11-05)
|
||||
### 0.8.6 (2018-11-05)
|
||||
|
||||
* fixed a potential security issue related to CVE-2018-18074.
|
||||
- fixed a potential security issue related to CVE-2018-18074.
|
||||
|
||||
|
||||
## 0.8.5 (2018-04-18)
|
||||
### 0.8.5 (2018-04-18)
|
||||
|
||||
* Fixed an encoding problem which occured on Windows during the installation
|
||||
- Fixed an encoding problem which occured on Windows during the installation
|
||||
of the module.
|
||||
|
||||
|
||||
## 0.8.4 (2018-02-28)
|
||||
### 0.8.4 (2018-02-28)
|
||||
|
||||
* Stegano is ready for use with pipenv and pipsi.
|
||||
- Stegano is ready for use with pipenv and pipsi.
|
||||
|
||||
|
||||
## 0.8.3 (2018-02-23)
|
||||
### 0.8.3 (2018-02-23)
|
||||
|
||||
* the recommended way to install Stegano is now to use pipenv.
|
||||
- the recommended way to install Stegano is now to use pipenv.
|
||||
|
||||
|
||||
## 0.8.2 (2017-12-20)
|
||||
### 0.8.2 (2017-12-20)
|
||||
|
||||
* Fixed a bug with the new 'encoding' function when using Stegano as a command
|
||||
- Fixed a bug with the new 'encoding' function when using Stegano as a command
|
||||
line tool. No default value was set. Default value is UTF-8.
|
||||
|
||||
|
||||
## 0.8.1 (2017-05-16)
|
||||
### 0.8.1 (2017-05-16)
|
||||
|
||||
* it is now possible to specify the encoding (UTF-8 or UTF-32LE) of the message
|
||||
- it is now possible to specify the encoding (UTF-8 or UTF-32LE) of the message
|
||||
to hide/reveal through the command line;
|
||||
* the help of the command line now displays the available choices for the
|
||||
- the help of the command line now displays the available choices for the
|
||||
arguments, if it is necessary (list of available encodings, list of available
|
||||
generators);
|
||||
* tests expected results lies now in a dedicated folder;
|
||||
* a script has been added in order to get proper exit code check for mypy.
|
||||
- tests expected results lies now in a dedicated folder;
|
||||
- a script has been added in order to get proper exit code check for mypy.
|
||||
|
||||
|
||||
## 0.8 (2017-05-06)
|
||||
### 0.8 (2017-05-06)
|
||||
|
||||
* updated command line. All commands are now prefixed with *stegano-*;
|
||||
* improved type hints;
|
||||
* it is possible to load and save images from and to file objects (BytesIO);
|
||||
* improved checks when revealing a message with the lsbset module fails.
|
||||
- updated command line. All commands are now prefixed with *stegano-*;
|
||||
- improved type hints;
|
||||
- it is possible to load and save images from and to file objects (BytesIO);
|
||||
- improved checks when revealing a message with the lsbset module fails.
|
||||
|
||||
|
||||
## 0.7.1 (2017-05-05)
|
||||
### 0.7.1 (2017-05-05)
|
||||
|
||||
* improved generators for the lsb-set module;
|
||||
* improved tests for the generators;
|
||||
* improved type hints.
|
||||
- improved generators for the lsb-set module;
|
||||
- improved tests for the generators;
|
||||
- improved type hints.
|
||||
|
||||
|
||||
## 0.7 (2017-05-04)
|
||||
### 0.7 (2017-05-04)
|
||||
|
||||
* unicode is now supported. By default UTF-8 encoding is used. UTF-32LE can also
|
||||
- unicode is now supported. By default UTF-8 encoding is used. UTF-32LE can also
|
||||
be used to hide non-ASCII characters. UTF-8 (8 bits) is the default choice
|
||||
since it is possible to hide longer messages with it.
|
||||
* improved checks with type hints.
|
||||
- improved checks with type hints.
|
||||
|
||||
|
||||
## 0.6.9 (2017-03-10)
|
||||
### 0.6.9 (2017-03-10)
|
||||
|
||||
* introduces some type hints (PEP 484);
|
||||
* more tests for the generators and for the tools module;
|
||||
* updated descriptions of generators;
|
||||
* fixed a bug with a generator that has been previously renamed.
|
||||
- introduces some type hints (PEP 484);
|
||||
- more tests for the generators and for the tools module;
|
||||
- updated descriptions of generators;
|
||||
- fixed a bug with a generator that has been previously renamed.
|
||||
|
||||
|
||||
## 0.6.8 (2017-03-08)
|
||||
### 0.6.8 (2017-03-08)
|
||||
|
||||
* bugfix: fixed #12: Error when revealing a hidden binary file in an image.
|
||||
- bugfix: fixed #12: Error when revealing a hidden binary file in an image.
|
||||
|
||||
|
||||
## 0.6.7 (2017-02-21)
|
||||
### 0.6.7 (2017-02-21)
|
||||
|
||||
* bugfix: added missing dependency in the setup.py file.
|
||||
- bugfix: added missing dependency in the setup.py file.
|
||||
|
||||
|
||||
## 0.6.6 (2017-02-20)
|
||||
### 0.6.6 (2017-02-20)
|
||||
|
||||
* improved docstrings for the desciption of the generators;
|
||||
* improved the command which displays the list of generators.
|
||||
- improved docstrings for the desciption of the generators;
|
||||
- improved the command which displays the list of generators.
|
||||
|
||||
|
||||
## 0.6.5 (2017-02-16)
|
||||
### 0.6.5 (2017-02-16)
|
||||
|
||||
* added a command to list all available generators for the lsb-set module;
|
||||
* test when the data image is coming via byte stream, for the lsb module.
|
||||
- added a command to list all available generators for the lsb-set module;
|
||||
- test when the data image is coming via byte stream, for the lsb module.
|
||||
|
||||
|
||||
## 0.6.4 (2017-02-06)
|
||||
### 0.6.4 (2017-02-06)
|
||||
|
||||
* a command line for the 'red' module has been added;
|
||||
* bugfix: fixed a bug in the lsb-set command line when the generator wasn't
|
||||
- a command line for the 'red' module has been added;
|
||||
- bugfix: fixed a bug in the lsb-set command line when the generator wasn't
|
||||
specified by the user.
|
||||
|
||||
|
||||
## 0.6.3 (2017-01-29)
|
||||
### 0.6.3 (2017-01-29)
|
||||
|
||||
* Support for transparent PNG images has been added (lsb and lsbset modules).
|
||||
- Support for transparent PNG images has been added (lsb and lsbset modules).
|
||||
|
||||
|
||||
## 0.6.2 (2017-01-19)
|
||||
### 0.6.2 (2017-01-19)
|
||||
|
||||
* bugfix: solved a bug when the image data is coming via byte streams (ByteIO),
|
||||
- bugfix: solved a bug when the image data is coming via byte streams (ByteIO),
|
||||
for the exifHeader hiding method.
|
||||
|
||||
|
||||
## 0.6.1 (2016-08-25)
|
||||
### 0.6.1 (2016-08-25)
|
||||
|
||||
* reorganization of the steganalysis sub-module.
|
||||
- reorganization of the steganalysis sub-module.
|
||||
|
||||
|
||||
## 0.6 (2016-08-04)
|
||||
### 0.6 (2016-08-04)
|
||||
|
||||
* improvements of the command line of Stéganô. The use of Stéganô through the
|
||||
- improvements of the command line of Stéganô. The use of Stéganô through the
|
||||
command line has slightly changed ('hide' and 'reveal' are now sub-parameters
|
||||
of the command line). No changes if you use Stéganô as a module in your
|
||||
software. The documentation has been updated accordingly.
|
||||
|
||||
|
||||
## 0.5.5 (2016-08-03)
|
||||
### 0.5.5 (2016-08-03)
|
||||
|
||||
* bugfix: Incorrect padding size in `base642string` in tools.base642binary().
|
||||
- bugfix: Incorrect padding size in `base642string` in tools.base642binary().
|
||||
|
||||
|
||||
## 0.5.4 (2016-05-22)
|
||||
### 0.5.4 (2016-05-22)
|
||||
|
||||
* the generator provided to the functions lsbset.hide() and lsbset.reveal() is
|
||||
- the generator provided to the functions lsbset.hide() and lsbset.reveal() is
|
||||
now a function. This is more convenient for a user who wants to use a custom
|
||||
generator (not in the module lsbset.generators).
|
||||
* performance improvements for the lsb and lsbset modules.
|
||||
- performance improvements for the lsb and lsbset modules.
|
||||
|
||||
|
||||
## 0.5.3 (2016-05-19)
|
||||
### 0.5.3 (2016-05-19)
|
||||
|
||||
* reorganization of all modules. No impact for the users of Stegano.
|
||||
- reorganization of all modules. No impact for the users of Stegano.
|
||||
|
||||
|
||||
## 0.5.2 (2016-05-18)
|
||||
### 0.5.2 (2016-05-18)
|
||||
|
||||
* improvements and bug fixes for the exifHeader module;
|
||||
* added unit tests for the exifHeader module;
|
||||
* improvements of the documentation.
|
||||
- improvements and bug fixes for the exifHeader module;
|
||||
- added unit tests for the exifHeader module;
|
||||
- improvements of the documentation.
|
||||
|
||||
|
||||
## 0.5.1 (2016-04-16)
|
||||
### 0.5.1 (2016-04-16)
|
||||
|
||||
* minor improvements and bug fixes;
|
||||
* added unit tests for the slsb and slsbset modules.
|
||||
- minor improvements and bug fixes;
|
||||
- added unit tests for the slsb and slsbset modules.
|
||||
|
||||
|
||||
## 0.5 (2016-03-18)
|
||||
### 0.5 (2016-03-18)
|
||||
|
||||
* management of greyscale images.
|
||||
- management of greyscale images.
|
||||
|
||||
|
||||
## 0.4.6 (2016-03-12)
|
||||
### 0.4.6 (2016-03-12)
|
||||
|
||||
* bugfix when the length of the message to hide is not divisible by 3,
|
||||
- bugfix when the length of the message to hide is not divisible by 3,
|
||||
for the slsb and slsbset module.
|
||||
|
||||
|
||||
## 0.4.5 (2015-12-23)
|
||||
### 0.4.5 (2015-12-23)
|
||||
|
||||
* bugfix.
|
||||
- bugfix.
|
||||
|
||||
|
||||
## 0.4.4 (2015-12-23)
|
||||
### 0.4.4 (2015-12-23)
|
||||
|
||||
* new project home page;
|
||||
* minor updated to the documentation.
|
||||
- new project home page;
|
||||
- minor updated to the documentation.
|
||||
|
||||
|
||||
## 0.4.3 (2015-10-06)
|
||||
### 0.4.3 (2015-10-06)
|
||||
|
||||
* bug fixes for Python 3;
|
||||
* bug fixes in the scripts in *./bin*.
|
||||
- bug fixes for Python 3;
|
||||
- bug fixes in the scripts in *./bin*.
|
||||
|
||||
|
||||
## 0.4.2 (2015-10-05)
|
||||
### 0.4.2 (2015-10-05)
|
||||
|
||||
* first stable release on PypI.
|
||||
- first stable release on PypI.
|
||||
|
||||
|
||||
## 0.4 (2012-01-02)
|
||||
### 0.4 (2012-01-02)
|
||||
|
||||
This release introduces a more advanced LSB (Least Significant Bit) method
|
||||
based on integers sets. The sets generated with Python generators
|
||||
|
@ -239,18 +324,18 @@ the pixels used to hide the information. You can use these new methods in your
|
|||
Python codes as a Python module or as a program in your scripts.
|
||||
|
||||
|
||||
## 0.3 (2011-04-15)
|
||||
### 0.3 (2011-04-15)
|
||||
|
||||
* you can now use Stéganô as a library in your Python program;
|
||||
- you can now use Stéganô as a library in your Python program;
|
||||
(python setup.py install) or as a 'program' thanks to the scripts provided
|
||||
in the bin directory;
|
||||
* new documentation (reStructuredText) comes with Stéganô.
|
||||
- new documentation (reStructuredText) comes with Stéganô.
|
||||
|
||||
|
||||
## 0.2 (2011-03-24)
|
||||
### 0.2 (2011-03-24)
|
||||
|
||||
* this release introduces some bugfixes and a major speed improvement of the
|
||||
- this release introduces some bugfixes and a major speed improvement of the
|
||||
*reveal* function for the LSB method. Moreover it is now possible to hide a
|
||||
binary file (ogg, executable, etc.);
|
||||
* a new technique for hiding/revealing a message in a JPEG picture by using the
|
||||
- a new technique for hiding/revealing a message in a JPEG picture by using the
|
||||
description field of the image is provided.
|
||||
|
|
|
@ -7,11 +7,15 @@
|
|||
## Contributors
|
||||
|
||||
|
||||
- Adrien Cosson <https://github.com/AdrienCos>
|
||||
- Adrien Cosson - https://cosson.io
|
||||
- Andrew Roberts <andy.roberts.uk@gmail.com>
|
||||
- Maxwell Gerber
|
||||
- Christophe Goessen - https://github.com/cgoessen
|
||||
- Flavien Roux - https://github.com/FlavienRx
|
||||
- Maxwell Gerber - https://github.com/maxwellgerber
|
||||
- Nejdet Çağdaş Yücesoy <nejdetyucesoy@gmail.com>
|
||||
- panni <panni@fragstore.net>
|
||||
- Peter Justin <peter@peterjustin.me>
|
||||
- thundersparkf - https://github.com/thundersparkf
|
||||
- Mickaël Schoentgen <mschoentgen@nuxeo.com>
|
||||
|
||||
Thank you to the testers!
|
||||
And thank you to the testers!
|
||||
|
|
2
COPYING
2
COPYING
|
@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
|
|||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
|
10
MANIFEST.in
10
MANIFEST.in
|
@ -1,10 +0,0 @@
|
|||
#documentation
|
||||
recursive-include docs *
|
||||
|
||||
# binary files
|
||||
recursive-include bin *
|
||||
|
||||
#Misc
|
||||
include COPYING
|
||||
include README.md
|
||||
include CHANGELOG.md
|
17
Pipfile
17
Pipfile
|
@ -1,17 +0,0 @@
|
|||
[[source]]
|
||||
url = "https://pypi.python.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
pillow = "*"
|
||||
piexif = "*"
|
||||
crayons = "*"
|
||||
|
||||
[dev-packages]
|
||||
twine = "*"
|
||||
pep8 = "*"
|
||||
coverage = "*"
|
||||
coveralls = "*"
|
||||
mypy = "*"
|
||||
nose = "*"
|
315
Pipfile.lock
generated
315
Pipfile.lock
generated
|
@ -1,315 +0,0 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "2dc6b9e183ea0a1262d387b7eac1caf5c303c6244a42891d75234a963fbef9c7"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.python.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"colorama": {
|
||||
"hashes": [
|
||||
"sha256:05eed71e2e327246ad6b38c540c4a3117230b19679b875190486ddd2d721422d",
|
||||
"sha256:f8ac84de7840f5b9c4e3347b3c1eaa50f7e49c2b07596221daec5edaabbd7c48"
|
||||
],
|
||||
"version": "==0.4.1"
|
||||
},
|
||||
"crayons": {
|
||||
"hashes": [
|
||||
"sha256:50e5fa729d313e2c607ae8bf7b53bb487652e10bd8e7a1e08c4bc8bf62755ffc",
|
||||
"sha256:8c9e4a3a607bc10e9a9140d496ecd16c6805088dd16c852c378f1f1d5db7aeb6"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.3.0"
|
||||
},
|
||||
"piexif": {
|
||||
"hashes": [
|
||||
"sha256:3bc435d171720150b81b15d27e05e54b8abbde7b4242cddd81ef160d283108b6",
|
||||
"sha256:83cb35c606bf3a1ea1a8f0a25cb42cf17e24353fd82e87ae3884e74a302a5f1b"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.1.3"
|
||||
},
|
||||
"pillow": {
|
||||
"hashes": [
|
||||
"sha256:047d9473cf68af50ac85f8ee5d5f21a60f849bc17d348da7fc85711287a75031",
|
||||
"sha256:0f66dc6c8a3cc319561a633b6aa82c44107f12594643efa37210d8c924fc1c71",
|
||||
"sha256:12c9169c4e8fe0a7329e8658c7e488001f6b4c8e88740e76292c2b857af2e94c",
|
||||
"sha256:248cffc168896982f125f5c13e9317c059f74fffdb4152893339f3be62a01340",
|
||||
"sha256:27faf0552bf8c260a5cee21a76e031acaea68babb64daf7e8f2e2540745082aa",
|
||||
"sha256:285edafad9bc60d96978ed24d77cdc0b91dace88e5da8c548ba5937c425bca8b",
|
||||
"sha256:384b12c9aa8ef95558abdcb50aada56d74bc7cc131dd62d28c2d0e4d3aadd573",
|
||||
"sha256:38950b3a707f6cef09cd3cbb142474357ad1a985ceb44d921bdf7b4647b3e13e",
|
||||
"sha256:4aad1b88933fd6dc2846552b89ad0c74ddbba2f0884e2c162aa368374bf5abab",
|
||||
"sha256:4ac6148008c169603070c092e81f88738f1a0c511e07bd2bb0f9ef542d375da9",
|
||||
"sha256:4deb1d2a45861ae6f0b12ea0a786a03d19d29edcc7e05775b85ec2877cb54c5e",
|
||||
"sha256:59aa2c124df72cc75ed72c8d6005c442d4685691a30c55321e00ed915ad1a291",
|
||||
"sha256:5a47d2123a9ec86660fe0e8d0ebf0aa6bc6a17edc63f338b73ea20ba11713f12",
|
||||
"sha256:5cc901c2ab9409b4b7ac7b5bcc3e86ac14548627062463da0af3b6b7c555a871",
|
||||
"sha256:6c1db03e8dff7b9f955a0fb9907eb9ca5da75b5ce056c0c93d33100a35050281",
|
||||
"sha256:7ce80c0a65a6ea90ef9c1f63c8593fcd2929448613fc8da0adf3e6bfad669d08",
|
||||
"sha256:809c19241c14433c5d6135e1b6c72da4e3b56d5c865ad5736ab99af8896b8f41",
|
||||
"sha256:83792cb4e0b5af480588601467c0764242b9a483caea71ef12d22a0d0d6bdce2",
|
||||
"sha256:846fa202bd7ee0f6215c897a1d33238ef071b50766339186687bd9b7a6d26ac5",
|
||||
"sha256:9f5529fc02009f96ba95bea48870173426879dc19eec49ca8e08cd63ecd82ddb",
|
||||
"sha256:a423c2ea001c6265ed28700df056f75e26215fd28c001e93ef4380b0f05f9547",
|
||||
"sha256:ac4428094b42907aba5879c7c000d01c8278d451a3b7cccd2103e21f6397ea75",
|
||||
"sha256:b1ae48d87f10d1384e5beecd169c77502fcc04a2c00a4c02b85f0a94b419e5f9",
|
||||
"sha256:bf4e972a88f8841d8fdc6db1a75e0f8d763e66e3754b03006cbc3854d89f1cb1",
|
||||
"sha256:c6414f6aad598364aaf81068cabb077894eb88fed99c6a65e6e8217bab62ae7a",
|
||||
"sha256:c710fcb7ee32f67baf25aa9ffede4795fd5d93b163ce95fdc724383e38c9df96",
|
||||
"sha256:c7be4b8a09852291c3c48d3c25d1b876d2494a0a674980089ac9d5e0d78bd132",
|
||||
"sha256:c9e5ffb910b14f090ac9c38599063e354887a5f6d7e6d26795e916b4514f2c1a",
|
||||
"sha256:e0697b826da6c2472bb6488db4c0a7fa8af0d52fa08833ceb3681358914b14e5",
|
||||
"sha256:e9a3edd5f714229d41057d56ac0f39ad9bdba6767e8c888c951869f0bdd129b0"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==6.2.1"
|
||||
}
|
||||
},
|
||||
"develop": {
|
||||
"bleach": {
|
||||
"hashes": [
|
||||
"sha256:213336e49e102af26d9cde77dd2d0397afabc5a6bf2fed985dc35b5d1e285a16",
|
||||
"sha256:3fdf7f77adcf649c9911387df51254b813185e32b2c6619f690b593a617e19fa"
|
||||
],
|
||||
"version": "==3.1.0"
|
||||
},
|
||||
"certifi": {
|
||||
"hashes": [
|
||||
"sha256:e4f3620cfea4f83eedc95b24abd9cd56f3c4b146dd0177e83a21b4eb49e21e50",
|
||||
"sha256:fd7c7c74727ddcf00e9acd26bba8da604ffec95bf1c2144e67aff7a8b50e6cef"
|
||||
],
|
||||
"version": "==2019.9.11"
|
||||
},
|
||||
"chardet": {
|
||||
"hashes": [
|
||||
"sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
|
||||
"sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"
|
||||
],
|
||||
"version": "==3.0.4"
|
||||
},
|
||||
"coverage": {
|
||||
"hashes": [
|
||||
"sha256:08907593569fe59baca0bf152c43f3863201efb6113ecb38ce7e97ce339805a6",
|
||||
"sha256:0be0f1ed45fc0c185cfd4ecc19a1d6532d72f86a2bac9de7e24541febad72650",
|
||||
"sha256:141f08ed3c4b1847015e2cd62ec06d35e67a3ac185c26f7635f4406b90afa9c5",
|
||||
"sha256:19e4df788a0581238e9390c85a7a09af39c7b539b29f25c89209e6c3e371270d",
|
||||
"sha256:23cc09ed395b03424d1ae30dcc292615c1372bfba7141eb85e11e50efaa6b351",
|
||||
"sha256:245388cda02af78276b479f299bbf3783ef0a6a6273037d7c60dc73b8d8d7755",
|
||||
"sha256:331cb5115673a20fb131dadd22f5bcaf7677ef758741312bee4937d71a14b2ef",
|
||||
"sha256:386e2e4090f0bc5df274e720105c342263423e77ee8826002dcffe0c9533dbca",
|
||||
"sha256:3a794ce50daee01c74a494919d5ebdc23d58873747fa0e288318728533a3e1ca",
|
||||
"sha256:60851187677b24c6085248f0a0b9b98d49cba7ecc7ec60ba6b9d2e5574ac1ee9",
|
||||
"sha256:63a9a5fc43b58735f65ed63d2cf43508f462dc49857da70b8980ad78d41d52fc",
|
||||
"sha256:6b62544bb68106e3f00b21c8930e83e584fdca005d4fffd29bb39fb3ffa03cb5",
|
||||
"sha256:6ba744056423ef8d450cf627289166da65903885272055fb4b5e113137cfa14f",
|
||||
"sha256:7494b0b0274c5072bddbfd5b4a6c6f18fbbe1ab1d22a41e99cd2d00c8f96ecfe",
|
||||
"sha256:826f32b9547c8091679ff292a82aca9c7b9650f9fda3e2ca6bf2ac905b7ce888",
|
||||
"sha256:93715dffbcd0678057f947f496484e906bf9509f5c1c38fc9ba3922893cda5f5",
|
||||
"sha256:9a334d6c83dfeadae576b4d633a71620d40d1c379129d587faa42ee3e2a85cce",
|
||||
"sha256:af7ed8a8aa6957aac47b4268631fa1df984643f07ef00acd374e456364b373f5",
|
||||
"sha256:bf0a7aed7f5521c7ca67febd57db473af4762b9622254291fbcbb8cd0ba5e33e",
|
||||
"sha256:bf1ef9eb901113a9805287e090452c05547578eaab1b62e4ad456fcc049a9b7e",
|
||||
"sha256:c0afd27bc0e307a1ffc04ca5ec010a290e49e3afbe841c5cafc5c5a80ecd81c9",
|
||||
"sha256:dd579709a87092c6dbee09d1b7cfa81831040705ffa12a1b248935274aee0437",
|
||||
"sha256:df6712284b2e44a065097846488f66840445eb987eb81b3cc6e4149e7b6982e1",
|
||||
"sha256:e07d9f1a23e9e93ab5c62902833bf3e4b1f65502927379148b6622686223125c",
|
||||
"sha256:e2ede7c1d45e65e209d6093b762e98e8318ddeff95317d07a27a2140b80cfd24",
|
||||
"sha256:e4ef9c164eb55123c62411f5936b5c2e521b12356037b6e1c2617cef45523d47",
|
||||
"sha256:eca2b7343524e7ba246cab8ff00cab47a2d6d54ada3b02772e908a45675722e2",
|
||||
"sha256:eee64c616adeff7db37cc37da4180a3a5b6177f5c46b187894e633f088fb5b28",
|
||||
"sha256:ef824cad1f980d27f26166f86856efe11eff9912c4fed97d3804820d43fa550c",
|
||||
"sha256:efc89291bd5a08855829a3c522df16d856455297cf35ae827a37edac45f466a7",
|
||||
"sha256:fa964bae817babece5aa2e8c1af841bebb6d0b9add8e637548809d040443fee0",
|
||||
"sha256:ff37757e068ae606659c28c3bd0d923f9d29a85de79bf25b2b34b148473b5025"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==4.5.4"
|
||||
},
|
||||
"coveralls": {
|
||||
"hashes": [
|
||||
"sha256:9bc5a1f92682eef59f688a8f280207190d9a6afb84cef8f567fa47631a784060",
|
||||
"sha256:fb51cddef4bc458de347274116df15d641a735d3f0a580a9472174e2e62f408c"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.8.2"
|
||||
},
|
||||
"docopt": {
|
||||
"hashes": [
|
||||
"sha256:49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491"
|
||||
],
|
||||
"version": "==0.6.2"
|
||||
},
|
||||
"docutils": {
|
||||
"hashes": [
|
||||
"sha256:6c4f696463b79f1fb8ba0c594b63840ebd41f059e92b31957c46b74a4599b6d0",
|
||||
"sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827",
|
||||
"sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99"
|
||||
],
|
||||
"version": "==0.15.2"
|
||||
},
|
||||
"idna": {
|
||||
"hashes": [
|
||||
"sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407",
|
||||
"sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c"
|
||||
],
|
||||
"version": "==2.8"
|
||||
},
|
||||
"mypy": {
|
||||
"hashes": [
|
||||
"sha256:1521c186a3d200c399bd5573c828ea2db1362af7209b2adb1bb8532cea2fb36f",
|
||||
"sha256:31a046ab040a84a0fc38bc93694876398e62bc9f35eca8ccbf6418b7297f4c00",
|
||||
"sha256:3b1a411909c84b2ae9b8283b58b48541654b918e8513c20a400bb946aa9111ae",
|
||||
"sha256:48c8bc99380575deb39f5d3400ebb6a8a1cb5cc669bbba4d3bb30f904e0a0e7d",
|
||||
"sha256:540c9caa57a22d0d5d3c69047cc9dd0094d49782603eb03069821b41f9e970e9",
|
||||
"sha256:672e418425d957e276c291930a3921b4a6413204f53fe7c37cad7bc57b9a3391",
|
||||
"sha256:6ed3b9b3fdc7193ea7aca6f3c20549b377a56f28769783a8f27191903a54170f",
|
||||
"sha256:9371290aa2cad5ad133e4cdc43892778efd13293406f7340b9ffe99d5ec7c1d9",
|
||||
"sha256:ace6ac1d0f87d4072f05b5468a084a45b4eda970e4d26704f201e06d47ab2990",
|
||||
"sha256:b428f883d2b3fe1d052c630642cc6afddd07d5cd7873da948644508be3b9d4a7",
|
||||
"sha256:d5bf0e6ec8ba346a2cf35cb55bf4adfddbc6b6576fcc9e10863daa523e418dbb",
|
||||
"sha256:d7574e283f83c08501607586b3167728c58e8442947e027d2d4c7dcd6d82f453",
|
||||
"sha256:dc889c84241a857c263a2b1cd1121507db7d5b5f5e87e77147097230f374d10b",
|
||||
"sha256:f4748697b349f373002656bf32fede706a0e713d67bfdcf04edf39b1f61d46eb"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.740"
|
||||
},
|
||||
"mypy-extensions": {
|
||||
"hashes": [
|
||||
"sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d",
|
||||
"sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"
|
||||
],
|
||||
"version": "==0.4.3"
|
||||
},
|
||||
"nose": {
|
||||
"hashes": [
|
||||
"sha256:9ff7c6cc443f8c51994b34a667bbcf45afd6d945be7477b52e97516fd17c53ac",
|
||||
"sha256:dadcddc0aefbf99eea214e0f1232b94f2fa9bd98fa8353711dacb112bfcbbb2a",
|
||||
"sha256:f1bffef9cbc82628f6e7d7b40d7e255aefaa1adb6a1b1d26c69a8b79e6208a98"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.3.7"
|
||||
},
|
||||
"pep8": {
|
||||
"hashes": [
|
||||
"sha256:b22cfae5db09833bb9bd7c8463b53e1a9c9b39f12e304a8d0bba729c501827ee",
|
||||
"sha256:fe249b52e20498e59e0b5c5256aa52ee99fc295b26ec9eaa85776ffdb9fe6374"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.7.1"
|
||||
},
|
||||
"pkginfo": {
|
||||
"hashes": [
|
||||
"sha256:7424f2c8511c186cd5424bbf31045b77435b37a8d604990b79d4e70d741148bb",
|
||||
"sha256:a6d9e40ca61ad3ebd0b72fbadd4fba16e4c0e4df0428c041e01e06eb6ee71f32"
|
||||
],
|
||||
"version": "==1.5.0.1"
|
||||
},
|
||||
"pygments": {
|
||||
"hashes": [
|
||||
"sha256:71e430bc85c88a430f000ac1d9b331d2407f681d6f6aec95e8bcfbc3df5b0127",
|
||||
"sha256:881c4c157e45f30af185c1ffe8d549d48ac9127433f2c380c24b84572ad66297"
|
||||
],
|
||||
"version": "==2.4.2"
|
||||
},
|
||||
"readme-renderer": {
|
||||
"hashes": [
|
||||
"sha256:bb16f55b259f27f75f640acf5e00cf897845a8b3e4731b5c1a436e4b8529202f",
|
||||
"sha256:c8532b79afc0375a85f10433eca157d6b50f7d6990f337fa498c96cd4bfc203d"
|
||||
],
|
||||
"version": "==24.0"
|
||||
},
|
||||
"requests": {
|
||||
"hashes": [
|
||||
"sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4",
|
||||
"sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31"
|
||||
],
|
||||
"version": "==2.22.0"
|
||||
},
|
||||
"requests-toolbelt": {
|
||||
"hashes": [
|
||||
"sha256:380606e1d10dc85c3bd47bf5a6095f815ec007be7a8b69c878507068df059e6f",
|
||||
"sha256:968089d4584ad4ad7c171454f0a5c6dac23971e9472521ea3b6d49d610aa6fc0"
|
||||
],
|
||||
"version": "==0.9.1"
|
||||
},
|
||||
"six": {
|
||||
"hashes": [
|
||||
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
|
||||
"sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
|
||||
],
|
||||
"version": "==1.12.0"
|
||||
},
|
||||
"tqdm": {
|
||||
"hashes": [
|
||||
"sha256:abc25d0ce2397d070ef07d8c7e706aede7920da163c64997585d42d3537ece3d",
|
||||
"sha256:dd3fcca8488bb1d416aa7469d2f277902f26260c45aa86b667b074cd44b3b115"
|
||||
],
|
||||
"version": "==4.36.1"
|
||||
},
|
||||
"twine": {
|
||||
"hashes": [
|
||||
"sha256:5319dd3e02ac73fcddcd94f035b9631589ab5d23e1f4699d57365199d85261e1",
|
||||
"sha256:9fe7091715c7576df166df8ef6654e61bada39571783f2fd415bdcba867c6993"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.0.0"
|
||||
},
|
||||
"typed-ast": {
|
||||
"hashes": [
|
||||
"sha256:1170afa46a3799e18b4c977777ce137bb53c7485379d9706af8a59f2ea1aa161",
|
||||
"sha256:18511a0b3e7922276346bcb47e2ef9f38fb90fd31cb9223eed42c85d1312344e",
|
||||
"sha256:262c247a82d005e43b5b7f69aff746370538e176131c32dda9cb0f324d27141e",
|
||||
"sha256:2b907eb046d049bcd9892e3076c7a6456c93a25bebfe554e931620c90e6a25b0",
|
||||
"sha256:354c16e5babd09f5cb0ee000d54cfa38401d8b8891eefa878ac772f827181a3c",
|
||||
"sha256:48e5b1e71f25cfdef98b013263a88d7145879fbb2d5185f2a0c79fa7ebbeae47",
|
||||
"sha256:4e0b70c6fc4d010f8107726af5fd37921b666f5b31d9331f0bd24ad9a088e631",
|
||||
"sha256:630968c5cdee51a11c05a30453f8cd65e0cc1d2ad0d9192819df9978984529f4",
|
||||
"sha256:66480f95b8167c9c5c5c87f32cf437d585937970f3fc24386f313a4c97b44e34",
|
||||
"sha256:71211d26ffd12d63a83e079ff258ac9d56a1376a25bc80b1cdcdf601b855b90b",
|
||||
"sha256:7954560051331d003b4e2b3eb822d9dd2e376fa4f6d98fee32f452f52dd6ebb2",
|
||||
"sha256:838997f4310012cf2e1ad3803bce2f3402e9ffb71ded61b5ee22617b3a7f6b6e",
|
||||
"sha256:95bd11af7eafc16e829af2d3df510cecfd4387f6453355188342c3e79a2ec87a",
|
||||
"sha256:bc6c7d3fa1325a0c6613512a093bc2a2a15aeec350451cbdf9e1d4bffe3e3233",
|
||||
"sha256:cc34a6f5b426748a507dd5d1de4c1978f2eb5626d51326e43280941206c209e1",
|
||||
"sha256:d755f03c1e4a51e9b24d899561fec4ccaf51f210d52abdf8c07ee2849b212a36",
|
||||
"sha256:d7c45933b1bdfaf9f36c579671fec15d25b06c8398f113dab64c18ed1adda01d",
|
||||
"sha256:d896919306dd0aa22d0132f62a1b78d11aaf4c9fc5b3410d3c666b818191630a",
|
||||
"sha256:fdc1c9bbf79510b76408840e009ed65958feba92a88833cdceecff93ae8fff66",
|
||||
"sha256:ffde2fbfad571af120fcbfbbc61c72469e72f550d676c3342492a9dfdefb8f12"
|
||||
],
|
||||
"version": "==1.4.0"
|
||||
},
|
||||
"typing-extensions": {
|
||||
"hashes": [
|
||||
"sha256:2ed632b30bb54fc3941c382decfd0ee4148f5c591651c9272473fea2c6397d95",
|
||||
"sha256:b1edbbf0652660e32ae780ac9433f4231e7339c7f9a8057d0f042fcbcea49b87",
|
||||
"sha256:d8179012ec2c620d3791ca6fe2bf7979d979acdbef1fca0bc56b37411db682ed"
|
||||
],
|
||||
"version": "==3.7.4"
|
||||
},
|
||||
"urllib3": {
|
||||
"hashes": [
|
||||
"sha256:3de946ffbed6e6746608990594d08faac602528ac7015ac28d33cee6a45b7398",
|
||||
"sha256:9a107b99a5393caf59c7aa3c1249c16e6879447533d0887f4336dde834c7be86"
|
||||
],
|
||||
"version": "==1.25.6"
|
||||
},
|
||||
"webencodings": {
|
||||
"hashes": [
|
||||
"sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78",
|
||||
"sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923"
|
||||
],
|
||||
"version": "==0.5.1"
|
||||
}
|
||||
}
|
||||
}
|
47
README.md
47
README.md
|
@ -1,11 +1,9 @@
|
|||
Stegano
|
||||
-------
|
||||
# Stegano
|
||||
|
||||
[](https://builds.sr.ht/~cedric/Stegano)
|
||||
[](https://github.com/cedricbonhomme/Stegano/actions?query=workflow%3A%22Python+application%22)
|
||||
|
||||
|
||||
[Stegano](https://github.com/cedricbonhomme/Stegano), a pure Python
|
||||
Steganography module.
|
||||
[Stegano](https://github.com/cedricbonhomme/Stegano), a pure Python Steganography
|
||||
module.
|
||||
|
||||
Steganography is the art and science of writing hidden messages in such a way
|
||||
that no one, apart from the sender and intended recipient, suspects the
|
||||
|
@ -13,11 +11,12 @@ existence of the message, a form of security through obscurity. Consequently,
|
|||
functions provided by Stegano only hide messages, without encryption.
|
||||
Steganography is often used with cryptography.
|
||||
|
||||
# Installation
|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
```bash
|
||||
$ pipenv install Stegano
|
||||
$ poetry install stegano
|
||||
```
|
||||
|
||||
You will be able to use Stegano in your Python programs.
|
||||
|
@ -25,14 +24,14 @@ You will be able to use Stegano in your Python programs.
|
|||
If you only want to install Stegano as a command line tool:
|
||||
|
||||
```bash
|
||||
$ pipx install Stegano
|
||||
$ pipx install stegano
|
||||
```
|
||||
|
||||
pipx installs scripts (system wide available) provided by Python packages into
|
||||
separate virtualenvs to shield them from your system and each other.
|
||||
|
||||
|
||||
# Usage
|
||||
## Usage
|
||||
|
||||
A [tutorial](https://stegano.readthedocs.io) is available.
|
||||
|
||||
|
@ -65,7 +64,7 @@ Secret Message
|
|||
### Hide the message with the Sieve of Eratosthenes
|
||||
|
||||
```bash
|
||||
$ stegano-lsb-set hide -i ./tests/sample-files/Lenna.png -m 'Secret Message' --generator eratosthenes -o Lena2.png
|
||||
$ stegano-lsb hide -i ./tests/sample-files/Lenna.png -m 'Secret Message' --generator eratosthenes -o Lena2.png
|
||||
```
|
||||
|
||||
The message will be scattered in the picture, following a set described by the
|
||||
|
@ -75,7 +74,7 @@ generators.
|
|||
This will make a steganalysis more complicated.
|
||||
|
||||
|
||||
# Running the tests
|
||||
## Running the tests
|
||||
|
||||
```bash
|
||||
$ python -m unittest discover -v
|
||||
|
@ -84,21 +83,33 @@ $ python -m unittest discover -v
|
|||
Running the static type checker:
|
||||
|
||||
```bash
|
||||
$ python tools/run_mypy.py
|
||||
$ mypy stegano
|
||||
```
|
||||
|
||||
|
||||
# Contributions
|
||||
## Contributions
|
||||
|
||||
Contributions are welcome. If you want to contribute to Stegano I highly
|
||||
recommend you to install it in a Python virtual environment with pipenv.
|
||||
recommend you to install it in a Python virtual environment with poetry.
|
||||
|
||||
|
||||
# License
|
||||
## Donations
|
||||
|
||||
If you wish and if you like Stegano, you can donate via GitHub Sponsors:
|
||||
|
||||
[](https://github.com/sponsors/cedricbonhomme)
|
||||
|
||||
or with Bitcoin to this address:
|
||||
bc1q56u6sj7cvlwu58v5lemljcvkh7v2gc3tv8mj0e
|
||||
|
||||
Thank you !
|
||||
|
||||
|
||||
## License
|
||||
|
||||
This software is licensed under
|
||||
[GNU General Public License version 3](https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
Copyright (C) 2010-2019 [Cédric Bonhomme](https://www.cedricbonhomme.org)
|
||||
Copyright (C) 2010-2025 [Cédric Bonhomme](https://www.cedricbonhomme.org)
|
||||
|
||||
For more information, [the list of authors and contributors](CONTRIBUTORS.rst) is available.
|
||||
For more information, [the list of authors and contributors](CONTRIBUTORS.md) is available.
|
||||
|
|
104
bin/stegano-lsb
104
bin/stegano-lsb
|
@ -1,104 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
__author__ = "Cedric Bonhomme"
|
||||
__version__ = "$Revision: 0.8 $"
|
||||
__date__ = "$Date: 2016/08/04 $"
|
||||
__revision__ = "$Date: 2019/06/01 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
try:
|
||||
from stegano import lsb
|
||||
except:
|
||||
print("Install Stegano: pipx install Stegano")
|
||||
|
||||
from stegano import tools
|
||||
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(prog='stegano-lsb')
|
||||
subparsers = parser.add_subparsers(help='sub-command help', dest='command')
|
||||
|
||||
# Subparser: Hide
|
||||
parser_hide = subparsers.add_parser('hide', help='hide help')
|
||||
# Original image
|
||||
parser_hide.add_argument("-i", "--input", dest="input_image_file",
|
||||
required=True, help="Input image file.")
|
||||
parser_hide.add_argument("-e", "--encoding", dest="encoding",
|
||||
choices=tools.ENCODINGS.keys(), default='UTF-8',
|
||||
help="Specify the encoding of the message to hide." +
|
||||
" UTF-8 (default) or UTF-32LE.")
|
||||
|
||||
group_secret = parser_hide.add_mutually_exclusive_group(required=True)
|
||||
# Non binary secret message to hide
|
||||
group_secret.add_argument("-m", dest="secret_message",
|
||||
help="Your secret message to hide (non binary).")
|
||||
# Binary secret message to hide
|
||||
group_secret.add_argument("-f", dest="secret_file",
|
||||
help="Your secret to hide (Text or any binary file).")
|
||||
|
||||
# Image containing the secret
|
||||
parser_hide.add_argument("-o", "--output", dest="output_image_file",
|
||||
required=True, help="Output image containing the secret.")
|
||||
|
||||
# Shift the message to hide
|
||||
parser_hide.add_argument("-s", "--shift", dest="shift", default=0,
|
||||
help="Shift for the message to hide")
|
||||
|
||||
# Subparser: Reveal
|
||||
parser_reveal = subparsers.add_parser('reveal', help='reveal help')
|
||||
parser_reveal.add_argument("-i", "--input", dest="input_image_file",
|
||||
required=True, help="Input image file.")
|
||||
parser_reveal.add_argument("-e", "--encoding", dest="encoding",
|
||||
choices=tools.ENCODINGS.keys(), default='UTF-8',
|
||||
help="Specify the encoding of the message to reveal." +
|
||||
" UTF-8 (default) or UTF-32LE.")
|
||||
parser_reveal.add_argument("-o", dest="secret_binary",
|
||||
help="Output for the binary secret (Text or any binary file).")
|
||||
# Shift the message to reveal
|
||||
parser_reveal.add_argument("-s", "--shift", dest="shift", default=0,
|
||||
help="Shift for the reveal")
|
||||
|
||||
arguments = parser.parse_args()
|
||||
|
||||
|
||||
if arguments.command == 'hide':
|
||||
if arguments.secret_message != None:
|
||||
secret = arguments.secret_message
|
||||
elif arguments.secret_file != None:
|
||||
secret = tools.binary2base64(arguments.secret_file)
|
||||
|
||||
img_encoded = lsb.hide(arguments.input_image_file, secret,
|
||||
arguments.encoding, int(arguments.shift))
|
||||
try:
|
||||
img_encoded.save(arguments.output_image_file)
|
||||
except Exception as e:
|
||||
# If hide() returns an error (Too long message).
|
||||
print(e)
|
||||
|
||||
elif arguments.command == 'reveal':
|
||||
secret = lsb.reveal(arguments.input_image_file, arguments.encoding,
|
||||
int(arguments.shift))
|
||||
if arguments.secret_binary != None:
|
||||
data = tools.base642binary(secret)
|
||||
with open(arguments.secret_binary, "wb") as f:
|
||||
f.write(data)
|
||||
else:
|
||||
print(secret)
|
|
@ -1,168 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
__author__ = "Cedric Bonhomme"
|
||||
__version__ = "$Revision: 0.7 $"
|
||||
__date__ = "$Date: 2016/03/18 $"
|
||||
__revision__ = "$Date: 2019/06/04 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
import inspect
|
||||
import crayons
|
||||
|
||||
try:
|
||||
from stegano import lsbset
|
||||
from stegano.lsbset import generators
|
||||
except:
|
||||
print("Install stegano: pipx install Stegano")
|
||||
|
||||
from stegano import tools
|
||||
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(prog='stegano-lsb-set')
|
||||
subparsers = parser.add_subparsers(help='sub-command help', dest='command')
|
||||
|
||||
|
||||
class ValidateGenerator(argparse.Action):
|
||||
def __call__(self, parser, args, values, option_string=None):
|
||||
valid_generators = [generator[0] for generator in inspect.getmembers(
|
||||
generators, inspect.isfunction)]
|
||||
# Verify that the generator is valid
|
||||
generator = values[0]
|
||||
if generator not in valid_generators:
|
||||
raise ValueError("Unknown generator: %s" % generator)
|
||||
# Set the generator_function arg of the parser
|
||||
setattr(args, self.dest, values)
|
||||
|
||||
|
||||
# Subparser: Hide
|
||||
parser_hide = subparsers.add_parser('hide', help='hide help')
|
||||
# Original image
|
||||
parser_hide.add_argument("-i", "--input", dest="input_image_file",
|
||||
required=True, help="Input image file.")
|
||||
parser_hide.add_argument("-e", "--encoding", dest="encoding",
|
||||
choices=tools.ENCODINGS.keys(), default='UTF-8',
|
||||
help="Specify the encoding of the message to hide." +
|
||||
" UTF-8 (default) or UTF-32LE.")
|
||||
|
||||
# Generator
|
||||
parser_hide.add_argument("-g", "--generator", dest="generator_function",
|
||||
action=ValidateGenerator,
|
||||
nargs='*', required=True, help="Generator (with optional arguments)")
|
||||
parser_hide.add_argument("-s", "--shift", dest="shift",
|
||||
default=0, help="Shift for the generator")
|
||||
|
||||
group_secret = parser_hide.add_mutually_exclusive_group(required=True)
|
||||
# Non binary secret message to hide
|
||||
group_secret.add_argument("-m", dest="secret_message",
|
||||
help="Your secret message to hide (non binary).")
|
||||
# Binary secret message to hide
|
||||
group_secret.add_argument("-f", dest="secret_file",
|
||||
help="Your secret to hide (Text or any binary file).")
|
||||
|
||||
# Image containing the secret
|
||||
parser_hide.add_argument("-o", "--output", dest="output_image_file",
|
||||
required=True, help="Output image containing the secret.")
|
||||
|
||||
|
||||
# Subparser: Reveal
|
||||
parser_reveal = subparsers.add_parser('reveal', help='reveal help')
|
||||
parser_reveal.add_argument("-i", "--input", dest="input_image_file",
|
||||
required=True, help="Input image file.")
|
||||
parser_reveal.add_argument("-e", "--encoding", dest="encoding",
|
||||
choices=tools.ENCODINGS.keys(), default='UTF-8',
|
||||
help="Specify the encoding of the message to reveal." +
|
||||
" UTF-8 (default) or UTF-32LE.")
|
||||
parser_reveal.add_argument("-g", "--generator", dest="generator_function",
|
||||
action=ValidateGenerator,
|
||||
nargs='*', required=True, help="Generator (with optional arguments)")
|
||||
parser_reveal.add_argument("-s", "--shift", dest="shift",
|
||||
default=0, help="Shift for the generator")
|
||||
parser_reveal.add_argument("-o", dest="secret_binary",
|
||||
help="Output for the binary secret (Text or any binary file).")
|
||||
|
||||
|
||||
# Subparser: List generators
|
||||
parser_list_generators = subparsers.add_parser('list-generators',
|
||||
help='list-generators help')
|
||||
|
||||
arguments = parser.parse_args()
|
||||
|
||||
if arguments.command != 'list-generators':
|
||||
try:
|
||||
arguments.generator_function[0]
|
||||
except AttributeError:
|
||||
print('You must specify the name of a generator.')
|
||||
parser.print_help()
|
||||
exit(1)
|
||||
|
||||
try:
|
||||
if (arguments.generator_function[0] == "LFSR"):
|
||||
# Compute the size of the image for use by the LFSR generator if needed
|
||||
tmp = tools.open_image(arguments.input_image_file)
|
||||
size = tmp.width * tmp.height
|
||||
tmp.close()
|
||||
arguments.generator_function.append(size)
|
||||
if (len(arguments.generator_function) > 1):
|
||||
generator = getattr(generators, arguments.generator_function[0])(
|
||||
*[int(e) for e in arguments.generator_function[1:]])
|
||||
else:
|
||||
generator = getattr(generators, arguments.generator_function[0])()
|
||||
|
||||
except AttributeError as e:
|
||||
print("Unknown generator: {}".format(arguments.generator_function))
|
||||
exit(1)
|
||||
|
||||
if arguments.command == 'hide':
|
||||
if arguments.secret_message != None:
|
||||
secret = arguments.secret_message
|
||||
elif arguments.secret_file != "":
|
||||
secret = tools.binary2base64(arguments.secret_file)
|
||||
|
||||
img_encoded = lsbset.hide(arguments.input_image_file, secret, generator,
|
||||
int(arguments.shift))
|
||||
try:
|
||||
img_encoded.save(arguments.output_image_file)
|
||||
except Exception as e:
|
||||
# If hide() returns an error (Too long message).
|
||||
print(e)
|
||||
|
||||
elif arguments.command == 'reveal':
|
||||
try:
|
||||
secret = lsbset.reveal(arguments.input_image_file, generator,
|
||||
int(arguments.shift))
|
||||
except IndexError:
|
||||
print("Impossible to detect message.")
|
||||
exit(0)
|
||||
if arguments.secret_binary != None:
|
||||
data = tools.base642binary(secret)
|
||||
with open(arguments.secret_binary, "w") as f:
|
||||
f.write(data)
|
||||
else:
|
||||
print(secret)
|
||||
|
||||
elif arguments.command == 'list-generators':
|
||||
all_generators = inspect.getmembers(generators, inspect.isfunction)
|
||||
for generator in all_generators:
|
||||
print('Generator id:')
|
||||
print(' {}'.format(crayons.green(generator[0], bold=True)))
|
||||
print('Desciption:')
|
||||
print(' {}'.format(generator[1].__doc__))
|
|
@ -1,56 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
__author__ = "Cedric Bonhomme"
|
||||
__version__ = "$Revision: 0.1 $"
|
||||
__date__ = "$Date: 2017/02/06 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
try:
|
||||
from stegano import red
|
||||
except:
|
||||
print("Install stegano: sudo pip install Stegano")
|
||||
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(prog='stegano-red')
|
||||
subparsers = parser.add_subparsers(help='sub-command help', dest='command')
|
||||
|
||||
parser_hide = subparsers.add_parser('hide', help='hide help')
|
||||
parser_hide.add_argument("-i", "--input", dest="input_image_file",
|
||||
help="Image file")
|
||||
parser_hide.add_argument("-m", dest="secret_message",
|
||||
help="Your secret message to hide (non binary).")
|
||||
parser_hide.add_argument("-o", "--output", dest="output_image_file",
|
||||
help="Image file")
|
||||
|
||||
parser_reveal = subparsers.add_parser('reveal', help='reveal help')
|
||||
parser_reveal.add_argument("-i", "--input", dest="input_image_file",
|
||||
help="Image file")
|
||||
|
||||
arguments = parser.parse_args()
|
||||
|
||||
if arguments.command == 'hide':
|
||||
secret = red.hide(arguments.input_image_file, arguments.secret_message)
|
||||
secret.save(arguments.output_image_file)
|
||||
|
||||
elif arguments.command == 'reveal':
|
||||
secret = red.reveal(arguments.input_image_file)
|
||||
print(secret)
|
164
docs/conf.py
164
docs/conf.py
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Stéganô documentation build configuration file, created by
|
||||
# sphinx-quickstart on Wed Jul 25 13:33:39 2012.
|
||||
|
@ -10,233 +9,162 @@
|
|||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
|
||||
# needs_sphinx = '1.0'
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = []
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
master_doc = "index"
|
||||
|
||||
# General information about the project.
|
||||
project = u'Stegano'
|
||||
copyright = u'2010-2019, Cédric Bonhomme'
|
||||
project = "Stegano"
|
||||
copyright = "2010-2025, Cédric Bonhomme"
|
||||
author = "Cédric Bonhomme <cedric@cedricbonhomme.org>"
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.8'
|
||||
version = "0.11"
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.8.6'
|
||||
release = "0.11.0"
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#language = None
|
||||
# language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
# today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = ["_build"]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
# show_authors = False
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
# modindex_common_prefix = []
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'bizstyle'
|
||||
html_theme = "sphinx_rtd_theme"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
# html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
# html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
# html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
html_static_path = ["_static"]
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
# html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
html_use_index = False
|
||||
# html_domain_indices = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
# html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
# html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
# html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'Stgandoc'
|
||||
# html_file_suffix = None
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
latex_engine = "pdflatex"
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'Stgan.tex', u'Stegano Documentation',
|
||||
u'Cédric Bonhomme', 'manual'),
|
||||
("index", "Stgan.tex", "Stegano Documentation", "Cédric Bonhomme", "howto"),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
latex_show_urls = True
|
||||
latex_show_pagerefs = True
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'stgan', u'Stéganô Documentation',
|
||||
[u'Cédric Bonhomme'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'Stgan', u'Stegano Documentation',
|
||||
u'Cédric Bonhomme', 'Stgan', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
ADDITIONAL_PREAMBLE = r"""
|
||||
\setcounter{tocdepth}{3}
|
||||
"""
|
||||
|
|
|
@ -6,19 +6,15 @@
|
|||
Presentation
|
||||
============
|
||||
|
||||
.. image:: https://builds.sr.ht/~cedric/Stegano.svg
|
||||
:target: https://builds.sr.ht/~cedric/Stegano
|
||||
|
||||
|
||||
Stegano_ is a pure Python steganography_ module.
|
||||
|
||||
Steganography is the art and science of writing hidden messages in such a way
|
||||
that no one, apart from the sender and intended recipient, suspects the
|
||||
existence of the message, a form of security through obscurity.
|
||||
Consequently, functions provided by Stéganô only hide messages,
|
||||
Consequently, functions provided by Stegano only hide messages,
|
||||
without encryption. Steganography is often used with cryptography.
|
||||
|
||||
Stéganô implements these methods of hiding:
|
||||
Stegano implements these methods of hiding:
|
||||
|
||||
- using the red portion of a pixel to hide ASCII messages;
|
||||
- using the `Least Significant Bit <http://en.wikipedia.org/wiki/Least_significant_bit>`_ (LSB) technique;
|
||||
|
@ -30,7 +26,7 @@ Moreover some methods of steganalysis_ are provided:
|
|||
- steganalysis of LSB encoding in color images;
|
||||
- statistical steganalysis.
|
||||
|
||||
You can also use Stegano through this `Web service <https://stegano-web.herokuapp.com>`_.
|
||||
You can also use Stegano through a `Web service <https://github.com/cedricbonhomme/stegano-web>`_.
|
||||
Not all functionalities of Stegano are covered.
|
||||
|
||||
Requirements
|
||||
|
@ -41,7 +37,7 @@ Requirements
|
|||
- `piexif`_.
|
||||
|
||||
|
||||
Turorial
|
||||
Tutorial
|
||||
========
|
||||
|
||||
.. toctree::
|
||||
|
@ -53,7 +49,7 @@ Turorial
|
|||
steganalysis
|
||||
|
||||
You can have a look at the
|
||||
`unit tests <https://git.sr.ht/~cedric/Stegano/tree/master/tests>`_.
|
||||
`unit tests <https://github.com/cedricbonhomme/Stegano/tree/master/tests>`_.
|
||||
|
||||
|
||||
License
|
||||
|
@ -65,8 +61,8 @@ Stegano_ is under GPL v3 license.
|
|||
Donation
|
||||
========
|
||||
|
||||
If you wish and if you like Stegano, you can donate via bitcoin.
|
||||
My bitcoin address: `1GVmhR9fbBeEh7rP1qNq76jWArDdDQ3otZ <http://blockexplorer.com/address/1GVmhR9fbBeEh7rP1qNq76jWArDdDQ3otZ>`_
|
||||
If you wish and if you like Stegano, you can
|
||||
`donate <https://github.com/sponsors/cedricbonhomme>`_.
|
||||
|
||||
|
||||
|
||||
|
@ -77,7 +73,7 @@ Contact
|
|||
|
||||
|
||||
.. _Python: https://www.python.org
|
||||
.. _Stegano: https://git.sr.ht/~cedric/Stegano
|
||||
.. _Stegano: https://github.com/cedricbonhomme/Stegano
|
||||
.. _`Pillow`: https://pypi.python.org/pypi/Pillow
|
||||
.. _`piexif`: https://pypi.python.org/pypi/piexif
|
||||
.. _steganography: http://en.wikipedia.org/wiki/Steganography
|
||||
|
|
|
@ -3,16 +3,13 @@ Installation
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
$ pipenv install Stegano
|
||||
$ poetry install Stegano
|
||||
|
||||
You will be able to use Stéganô in your Python programs
|
||||
You will be able to use Stegano in your Python programs
|
||||
or as a command line tool.
|
||||
|
||||
If you want to retrieve the source code (with the unit tests):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ git clone https://git.sr.ht/~cedric/Stegano
|
||||
|
||||
.. image:: https://api.travis-ci.org/cedricbonhomme/Stegano.svg?branch=master
|
||||
:target: https://travis-ci.org/cedricbonhomme/Stegano
|
||||
$ git clone https://github.com/cedricbonhomme/Stegano
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
Using Stéganô as a Python module
|
||||
Using Stegano as a Python module
|
||||
================================
|
||||
|
||||
You can find more examples in the
|
||||
`unit tests directory <https://git.sr.ht/~cedric/Stegano/tree/master/tests>`_.
|
||||
`unit tests directory <https://github.com/cedricbonhomme/Stegano/tree/master/tests>`_.
|
||||
|
||||
LSB method
|
||||
----------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
Python 3.5.1 (default, Dec 7 2015, 11:33:57)
|
||||
[GCC 4.9.2] on linux
|
||||
Python 3.11.0 (main, Oct 31 2022, 15:15:22) [GCC 12.2.0] on linux
|
||||
Type "help", "copyright", "credits" or "license" for more information.
|
||||
>>> from stegano import lsb
|
||||
>>> secret = lsb.hide("./tests/sample-files/Lenna.png", "Hello world!")
|
||||
|
@ -27,29 +26,33 @@ Sets are used in order to select the pixels where the message will be hidden.
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
Python 3.5.1 (default, Dec 7 2015, 11:33:57)
|
||||
[GCC 4.9.2] on linux
|
||||
Python 3.11.0 (main, Oct 31 2022, 15:15:22) [GCC 12.2.0] on linux
|
||||
Type "help", "copyright", "credits" or "license" for more information.
|
||||
>>> from stegano import lsbset
|
||||
>>> from stegano.lsbset import generators
|
||||
>>> from stegano import lsb
|
||||
>>> from stegano.lsb import generators
|
||||
|
||||
# Hide a secret with the Sieve of Eratosthenes
|
||||
>>> secret_message = "Hello World!"
|
||||
>>> secret_image = lsbset.hide("./tests/sample-files/Lenna.png",
|
||||
secret_message,
|
||||
generators.eratosthenes())
|
||||
>>> secret_image = lsb.hide("./tests/sample-files/Lenna.png", secret_message, generators.eratosthenes())
|
||||
>>> secret_image.save("./image.png")
|
||||
|
||||
# Try to decode with another generator
|
||||
>>> message = lsbset.reveal("./image.png", generators.fibonacci())
|
||||
>>> message = lsb.reveal("./image.png", generators.fibonacci())
|
||||
Traceback (most recent call last):
|
||||
File "<stdin>", line 1, in <module>
|
||||
File "/home/cedric/projects/Stegano/stegano/lsbset/lsbset.py", line 111, in reveal
|
||||
for color in img_list[generated_number]:
|
||||
IndexError: list index out of range
|
||||
File "/Users/flavien/.local/share/virtualenvs/Stegano-sY_cwr69/bin/stegano-lsb", line 6, in <module>
|
||||
sys.exit(main())
|
||||
File "/Users/flavien/Perso/dev/Stegano/bin/lsb.py", line 190, in main
|
||||
img_encoded = lsb.hide(
|
||||
File "/Users/flavien/Perso/dev/Stegano/stegano/lsb/lsb.py", line 63, in hide
|
||||
hider.encode_pixel((col, row))
|
||||
File "/Users/flavien/Perso/dev/Stegano/stegano/tools.py", line 165, in encode_pixel
|
||||
r, g, b, *a = self.encoded_image.getpixel(coordinate)
|
||||
File "/Users/flavien/.local/share/virtualenvs/Stegano-sY_cwr69/lib/python3.10/site-packages/PIL/Image.py", line 1481, in getpixel
|
||||
return self.im.getpixel(xy)
|
||||
IndexError: image index out of range
|
||||
|
||||
# Decode with Eratosthenes
|
||||
>>> message = lsbset.reveal("./image.png", generators.eratosthenes())
|
||||
>>> message = lsb.reveal("./image.png", generators.eratosthenes())
|
||||
>>> message
|
||||
'Hello World!'
|
||||
|
||||
|
@ -94,6 +97,12 @@ Sets are used in order to select the pixels where the message will be hidden.
|
|||
syracuse
|
||||
Generate the sequence of Syracuse.
|
||||
|
||||
shi_tomashi Shi-Tomachi corner generator of the given points
|
||||
https://docs.opencv.org/4.x/d4/d8c/tutorial_py_shi_tomasi.html
|
||||
|
||||
triangular_numbers Triangular numbers: a(n) = C(n+1,2) = n(n+1)/2 = 0+1+2+...+n.
|
||||
http://oeis.org/A000217
|
||||
|
||||
|
||||
|
||||
Description field of the image
|
||||
|
@ -103,8 +112,7 @@ For JPEG and TIFF images.
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
Python 3.5.1 (default, Dec 7 2015, 11:33:57)
|
||||
[GCC 4.9.2] on linux
|
||||
Python 3.11.0 (main, Oct 31 2022, 15:15:22) [GCC 12.2.0] on linux
|
||||
Type "help", "copyright", "credits" or "license" for more information.
|
||||
>>> from stegano import exifHeader
|
||||
>>> secret = exifHeader.hide("./tests/sample-files/20160505T130442.jpg",
|
||||
|
|
2
docs/requirements.txt
Normal file
2
docs/requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
sphinx
|
||||
sphinx_rtd_theme
|
|
@ -1,4 +1,4 @@
|
|||
Using Stéganô in command line
|
||||
Using Stegano in command line
|
||||
=============================
|
||||
|
||||
The command ``stegano-lsb``
|
||||
|
@ -12,52 +12,56 @@ Display help
|
|||
.. code-block:: bash
|
||||
|
||||
$ stegano-lsb --help
|
||||
usage: stegano-lsb [-h] {hide,reveal} ...
|
||||
usage: stegano-lsb [-h] {hide,reveal,list-generators} ...
|
||||
|
||||
positional arguments:
|
||||
{hide,reveal} sub-command help
|
||||
hide hide help
|
||||
reveal reveal help
|
||||
{hide,reveal,list-generators}
|
||||
sub-command help
|
||||
hide hide help
|
||||
reveal reveal help
|
||||
list-generators list-generators help
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
options:
|
||||
-h, --help show this help message and exit
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ stegano-lsb hide --help
|
||||
usage: stegano-lsb hide [-h] -i INPUT_IMAGE_FILE [-e {UTF-8,UTF-32LE}]
|
||||
(-m SECRET_MESSAGE | -f SECRET_FILE) -o
|
||||
OUTPUT_IMAGE_FILE
|
||||
usage: stegano-lsb hide [-h] -i INPUT_IMAGE_FILE [-e {UTF-8,UTF-32LE}] [-g [GENERATOR_FUNCTION ...]] [-s SHIFT] (-m SECRET_MESSAGE | -f SECRET_FILE) -o OUTPUT_IMAGE_FILE
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-i INPUT_IMAGE_FILE, --input INPUT_IMAGE_FILE
|
||||
options:
|
||||
-h, --help show this help message and exit
|
||||
-i INPUT_IMAGE_FILE, --input INPUT_IMAGE_FILE
|
||||
Input image file.
|
||||
-e {UTF-8,UTF-32LE}, --encoding {UTF-8,UTF-32LE}
|
||||
Specify the encoding of the message to hide. UTF-8
|
||||
(default) or UTF-32LE.
|
||||
-m SECRET_MESSAGE Your secret message to hide (non binary).
|
||||
-f SECRET_FILE Your secret to hide (Text or any binary file).
|
||||
-o OUTPUT_IMAGE_FILE, --output OUTPUT_IMAGE_FILE
|
||||
-e {UTF-8,UTF-32LE}, --encoding {UTF-8,UTF-32LE}
|
||||
Specify the encoding of the message to hide. UTF-8 (default) or UTF-32LE.
|
||||
-g [GENERATOR_FUNCTION ...], --generator [GENERATOR_FUNCTION ...]
|
||||
Generator (with optional arguments)
|
||||
-s SHIFT, --shift SHIFT
|
||||
Shift for the generator
|
||||
-m SECRET_MESSAGE Your secret message to hide (non binary).
|
||||
-f SECRET_FILE Your secret to hide (Text or any binary file).
|
||||
-o OUTPUT_IMAGE_FILE, --output OUTPUT_IMAGE_FILE
|
||||
Output image containing the secret.
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ stegano-lsb reveal --help
|
||||
usage: stegano-lsb reveal [-h] -i INPUT_IMAGE_FILE [-e {UTF-8,UTF-32LE}]
|
||||
[-o SECRET_BINARY]
|
||||
usage: stegano-lsb reveal [-h] -i INPUT_IMAGE_FILE [-e {UTF-8,UTF-32LE}] [-g [GENERATOR_FUNCTION ...]] [-s SHIFT] [-o SECRET_BINARY]
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-i INPUT_IMAGE_FILE, --input INPUT_IMAGE_FILE
|
||||
options:
|
||||
-h, --help show this help message and exit
|
||||
-i INPUT_IMAGE_FILE, --input INPUT_IMAGE_FILE
|
||||
Input image file.
|
||||
-e {UTF-8,UTF-32LE}, --encoding {UTF-8,UTF-32LE}
|
||||
Specify the encoding of the message to reveal. UTF-8
|
||||
(default) or UTF-32LE.
|
||||
-o SECRET_BINARY Output for the binary secret (Text or any binary
|
||||
file).
|
||||
-e {UTF-8,UTF-32LE}, --encoding {UTF-8,UTF-32LE}
|
||||
Specify the encoding of the message to reveal. UTF-8 (default) or UTF-32LE.
|
||||
-g [GENERATOR_FUNCTION ...], --generator [GENERATOR_FUNCTION ...]
|
||||
Generator (with optional arguments)
|
||||
-s SHIFT, --shift SHIFT
|
||||
Shift for the generator
|
||||
-o SECRET_BINARY Output for the binary secret (Text or any binary file).
|
||||
|
||||
|
||||
Hide and reveal a text message
|
||||
|
@ -92,71 +96,48 @@ Hide and reveal a binary file
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
The command ``stegano-lsb-set``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Sets are used in order to select the pixels where the message will be hidden.
|
||||
|
||||
Hide and reveal a text message
|
||||
------------------------------
|
||||
Hide and reveal a text message with set
|
||||
---------------------------------------
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Hide the message with the Sieve of Eratosthenes
|
||||
$ stegano-lsb-set hide -i ./tests/sample-files/Montenach.png --generator eratosthenes -m 'Joyeux Noël!' -o ./surprise.png
|
||||
$ stegano-lsb hide -i ./tests/sample-files/Montenach.png --generator eratosthenes -m 'Joyeux Noël!' -o ./surprise.png
|
||||
|
||||
# Try to reveal with Mersenne numbers
|
||||
$ stegano-lsb-set reveal --generator mersenne -i ./surprise.png
|
||||
$ stegano-lsb reveal --generator mersenne -i ./surprise.png
|
||||
|
||||
# Try to reveal with fermat numbers
|
||||
$ stegano-lsb-set reveal --generator fermat -i ./surprise.png
|
||||
$ stegano-lsb reveal --generator fermat -i ./surprise.png
|
||||
|
||||
# Try to reveal with carmichael numbers
|
||||
$ stegano-lsb-set reveal --generator carmichael -i ./surprise.png
|
||||
$ stegano-lsb reveal --generator carmichael -i ./surprise.png
|
||||
|
||||
# Try to reveal with Sieve of Eratosthenes
|
||||
$ stegano-lsb-set reveal --generator eratosthenes -i ./surprise.png
|
||||
|
||||
An other example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Hide the message - LSB with a set defined by the identity function (f(x) = x).
|
||||
stegano-lsb-set hide -i ./tests/sample-files/Montenach.png --generator identity -m 'I like steganography.' -o ./enc-identity.png
|
||||
|
||||
# Hide the message - LSB only.
|
||||
stegano-lsb hide -i ./tests/sample-files/Montenach.png -m 'I like steganography.' -o ./enc.png
|
||||
|
||||
# Check if the two generated files are the same.
|
||||
sha1sum ./enc-identity.png ./enc.png
|
||||
|
||||
# The output of lsb is given to lsb-set.
|
||||
stegano-lsb-set reveal -i ./enc.png --generator identity
|
||||
|
||||
# The output of lsb-set is given to lsb.
|
||||
stegano-lsb reveal -i ./enc-identity.png
|
||||
$ stegano-lsb reveal --generator eratosthenes -i ./surprise.png
|
||||
|
||||
|
||||
Sometimes it can be useful to skip the first values of a set. For example if you want
|
||||
to hide several messages or because due to the selected generator
|
||||
(Fibonacci starts with 0, 1, 1, etc.). Or maybe you just want to add more complexity.
|
||||
In this case, simply use the optional arguments ``--shift``:
|
||||
In this case, simply use the optional arguments ``--shift`` or ``-s``:
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
stegano-lsb-set reveal -i ./tests/sample-files/Lenna.png --generator fibonacci --shift 7
|
||||
|
||||
|
||||
$ stegano-lsb hide -i ./tests/sample-files/Lenna.png -m 'Shifted secret message' -o ~/Lenna1.png --shift 7
|
||||
$ stegano-lsb reveal -i ~/Lenna1.png --shift 7
|
||||
Shifted secret message
|
||||
|
||||
|
||||
List all available generators
|
||||
------------------------------
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ stegano-lsb-set list-generators
|
||||
$ stegano-lsb list-generators
|
||||
Generator id:
|
||||
ackermann
|
||||
Desciption:
|
||||
|
|
|
@ -7,7 +7,7 @@ Parity
|
|||
.. code-block:: bash
|
||||
|
||||
# Hide the message with Sieve of Eratosthenes
|
||||
stegano-lsb-set hide -i ./tests/sample-files/20160505T130442.jpg -o ./surprise.png --generator eratosthenes -m 'Very important message.'
|
||||
stegano-lsb hide -i ./tests/sample-files/20160505T130442.jpg -o ./surprise.png --generator eratosthenes -m 'Very important message.'
|
||||
|
||||
# Steganalysis of the original photo
|
||||
stegano-steganalysis-parity -i ./tests/sample-files/20160505T130442.jpg -o ./surprise_st_original.png
|
||||
|
@ -16,4 +16,4 @@ Parity
|
|||
stegano-steganalysis-parity -i ./surprise.png -o ./surprise_st_secret.png
|
||||
|
||||
# Reveal with Sieve of Eratosthenes
|
||||
stegano-lsb-set reveal -i ./surprise.png --generator eratosthenes
|
||||
stegano-lsb reveal -i ./surprise.png --generator eratosthenes
|
||||
|
|
1095
poetry.lock
generated
Normal file
1095
poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
93
pyproject.toml
Normal file
93
pyproject.toml
Normal file
|
@ -0,0 +1,93 @@
|
|||
[build-system]
|
||||
requires = ["poetry-core>=2.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
|
||||
[project]
|
||||
name = "stegano"
|
||||
version = "1.0.1"
|
||||
description = "A pure Python Steganography module."
|
||||
authors = [
|
||||
{name = "Cédric Bonhomme", email= "cedric@cedricbonhomme.org"}
|
||||
]
|
||||
license = "GPL-3.0-or-later"
|
||||
readme = "README.md"
|
||||
keywords = ["Steganography", "Security", "Stegano"]
|
||||
|
||||
dynamic = ["classifiers"]
|
||||
|
||||
requires-python = ">=3.10,<4.0"
|
||||
dependencies = [
|
||||
"pillow (>=9.5,<11.0)",
|
||||
"piexif (>=1.1.3)",
|
||||
"crayons (>=0.4.0)",
|
||||
"opencv-python (>=4.8.1.78)"
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://github.com/cedricbonhomme/Stegano"
|
||||
Changelog = "https://github.com/cedricbonhomme/Stegano/blob/master/CHANGELOG.md"
|
||||
Repository = "https://github.com/cedricbonhomme/Stegano"
|
||||
Documentation = "https://stegano.readthedocs.io"
|
||||
|
||||
[project.scripts]
|
||||
stegano-lsb = "stegano.console.lsb:main"
|
||||
stegano-red = "stegano.console.red:main"
|
||||
stegano-steganalysis-parity = "stegano.console.parity:main"
|
||||
stegano-steganalysis-statistics = "stegano.console.statistics:main"
|
||||
|
||||
|
||||
[tool.poetry]
|
||||
requires-poetry = ">=2.0"
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Environment :: Console",
|
||||
"Intended Audience :: Developers",
|
||||
"Intended Audience :: Science/Research",
|
||||
"Topic :: Security",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)"
|
||||
]
|
||||
include = [
|
||||
"README.md",
|
||||
"COPYING",
|
||||
"CHANGELOG.md",
|
||||
"docs/**/*",
|
||||
]
|
||||
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
mypy = "^1.8.0"
|
||||
flake8 = "^6.0.0"
|
||||
nose2 = "^0.14.0"
|
||||
Sphinx = "^6.2.1"
|
||||
pre-commit = "^3.6.0"
|
||||
|
||||
|
||||
[tool.poetry.group.dev]
|
||||
optional = true
|
||||
|
||||
|
||||
[tool.mypy]
|
||||
python_version = "3.12"
|
||||
check_untyped_defs = true
|
||||
ignore_errors = false
|
||||
ignore_missing_imports = true
|
||||
strict_optional = true
|
||||
no_implicit_optional = true
|
||||
warn_unused_ignores = true
|
||||
warn_redundant_casts = true
|
||||
warn_unused_configs = true
|
||||
warn_unreachable = true
|
||||
|
||||
show_error_context = true
|
||||
pretty = true
|
||||
|
||||
exclude = "build|dist|docs|stegano.egg-info"
|
||||
|
||||
[tool.isort]
|
||||
profile = "black"
|
|
@ -1,2 +0,0 @@
|
|||
[metadata]
|
||||
description-file = README.md
|
60
setup.py
60
setup.py
|
@ -1,60 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
import codecs
|
||||
import os
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
packages = [
|
||||
'stegano',
|
||||
'stegano.red',
|
||||
'stegano.exifHeader',
|
||||
'stegano.lsb',
|
||||
'stegano.lsbset',
|
||||
'stegano.steganalysis'
|
||||
]
|
||||
|
||||
scripts = [
|
||||
'bin/stegano-lsb',
|
||||
'bin/stegano-lsb-set',
|
||||
'bin/stegano-red',
|
||||
'bin/stegano-steganalysis-parity',
|
||||
'bin/stegano-steganalysis-statistics'
|
||||
]
|
||||
|
||||
requires = ['pillow', 'piexif', 'crayons']
|
||||
|
||||
with codecs.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
|
||||
readme = f.read()
|
||||
with codecs.open(os.path.join(here, 'CHANGELOG.md'), encoding='utf-8') as f:
|
||||
changelog = f.read()
|
||||
|
||||
setup(
|
||||
name='Stegano',
|
||||
version='0.9.5',
|
||||
author='Cédric Bonhomme',
|
||||
author_email='cedric@cedricbonhomme.org',
|
||||
packages=packages,
|
||||
include_package_data=True,
|
||||
scripts=scripts,
|
||||
url='https://git.sr.ht/~cedric/Stegano',
|
||||
description='A pure Python Steganography module.',
|
||||
long_description=readme + '\n\n' + changelog,
|
||||
platforms = ['Linux'],
|
||||
license='GPLv3',
|
||||
install_requires=requires,
|
||||
zip_safe=False,
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Environment :: Console',
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: Science/Research',
|
||||
'Topic :: Security',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)'
|
||||
]
|
||||
)
|
|
@ -1,9 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import red
|
||||
from . import exifHeader
|
||||
from . import lsb
|
||||
from . import lsbset
|
||||
from . import exifHeader, lsb, red, steganalysis
|
||||
|
||||
from . import steganalysis
|
||||
__all__ = ["red", "exifHeader", "lsb", "steganalysis"]
|
||||
|
|
0
stegano/console/__init__.py
Normal file
0
stegano/console/__init__.py
Normal file
227
stegano/console/lsb.py
Executable file
227
stegano/console/lsb.py
Executable file
|
@ -0,0 +1,227 @@
|
|||
#!/usr/bin/env python
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2025 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
__author__ = "Cedric Bonhomme"
|
||||
__version__ = "$Revision: 0.7 $"
|
||||
__date__ = "$Date: 2016/03/18 $"
|
||||
__revision__ = "$Date: 2019/06/04 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
import inspect
|
||||
|
||||
import crayons
|
||||
|
||||
try:
|
||||
from stegano import lsb
|
||||
from stegano.lsb import generators
|
||||
except Exception:
|
||||
print("Install stegano: pipx install Stegano")
|
||||
|
||||
import argparse
|
||||
|
||||
from stegano import tools
|
||||
|
||||
|
||||
class ValidateGenerator(argparse.Action):
|
||||
def __call__(self, parser, args, values, option_string=None):
|
||||
valid_generators = [
|
||||
generator[0]
|
||||
for generator in inspect.getmembers(generators, inspect.isfunction)
|
||||
]
|
||||
# Verify that the generator is valid
|
||||
generator = values[0]
|
||||
if generator not in valid_generators:
|
||||
raise ValueError("Unknown generator: %s" % generator)
|
||||
# Set the generator_function arg of the parser
|
||||
setattr(args, self.dest, values)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(prog="stegano-lsb")
|
||||
subparsers = parser.add_subparsers(
|
||||
help="sub-command help", dest="command", required=True
|
||||
)
|
||||
|
||||
# Subparser: Hide
|
||||
parser_hide = subparsers.add_parser("hide", help="hide help")
|
||||
# Original image
|
||||
parser_hide.add_argument(
|
||||
"-i",
|
||||
"--input",
|
||||
dest="input_image_file",
|
||||
required=True,
|
||||
help="Input image file.",
|
||||
)
|
||||
parser_hide.add_argument(
|
||||
"-e",
|
||||
"--encoding",
|
||||
dest="encoding",
|
||||
choices=tools.ENCODINGS.keys(),
|
||||
default="UTF-8",
|
||||
help="Specify the encoding of the message to hide."
|
||||
" UTF-8 (default) or UTF-32LE.",
|
||||
)
|
||||
|
||||
# Generator
|
||||
parser_hide.add_argument(
|
||||
"-g",
|
||||
"--generator",
|
||||
dest="generator_function",
|
||||
action=ValidateGenerator,
|
||||
nargs="*",
|
||||
required=False,
|
||||
default=None,
|
||||
help="Generator (with optional arguments)",
|
||||
)
|
||||
|
||||
# Shift the message to hide
|
||||
parser_hide.add_argument(
|
||||
"-s", "--shift", dest="shift", default=0, help="Shift for the generator"
|
||||
)
|
||||
|
||||
group_secret = parser_hide.add_mutually_exclusive_group(required=True)
|
||||
# Non binary secret message to hide
|
||||
group_secret.add_argument(
|
||||
"-m", dest="secret_message", help="Your secret message to hide (non binary)."
|
||||
)
|
||||
# Binary secret message to hide
|
||||
group_secret.add_argument(
|
||||
"-f", dest="secret_file", help="Your secret to hide (Text or any binary file)."
|
||||
)
|
||||
|
||||
# Image containing the secret
|
||||
parser_hide.add_argument(
|
||||
"-o",
|
||||
"--output",
|
||||
dest="output_image_file",
|
||||
required=True,
|
||||
help="Output image containing the secret.",
|
||||
)
|
||||
|
||||
# Subparser: Reveal
|
||||
parser_reveal = subparsers.add_parser("reveal", help="reveal help")
|
||||
parser_reveal.add_argument(
|
||||
"-i",
|
||||
"--input",
|
||||
dest="input_image_file",
|
||||
required=True,
|
||||
help="Input image file.",
|
||||
)
|
||||
parser_reveal.add_argument(
|
||||
"-e",
|
||||
"--encoding",
|
||||
dest="encoding",
|
||||
choices=tools.ENCODINGS.keys(),
|
||||
default="UTF-8",
|
||||
help="Specify the encoding of the message to reveal."
|
||||
" UTF-8 (default) or UTF-32LE.",
|
||||
)
|
||||
|
||||
# Generator
|
||||
parser_reveal.add_argument(
|
||||
"-g",
|
||||
"--generator",
|
||||
dest="generator_function",
|
||||
action=ValidateGenerator,
|
||||
nargs="*",
|
||||
required=False,
|
||||
help="Generator (with optional arguments)",
|
||||
)
|
||||
|
||||
# Shift the message to reveal
|
||||
parser_reveal.add_argument(
|
||||
"-s", "--shift", dest="shift", default=0, help="Shift for the generator"
|
||||
)
|
||||
parser_reveal.add_argument(
|
||||
"-o",
|
||||
dest="secret_binary",
|
||||
help="Output for the binary secret (Text or any binary file).",
|
||||
)
|
||||
|
||||
# Subparser: List generators
|
||||
subparsers.add_parser("list-generators", help="list-generators help")
|
||||
|
||||
arguments = parser.parse_args()
|
||||
|
||||
if arguments.command != "list-generators":
|
||||
if not arguments.generator_function:
|
||||
generator = None
|
||||
else:
|
||||
try:
|
||||
if arguments.generator_function[0] == "LFSR":
|
||||
# Compute the size of the image for use by the LFSR generator if needed
|
||||
tmp = tools.open_image(arguments.input_image_file)
|
||||
size = tmp.width * tmp.height
|
||||
tmp.close()
|
||||
arguments.generator_function.append(size)
|
||||
if len(arguments.generator_function) > 1:
|
||||
generator = getattr(generators, arguments.generator_function[0])(
|
||||
*[int(e) for e in arguments.generator_function[1:]]
|
||||
)
|
||||
else:
|
||||
generator = getattr(generators, arguments.generator_function[0])()
|
||||
|
||||
except AttributeError:
|
||||
print(f"Unknown generator: {arguments.generator_function}")
|
||||
exit(1)
|
||||
|
||||
if arguments.command == "hide":
|
||||
if arguments.secret_message is not None:
|
||||
secret = arguments.secret_message
|
||||
elif arguments.secret_file != "":
|
||||
secret = tools.binary2base64(arguments.secret_file)
|
||||
|
||||
img_encoded = lsb.hide(
|
||||
image=arguments.input_image_file,
|
||||
message=secret,
|
||||
generator=generator,
|
||||
shift=int(arguments.shift),
|
||||
encoding=arguments.encoding,
|
||||
)
|
||||
try:
|
||||
img_encoded.save(arguments.output_image_file)
|
||||
except Exception as e:
|
||||
# If hide() returns an error (Too long message).
|
||||
print(e)
|
||||
|
||||
elif arguments.command == "reveal":
|
||||
try:
|
||||
secret = lsb.reveal(
|
||||
encoded_image=arguments.input_image_file,
|
||||
generator=generator,
|
||||
shift=int(arguments.shift),
|
||||
encoding=arguments.encoding,
|
||||
)
|
||||
except IndexError:
|
||||
print("Impossible to detect message.")
|
||||
exit(0)
|
||||
if arguments.secret_binary is not None:
|
||||
data = tools.base642binary(secret)
|
||||
with open(arguments.secret_binary, "wb") as f:
|
||||
f.write(data)
|
||||
else:
|
||||
print(secret)
|
||||
|
||||
elif arguments.command == "list-generators":
|
||||
all_generators = inspect.getmembers(generators, inspect.isfunction)
|
||||
for generator in all_generators:
|
||||
print("Generator id:")
|
||||
print(f" {crayons.green(generator[0], bold=True)}")
|
||||
print("Desciption:")
|
||||
print(f" {generator[1].__doc__}")
|
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
# Copyright (C) 2010-2025 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
|
@ -24,21 +22,34 @@ __version__ = "$Revision: 0.7 $"
|
|||
__date__ = "$Date: 2016/08/25 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
try:
|
||||
from stegano.steganalysis import parity
|
||||
except:
|
||||
print("Install Stegano: pipx install Stegano")
|
||||
import argparse
|
||||
|
||||
from PIL import Image
|
||||
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(prog='stegano-steganalysis-parity')
|
||||
parser.add_argument("-i", "--input", dest="input_image_file",
|
||||
required=True, help="Input image file.")
|
||||
parser.add_argument("-o", "--output", dest="output_image_file",
|
||||
required=True, help="Output image file.")
|
||||
arguments = parser.parse_args()
|
||||
try:
|
||||
from stegano.steganalysis import parity
|
||||
except Exception:
|
||||
print("Install Stegano: pipx install Stegano")
|
||||
|
||||
input_image_file = Image.open(arguments.input_image_file)
|
||||
output_image = parity.steganalyse(input_image_file)
|
||||
output_image.save(arguments.output_image_file)
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(prog="stegano-steganalysis-parity")
|
||||
parser.add_argument(
|
||||
"-i",
|
||||
"--input",
|
||||
dest="input_image_file",
|
||||
required=True,
|
||||
help="Input image file.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-o",
|
||||
"--output",
|
||||
dest="output_image_file",
|
||||
required=True,
|
||||
help="Output image file.",
|
||||
)
|
||||
arguments = parser.parse_args()
|
||||
|
||||
input_image_file = Image.open(arguments.input_image_file)
|
||||
output_image = parity.steganalyse(input_image_file)
|
||||
output_image.save(arguments.output_image_file)
|
61
stegano/console/red.py
Normal file
61
stegano/console/red.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env python
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2025 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
__author__ = "Cedric Bonhomme"
|
||||
__version__ = "$Revision: 0.1 $"
|
||||
__date__ = "$Date: 2017/02/06 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
import argparse
|
||||
|
||||
try:
|
||||
from stegano import red
|
||||
except Exception:
|
||||
print("Install stegano: sudo pip install Stegano")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(prog="stegano-red")
|
||||
subparsers = parser.add_subparsers(help="sub-command help", dest="command")
|
||||
|
||||
parser_hide = subparsers.add_parser("hide", help="hide help")
|
||||
parser_hide.add_argument(
|
||||
"-i", "--input", dest="input_image_file", help="Image file"
|
||||
)
|
||||
parser_hide.add_argument(
|
||||
"-m", dest="secret_message", help="Your secret message to hide (non binary)."
|
||||
)
|
||||
parser_hide.add_argument(
|
||||
"-o", "--output", dest="output_image_file", help="Image file"
|
||||
)
|
||||
|
||||
parser_reveal = subparsers.add_parser("reveal", help="reveal help")
|
||||
parser_reveal.add_argument(
|
||||
"-i", "--input", dest="input_image_file", help="Image file"
|
||||
)
|
||||
|
||||
arguments = parser.parse_args()
|
||||
|
||||
if arguments.command == "hide":
|
||||
secret = red.hide(arguments.input_image_file, arguments.secret_message)
|
||||
secret.save(arguments.output_image_file)
|
||||
|
||||
elif arguments.command == "reveal":
|
||||
secret = red.reveal(arguments.input_image_file)
|
||||
print(secret)
|
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
# Copyright (C) 2010-2025 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
|
@ -25,21 +23,22 @@ __date__ = "$Date: 2016/08/26 $"
|
|||
__revision__ = "$Date: 2016/08/26 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
try:
|
||||
from stegano.steganalysis import statistics
|
||||
except:
|
||||
print("Install Stegano: sudo pip install Stegano")
|
||||
import argparse
|
||||
|
||||
from PIL import Image
|
||||
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(prog='stegano-steganalysis-parity')
|
||||
parser.add_argument("-i", "--input", dest="input_image_file",
|
||||
help="Image file")
|
||||
parser.add_argument("-o", "--output", dest="output_image_file",
|
||||
help="Image file")
|
||||
arguments = parser.parse_args()
|
||||
try:
|
||||
from stegano.steganalysis import statistics
|
||||
except Exception:
|
||||
print("Install Stegano: sudo pip install Stegano")
|
||||
|
||||
input_image_file = Image.open(arguments.input_image_file)
|
||||
output_image = statistics.steganalyse(input_image_file)
|
||||
output_image.save(arguments.output_image_file)
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(prog="stegano-steganalysis-parity")
|
||||
parser.add_argument("-i", "--input", dest="input_image_file", help="Image file")
|
||||
parser.add_argument("-o", "--output", dest="output_image_file", help="Image file")
|
||||
arguments = parser.parse_args()
|
||||
|
||||
input_image_file = Image.open(arguments.input_image_file)
|
||||
output_image = statistics.steganalyse(input_image_file)
|
||||
output_image.save(arguments.output_image_file)
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
from .exifHeader import *
|
||||
from .exifHeader import hide, reveal
|
||||
|
||||
__all__ = ["hide", "reveal"]
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
# Copyright (C) 2010-2025 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
|
@ -26,6 +24,7 @@ __revision__ = "$Date: 2017/01/18 $"
|
|||
__license__ = "GPLv3"
|
||||
|
||||
import piexif
|
||||
|
||||
from stegano import tools
|
||||
|
||||
|
||||
|
@ -36,18 +35,17 @@ def hide(
|
|||
secret_file=None,
|
||||
img_format=None,
|
||||
):
|
||||
"""Hide a message (string) in an image.
|
||||
"""
|
||||
from zlib import compress
|
||||
"""Hide a message (string) in an image."""
|
||||
from base64 import b64encode
|
||||
from zlib import compress
|
||||
|
||||
if secret_file != None:
|
||||
with open(secret_file, "r") as f:
|
||||
if secret_file is not None:
|
||||
with open(secret_file) as f:
|
||||
secret_message = f.read()
|
||||
|
||||
try:
|
||||
text = compress(b64encode(bytes(secret_message, "utf-8")))
|
||||
except:
|
||||
except Exception:
|
||||
text = compress(b64encode(secret_message))
|
||||
|
||||
img = tools.open_image(input_image_file)
|
||||
|
@ -68,8 +66,7 @@ def hide(
|
|||
|
||||
|
||||
def reveal(input_image_file):
|
||||
"""Find a message in an image.
|
||||
"""
|
||||
"""Find a message in an image."""
|
||||
from base64 import b64decode
|
||||
from zlib import decompress
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
from .lsb import *
|
||||
from .lsb import hide, reveal
|
||||
|
||||
__all__ = ["hide", "reveal"]
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
# Copyright (C) 2010-2025 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
|
@ -22,17 +20,19 @@
|
|||
__author__ = "Cedric Bonhomme"
|
||||
__version__ = "$Revision: 0.3 $"
|
||||
__date__ = "$Date: 2011/12/28 $"
|
||||
__revision__ = "$Date: 2019/06/04 $"
|
||||
__revision__ = "$Date: 2021/11/29 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
import itertools
|
||||
import math
|
||||
from typing import Dict, Iterator, List
|
||||
from typing import Any, Dict, Iterator, List
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
|
||||
def identity() -> Iterator[int]:
|
||||
"""f(x) = x
|
||||
"""
|
||||
"""f(x) = x"""
|
||||
n = 0
|
||||
while True:
|
||||
yield n
|
||||
|
@ -72,7 +72,7 @@ def eratosthenes() -> Iterator[int]:
|
|||
"""Generate the prime numbers with the sieve of Eratosthenes.
|
||||
https://oeis.org/A000040
|
||||
"""
|
||||
d = {} # type: Dict[int, List[int]]
|
||||
d: Dict[int, List[int]] = {}
|
||||
for i in itertools.count(2):
|
||||
if i in d:
|
||||
for j in d[i]:
|
||||
|
@ -89,8 +89,7 @@ def composite() -> Iterator[int]:
|
|||
"""
|
||||
p1 = 3
|
||||
for p2 in eratosthenes():
|
||||
for n in range(p1 + 1, p2):
|
||||
yield n
|
||||
yield from range(p1 + 1, p2)
|
||||
p1 = p2
|
||||
|
||||
|
||||
|
@ -108,8 +107,7 @@ def carmichael() -> Iterator[int]:
|
|||
|
||||
|
||||
def ackermann_slow(m: int, n: int) -> int:
|
||||
"""Ackermann number.
|
||||
"""
|
||||
"""Ackermann number."""
|
||||
if m == 0:
|
||||
return n + 1
|
||||
elif n == 0:
|
||||
|
@ -119,8 +117,7 @@ def ackermann_slow(m: int, n: int) -> int:
|
|||
|
||||
|
||||
def ackermann_naive(m: int) -> Iterator[int]:
|
||||
"""Naive Ackermann encapsulated in a generator
|
||||
"""
|
||||
"""Naive Ackermann encapsulated in a generator."""
|
||||
n = 0
|
||||
while True:
|
||||
yield ackermann_slow(m, n)
|
||||
|
@ -128,8 +125,7 @@ def ackermann_naive(m: int) -> Iterator[int]:
|
|||
|
||||
|
||||
def ackermann_fast(m: int, n: int) -> int:
|
||||
"""Ackermann number.
|
||||
"""
|
||||
"""Ackermann number."""
|
||||
while m >= 4:
|
||||
if n == 0:
|
||||
n = 1
|
||||
|
@ -147,8 +143,7 @@ def ackermann_fast(m: int, n: int) -> int:
|
|||
|
||||
|
||||
def ackermann(m: int) -> Iterator[int]:
|
||||
"""Ackermann encapsulated in a generator.
|
||||
"""
|
||||
"""Ackermann encapsulated in a generator."""
|
||||
n = 0
|
||||
while True:
|
||||
yield ackermann_fast(m, n)
|
||||
|
@ -166,8 +161,7 @@ def fibonacci() -> Iterator[int]:
|
|||
|
||||
|
||||
def log_gen() -> Iterator[int]:
|
||||
"""Logarithmic generator.
|
||||
"""
|
||||
"""Logarithmic generator."""
|
||||
y = 1
|
||||
while True:
|
||||
adder = max(1, math.pow(10, int(math.log10(y))))
|
||||
|
@ -175,36 +169,38 @@ def log_gen() -> Iterator[int]:
|
|||
y = y + int(adder)
|
||||
|
||||
|
||||
polys = {2: [2, 1],
|
||||
3: [3, 1],
|
||||
4: [4, 1],
|
||||
5: [5, 2],
|
||||
6: [6, 1],
|
||||
7: [7, 1],
|
||||
8: [8, 4, 3, 2],
|
||||
9: [9, 4],
|
||||
10: [10, 3],
|
||||
11: [11, 2],
|
||||
12: [12, 6, 4, 1],
|
||||
13: [13, 4, 3, 1],
|
||||
14: [14, 8, 6, 1],
|
||||
15: [15, 1],
|
||||
16: [16, 12, 3, 1],
|
||||
17: [17, 3],
|
||||
18: [18, 7],
|
||||
19: [19, 5, 2, 1],
|
||||
20: [20, 3],
|
||||
21: [21, 2],
|
||||
22: [22, 1],
|
||||
23: [23, 5],
|
||||
24: [24, 7, 2, 1],
|
||||
25: [25, 3],
|
||||
26: [26, 6, 2, 1],
|
||||
27: [27, 5, 2, 1],
|
||||
28: [28, 3],
|
||||
29: [29, 2],
|
||||
30: [30, 23, 2, 1],
|
||||
31: [31, 3]}
|
||||
polys = {
|
||||
2: [2, 1],
|
||||
3: [3, 1],
|
||||
4: [4, 1],
|
||||
5: [5, 2],
|
||||
6: [6, 1],
|
||||
7: [7, 1],
|
||||
8: [8, 4, 3, 2],
|
||||
9: [9, 4],
|
||||
10: [10, 3],
|
||||
11: [11, 2],
|
||||
12: [12, 6, 4, 1],
|
||||
13: [13, 4, 3, 1],
|
||||
14: [14, 8, 6, 1],
|
||||
15: [15, 1],
|
||||
16: [16, 12, 3, 1],
|
||||
17: [17, 3],
|
||||
18: [18, 7],
|
||||
19: [19, 5, 2, 1],
|
||||
20: [20, 3],
|
||||
21: [21, 2],
|
||||
22: [22, 1],
|
||||
23: [23, 5],
|
||||
24: [24, 7, 2, 1],
|
||||
25: [25, 3],
|
||||
26: [26, 6, 2, 1],
|
||||
27: [27, 5, 2, 1],
|
||||
28: [28, 3],
|
||||
29: [29, 2],
|
||||
30: [30, 23, 2, 1],
|
||||
31: [31, 3],
|
||||
}
|
||||
|
||||
|
||||
def LFSR(m: int) -> Iterator[int]:
|
||||
|
@ -227,5 +223,32 @@ def LFSR(m: int) -> Iterator[int]:
|
|||
# Add the feedback bit
|
||||
state.insert(0, feedback)
|
||||
# Convert the registers to an int
|
||||
out = sum([e * (2**i) for i, e in enumerate(state)])
|
||||
out = sum(e * (2**i) for i, e in enumerate(state))
|
||||
yield out
|
||||
|
||||
|
||||
def shi_tomashi(
|
||||
image_path: str,
|
||||
max_corners: int = 100,
|
||||
quality: float = 0.01,
|
||||
min_distance: float = 10.0,
|
||||
) -> Iterator[int]:
|
||||
"""Shi-Tomachi corner generator of the given points
|
||||
https://docs.opencv.org/4.x/d4/d8c/tutorial_py_shi_tomasi.html
|
||||
"""
|
||||
image = cv2.imread(image_path)
|
||||
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||
corners: np.ndarray = cv2.goodFeaturesToTrack(
|
||||
gray, max_corners, quality, min_distance
|
||||
)
|
||||
corners_int: np.ndarray[Any, np.dtype[np.signedinteger[Any]]] = np.array(
|
||||
np.intp(corners)
|
||||
)
|
||||
i = 0
|
||||
while True:
|
||||
x, y = corners_int[i].ravel()
|
||||
# Compute the pixel number with top left of image as origin
|
||||
# using coordinates of the corner.
|
||||
# (y * number of pixels a row) + pixels left in last row
|
||||
yield (y * image.shape[1]) + x
|
||||
i += 1
|
142
stegano/lsb/lsb.py
Executable file → Normal file
142
stegano/lsb/lsb.py
Executable file → Normal file
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
# Copyright (C) 2010-2025 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
|
@ -20,119 +18,73 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
__author__ = "Cedric Bonhomme"
|
||||
__version__ = "$Revision: 0.4 $"
|
||||
__date__ = "$Date: 2016/08/04 $"
|
||||
__revision__ = "$Date: 2019/06/01 $"
|
||||
__version__ = "$Revision: 0.7 $"
|
||||
__date__ = "$Date: 2016/03/13 $"
|
||||
__revision__ = "$Date: 2019/05/31 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
from typing import IO, Union
|
||||
from typing import IO, Iterator, Union
|
||||
|
||||
from stegano import tools
|
||||
|
||||
from .generators import identity
|
||||
|
||||
|
||||
def hide(
|
||||
input_image: Union[str, IO[bytes]],
|
||||
image: Union[str, IO[bytes]],
|
||||
message: str,
|
||||
encoding: str = "UTF-8",
|
||||
generator: Union[None, Iterator[int]] = None,
|
||||
shift: int = 0,
|
||||
encoding: str = "UTF-8",
|
||||
auto_convert_rgb: bool = False,
|
||||
):
|
||||
"""Hide a message (string) in an image with the
|
||||
LSB (Least Significant Bit) technique.
|
||||
"""
|
||||
message_length = len(message)
|
||||
assert message_length != 0, "message length is zero"
|
||||
hider = tools.Hider(image, message, encoding, auto_convert_rgb)
|
||||
width = hider.encoded_image.width
|
||||
|
||||
img = tools.open_image(input_image)
|
||||
if not generator:
|
||||
generator = identity()
|
||||
|
||||
if img.mode not in ["RGB", "RGBA"]:
|
||||
if not auto_convert_rgb:
|
||||
print(
|
||||
"The mode of the image is not RGB. Mode is {}".format(img.mode)
|
||||
)
|
||||
answer = input("Convert the image to RGB ? [Y / n]\n") or "Y"
|
||||
if answer.lower() == "n":
|
||||
raise Exception("Not a RGB image.")
|
||||
img = img.convert("RGB")
|
||||
while shift != 0:
|
||||
next(generator)
|
||||
shift -= 1
|
||||
|
||||
encoded = img.copy()
|
||||
width, height = img.size
|
||||
index = 0
|
||||
while hider.encode_another_pixel():
|
||||
generated_number = next(generator)
|
||||
|
||||
message = str(message_length) + ":" + str(message)
|
||||
message_bits = "".join(tools.a2bits_list(message, encoding))
|
||||
message_bits += "0" * ((3 - (len(message_bits) % 3)) % 3)
|
||||
col = generated_number % width
|
||||
row = int(generated_number / width)
|
||||
|
||||
npixels = width * height
|
||||
len_message_bits = len(message_bits)
|
||||
if len_message_bits > npixels * 3:
|
||||
raise Exception(
|
||||
"The message you want to hide is too long: {}".format(
|
||||
message_length
|
||||
)
|
||||
)
|
||||
for row in range(height):
|
||||
for col in range(width):
|
||||
if shift != 0:
|
||||
shift -= 1
|
||||
continue
|
||||
if index + 3 <= len_message_bits:
|
||||
hider.encode_pixel((col, row))
|
||||
|
||||
# Get the colour component.
|
||||
pixel = img.getpixel((col, row))
|
||||
r = pixel[0]
|
||||
g = pixel[1]
|
||||
b = pixel[2]
|
||||
|
||||
# Change the Least Significant Bit of each colour component.
|
||||
r = tools.setlsb(r, message_bits[index])
|
||||
g = tools.setlsb(g, message_bits[index + 1])
|
||||
b = tools.setlsb(b, message_bits[index + 2])
|
||||
|
||||
# Save the new pixel
|
||||
if img.mode == "RGBA":
|
||||
encoded.putpixel((col, row), (r, g, b, pixel[3]))
|
||||
else:
|
||||
encoded.putpixel((col, row), (r, g, b))
|
||||
|
||||
index += 3
|
||||
else:
|
||||
img.close()
|
||||
return encoded
|
||||
return hider.encoded_image
|
||||
|
||||
|
||||
def reveal(input_image: Union[str, IO[bytes]],
|
||||
encoding: str = "UTF-8",
|
||||
shift: int = 0
|
||||
def reveal(
|
||||
encoded_image: Union[str, IO[bytes]],
|
||||
generator: Union[None, Iterator[int]] = None,
|
||||
shift: int = 0,
|
||||
encoding: str = "UTF-8",
|
||||
close_file: bool = True,
|
||||
):
|
||||
"""Find a message in an image (with the LSB technique).
|
||||
"""
|
||||
img = tools.open_image(input_image)
|
||||
width, height = img.size
|
||||
buff, count = 0, 0
|
||||
bitab = []
|
||||
limit = None
|
||||
for row in range(height):
|
||||
for col in range(width):
|
||||
if shift != 0:
|
||||
shift -= 1
|
||||
continue
|
||||
# pixel = [r, g, b] or [r,g,b,a]
|
||||
pixel = img.getpixel((col, row))
|
||||
if img.mode == "RGBA":
|
||||
pixel = pixel[:3] # ignore the alpha
|
||||
for color in pixel:
|
||||
buff += (color & 1) << (tools.ENCODINGS[encoding] - 1 - count)
|
||||
count += 1
|
||||
if count == tools.ENCODINGS[encoding]:
|
||||
bitab.append(chr(buff))
|
||||
buff, count = 0, 0
|
||||
if bitab[-1] == ":" and limit is None:
|
||||
try:
|
||||
limit = int("".join(bitab[:-1]))
|
||||
except:
|
||||
pass
|
||||
"""Find a message in an image (with the LSB technique)."""
|
||||
revealer = tools.Revealer(encoded_image, encoding, close_file)
|
||||
width = revealer.encoded_image.width
|
||||
|
||||
if len(bitab) - len(str(limit)) - 1 == limit:
|
||||
img.close()
|
||||
return "".join(bitab)[len(str(limit)) + 1 :]
|
||||
if not generator:
|
||||
generator = identity()
|
||||
|
||||
while shift != 0:
|
||||
next(generator)
|
||||
shift -= 1
|
||||
|
||||
while True:
|
||||
generated_number = next(generator)
|
||||
|
||||
col = generated_number % width
|
||||
row = int(generated_number / width)
|
||||
|
||||
if revealer.decode_pixel((col, row)):
|
||||
return revealer.secret_message
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
from .lsbset import *
|
|
@ -1,141 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
__author__ = "Cedric Bonhomme"
|
||||
__version__ = "$Revision: 0.7 $"
|
||||
__date__ = "$Date: 2016/03/13 $"
|
||||
__revision__ = "$Date: 2019/05/31 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
from typing import IO, Iterator, Union
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from stegano import tools
|
||||
|
||||
|
||||
def hide(
|
||||
input_image: Union[str, IO[bytes]],
|
||||
message: str,
|
||||
generator: Iterator[int],
|
||||
shift: int = 0,
|
||||
encoding: str = "UTF-8",
|
||||
auto_convert_rgb: bool = False,
|
||||
):
|
||||
"""Hide a message (string) in an image with the
|
||||
LSB (Least Significant Bit) technique.
|
||||
"""
|
||||
message_length = len(message)
|
||||
assert message_length != 0, "message length is zero"
|
||||
|
||||
img = tools.open_image(input_image)
|
||||
|
||||
if img.mode not in ["RGB", "RGBA"]:
|
||||
if not auto_convert_rgb:
|
||||
print(
|
||||
"The mode of the image is not RGB. Mode is {}".format(img.mode)
|
||||
)
|
||||
answer = input("Convert the image to RGB ? [Y / n]\n") or "Y"
|
||||
if answer.lower() == "n":
|
||||
raise Exception("Not a RGB image.")
|
||||
img = img.convert("RGB")
|
||||
|
||||
img_list = list(img.getdata())
|
||||
width, height = img.size
|
||||
index = 0
|
||||
|
||||
message = str(message_length) + ":" + str(message)
|
||||
message_bits = "".join(tools.a2bits_list(message, encoding))
|
||||
message_bits += "0" * ((3 - (len(message_bits) % 3)) % 3)
|
||||
|
||||
npixels = width * height
|
||||
len_message_bits = len(message_bits)
|
||||
if len_message_bits > npixels * 3:
|
||||
raise Exception(
|
||||
"The message you want to hide is too long: {}".format(
|
||||
message_length
|
||||
)
|
||||
)
|
||||
while shift != 0:
|
||||
next(generator)
|
||||
shift -= 1
|
||||
|
||||
while index + 3 <= len_message_bits:
|
||||
generated_number = next(generator)
|
||||
r, g, b, *a = img_list[generated_number]
|
||||
|
||||
# Change the Least Significant Bit of each colour component.
|
||||
r = tools.setlsb(r, message_bits[index])
|
||||
g = tools.setlsb(g, message_bits[index + 1])
|
||||
b = tools.setlsb(b, message_bits[index + 2])
|
||||
|
||||
# Save the new pixel
|
||||
if img.mode == "RGBA":
|
||||
img_list[generated_number] = (r, g, b, *a)
|
||||
else:
|
||||
img_list[generated_number] = (r, g, b)
|
||||
|
||||
index += 3
|
||||
|
||||
# create empty new image of appropriate format
|
||||
encoded = Image.new(img.mode, (img.size))
|
||||
|
||||
# insert saved data into the image
|
||||
encoded.putdata(img_list)
|
||||
|
||||
return encoded
|
||||
|
||||
|
||||
def reveal(
|
||||
input_image: Union[str, IO[bytes]],
|
||||
generator: Iterator[int],
|
||||
shift: int = 0,
|
||||
encoding: str = "UTF-8",
|
||||
):
|
||||
"""Find a message in an image (with the LSB technique).
|
||||
"""
|
||||
img = tools.open_image(input_image)
|
||||
img_list = list(img.getdata())
|
||||
width, height = img.size
|
||||
buff, count = 0, 0
|
||||
bitab = []
|
||||
limit = None
|
||||
|
||||
while shift != 0:
|
||||
next(generator)
|
||||
shift -= 1
|
||||
|
||||
while True:
|
||||
generated_number = next(generator)
|
||||
# color = [r, g, b]
|
||||
for color in img_list[generated_number][:3]: # ignore the alpha
|
||||
buff += (color & 1) << (tools.ENCODINGS[encoding] - 1 - count)
|
||||
count += 1
|
||||
if count == tools.ENCODINGS[encoding]:
|
||||
bitab.append(chr(buff))
|
||||
buff, count = 0, 0
|
||||
if bitab[-1] == ":" and limit == None:
|
||||
if "".join(bitab[:-1]).isdigit():
|
||||
limit = int("".join(bitab[:-1]))
|
||||
else:
|
||||
raise IndexError("Impossible to detect message.")
|
||||
if len(bitab) - len(str(limit)) - 1 == limit:
|
||||
return "".join(bitab)[len(str(limit)) + 1 :]
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
from .red import *
|
||||
from .red import hide, reveal
|
||||
|
||||
__all__ = ["hide", "reveal"]
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stéganô is a basic Python Steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
# Copyright (C) 2010-2024 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
|
|
|
@ -1,5 +1 @@
|
|||
#!/usr/bin/env python
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
from .parity import *
|
||||
from .statistics import *
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
# Copyright (C) 2010-2025 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
|
@ -36,7 +34,10 @@ def steganalyse(img: Image.Image) -> Image.Image:
|
|||
width, height = img.size
|
||||
for row in range(height):
|
||||
for col in range(width):
|
||||
r, g, b = img.getpixel((col, row))[0:3]
|
||||
if pixel := img.getpixel((col, row)):
|
||||
r, g, b = pixel[0:3]
|
||||
else:
|
||||
raise Exception("Error during steganlysis.")
|
||||
if r % 2 == 0:
|
||||
r = 0
|
||||
else:
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
# Copyright (C) 2010-2025 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
|
@ -22,35 +20,33 @@
|
|||
__author__ = "Cedric Bonhomme"
|
||||
__version__ = "$Revision: 0.2 $"
|
||||
__date__ = "$Date: 2010/10/01 $"
|
||||
__revision__ = "$Date: 2016/08/26 $"
|
||||
__revision__ = "$Date: 2021/11/01 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
import operator
|
||||
import typing
|
||||
from collections import Counter, OrderedDict
|
||||
|
||||
from PIL import Image
|
||||
from collections import Counter
|
||||
from collections import OrderedDict
|
||||
|
||||
def steganalyse(img):
|
||||
"""
|
||||
Steganlysis of the LSB technique.
|
||||
"""
|
||||
encoded = img.copy()
|
||||
width, height = img.size
|
||||
colours_counter = Counter() # type: Counter[int]
|
||||
colours_counter: typing.Counter[int] = Counter()
|
||||
for row in range(height):
|
||||
for col in range(width):
|
||||
r, g, b = img.getpixel((col, row))
|
||||
colours_counter[r] += 1
|
||||
|
||||
most_common = colours_counter.most_common(10)
|
||||
dict_colours = OrderedDict(sorted(list(colours_counter.items()),
|
||||
key=lambda t: t[1]))
|
||||
dict_colours = OrderedDict(
|
||||
sorted(list(colours_counter.items()), key=lambda t: t[1])
|
||||
)
|
||||
|
||||
colours = 0 # type: float
|
||||
colours: float = 0
|
||||
for colour in list(dict_colours.keys()):
|
||||
colours += colour
|
||||
colours = colours / len(dict_colours)
|
||||
|
||||
#return colours.most_common(10)
|
||||
# return colours.most_common(10)
|
||||
return list(dict_colours.keys())[:30], most_common
|
||||
|
|
133
stegano/tools.py
133
stegano/tools.py
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
# Copyright (C) 2010-2025 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
|
@ -28,7 +26,7 @@ __license__ = "GPLv3"
|
|||
import base64
|
||||
import itertools
|
||||
from functools import reduce
|
||||
from typing import IO, Iterator, List, Tuple, Union
|
||||
from typing import IO, List, Union
|
||||
|
||||
from PIL import Image
|
||||
|
||||
|
@ -41,9 +39,7 @@ def a2bits(chars: str) -> str:
|
|||
>>> a2bits("Hello World!")
|
||||
'010010000110010101101100011011000110111100100000010101110110111101110010011011000110010000100001'
|
||||
"""
|
||||
return bin(reduce(lambda x, y: (x << 8) + y, (ord(c) for c in chars), 1))[
|
||||
3:
|
||||
]
|
||||
return bin(reduce(lambda x, y: (x << 8) + y, (ord(c) for c in chars), 1))[3:]
|
||||
|
||||
|
||||
def a2bits_list(chars: str, encoding: str = "UTF-8") -> List[str]:
|
||||
|
@ -69,20 +65,16 @@ def a2bits_list(chars: str, encoding: str = "UTF-8") -> List[str]:
|
|||
|
||||
|
||||
def bs(s: int) -> str:
|
||||
"""Converts an int to its bits representation as a string of 0's and 1's.
|
||||
"""
|
||||
"""Converts an int to its bits representation as a string of 0's and 1's."""
|
||||
return str(s) if s <= 1 else bs(s >> 1) + str(s & 1)
|
||||
|
||||
|
||||
def setlsb(component: int, bit: str) -> int:
|
||||
"""Set Least Significant Bit of a colour component.
|
||||
"""
|
||||
"""Set Least Significant Bit of a colour component."""
|
||||
return component & ~1 | int(bit)
|
||||
|
||||
|
||||
def n_at_a_time(
|
||||
items: List[int], n: int, fillvalue: str
|
||||
) -> Iterator[Tuple[Union[int, str]]]:
|
||||
def n_at_a_time(items: List[int], n: int, fillvalue: str):
|
||||
"""Returns an iterator which groups n items at a time.
|
||||
Any final partial tuple will be padded with the fillvalue
|
||||
|
||||
|
@ -104,8 +96,7 @@ def binary2base64(binary_file: str) -> str:
|
|||
|
||||
|
||||
def base642binary(b64_fname: str) -> bytes:
|
||||
"""Convert a printable string to a binary file.
|
||||
"""
|
||||
"""Convert a printable string to a binary file."""
|
||||
b64_fname += "==="
|
||||
return base64.b64decode(b64_fname)
|
||||
|
||||
|
@ -120,3 +111,113 @@ def open_image(fname_or_instance: Union[str, IO[bytes]]):
|
|||
return fname_or_instance
|
||||
|
||||
return Image.open(fname_or_instance)
|
||||
|
||||
|
||||
class Hider:
|
||||
def __init__(
|
||||
self,
|
||||
input_image: Union[str, IO[bytes]],
|
||||
message: str,
|
||||
encoding: str = "UTF-8",
|
||||
auto_convert_rgb: bool = False,
|
||||
):
|
||||
self._index = 0
|
||||
|
||||
message_length = len(message)
|
||||
assert message_length != 0, "message length is zero"
|
||||
|
||||
image = open_image(input_image)
|
||||
|
||||
if image.mode not in ["RGB", "RGBA"]:
|
||||
if not auto_convert_rgb:
|
||||
print(f"The mode of the image is not RGB. Mode is {image.mode}")
|
||||
answer = input("Convert the image to RGB ? [Y / n]\n") or "Y"
|
||||
if answer.lower() == "n":
|
||||
raise Exception("Not a RGB image.")
|
||||
|
||||
image = image.convert("RGB")
|
||||
|
||||
self.encoded_image = image.copy()
|
||||
image.close()
|
||||
|
||||
message = str(message_length) + ":" + str(message)
|
||||
self._message_bits = "".join(a2bits_list(message, encoding))
|
||||
self._message_bits += "0" * ((3 - (len(self._message_bits) % 3)) % 3)
|
||||
|
||||
width, height = self.encoded_image.size
|
||||
npixels = width * height
|
||||
self._len_message_bits = len(self._message_bits)
|
||||
|
||||
if self._len_message_bits > npixels * 3:
|
||||
raise Exception(
|
||||
f"The message you want to hide is too long: {message_length}"
|
||||
)
|
||||
|
||||
def encode_another_pixel(self):
|
||||
return True if self._index + 3 <= self._len_message_bits else False
|
||||
|
||||
def encode_pixel(self, coordinate: tuple):
|
||||
# Get the colour component.
|
||||
r, g, b, *a = self.encoded_image.getpixel(coordinate)
|
||||
|
||||
# Change the Least Significant Bit of each colour component.
|
||||
r = setlsb(r, self._message_bits[self._index])
|
||||
g = setlsb(g, self._message_bits[self._index + 1])
|
||||
b = setlsb(b, self._message_bits[self._index + 2])
|
||||
|
||||
# Save the new pixel
|
||||
if self.encoded_image.mode == "RGBA":
|
||||
self.encoded_image.putpixel(coordinate, (r, g, b, *a))
|
||||
else:
|
||||
self.encoded_image.putpixel(coordinate, (r, g, b))
|
||||
|
||||
self._index += 3
|
||||
|
||||
|
||||
class Revealer:
|
||||
def __init__(
|
||||
self,
|
||||
encoded_image: Union[str, IO[bytes]],
|
||||
encoding: str = "UTF-8",
|
||||
close_file: bool = True,
|
||||
):
|
||||
self.encoded_image = open_image(encoded_image)
|
||||
self._encoding_length = ENCODINGS[encoding]
|
||||
self._buff, self._count = 0, 0
|
||||
self._bitab: List[str] = []
|
||||
self._limit: Union[None, int] = None
|
||||
self.secret_message = ""
|
||||
self.close_file = close_file
|
||||
|
||||
def decode_pixel(self, coordinate: tuple):
|
||||
# pixel = [r, g, b] or [r,g,b,a]
|
||||
pixel = self.encoded_image.getpixel(coordinate)
|
||||
|
||||
if self.encoded_image.mode == "RGBA":
|
||||
pixel = pixel[:3] # ignore the alpha
|
||||
|
||||
for color in pixel:
|
||||
self._buff += (color & 1) << (self._encoding_length - 1 - self._count)
|
||||
self._count += 1
|
||||
|
||||
if self._count == self._encoding_length:
|
||||
self._bitab.append(chr(self._buff))
|
||||
self._buff, self._count = 0, 0
|
||||
|
||||
if self._bitab[-1] == ":" and self._limit is None:
|
||||
if "".join(self._bitab[:-1]).isdigit():
|
||||
self._limit = int("".join(self._bitab[:-1]))
|
||||
else:
|
||||
raise IndexError("Impossible to detect message.")
|
||||
|
||||
if len(self._bitab) - len(str(self._limit)) - 1 == self._limit:
|
||||
self.secret_message = "".join(self._bitab)[
|
||||
len(str(self._limit)) + 1 : # noqa: E203
|
||||
]
|
||||
if self.close_file:
|
||||
self.encoded_image.close()
|
||||
|
||||
return True
|
||||
|
||||
else:
|
||||
return False
|
||||
|
|
1000
tests/expected-results/shi_tomashi.txt
Normal file
1000
tests/expected-results/shi_tomashi.txt
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
# Copyright (C) 2010-2025 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
|
@ -25,20 +23,19 @@ __date__ = "$Date: 2016/05/17 $"
|
|||
__revision__ = "$Date: 2017/01/18 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
import io
|
||||
import os
|
||||
import unittest
|
||||
import io
|
||||
|
||||
from stegano import exifHeader
|
||||
|
||||
class TestEXIFHeader(unittest.TestCase):
|
||||
|
||||
class TestEXIFHeader(unittest.TestCase):
|
||||
def test_hide_empty_message(self):
|
||||
"""Test hiding the empty string.
|
||||
"""
|
||||
secret = exifHeader.hide("./tests/sample-files/20160505T130442.jpg",
|
||||
"./image.jpg", secret_message="")
|
||||
#secret.save(""./image.png"")
|
||||
"""Test hiding the empty string."""
|
||||
exifHeader.hide(
|
||||
"./tests/sample-files/20160505T130442.jpg", "./image.jpg", secret_message=""
|
||||
)
|
||||
|
||||
clear_message = exifHeader.reveal("./image.jpg")
|
||||
|
||||
|
@ -48,17 +45,20 @@ class TestEXIFHeader(unittest.TestCase):
|
|||
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||
|
||||
for message in messages_to_hide:
|
||||
secret = exifHeader.hide("./tests/sample-files/20160505T130442.jpg",
|
||||
"./image.jpg", secret_message=message)
|
||||
exifHeader.hide(
|
||||
"./tests/sample-files/20160505T130442.jpg",
|
||||
"./image.jpg",
|
||||
secret_message=message,
|
||||
)
|
||||
|
||||
clear_message = exifHeader.reveal("./image.jpg")
|
||||
|
||||
self.assertEqual(message, message)
|
||||
self.assertEqual(message, clear_message.decode())
|
||||
|
||||
def test_with_image_without_exif_data(self):
|
||||
secret = exifHeader.hide("./tests/sample-files/Lenna.jpg",
|
||||
"./image.jpg", secret_message="")
|
||||
#secret.save(""./image.png"")
|
||||
exifHeader.hide(
|
||||
"./tests/sample-files/Lenna.jpg", "./image.jpg", secret_message=""
|
||||
)
|
||||
|
||||
clear_message = exifHeader.reveal("./image.jpg")
|
||||
|
||||
|
@ -68,25 +68,27 @@ class TestEXIFHeader(unittest.TestCase):
|
|||
text_file_to_hide = "./tests/sample-files/lorem_ipsum.txt"
|
||||
with open(text_file_to_hide, "rb") as f:
|
||||
message = f.read()
|
||||
secret = exifHeader.hide("./tests/sample-files/20160505T130442.jpg",
|
||||
img_enc="./image.jpg",
|
||||
secret_file=text_file_to_hide)
|
||||
exifHeader.hide(
|
||||
"./tests/sample-files/20160505T130442.jpg",
|
||||
img_enc="./image.jpg",
|
||||
secret_file=text_file_to_hide,
|
||||
)
|
||||
|
||||
clear_message = exifHeader.reveal("./image.jpg")
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_with_png_image(self):
|
||||
secret = exifHeader.hide("./tests/sample-files/Lenna.png",
|
||||
"./image.png", secret_message="Secret")
|
||||
#secret.save(""./image.png"")
|
||||
exifHeader.hide(
|
||||
"./tests/sample-files/Lenna.png", "./image.png", secret_message="Secret"
|
||||
)
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
clear_message = exifHeader.reveal("./image.png")
|
||||
exifHeader.reveal("./image.png")
|
||||
|
||||
def test_with_bytes(self):
|
||||
outputBytes = io.BytesIO()
|
||||
message = b"Secret"
|
||||
with open("./tests/sample-files/20160505T130442.jpg", 'rb') as f:
|
||||
with open("./tests/sample-files/20160505T130442.jpg", "rb") as f:
|
||||
exifHeader.hide(f, outputBytes, secret_message=message)
|
||||
|
||||
clear_message = exifHeader.reveal(outputBytes)
|
||||
|
@ -95,12 +97,13 @@ class TestEXIFHeader(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
try:
|
||||
os.unlink("./image.jpg")
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
os.unlink("./image.png")
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
# Copyright (C) 2010-2025 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
|
@ -25,116 +23,179 @@ __date__ = "$Date: 2017/03/01 $"
|
|||
__revision__ = "$Date: 2017/03/01 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
import unittest
|
||||
import itertools
|
||||
import unittest
|
||||
|
||||
from stegano.lsbset import generators
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
from stegano.lsb import generators
|
||||
|
||||
|
||||
class TestGenerators(unittest.TestCase):
|
||||
|
||||
def test_identity(self):
|
||||
"""Test the identity generator.
|
||||
"""
|
||||
self.assertEqual(tuple(itertools.islice(generators.identity(), 15)),
|
||||
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14))
|
||||
"""Test the identity generator."""
|
||||
self.assertEqual(
|
||||
tuple(itertools.islice(generators.identity(), 15)),
|
||||
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14),
|
||||
)
|
||||
|
||||
def test_fibonacci(self):
|
||||
"""Test the Fibonacci generator.
|
||||
"""
|
||||
self.assertEqual(tuple(itertools.islice(generators.fibonacci(), 20)),
|
||||
(1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610,
|
||||
987, 1597, 2584, 4181, 6765, 10946))
|
||||
"""Test the Fibonacci generator."""
|
||||
self.assertEqual(
|
||||
tuple(itertools.islice(generators.fibonacci(), 20)),
|
||||
(
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
5,
|
||||
8,
|
||||
13,
|
||||
21,
|
||||
34,
|
||||
55,
|
||||
89,
|
||||
144,
|
||||
233,
|
||||
377,
|
||||
610,
|
||||
987,
|
||||
1597,
|
||||
2584,
|
||||
4181,
|
||||
6765,
|
||||
10946,
|
||||
),
|
||||
)
|
||||
|
||||
def test_eratosthenes(self):
|
||||
"""Test the Eratosthenes sieve.
|
||||
"""
|
||||
with open('./tests/expected-results/eratosthenes', 'r') as f:
|
||||
self.assertEqual(tuple(itertools.islice(generators.eratosthenes(), 168)),
|
||||
tuple(int(line) for line in f))
|
||||
"""Test the Eratosthenes sieve."""
|
||||
with open("./tests/expected-results/eratosthenes") as f:
|
||||
self.assertEqual(
|
||||
tuple(itertools.islice(generators.eratosthenes(), 168)),
|
||||
tuple(int(line) for line in f),
|
||||
)
|
||||
|
||||
def test_composite(self):
|
||||
"""Test the composite sieve.
|
||||
"""
|
||||
with open('./tests/expected-results/composite', 'r') as f:
|
||||
self.assertEqual(tuple(itertools.islice(generators.composite(), 114)),
|
||||
tuple(int(line) for line in f))
|
||||
"""Test the composite sieve."""
|
||||
with open("./tests/expected-results/composite") as f:
|
||||
self.assertEqual(
|
||||
tuple(itertools.islice(generators.composite(), 114)),
|
||||
tuple(int(line) for line in f),
|
||||
)
|
||||
|
||||
def test_fermat(self):
|
||||
"""Test the Fermat generator.
|
||||
"""
|
||||
with open('./tests/expected-results/fermat', 'r') as f:
|
||||
self.assertEqual(tuple(itertools.islice(generators.fermat(), 9)),
|
||||
tuple(int(line) for line in f))
|
||||
"""Test the Fermat generator."""
|
||||
with open("./tests/expected-results/fermat") as f:
|
||||
self.assertEqual(
|
||||
tuple(itertools.islice(generators.fermat(), 9)),
|
||||
tuple(int(line) for line in f),
|
||||
)
|
||||
|
||||
def test_triangular_numbers(self):
|
||||
"""Test the Triangular numbers generator.
|
||||
"""
|
||||
with open('./tests/expected-results/triangular_numbers', 'r') as f:
|
||||
self.assertEqual(tuple(itertools.islice(generators.triangular_numbers(), 54)),
|
||||
tuple(int(line) for line in f))
|
||||
"""Test the Triangular numbers generator."""
|
||||
with open("./tests/expected-results/triangular_numbers") as f:
|
||||
self.assertEqual(
|
||||
tuple(itertools.islice(generators.triangular_numbers(), 54)),
|
||||
tuple(int(line) for line in f),
|
||||
)
|
||||
|
||||
def test_mersenne(self):
|
||||
"""Test the Mersenne generator.
|
||||
"""
|
||||
with open('./tests/expected-results/mersenne', 'r') as f:
|
||||
self.assertEqual(tuple(itertools.islice(generators.mersenne(), 20)),
|
||||
tuple(int(line) for line in f))
|
||||
"""Test the Mersenne generator."""
|
||||
with open("./tests/expected-results/mersenne") as f:
|
||||
self.assertEqual(
|
||||
tuple(itertools.islice(generators.mersenne(), 20)),
|
||||
tuple(int(line) for line in f),
|
||||
)
|
||||
|
||||
def test_carmichael(self):
|
||||
"""Test the Carmichael generator.
|
||||
"""
|
||||
with open('./tests/expected-results/carmichael', 'r') as f:
|
||||
self.assertEqual(tuple(itertools.islice(generators.carmichael(), 33)),
|
||||
tuple(int(line) for line in f))
|
||||
"""Test the Carmichael generator."""
|
||||
with open("./tests/expected-results/carmichael") as f:
|
||||
self.assertEqual(
|
||||
tuple(itertools.islice(generators.carmichael(), 33)),
|
||||
tuple(int(line) for line in f),
|
||||
)
|
||||
|
||||
def test_ackermann_slow(self):
|
||||
"""Test the Ackermann set.
|
||||
"""
|
||||
with open('./tests/expected-results/ackermann', 'r') as f:
|
||||
self.assertEqual(generators.ackermann_slow(
|
||||
3, 1), int(f.readline()))
|
||||
self.assertEqual(generators.ackermann_slow(
|
||||
3, 2), int(f.readline()))
|
||||
"""Test the Ackermann set."""
|
||||
with open("./tests/expected-results/ackermann") as f:
|
||||
self.assertEqual(generators.ackermann_slow(3, 1), int(f.readline()))
|
||||
self.assertEqual(generators.ackermann_slow(3, 2), int(f.readline()))
|
||||
|
||||
def test_ackermann_naive(self):
|
||||
"""Test the Naive Ackermann generator
|
||||
"""
|
||||
"""Test the Naive Ackermann generator"""
|
||||
gen = generators.ackermann_naive(3)
|
||||
next(gen)
|
||||
with open('./tests/expected-results/ackermann', 'r') as f:
|
||||
with open("./tests/expected-results/ackermann") as f:
|
||||
self.assertEqual(next(gen), int(f.readline()))
|
||||
self.assertEqual(next(gen), int(f.readline()))
|
||||
|
||||
def test_ackermann_fast(self):
|
||||
"""Test the Ackermann set.
|
||||
"""
|
||||
with open('./tests/expected-results/ackermann', 'r') as f:
|
||||
self.assertEqual(generators.ackermann_fast(
|
||||
3, 1), int(f.readline()))
|
||||
self.assertEqual(generators.ackermann_fast(
|
||||
3, 2), int(f.readline()))
|
||||
self.assertEqual(generators.ackermann_fast(
|
||||
4, 1), int(f.readline()))
|
||||
self.assertEqual(generators.ackermann_fast(
|
||||
4, 2), int(f.readline()))
|
||||
"""Test the Ackermann set."""
|
||||
with open("./tests/expected-results/ackermann") as f:
|
||||
self.assertEqual(generators.ackermann_fast(3, 1), int(f.readline()))
|
||||
self.assertEqual(generators.ackermann_fast(3, 2), int(f.readline()))
|
||||
self.assertEqual(generators.ackermann_fast(4, 1), int(f.readline()))
|
||||
|
||||
def test_ackermann(self):
|
||||
"""Test the Ackermann generator
|
||||
"""
|
||||
"""Test the Ackermann generator"""
|
||||
gen = generators.ackermann(3)
|
||||
next(gen)
|
||||
with open('./tests/expected-results/ackermann', 'r') as f:
|
||||
with open("./tests/expected-results/ackermann") as f:
|
||||
self.assertEqual(next(gen), int(f.readline()))
|
||||
self.assertEqual(next(gen), int(f.readline()))
|
||||
|
||||
def test_LFSR(self):
|
||||
""" Test the LFSR generator
|
||||
"""Test the LFSR generator"""
|
||||
with open("./tests/expected-results/LFSR") as f:
|
||||
self.assertEqual(
|
||||
tuple(itertools.islice(generators.LFSR(2**8), 256)),
|
||||
tuple(int(line) for line in f),
|
||||
)
|
||||
|
||||
def test_shi_tomashi(self):
|
||||
"""Test the Shi Tomashi generator"""
|
||||
|
||||
# The expected results are only for tests/sample-files/Montenach.png file and
|
||||
# the below mentioned shi-tomashi configuration.
|
||||
# If the values below are changed,
|
||||
# please ensure the tests/expected-results/shi_tomashi.txt
|
||||
# is also appropriately modified
|
||||
# Using the shi_tomashi_reconfigure static method
|
||||
|
||||
image = cv2.imread("tests/sample-files/Montenach.png")
|
||||
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||
corners = cv2.goodFeaturesToTrack(gray, 1000, 0.001, 10)
|
||||
# Commented because min_distance argument of generators.shi_tomashi is now set
|
||||
# to 10.0:
|
||||
# corners = np.int0(corners)
|
||||
corners = corners.reshape(corners.shape[0], -1)
|
||||
test_file = np.loadtxt("tests/expected-results/shi_tomashi.txt")
|
||||
test_file_reshaped = test_file.reshape(
|
||||
int(test_file.shape[0]), int(test_file.shape[1])
|
||||
)
|
||||
res = np.testing.assert_allclose(corners, test_file_reshaped, rtol=1e-0, atol=0) # type: ignore
|
||||
self.assertIsNone(res)
|
||||
|
||||
@staticmethod
|
||||
def shi_tomashi_reconfigure(
|
||||
file_name: str,
|
||||
max_corners: int = 1000,
|
||||
quality: float = 0.001,
|
||||
min_distance: int = 10,
|
||||
):
|
||||
"""
|
||||
with open('./tests/expected-results/LFSR', 'r') as f:
|
||||
self.assertEqual(tuple(itertools.islice(generators.LFSR(2**8), 256)),
|
||||
tuple(int(line) for line in f))
|
||||
Method to update/reconfigure Shi-Tomashi for various images and configuration
|
||||
"""
|
||||
image = cv2.imread(file_name)
|
||||
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||
corners = cv2.goodFeaturesToTrack(gray, max_corners, quality, min_distance)
|
||||
# Commented because min_distance argument of generators.shi_tomashi is now set
|
||||
# to 10.0:
|
||||
# corners = np.int0(corners)
|
||||
corners = corners.reshape(corners.shape[0], -1)
|
||||
np.savetxt("tests/expected-results/shi_tomashi.txt", corners)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
# Copyright (C) 2010-2024 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
|
@ -20,147 +18,231 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
__author__ = "Cedric Bonhomme"
|
||||
__version__ = "$Revision: 0.3 $"
|
||||
__date__ = "$Date: 2016/04/12 $"
|
||||
__revision__ = "$Date: 2017/05/04 $"
|
||||
__version__ = "$Revision: 0.6 $"
|
||||
__date__ = "$Date: 2016/04/13 $"
|
||||
__revision__ = "$Date: 2022/01/04 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
import io
|
||||
import os
|
||||
import base64
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from stegano import lsb
|
||||
from stegano.lsb import generators
|
||||
|
||||
|
||||
class TestLSB(unittest.TestCase):
|
||||
|
||||
def test_hide_empty_message(self):
|
||||
"""
|
||||
Test hiding the empty string.
|
||||
"""
|
||||
with self.assertRaises(AssertionError):
|
||||
secret = lsb.hide("./tests/sample-files/Lenna.png", "")
|
||||
lsb.hide("./tests/sample-files/Lenna.png", "", generators.eratosthenes())
|
||||
|
||||
def test_hide_and_reveal(self):
|
||||
messages_to_hide = ['a', 'foo', 'Hello World!', ':Python:']
|
||||
def test_hide_and_reveal_without_generator(self):
|
||||
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||
for message in messages_to_hide:
|
||||
secret = lsb.hide("./tests/sample-files/Lenna.png", message)
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsb.reveal("./image.png")
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_hide_and_reveal_with_eratosthenes(self):
|
||||
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||
for message in messages_to_hide:
|
||||
secret = lsb.hide(
|
||||
"./tests/sample-files/Lenna.png", message, generators.eratosthenes()
|
||||
)
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsb.reveal("./image.png", generators.eratosthenes())
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_hide_and_reveal_with_ackermann(self):
|
||||
messages_to_hide = ["foo"]
|
||||
for message in messages_to_hide:
|
||||
secret = lsb.hide(
|
||||
"./tests/sample-files/Lenna.png", message, generators.ackermann(m=3)
|
||||
)
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsb.reveal("./image.png", generators.ackermann(m=3))
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_hide_and_reveal_with_ackermann_naive(self):
|
||||
messages_to_hide = ["foo"]
|
||||
for message in messages_to_hide:
|
||||
secret = lsb.hide(
|
||||
"./tests/sample-files/Lenna.png",
|
||||
message,
|
||||
generators.ackermann_naive(m=2),
|
||||
)
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsb.reveal("./image.png", generators.ackermann_naive(m=2))
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_hide_and_reveal_with_mersenne(self):
|
||||
messages_to_hide = ["f"]
|
||||
for message in messages_to_hide:
|
||||
secret = lsb.hide(
|
||||
"./tests/sample-files/Montenach.png",
|
||||
message,
|
||||
generators.mersenne(),
|
||||
)
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsb.reveal("./image.png", generators.mersenne())
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_hide_and_reveal_with_shi_tomashi(self):
|
||||
messages_to_hide = ["foo bar"]
|
||||
for message in messages_to_hide:
|
||||
secret = lsb.hide(
|
||||
"./tests/sample-files/Lenna.png",
|
||||
message,
|
||||
generators.shi_tomashi("./tests/sample-files/Lenna.png"),
|
||||
)
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsb.reveal(
|
||||
"./image.png", generators.shi_tomashi("./tests/sample-files/Lenna.png")
|
||||
)
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_hide_and_reveal_with_shift(self):
|
||||
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||
for message in messages_to_hide:
|
||||
secret = lsb.hide(
|
||||
"./tests/sample-files/Lenna.png", message, generators.eratosthenes(), 4
|
||||
)
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsb.reveal("./image.png", generators.eratosthenes(), 4)
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_hide_and_reveal_UTF32LE(self):
|
||||
messages_to_hide = 'I love 🍕 and 🍫!'
|
||||
secret = lsb.hide("./tests/sample-files/Lenna.png",
|
||||
messages_to_hide, encoding='UTF-32LE')
|
||||
messages_to_hide = "I love 🍕 and 🍫!"
|
||||
secret = lsb.hide(
|
||||
"./tests/sample-files/Lenna.png",
|
||||
messages_to_hide,
|
||||
generators.eratosthenes(),
|
||||
encoding="UTF-32LE",
|
||||
)
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsb.reveal("./image.png", encoding='UTF-32LE')
|
||||
clear_message = lsb.reveal(
|
||||
"./image.png", generators.eratosthenes(), encoding="UTF-32LE"
|
||||
)
|
||||
self.assertEqual(messages_to_hide, clear_message)
|
||||
|
||||
def test_with_transparent_png(self):
|
||||
messages_to_hide = ['🍕', 'a', 'foo', 'Hello World!', ':Python:']
|
||||
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||
for message in messages_to_hide:
|
||||
secret = lsb.hide("./tests/sample-files/transparent.png",
|
||||
message, encoding='UTF-32LE')
|
||||
secret = lsb.hide(
|
||||
"./tests/sample-files/transparent.png",
|
||||
message,
|
||||
generators.eratosthenes(),
|
||||
)
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsb.reveal("./image.png", encoding='UTF-32LE')
|
||||
clear_message = lsb.reveal("./image.png", generators.eratosthenes())
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
@patch('builtins.input', return_value='y')
|
||||
@patch("builtins.input", return_value="y")
|
||||
def test_manual_convert_rgb(self, input):
|
||||
message_to_hide = 'I love 🍕 and 🍫!'
|
||||
secret = lsb.hide("./tests/sample-files/Lenna-grayscale.png",
|
||||
message_to_hide, encoding='UTF-32LE')
|
||||
message_to_hide = "Hello World!"
|
||||
lsb.hide(
|
||||
"./tests/sample-files/Lenna-grayscale.png",
|
||||
message_to_hide,
|
||||
generators.eratosthenes(),
|
||||
)
|
||||
|
||||
@patch('builtins.input', return_value='n')
|
||||
@patch("builtins.input", return_value="n")
|
||||
def test_refuse_convert_rgb(self, input):
|
||||
message_to_hide = 'I love 🍕 and 🍫!'
|
||||
with self.assertRaises(Exception):
|
||||
secret = lsb.hide("./tests/sample-files/Lenna-grayscale.png",
|
||||
message_to_hide, encoding='UTF-32LE')
|
||||
|
||||
def test_auto_convert_rgb(self):
|
||||
message_to_hide = 'I love 🍕 and 🍫!'
|
||||
secret = lsb.hide("./tests/sample-files/Lenna-grayscale.png",
|
||||
message_to_hide, encoding='UTF-32LE', auto_convert_rgb=True)
|
||||
|
||||
def test_with_text_file(self):
|
||||
text_file_to_hide = './tests/sample-files/lorem_ipsum.txt'
|
||||
with open(text_file_to_hide) as f:
|
||||
message = f.read()
|
||||
secret = lsb.hide("./tests/sample-files/Lenna.png", message)
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsb.reveal("./image.png")
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_with_binary_file(self):
|
||||
binary_file_to_hide = "./tests/sample-files/free-software-song.ogg"
|
||||
with open(binary_file_to_hide, "rb") as bin_file:
|
||||
encoded_string = base64.b64encode(bin_file.read())
|
||||
message = encoded_string.decode()
|
||||
secret = lsb.hide("./tests/sample-files/Montenach.png", message)
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsb.reveal("./image.png")
|
||||
clear_message += '==='
|
||||
clear_message = base64.b64decode(clear_message)
|
||||
with open('file1', 'wb') as f:
|
||||
f.write(clear_message)
|
||||
with open('file1', 'rb') as bin_file:
|
||||
encoded_string = base64.b64encode(bin_file.read())
|
||||
message1 = encoded_string.decode()
|
||||
self.assertEqual(message, message1)
|
||||
try:
|
||||
os.unlink('./file1')
|
||||
except:
|
||||
pass
|
||||
|
||||
def test_with_too_long_message(self):
|
||||
with open("./tests/sample-files/lorem_ipsum.txt") as f:
|
||||
message = f.read()
|
||||
message += message*2
|
||||
with self.assertRaises(Exception):
|
||||
lsb.hide("./tests/sample-files/Lenna.png", message)
|
||||
|
||||
def test_with_bytes(self):
|
||||
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||
|
||||
for message in messages_to_hide:
|
||||
outputBytes = io.BytesIO()
|
||||
with open("./tests/sample-files/20160505T130442.jpg", 'rb') as f:
|
||||
bytes_image = lsb.hide(f, message)
|
||||
bytes_image.save(outputBytes, "PNG")
|
||||
outputBytes.seek(0)
|
||||
|
||||
clear_message = lsb.reveal(outputBytes)
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
message_to_hide = "Hello World!"
|
||||
# lsb.hide(
|
||||
# "./tests/sample-files/Lenna-grayscale.png",
|
||||
# message_to_hide,
|
||||
# generators.eratosthenes(),
|
||||
# )
|
||||
with self.assertRaisesRegex(Exception, "Not a RGB image."):
|
||||
lsb.hide(
|
||||
"./tests/sample-files/Lenna-grayscale.png",
|
||||
message_to_hide,
|
||||
generators.eratosthenes(),
|
||||
)
|
||||
|
||||
def test_with_location_of_image_as_argument(self):
|
||||
messages_to_hide = ["Hello World!"]
|
||||
|
||||
for message in messages_to_hide:
|
||||
outputBytes = io.BytesIO()
|
||||
bytes_image = lsb.hide("./tests/sample-files/20160505T130442.jpg", message)
|
||||
bytes_image = lsb.hide(
|
||||
"./tests/sample-files/20160505T130442.jpg",
|
||||
message,
|
||||
generators.identity(),
|
||||
)
|
||||
bytes_image.save(outputBytes, "PNG")
|
||||
outputBytes.seek(0)
|
||||
|
||||
clear_message = lsb.reveal(outputBytes)
|
||||
clear_message = lsb.reveal(outputBytes, generators.identity())
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_auto_convert_rgb(self):
|
||||
message_to_hide = "Hello World!"
|
||||
lsb.hide(
|
||||
"./tests/sample-files/Lenna-grayscale.png",
|
||||
message_to_hide,
|
||||
generators.eratosthenes(),
|
||||
auto_convert_rgb=True,
|
||||
)
|
||||
|
||||
def test_with_too_long_message(self):
|
||||
with open("./tests/sample-files/lorem_ipsum.txt") as f:
|
||||
message = f.read()
|
||||
message += message * 2
|
||||
with self.assertRaisesRegex(
|
||||
Exception, "The message you want to hide is too long:"
|
||||
):
|
||||
lsb.hide("./tests/sample-files/Lenna.png", message, generators.identity())
|
||||
|
||||
def test_hide_and_reveal_with_bad_generator(self):
|
||||
message_to_hide = "Hello World!"
|
||||
secret = lsb.hide(
|
||||
"./tests/sample-files/Lenna.png", message_to_hide, generators.eratosthenes()
|
||||
)
|
||||
secret.save("./image.png")
|
||||
|
||||
with self.assertRaises(IndexError):
|
||||
lsb.reveal("./image.png", generators.identity())
|
||||
|
||||
def test_with_unknown_generator(self):
|
||||
message_to_hide = "Hello World!"
|
||||
with self.assertRaises(AttributeError):
|
||||
lsb.hide(
|
||||
"./tests/sample-files/Lenna.png",
|
||||
message_to_hide,
|
||||
generators.unknown_generator(), # type: ignore
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
os.unlink("./image.png")
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -1,170 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2017 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
__author__ = "Cedric Bonhomme"
|
||||
__version__ = "$Revision: 0.4 $"
|
||||
__date__ = "$Date: 2016/04/13 $"
|
||||
__revision__ = "$Date: 2017/05/04 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
import io
|
||||
import os
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from stegano import lsbset
|
||||
from stegano.lsbset import generators
|
||||
|
||||
class TestLSBSet(unittest.TestCase):
|
||||
|
||||
def test_hide_empty_message(self):
|
||||
"""
|
||||
Test hiding the empty string.
|
||||
"""
|
||||
with self.assertRaises(AssertionError):
|
||||
secret = lsbset.hide("./tests/sample-files/Lenna.png", "",
|
||||
generators.eratosthenes())
|
||||
|
||||
def test_hide_and_reveal(self):
|
||||
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||
for message in messages_to_hide:
|
||||
secret = lsbset.hide("./tests/sample-files/Lenna.png", message,
|
||||
generators.eratosthenes())
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsbset.reveal("./image.png",
|
||||
generators.eratosthenes())
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_hide_and_reveal_with_ackermann(self):
|
||||
messages_to_hide = ["foo"]
|
||||
for message in messages_to_hide:
|
||||
secret = lsbset.hide("./tests/sample-files/Lenna.png", message,
|
||||
generators.ackermann(m=3))
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsbset.reveal("./image.png",
|
||||
generators.ackermann(m=3))
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_hide_and_reveal_with_shift(self):
|
||||
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||
for message in messages_to_hide:
|
||||
secret = lsbset.hide("./tests/sample-files/Lenna.png", message,
|
||||
generators.eratosthenes(), 4)
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsbset.reveal("./image.png",
|
||||
generators.eratosthenes(), 4)
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_hide_and_reveal_UTF32LE(self):
|
||||
messages_to_hide = 'I love 🍕 and 🍫!'
|
||||
secret = lsbset.hide("./tests/sample-files/Lenna.png",
|
||||
messages_to_hide,
|
||||
generators.eratosthenes(),
|
||||
encoding='UTF-32LE')
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsbset.reveal("./image.png", generators.eratosthenes(),
|
||||
encoding='UTF-32LE')
|
||||
self.assertEqual(messages_to_hide, clear_message)
|
||||
|
||||
def test_with_transparent_png(self):
|
||||
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||
for message in messages_to_hide:
|
||||
secret = lsbset.hide("./tests/sample-files/transparent.png",
|
||||
message, generators.eratosthenes())
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsbset.reveal("./image.png",
|
||||
generators.eratosthenes())
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
@patch('builtins.input', return_value='y')
|
||||
def test_manual_convert_rgb(self, input):
|
||||
message_to_hide = "Hello World!"
|
||||
secret = lsbset.hide("./tests/sample-files/Lenna-grayscale.png",
|
||||
message_to_hide, generators.eratosthenes())
|
||||
|
||||
@patch('builtins.input', return_value='n')
|
||||
def test_refuse_convert_rgb(self, input):
|
||||
message_to_hide = "Hello World!"
|
||||
with self.assertRaises(Exception):
|
||||
secret = lsbset.hide("./tests/sample-files/Lenna-grayscale.png",
|
||||
message_to_hide, generators.eratosthenes())
|
||||
|
||||
def test_with_location_of_image_as_argument(self):
|
||||
messages_to_hide = ["Hello World!"]
|
||||
|
||||
for message in messages_to_hide:
|
||||
outputBytes = io.BytesIO()
|
||||
bytes_image = lsbset.hide("./tests/sample-files/20160505T130442.jpg", message,
|
||||
generators.identity())
|
||||
bytes_image.save(outputBytes, "PNG")
|
||||
outputBytes.seek(0)
|
||||
|
||||
clear_message = lsbset.reveal(outputBytes, generators.identity())
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_auto_convert_rgb(self):
|
||||
message_to_hide = "Hello World!"
|
||||
secret = lsbset.hide("./tests/sample-files/Lenna-grayscale.png",
|
||||
message_to_hide, generators.eratosthenes(),
|
||||
auto_convert_rgb=True)
|
||||
|
||||
def test_with_too_long_message(self):
|
||||
with open("./tests/sample-files/lorem_ipsum.txt") as f:
|
||||
message = f.read()
|
||||
message += message*2
|
||||
with self.assertRaises(Exception):
|
||||
lsbset.hide("./tests/sample-files/Lenna.png", message,
|
||||
generators.identity())
|
||||
|
||||
def test_hide_and_reveal_with_bad_generator(self):
|
||||
message_to_hide = "Hello World!"
|
||||
secret = lsbset.hide("./tests/sample-files/Lenna.png", message_to_hide,
|
||||
generators.eratosthenes())
|
||||
secret.save("./image.png")
|
||||
|
||||
with self.assertRaises(IndexError):
|
||||
clear_message = lsbset.reveal("./image.png", generators.identity())
|
||||
|
||||
def test_with_unknown_generator(self):
|
||||
message_to_hide = "Hello World!"
|
||||
with self.assertRaises(AttributeError):
|
||||
secret = lsbset.hide("./tests/sample-files/Lenna.png",
|
||||
message_to_hide, generators.eratosthene())
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
os.unlink("./image.png")
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
# Copyright (C) 2010-2025 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
|
@ -29,14 +27,14 @@ import unittest
|
|||
|
||||
from stegano import red
|
||||
|
||||
class TestRed(unittest.TestCase):
|
||||
|
||||
class TestRed(unittest.TestCase):
|
||||
def test_hide_empty_message(self):
|
||||
"""
|
||||
Test hiding the empty string.
|
||||
"""
|
||||
with self.assertRaises(AssertionError):
|
||||
secret = red.hide("./tests/sample-files/Lenna.png", "")
|
||||
red.hide("./tests/sample-files/Lenna.png", "")
|
||||
|
||||
def test_hide_and_reveal(self):
|
||||
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||
|
@ -47,7 +45,7 @@ class TestRed(unittest.TestCase):
|
|||
|
||||
clear_message = red.reveal("./image.png")
|
||||
|
||||
self.assertEqual(message, message)
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_with_too_long_message(self):
|
||||
with open("./tests/sample-files/lorem_ipsum.txt") as f:
|
||||
|
@ -58,9 +56,9 @@ class TestRed(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
try:
|
||||
os.unlink("./image.png")
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2017 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
|
@ -25,23 +24,18 @@ __date__ = "$Date: 2019/06/06 $"
|
|||
__revision__ = "$Date: 2019/06/06 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
import io
|
||||
import os
|
||||
import base64
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from PIL import Image, ImageChops
|
||||
|
||||
from stegano import lsb
|
||||
from stegano.steganalysis import parity, statistics
|
||||
from PIL import Image, ImageChops
|
||||
|
||||
|
||||
class TestSteganalysis(unittest.TestCase):
|
||||
|
||||
def test_parity(self):
|
||||
"""Test stegano.steganalysis.parity
|
||||
"""
|
||||
text_file_to_hide = './tests/sample-files/lorem_ipsum.txt'
|
||||
"""Test stegano.steganalysis.parity"""
|
||||
text_file_to_hide = "./tests/sample-files/lorem_ipsum.txt"
|
||||
with open(text_file_to_hide) as f:
|
||||
message = f.read()
|
||||
secret = lsb.hide("./tests/sample-files/Lenna.png", message)
|
||||
|
@ -51,24 +45,22 @@ class TestSteganalysis(unittest.TestCase):
|
|||
self.assertTrue(diff is None)
|
||||
|
||||
def test_parity_rgba(self):
|
||||
""" Test that stegano.steganalysis.parity works with RGBA images
|
||||
"""
|
||||
img = Image.open('./tests/sample-files/transparent.png')
|
||||
"""Test that stegano.steganalysis.parity works with RGBA images"""
|
||||
img = Image.open("./tests/sample-files/transparent.png")
|
||||
analysis = parity.steganalyse(img)
|
||||
target = Image.open("./tests/expected-results/parity_rgba.png")
|
||||
diff = ImageChops.difference(target, analysis).getbbox()
|
||||
self.assertTrue(diff is None)
|
||||
|
||||
def test_statistics(self):
|
||||
""" Test stegano.steganalysis.statistics
|
||||
"""
|
||||
"""Test stegano.steganalysis.statistics"""
|
||||
image = Image.open("./tests/sample-files/Lenna.png")
|
||||
stats = str(statistics.steganalyse(image)) + '\n'
|
||||
stats = str(statistics.steganalyse(image)) + "\n"
|
||||
file = open("./tests/expected-results/statistics")
|
||||
target = file.read()
|
||||
file.close()
|
||||
self.assertEqual(stats, target)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Stegano - Stegano is a pure Python steganography module.
|
||||
# Copyright (C) 2010-2019 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
# Copyright (C) 2010-2025 Cédric Bonhomme - https://www.cedricbonhomme.org
|
||||
#
|
||||
# For more information : https://github.com/cedricbonhomme/Stegano
|
||||
#
|
||||
|
@ -25,54 +23,65 @@ __date__ = "$Date: 2017/02/22 $"
|
|||
__revision__ = "$Date: 2017/02/22 $"
|
||||
__license__ = "GPLv3"
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import io
|
||||
|
||||
from stegano import tools
|
||||
|
||||
class TestTools(unittest.TestCase):
|
||||
|
||||
class TestTools(unittest.TestCase):
|
||||
def test_a2bits(self):
|
||||
bits = tools.a2bits("Hello World!")
|
||||
self.assertEqual(bits, '010010000110010101101100011011000110111100100000010101110110111101110010011011000110010000100001')
|
||||
self.assertEqual(
|
||||
bits,
|
||||
"010010000110010101101100011011000110111100100000010101110110111101110010011011000110010000100001",
|
||||
)
|
||||
|
||||
def test_a2bits_list_UTF8(self):
|
||||
list_of_bits = tools.a2bits_list("Hello World!")
|
||||
self.assertEqual(list_of_bits, ['01001000',
|
||||
'01100101',
|
||||
'01101100',
|
||||
'01101100',
|
||||
'01101111',
|
||||
'00100000',
|
||||
'01010111',
|
||||
'01101111',
|
||||
'01110010',
|
||||
'01101100',
|
||||
'01100100',
|
||||
'00100001'])
|
||||
self.assertEqual(
|
||||
list_of_bits,
|
||||
[
|
||||
"01001000",
|
||||
"01100101",
|
||||
"01101100",
|
||||
"01101100",
|
||||
"01101111",
|
||||
"00100000",
|
||||
"01010111",
|
||||
"01101111",
|
||||
"01110010",
|
||||
"01101100",
|
||||
"01100100",
|
||||
"00100001",
|
||||
],
|
||||
)
|
||||
|
||||
def test_a2bits_list_UTF32LE(self):
|
||||
list_of_bits = tools.a2bits_list("Hello World!", 'UTF-32LE')
|
||||
self.assertEqual(list_of_bits, ['00000000000000000000000001001000',
|
||||
'00000000000000000000000001100101',
|
||||
'00000000000000000000000001101100',
|
||||
'00000000000000000000000001101100',
|
||||
'00000000000000000000000001101111',
|
||||
'00000000000000000000000000100000',
|
||||
'00000000000000000000000001010111',
|
||||
'00000000000000000000000001101111',
|
||||
'00000000000000000000000001110010',
|
||||
'00000000000000000000000001101100',
|
||||
'00000000000000000000000001100100',
|
||||
'00000000000000000000000000100001'])
|
||||
list_of_bits = tools.a2bits_list("Hello World!", "UTF-32LE")
|
||||
self.assertEqual(
|
||||
list_of_bits,
|
||||
[
|
||||
"00000000000000000000000001001000",
|
||||
"00000000000000000000000001100101",
|
||||
"00000000000000000000000001101100",
|
||||
"00000000000000000000000001101100",
|
||||
"00000000000000000000000001101111",
|
||||
"00000000000000000000000000100000",
|
||||
"00000000000000000000000001010111",
|
||||
"00000000000000000000000001101111",
|
||||
"00000000000000000000000001110010",
|
||||
"00000000000000000000000001101100",
|
||||
"00000000000000000000000001100100",
|
||||
"00000000000000000000000000100001",
|
||||
],
|
||||
)
|
||||
|
||||
def test_n_at_a_time(self):
|
||||
result = tools.n_at_a_time([1, 2, 3, 4, 5], 2, 'X')
|
||||
self.assertEqual(list(result), [(1, 2), (3, 4), (5, 'X')])
|
||||
result = tools.n_at_a_time([1, 2, 3, 4, 5], 2, "X")
|
||||
self.assertEqual(list(result), [(1, 2), (3, 4), (5, "X")])
|
||||
|
||||
def test_binary2base64(self):
|
||||
with open('./tests/expected-results/binary2base64', 'r') as f:
|
||||
expected_value = f.read()
|
||||
value = tools.binary2base64('tests/sample-files/free-software-song.ogg')
|
||||
with open("./tests/expected-results/binary2base64") as f:
|
||||
expected_value = f.read()
|
||||
value = tools.binary2base64("tests/sample-files/free-software-song.ogg")
|
||||
self.assertEqual(expected_value, value)
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
import subprocess
|
||||
import sys
|
||||
|
||||
modules = ["stegano/tools.py",
|
||||
"stegano/lsb/lsb.py",
|
||||
"stegano/lsbset/lsbset.py",
|
||||
"stegano/lsbset/generators.py",
|
||||
"stegano/red/red.py",
|
||||
"stegano/exifHeader/exifHeader.py",
|
||||
"stegano/steganalysis/parity.py",
|
||||
"stegano/steganalysis/statistics.py"]
|
||||
|
||||
exit_codes = []
|
||||
for module in modules:
|
||||
rc = subprocess.call(["mypy", "--ignore-missing-imports",
|
||||
"--follow-imports", "skip", module])
|
||||
exit_codes.append(rc)
|
||||
sys.exit(max(exit_codes))
|
Loading…
Add table
Reference in a new issue