diff --git a/README.md b/README.md new file mode 100644 index 0000000..e6c0aff --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +## STAG Suite Tools + +### About + +This is a suite that has two associated projects, one intended for Steganography - STAG hide, and other intended for Steganalysis - STAG find. They were developed using C++ and the Qt suite, the 4.8 version. + +**Disclaimer:** +This was a project I done when I was an undergrad student researcher at GRIS, the CSIRT (Computer Security Incident Response Team) of UFRJ (Federal University of Rio de Janeiro - Brazil). This project works fine and achieved its purpose of making me understand Steganography and Steganalysis. Even though there's a lot of work that could be done to add new methods and improve the steganalysis tool overall, I don't plan on improving this project anytime soon because I don't quite have the time currently. The tools were made in Portuguese, but I guess it is pretty straight-forward for anyone interested in using it. + +### STAG hide + +This was the project related to the Steganography part, where I wanted to hide information in images. I use the LSB filter, which stands for Least Significant Bits. This means that, for every pixel in a chosen image, I use the *n* least significant bits for its color components (red, blue and green) to hide some information, where *n* is a number input by the user. In a practical perspective, this means that when *n* is up to 3, I change each color component of a pixel in a maximum absolute value of 8, which is pretty much imperceptible if you are not comparing the result image to the original very closely. And even with a lower *n* (most of the time 1 is enough), you can write a lot of info in an image. + +With n equals to 1, you can write 3 bits per pixel, which roughly translates to 1 byte every 3 pixels. In unicode, each char uses 1 byte, so even a low resolution image can store a lot of information. + +For simplicity, I only allow the user to hide text inputs, but I store them as bits, so I could store anything actually, but the user interface would get more complex and I was still trying to fully grasp what I could learn of Steganography. + +I also write the length of the hidden info in the first pixel of the message hiding, so I can read that more easily from the *STAG find*, but that might not have been the best solution. + +### STAG find + +This was the Steganalysis counter-part. But it is not really an analysis tool, it is a reader for when the user already knows at what pixel the message starts, and the number of bits used for the LSB algorithm. It works like that, but it could be more aggressive in the *analysis* part, like trying to infer the initial pixel and number of bits by reading the pixels of the image. Or just outputting some possibilities for the user so he could make an educated guess. But I never got to really work on that part =(. \ No newline at end of file diff --git a/release/STAG find/Projeto-Gris-Esteganalise.exe b/release/STAG find/Projeto-Gris-Esteganalise.exe new file mode 100644 index 0000000..4b00b11 Binary files /dev/null and b/release/STAG find/Projeto-Gris-Esteganalise.exe differ diff --git a/release/STAG find/QtCore4.dll b/release/STAG find/QtCore4.dll new file mode 100644 index 0000000..aff9aaf Binary files /dev/null and b/release/STAG find/QtCore4.dll differ diff --git a/release/STAG find/QtGui4.dll b/release/STAG find/QtGui4.dll new file mode 100644 index 0000000..34029fa Binary files /dev/null and b/release/STAG find/QtGui4.dll differ diff --git a/release/STAG find/algoritmos.o b/release/STAG find/algoritmos.o new file mode 100644 index 0000000..0b6b305 Binary files /dev/null and b/release/STAG find/algoritmos.o differ diff --git a/release/STAG find/libgcc_s_dw2-1.dll b/release/STAG find/libgcc_s_dw2-1.dll new file mode 100644 index 0000000..9e32dc2 Binary files /dev/null and b/release/STAG find/libgcc_s_dw2-1.dll differ diff --git a/release/STAG find/main.o b/release/STAG find/main.o new file mode 100644 index 0000000..f0cbade Binary files /dev/null and b/release/STAG find/main.o differ diff --git a/release/STAG find/mainwindow.o b/release/STAG find/mainwindow.o new file mode 100644 index 0000000..ac762c2 Binary files /dev/null and b/release/STAG find/mainwindow.o differ diff --git a/release/STAG find/mingwm10.dll b/release/STAG find/mingwm10.dll new file mode 100644 index 0000000..572f888 Binary files /dev/null and b/release/STAG find/mingwm10.dll differ diff --git a/release/STAG find/moc_mainwindow.cpp b/release/STAG find/moc_mainwindow.cpp new file mode 100644 index 0000000..b7cd8b0 --- /dev/null +++ b/release/STAG find/moc_mainwindow.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** Meta object code from reading C++ file 'mainwindow.h' +** +** Created: Wed 3. Oct 23:54:06 2012 +** by: The Qt Meta Object Compiler version 63 (Qt 4.8.1) +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#include "../../Projeto-Gris-Esteganalise/mainwindow.h" +#if !defined(Q_MOC_OUTPUT_REVISION) +#error "The header file 'mainwindow.h' doesn't include ." +#elif Q_MOC_OUTPUT_REVISION != 63 +#error "This file was generated using the moc from 4.8.1. It" +#error "cannot be used with the include files from this version of Qt." +#error "(The moc has changed too much.)" +#endif + +QT_BEGIN_MOC_NAMESPACE +static const uint qt_meta_data_MainWindow[] = { + + // content: + 6, // revision + 0, // classname + 0, 0, // classinfo + 3, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 12, 11, 11, 11, 0x08, + 46, 11, 11, 11, 0x08, + 73, 11, 11, 11, 0x08, + + 0 // eod +}; + +static const char qt_meta_stringdata_MainWindow[] = { + "MainWindow\0\0on_actionAbrir_Imagem_triggered()\0" + "on_actionAjuda_triggered()\0" + "on_btnAnalisar_clicked()\0" +}; + +void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) +{ + if (_c == QMetaObject::InvokeMetaMethod) { + Q_ASSERT(staticMetaObject.cast(_o)); + MainWindow *_t = static_cast(_o); + switch (_id) { + case 0: _t->on_actionAbrir_Imagem_triggered(); break; + case 1: _t->on_actionAjuda_triggered(); break; + case 2: _t->on_btnAnalisar_clicked(); break; + default: ; + } + } + Q_UNUSED(_a); +} + +const QMetaObjectExtraData MainWindow::staticMetaObjectExtraData = { + 0, qt_static_metacall +}; + +const QMetaObject MainWindow::staticMetaObject = { + { &QMainWindow::staticMetaObject, qt_meta_stringdata_MainWindow, + qt_meta_data_MainWindow, &staticMetaObjectExtraData } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &MainWindow::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *MainWindow::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *MainWindow::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_MainWindow)) + return static_cast(const_cast< MainWindow*>(this)); + return QMainWindow::qt_metacast(_clname); +} + +int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QMainWindow::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + if (_id < 3) + qt_static_metacall(this, _c, _id, _a); + _id -= 3; + } + return _id; +} +QT_END_MOC_NAMESPACE diff --git a/release/STAG find/moc_mainwindow.o b/release/STAG find/moc_mainwindow.o new file mode 100644 index 0000000..746285c Binary files /dev/null and b/release/STAG find/moc_mainwindow.o differ diff --git a/release/STAG hide/Projeto-Gris-Esteganografia.exe b/release/STAG hide/Projeto-Gris-Esteganografia.exe new file mode 100644 index 0000000..4602f64 Binary files /dev/null and b/release/STAG hide/Projeto-Gris-Esteganografia.exe differ diff --git a/release/STAG hide/QtCore4.dll b/release/STAG hide/QtCore4.dll new file mode 100644 index 0000000..aff9aaf Binary files /dev/null and b/release/STAG hide/QtCore4.dll differ diff --git a/release/STAG hide/QtGui4.dll b/release/STAG hide/QtGui4.dll new file mode 100644 index 0000000..34029fa Binary files /dev/null and b/release/STAG hide/QtGui4.dll differ diff --git a/release/STAG hide/algoritmos.o b/release/STAG hide/algoritmos.o new file mode 100644 index 0000000..ab86e6c Binary files /dev/null and b/release/STAG hide/algoritmos.o differ diff --git a/release/STAG hide/errordialog.o b/release/STAG hide/errordialog.o new file mode 100644 index 0000000..036b60d Binary files /dev/null and b/release/STAG hide/errordialog.o differ diff --git a/release/STAG hide/libgcc_s_dw2-1.dll b/release/STAG hide/libgcc_s_dw2-1.dll new file mode 100644 index 0000000..9e32dc2 Binary files /dev/null and b/release/STAG hide/libgcc_s_dw2-1.dll differ diff --git a/release/STAG hide/main.o b/release/STAG hide/main.o new file mode 100644 index 0000000..65806d2 Binary files /dev/null and b/release/STAG hide/main.o differ diff --git a/release/STAG hide/mainwindow.o b/release/STAG hide/mainwindow.o new file mode 100644 index 0000000..03f95e6 Binary files /dev/null and b/release/STAG hide/mainwindow.o differ diff --git a/release/STAG hide/mingwm10.dll b/release/STAG hide/mingwm10.dll new file mode 100644 index 0000000..572f888 Binary files /dev/null and b/release/STAG hide/mingwm10.dll differ diff --git a/release/STAG hide/moc_errordialog.cpp b/release/STAG hide/moc_errordialog.cpp new file mode 100644 index 0000000..3670101 --- /dev/null +++ b/release/STAG hide/moc_errordialog.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** Meta object code from reading C++ file 'errordialog.h' +** +** Created: Wed 3. Oct 23:53:32 2012 +** by: The Qt Meta Object Compiler version 63 (Qt 4.8.1) +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#include "../../Projeto-Gris-Esteganografia/errordialog.h" +#if !defined(Q_MOC_OUTPUT_REVISION) +#error "The header file 'errordialog.h' doesn't include ." +#elif Q_MOC_OUTPUT_REVISION != 63 +#error "This file was generated using the moc from 4.8.1. It" +#error "cannot be used with the include files from this version of Qt." +#error "(The moc has changed too much.)" +#endif + +QT_BEGIN_MOC_NAMESPACE +static const uint qt_meta_data_ErrorDialog[] = { + + // content: + 6, // revision + 0, // classname + 0, 0, // classinfo + 1, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 13, 12, 12, 12, 0x08, + + 0 // eod +}; + +static const char qt_meta_stringdata_ErrorDialog[] = { + "ErrorDialog\0\0on_buttonBox_accepted()\0" +}; + +void ErrorDialog::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) +{ + if (_c == QMetaObject::InvokeMetaMethod) { + Q_ASSERT(staticMetaObject.cast(_o)); + ErrorDialog *_t = static_cast(_o); + switch (_id) { + case 0: _t->on_buttonBox_accepted(); break; + default: ; + } + } + Q_UNUSED(_a); +} + +const QMetaObjectExtraData ErrorDialog::staticMetaObjectExtraData = { + 0, qt_static_metacall +}; + +const QMetaObject ErrorDialog::staticMetaObject = { + { &QDialog::staticMetaObject, qt_meta_stringdata_ErrorDialog, + qt_meta_data_ErrorDialog, &staticMetaObjectExtraData } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &ErrorDialog::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *ErrorDialog::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *ErrorDialog::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_ErrorDialog)) + return static_cast(const_cast< ErrorDialog*>(this)); + return QDialog::qt_metacast(_clname); +} + +int ErrorDialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QDialog::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + if (_id < 1) + qt_static_metacall(this, _c, _id, _a); + _id -= 1; + } + return _id; +} +QT_END_MOC_NAMESPACE diff --git a/release/STAG hide/moc_errordialog.o b/release/STAG hide/moc_errordialog.o new file mode 100644 index 0000000..4fedebd Binary files /dev/null and b/release/STAG hide/moc_errordialog.o differ diff --git a/release/STAG hide/moc_mainwindow.cpp b/release/STAG hide/moc_mainwindow.cpp new file mode 100644 index 0000000..e9d7961 --- /dev/null +++ b/release/STAG hide/moc_mainwindow.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** Meta object code from reading C++ file 'mainwindow.h' +** +** Created: Wed 3. Oct 23:53:31 2012 +** by: The Qt Meta Object Compiler version 63 (Qt 4.8.1) +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#include "../../Projeto-Gris-Esteganografia/mainwindow.h" +#if !defined(Q_MOC_OUTPUT_REVISION) +#error "The header file 'mainwindow.h' doesn't include ." +#elif Q_MOC_OUTPUT_REVISION != 63 +#error "This file was generated using the moc from 4.8.1. It" +#error "cannot be used with the include files from this version of Qt." +#error "(The moc has changed too much.)" +#endif + +QT_BEGIN_MOC_NAMESPACE +static const uint qt_meta_data_MainWindow[] = { + + // content: + 6, // revision + 0, // classname + 0, 0, // classinfo + 5, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 12, 11, 11, 11, 0x08, + 37, 11, 11, 11, 0x08, + 71, 11, 11, 11, 0x08, + 106, 11, 11, 11, 0x08, + 138, 133, 11, 11, 0x08, + + 0 // eod +}; + +static const char qt_meta_stringdata_MainWindow[] = { + "MainWindow\0\0on_btnEsconder_clicked()\0" + "on_actionAbrir_Imagem_triggered()\0" + "on_actionSalvar_Imagem_triggered()\0" + "on_actionAjuda_triggered()\0arg1\0" + "on_sbNumBits_valueChanged(int)\0" +}; + +void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) +{ + if (_c == QMetaObject::InvokeMetaMethod) { + Q_ASSERT(staticMetaObject.cast(_o)); + MainWindow *_t = static_cast(_o); + switch (_id) { + case 0: _t->on_btnEsconder_clicked(); break; + case 1: _t->on_actionAbrir_Imagem_triggered(); break; + case 2: _t->on_actionSalvar_Imagem_triggered(); break; + case 3: _t->on_actionAjuda_triggered(); break; + case 4: _t->on_sbNumBits_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break; + default: ; + } + } +} + +const QMetaObjectExtraData MainWindow::staticMetaObjectExtraData = { + 0, qt_static_metacall +}; + +const QMetaObject MainWindow::staticMetaObject = { + { &QMainWindow::staticMetaObject, qt_meta_stringdata_MainWindow, + qt_meta_data_MainWindow, &staticMetaObjectExtraData } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &MainWindow::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *MainWindow::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *MainWindow::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_MainWindow)) + return static_cast(const_cast< MainWindow*>(this)); + return QMainWindow::qt_metacast(_clname); +} + +int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QMainWindow::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + if (_id < 5) + qt_static_metacall(this, _c, _id, _a); + _id -= 5; + } + return _id; +} +QT_END_MOC_NAMESPACE diff --git a/release/STAG hide/moc_mainwindow.o b/release/STAG hide/moc_mainwindow.o new file mode 100644 index 0000000..4bb232d Binary files /dev/null and b/release/STAG hide/moc_mainwindow.o differ diff --git a/source/STAG find/Projeto-Gris-Esteganalise.pro b/source/STAG find/Projeto-Gris-Esteganalise.pro new file mode 100644 index 0000000..63c829b --- /dev/null +++ b/source/STAG find/Projeto-Gris-Esteganalise.pro @@ -0,0 +1,20 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2012-04-19T19:01:33 +# +#------------------------------------------------- + +QT += core gui + +TARGET = Projeto-Gris-Esteganalise +TEMPLATE = app + + +SOURCES += main.cpp\ + mainwindow.cpp \ + algoritmos.cpp + +HEADERS += mainwindow.h \ + algoritmos.h + +FORMS += mainwindow.ui diff --git a/source/STAG find/Projeto-Gris-Esteganalise.pro.user b/source/STAG find/Projeto-Gris-Esteganalise.pro.user new file mode 100644 index 0000000..2285a68 --- /dev/null +++ b/source/STAG find/Projeto-Gris-Esteganalise.pro.user @@ -0,0 +1,365 @@ + + + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + System + false + 4 + true + 1 + true + 0 + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Qt4ProjectManager.Target.DesktopTarget + 1 + 0 + 0 + + ProjectExplorer.ToolChain.Mingw:C:/QtSDK/mingw/bin/mingw32-g++.exe.x86-windows-msys-pe-32bit.C:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe + + + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt 4.8.1 for Desktop - MinGW (Qt SDK) Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + C:/Users/Gabriel/Desktop/Gabriel/Faculdade/GRIS/Projetos/Esteganografia/Projeto-Gris-Esteganalise-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug + 2 + true + + + ProjectExplorer.ToolChain.Mingw:C:/QtSDK/mingw/bin/mingw32-g++.exe.x86-windows-msys-pe-32bit.C:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe + + + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt 4.8.1 for Desktop - MinGW (Qt SDK) Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + C:/Users/Gabriel/Desktop/Gabriel/Faculdade/GRIS/Projetos/Esteganografia/Projeto-Gris-Esteganalise-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Release + 2 + true + + + ProjectExplorer.ToolChain.Mingw:C:/QtSDK/mingw/bin/mingw32-g++.exe.x86-windows-msys-pe-32bit.C:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe + + + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt 4.8.0 for Desktop - MinGW (Qt SDK) Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + C:/Users/Gabriel/Desktop/Gabriel/Faculdade/GRIS/Projetos/Esteganografia/Projeto-Gris-Esteganalise-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK__Debug + 1 + true + + + ProjectExplorer.ToolChain.Mingw:C:/QtSDK/mingw/bin/mingw32-g++.exe.x86-windows-msys-pe-32bit.C:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe + + + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt 4.8.0 for Desktop - MinGW (Qt SDK) Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + C:/Users/Gabriel/Desktop/Gabriel/Faculdade/GRIS/Projetos/Esteganografia/Projeto-Gris-Esteganalise-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK__Release + 1 + true + + 4 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + + + false + false + false + false + false + false + false + false + true + true + 0.01 + 0.01 + 10 + 10 + true + true + 25 + 25 + + + true + true + valgrind + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + Projeto-Gris-Esteganalise + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + Projeto-Gris-Esteganalise.pro + false + false + + + 3768 + true + false + false + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.EnvironmentId + {87ceb59b-4745-4587-861a-6fdc304303a4} + + + ProjectExplorer.Project.Updater.FileVersion + 10 + + diff --git a/source/STAG find/algoritmos.cpp b/source/STAG find/algoritmos.cpp new file mode 100644 index 0000000..1e2da11 --- /dev/null +++ b/source/STAG find/algoritmos.cpp @@ -0,0 +1,172 @@ +#include "algoritmos.h" + +Algoritmos::Algoritmos() +{ +} + +Algoritmos::Algoritmos(QImage img) +{ + imagem = img; +} + +int Algoritmos::descobreBitDaPosicao(int num, int pos) +{ + int mascara = 1 << pos; + int retorno = (num & mascara); + retorno = retorno >> pos; + return retorno; +} + +int Algoritmos::pegaBits(int num, int posIni, int numBits) +{ + if (posIni < 0) + { + return 0; + } + + int resultado = 0; + + for(int i = 0; i < numBits; i++) + { + if ((posIni - i) < 0 ) + { + break; + } + + int temp = descobreBitDaPosicao(num, posIni - i); + temp = temp << (numBits - i - 1); + resultado += temp; + } + + return resultado; +} + +int Algoritmos::pegaTamanhoLsbSimples(int numBits, int pixelIniLargura, int pixelIniAltura) +{ + // Descubro quantos pixels preciso ler pra ter o tamanho + int tamInt = (sizeof(int) * 8); + int quantPixels = tamInt/(numBits * 3); + + if (tamInt % (numBits * 3) != 0) + { + quantPixels++; + } + + int resultado = 0; + + // Laço pra pegar os 32 bits que formam um inteiro + int pixelLargura = pixelIniLargura; + int pixelAltura = pixelIniAltura; + int maxLargura = imagem.size().width(); + int posLeitura = 31; + for (int i = 0; i < quantPixels; i++) + { + QRgb orgPixel = imagem.pixel(pixelLargura, pixelAltura); + int vermelho = qRed(orgPixel); + int azul = qBlue(orgPixel); + int verde = qGreen(orgPixel); + + // Pega informação do Vermelho + int flippedBits = pegaBits(vermelho, (numBits - 1), numBits); + resultado += (flippedBits << posLeitura); + posLeitura -= numBits; + + if (posLeitura >= 0) + { + // Pega informação do Verde + flippedBits = pegaBits(verde, (numBits - 1), numBits); + resultado += (flippedBits << posLeitura); + posLeitura -= numBits; + } + + if (posLeitura >= 0) + { + // Pega informação do Azul + flippedBits = pegaBits(azul, (numBits - 1), numBits); + resultado += (flippedBits << posLeitura); + posLeitura -= numBits; + } + + pixelLargura++; + if (pixelLargura >= maxLargura) + { + pixelLargura = 0; + pixelAltura++; + } + } + + return resultado; +} + +QString Algoritmos::pegaMensagemLsbSimples(int tamanho, int numBits, int pixelIniLargura, int pixelIniAltura) +{ + QString mensagem(""); + + // Descubro quantos pixels preciso ler pra ter um inteiro + int tamInt = (sizeof(int) * 8); + int quantPixels = tamInt/(numBits * 3); + + if (tamInt % (numBits * 3) != 0) + { + quantPixels++; + } + + int maxLargura = imagem.size().width(); + int pixelLargura = pixelIniLargura + quantPixels; + int pixelAltura = pixelIniAltura; + + if (pixelLargura >= maxLargura) + { + pixelLargura -= maxLargura; + pixelAltura++; + } + + + for (int j = 0; j < tamanho; j++) + { + int resultado = 0; + + // Laço pra pegar os 32 bits que formam um inteiro + int posLeitura = 31; + for (int i = 0; i < quantPixels; i++) + { + QRgb orgPixel = imagem.pixel(pixelLargura, pixelAltura); + int vermelho = qRed(orgPixel); + int azul = qBlue(orgPixel); + int verde = qGreen(orgPixel); + + // Pega informação do Vermelho + int flippedBits = pegaBits(vermelho, (numBits - 1), numBits); + resultado += (flippedBits << posLeitura); + posLeitura -= numBits; + + if (posLeitura >= 0) + { + // Pega informação do Verde + flippedBits = pegaBits(verde, (numBits - 1), numBits); + resultado += (flippedBits << posLeitura); + posLeitura -= numBits; + } + + if (posLeitura >= 0) + { + // Pega informação do Azul + flippedBits = pegaBits(azul, (numBits - 1), numBits); + resultado += (flippedBits << posLeitura); + posLeitura -= numBits; + } + + pixelLargura++; + if (pixelLargura >= maxLargura) + { + pixelLargura = 0; + pixelAltura++; + } + } + + QChar temp(resultado); + mensagem.append(temp); + } + + return mensagem; +} diff --git a/source/STAG find/algoritmos.h b/source/STAG find/algoritmos.h new file mode 100644 index 0000000..4dfbcb2 --- /dev/null +++ b/source/STAG find/algoritmos.h @@ -0,0 +1,22 @@ +#ifndef ALGORITMOS_H +#define ALGORITMOS_H + +#include "QImage.h" + +class Algoritmos +{ + public: + Algoritmos(); + Algoritmos(QImage img); + + int pegaTamanhoLsbSimples(int numBits, int pixelIniLargura = 0, int pixelIniAltura = 0); + QString pegaMensagemLsbSimples(int tamanho, int numBits, int pixelIniLargura = 0, int pixelIniAltura = 0); + + private: + QImage imagem; + + int descobreBitDaPosicao(int num, int pos); + int pegaBits(int num, int posIni, int numBits); +}; + +#endif // ALGORITMOS_H diff --git a/source/STAG find/main.cpp b/source/STAG find/main.cpp new file mode 100644 index 0000000..d951345 --- /dev/null +++ b/source/STAG find/main.cpp @@ -0,0 +1,11 @@ +#include +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/source/STAG find/mainwindow.cpp b/source/STAG find/mainwindow.cpp new file mode 100644 index 0000000..c7c0555 --- /dev/null +++ b/source/STAG find/mainwindow.cpp @@ -0,0 +1,64 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include +#include "algoritmos.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + ui->btnAnalisar->setEnabled(false); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::on_actionAbrir_Imagem_triggered() +{ + // Pega o endereço da imagem selecionada + QString imagePath = QFileDialog::getOpenFileName(); + + // Cria um objeto imagem e carrega do arquivo selecionado + QImage imagem; + imagemAnalise.load( imagePath ); + + // Redimensiona para o tamanho das labels! + // Mantenho a imagemAnalise sem modificar! + imagem = imagemAnalise.scaled(241, 201); + + // Seta imagemOriginalEscolhida pra eu poder calcular propriedades + //imagemOriginalEscolhida = true; + //atualizaDimensoesComImagem(); + + // Exibe a imagem na tela + ui->labelImagem->setPixmap( QPixmap::fromImage(imagem) ); + ui->btnAnalisar->setEnabled(true); +} + +void MainWindow::on_actionAjuda_triggered() +{ + QString mensagem = "Seção de Ajuda em construção!\nDesculpe o inconveniente."; + //ErrorDialog *errordialog = new ErrorDialog(this, mensagem); + //errordialog->show(); +} + +void MainWindow::on_btnAnalisar_clicked() +{ + // Preciso ver a opção de algoritmo que foi marcada e executar o + // algoritmo correspondente na imagem + + // Primeira coisa a fazer é descobrir o tamanho! + Algoritmos alg = Algoritmos(imagemAnalise); + int numBits = ui->sbNumBits->value(); + + int tam = alg.pegaTamanhoLsbSimples(numBits); + + QString tamanho = QString::number(tam); + ui->leTamMensagem->setText( tamanho ); + + QString mensagem = alg.pegaMensagemLsbSimples(tam, numBits); + ui->tbMensagemRecuperada->setText(mensagem); +} diff --git a/source/STAG find/mainwindow.h b/source/STAG find/mainwindow.h new file mode 100644 index 0000000..266e231 --- /dev/null +++ b/source/STAG find/mainwindow.h @@ -0,0 +1,32 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + QImage imagemAnalise; + +private slots: + void on_actionAbrir_Imagem_triggered(); + + void on_actionAjuda_triggered(); + + void on_btnAnalisar_clicked(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/source/STAG find/mainwindow.ui b/source/STAG find/mainwindow.ui new file mode 100644 index 0000000..7743811 --- /dev/null +++ b/source/STAG find/mainwindow.ui @@ -0,0 +1,410 @@ + + + MainWindow + + + + 0 + 0 + 831 + 496 + + + + GRIS - Esteganálise + + + + + + 30 + 40 + 240 + 201 + + + + + + + + + + 37 + 19 + 141 + 16 + + + + + Mongolian Baiti + 11 + + + + Imagem Analisada + + + + + + 30 + 293 + 191 + 141 + + + + + + + 37 + 266 + 161 + 20 + + + + + Mongolian Baiti + 11 + + + + Informação Recuperada + + + + + + 600 + 40 + 141 + 121 + + + + + Mongolian Baiti + 10 + + + + Algoritmos + + + + + 10 + 24 + 145 + 74 + + + + + + + LSB Simples + + + buttonGroup + + + + + + + Filtro LSB + + + buttonGroup + + + + + + + LSB Chave Secreta + + + buttonGroup + + + + + + + + + + 600 + 200 + 141 + 171 + + + + + Mongolian Baiti + 10 + + + + Configurações + + + + + 49 + 39 + 42 + 22 + + + + 3 + + + 1 + + + + + + 10 + 100 + 51 + 20 + + + + + 9 + + + + + + + 80 + 100 + 51 + 20 + + + + + 9 + + + + + + + 36 + 101 + 71 + 20 + + + + + 11 + 75 + true + + + + X + + + Qt::AlignCenter + + + + + + 5 + 17 + 131 + 20 + + + + + 10 + 50 + false + + + + Número de Bits Usados + + + Qt::AlignCenter + + + + + + 3 + 66 + 131 + 21 + + + + + 75 + true + + + + Pixel Inicial + + + Qt::AlignCenter + + + + + + 9 + 80 + 131 + 20 + + + + + 7 + + + + 0x0 por padrão + + + Qt::AlignCenter + + + + + + + 250 + 397 + 131 + 16 + + + + + Mongolian Baiti + 10 + 50 + false + + + + Tamanho em Bytes + + + + + + 250 + 414 + 113 + 20 + + + + + Mongolian Baiti + 9 + + + + true + + + + + + 640 + 390 + 75 + 23 + + + + + Mongolian Baiti + 11 + + + + Analisar + + + false + + + false + + + false + + + false + + + + + + + 0 + 0 + 831 + 21 + + + + + Arquivo + + + + + + + + + + TopToolBarArea + + + false + + + + + + Abrir Imagem + + + + + Ajuda + + + + + + + + + + diff --git a/source/STAG hide/Projeto-Gris-Esteganografia.pro b/source/STAG hide/Projeto-Gris-Esteganografia.pro new file mode 100644 index 0000000..3ce57eb --- /dev/null +++ b/source/STAG hide/Projeto-Gris-Esteganografia.pro @@ -0,0 +1,23 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2012-04-17T22:22:16 +# +#------------------------------------------------- + +QT += core gui + +TARGET = Projeto-Gris-Esteganografia +TEMPLATE = app + + +SOURCES += main.cpp\ + mainwindow.cpp \ + errordialog.cpp \ + algoritmos.cpp + +HEADERS += mainwindow.h \ + errordialog.h \ + algoritmos.h + +FORMS += mainwindow.ui \ + errordialog.ui diff --git a/source/STAG hide/Projeto-Gris-Esteganografia.pro.user b/source/STAG hide/Projeto-Gris-Esteganografia.pro.user new file mode 100644 index 0000000..60718de --- /dev/null +++ b/source/STAG hide/Projeto-Gris-Esteganografia.pro.user @@ -0,0 +1,365 @@ + + + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + System + false + 4 + true + 1 + true + 0 + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Qt4ProjectManager.Target.DesktopTarget + 1 + 0 + 0 + + ProjectExplorer.ToolChain.Mingw:C:/QtSDK/mingw/bin/mingw32-g++.exe.x86-windows-msys-pe-32bit.C:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe + + + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt 4.8.1 for Desktop - MinGW (Qt SDK) Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + C:/Users/Gabriel/Desktop/Gabriel/Faculdade/GRIS/Projetos/Esteganografia/Projeto-Gris-Esteganografia-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug + 2 + true + + + ProjectExplorer.ToolChain.Mingw:C:/QtSDK/mingw/bin/mingw32-g++.exe.x86-windows-msys-pe-32bit.C:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe + + + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt 4.8.1 for Desktop - MinGW (Qt SDK) Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + C:/Users/Gabriel/Desktop/Gabriel/Faculdade/GRIS/Projetos/Esteganografia/Projeto-Gris-Esteganografia-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Release + 2 + true + + + ProjectExplorer.ToolChain.Mingw:C:/QtSDK/mingw/bin/mingw32-g++.exe.x86-windows-msys-pe-32bit.C:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe + + + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt 4.8.0 for Desktop - MinGW (Qt SDK) Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + C:/Users/Gabriel/Desktop/Gabriel/Faculdade/GRIS/Projetos/Esteganografia/Projeto-Gris-Esteganografia-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK__Debug + 1 + true + + + ProjectExplorer.ToolChain.Mingw:C:/QtSDK/mingw/bin/mingw32-g++.exe.x86-windows-msys-pe-32bit.C:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe + + + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt 4.8.0 for Desktop - MinGW (Qt SDK) Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + C:/Users/Gabriel/Desktop/Gabriel/Faculdade/GRIS/Projetos/Esteganografia/Projeto-Gris-Esteganografia-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK__Release + 1 + true + + 4 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + + + false + false + false + false + false + false + false + false + true + true + 0.01 + 0.01 + 10 + 10 + true + true + 25 + 25 + + + true + true + valgrind + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + Projeto-Gris-Esteganografia + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + Projeto-Gris-Esteganografia.pro + false + false + + + 3768 + true + false + false + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.EnvironmentId + {87ceb59b-4745-4587-861a-6fdc304303a4} + + + ProjectExplorer.Project.Updater.FileVersion + 10 + + diff --git a/source/STAG hide/algoritmos.cpp b/source/STAG hide/algoritmos.cpp new file mode 100644 index 0000000..bbc3ef0 --- /dev/null +++ b/source/STAG hide/algoritmos.cpp @@ -0,0 +1,218 @@ +#include "algoritmos.h" + +Algoritmos::Algoritmos() +{ +} + +Algoritmos::Algoritmos(QImage imagem) +{ + imagemOriginal = imagem; +} + +int Algoritmos::descobreBitDaPosicao(int num, int pos) +{ + int mascara = 1 << pos; + int retorno = (num & mascara); + retorno = retorno >> pos; + return retorno; +} + +int Algoritmos::pegaBits(int num, int posIni, int numBits) +{ + if (posIni < 0) + { + return 0; + } + + int resultado = 0; + + for(int i = 0; i < numBits; i++) + { + if ((posIni - i) < 0 ) + { + break; + } + + int temp = descobreBitDaPosicao(num, posIni - i); + temp = temp << (numBits - i - 1); + resultado += temp; + } + + return resultado; +} + +int Algoritmos::defineMascara(int numBits) +{ + // Máscara de Bits == 0xFF - (2^numBits - 1) + int mascara; + + if (numBits == 1) + { + mascara = 0xFE; + } + else if (numBits == 2) + { + mascara = 0xFC; + } + else + { + mascara = 0xF8; + } + + return mascara; +} + +QImage Algoritmos::aplicaLSB(int numBits, QString mensagem) +{ + QImage retorno = imagemOriginal; + + int tamMensagem = mensagem.size(); + + // Objetivo é esconder bits em cada canal de cor de cada pixel. + // Ou seja, esconder "numBits" bits em R, G e B de cada pixel, alterando + // os menos significativos. + // Maneira mais eficiente de fazer isso é usando uma "Máscara de Bits" e + // fazendo operações binárias, como ANDs e ORs, bit a bit. + + // BIT MASK + // Primeiro fazer um AND entre a cor e o hexa 0xFF - (2^numbits - 1) + + // EXEMPLO: numbits = 3, hexa = 0xF8 + // 0xF8 = 1 1 1 1 1 0 0 0 + // R = 128 = 0xFF = 1 0 0 0 0 0 0 0 + // 0xF8 AND R = 1 0 0 0 0 0 0 0 = 0x80 + // Agora e só fazer um OR com os bits que se quer acrescentar + // se quero esconder 101 + // 101 = 0x5 + // 0x80 OR 0x5 = 1 0 0 0 0 1 0 1 + + int mascara = defineMascara(numBits); + + /** + Passo 1 : Escondendo o tamanho + **/ + int quantPixels = (sizeof(int) * 8)/(3*numBits); + if (( (sizeof(int) * 8) % 3*numBits) != 0) + { + quantPixels++; + } + + int pixelLargura = 0; + int pixelAltura = 0; + int maxLargura = retorno.size().width(); + int posAtualInt = 31; + for (int i = 0; i < quantPixels; i++) + { + QRgb orgPixel = retorno.pixel(pixelLargura, pixelAltura); + int vermelho = qRed(orgPixel); + int azul = qBlue(orgPixel); + int verde = qGreen(orgPixel); + int alpha = qAlpha(orgPixel); + + // Altera pixel + // Altera vermelho + int flippedBits = pegaBits(tamMensagem, posAtualInt, numBits); + posAtualInt -= numBits; + // Aplica a máscara + vermelho = (vermelho & mascara); + // Muda LSB + vermelho = (vermelho | flippedBits); + + if (posAtualInt >= 0) + { + // Altera verde + flippedBits = pegaBits(tamMensagem, posAtualInt, numBits); + posAtualInt -= numBits; + // Aplica a máscara + verde = (verde & mascara); + // Muda LSB + verde = (verde | flippedBits); + } + + if (posAtualInt >= 0) + { + // Altera azul + flippedBits = pegaBits(tamMensagem, posAtualInt, numBits); + posAtualInt -= numBits; + // Aplica a máscara + azul = (azul & mascara); + // Muda LSB + azul = (azul | flippedBits); + } + + QRgb modPixel = qRgba(vermelho, verde, azul, alpha); + retorno.setPixel(pixelLargura, pixelAltura, modPixel); + + // Muda posição do pixel que eu to pegando no laço + pixelLargura++; + if (pixelLargura >= maxLargura) + { + pixelAltura++; + pixelLargura = 0; + } + } + + // Escondendo mensagem + quantPixels = (sizeof(int) * 8)/(3*numBits); + if (( (sizeof(int) * 8) % 3*numBits) != 0) + { + quantPixels++; + } + + for (int j = 0; j < tamMensagem; j++) + { + int temp = mensagem.at(j).toAscii(); + posAtualInt = 31; + for(int i = 0; i < quantPixels; i++) + { + QRgb orgPixel = retorno.pixel(pixelLargura, pixelAltura); + int vermelho = qRed(orgPixel); + int azul = qBlue(orgPixel); + int verde = qGreen(orgPixel); + + // Altera pixel + // Altera vermelho + int flippedBits = pegaBits(temp, posAtualInt, numBits); + posAtualInt -= numBits; + // Aplica a máscara + vermelho = (vermelho & mascara); + // Muda LSB + vermelho = (vermelho | flippedBits); + + if (posAtualInt >= 0) + { + // Altera verde + flippedBits = pegaBits(temp, posAtualInt, numBits); + posAtualInt -= numBits; + // Aplica a máscara + verde = (verde & mascara); + // Muda LSB + verde = (verde | flippedBits); + } + + if (posAtualInt >= 0) + { + // Altera azul + flippedBits = pegaBits(temp, posAtualInt, numBits); + posAtualInt -= numBits; + // Aplica a máscara + azul = (azul & mascara); + // Muda LSB + azul = (azul | flippedBits); + } + + QRgb modPixel = qRgba(vermelho, verde, azul, 0); + retorno.setPixel(pixelLargura, pixelAltura, modPixel); + + // Muda posição do pixel que eu to pegando no laço + pixelLargura++; + if (pixelLargura >= maxLargura) + { + pixelAltura++; + pixelLargura = 0; + } + } + } + + return retorno; +} diff --git a/source/STAG hide/algoritmos.h b/source/STAG hide/algoritmos.h new file mode 100644 index 0000000..9937efd --- /dev/null +++ b/source/STAG hide/algoritmos.h @@ -0,0 +1,22 @@ +#ifndef ALGORITMOS_H +#define ALGORITMOS_H + +#include "QImage.h" + +class Algoritmos +{ + public: + Algoritmos(); + Algoritmos(QImage imagem); + + QImage aplicaLSB( int numBits, QString mensagem ); + + private: + QImage imagemOriginal; + + int defineMascara(int numBits); + int descobreBitDaPosicao(int num, int pos); + int pegaBits(int num, int posIni, int numBits); +}; + +#endif // ALGORITMOS_H diff --git a/source/STAG hide/errordialog.cpp b/source/STAG hide/errordialog.cpp new file mode 100644 index 0000000..98f5434 --- /dev/null +++ b/source/STAG hide/errordialog.cpp @@ -0,0 +1,27 @@ +#include "errordialog.h" +#include "ui_errordialog.h" + +ErrorDialog::ErrorDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::ErrorDialog) +{ + ui->setupUi(this); +} + +ErrorDialog::ErrorDialog(QWidget *parent, QString mensagem) : + QDialog(parent), + ui(new Ui::ErrorDialog) +{ + ui->setupUi(this); + ui->labelMensagem->setText(mensagem); +} + +ErrorDialog::~ErrorDialog() +{ + delete ui; +} + +void ErrorDialog::on_buttonBox_accepted() +{ + deleteLater(); +} diff --git a/source/STAG hide/errordialog.h b/source/STAG hide/errordialog.h new file mode 100644 index 0000000..448c63d --- /dev/null +++ b/source/STAG hide/errordialog.h @@ -0,0 +1,26 @@ +#ifndef ERRORDIALOG_H +#define ERRORDIALOG_H + +#include + +namespace Ui { +class ErrorDialog; +} + +class ErrorDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ErrorDialog(QWidget *parent = 0); + explicit ErrorDialog(QWidget *parent = 0, QString mensagem = ""); + ~ErrorDialog(); + +private slots: + void on_buttonBox_accepted(); + +private: + Ui::ErrorDialog *ui; +}; + +#endif // ERRORDIALOG_H diff --git a/source/STAG hide/errordialog.ui b/source/STAG hide/errordialog.ui new file mode 100644 index 0000000..6785f42 --- /dev/null +++ b/source/STAG hide/errordialog.ui @@ -0,0 +1,84 @@ + + + ErrorDialog + + + + 0 + 0 + 363 + 153 + + + + Dialog + + + + + -7 + 110 + 381 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + true + + + + + + 0 + 96 + 381 + 20 + + + + Qt::Horizontal + + + + + + 20 + 20 + 241 + 71 + + + + TextLabel + + + true + + + + + + + buttonBox + accepted() + ErrorDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + diff --git a/source/STAG hide/main.cpp b/source/STAG hide/main.cpp new file mode 100644 index 0000000..d951345 --- /dev/null +++ b/source/STAG hide/main.cpp @@ -0,0 +1,11 @@ +#include +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/source/STAG hide/mainwindow.cpp b/source/STAG hide/mainwindow.cpp new file mode 100644 index 0000000..5e387c4 --- /dev/null +++ b/source/STAG hide/mainwindow.cpp @@ -0,0 +1,173 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include "errordialog.h" +#include "algoritmos.h" +#include + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + imagemOriginalEscolhida = false; + existeImagemModificada = false; + + tamHeaderBits = 32; + quantBits = 0; +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::on_btnEsconder_clicked() +{ + // Aqui vou fazer a ação de esconder a mensagem dada na imagem. + // O que preciso fazer: + // 1 - Pegar o tamanho da mensagem, em bits e verificar se cabe na imagem + // 2 - Lembrar que preciso guardar os 4 primeiros bytes para header (inteiro correspondente ao tamanho) + // 3 - Finalmente alterar os bits desejados, usando o LSB mais simples possível, ou seja, começando do canto superior esquerdo + // e avançando linha a linha, da esquerda para a direita. + + // Testa se a mensagem a ser inserida não está vazia. + if ( ui->MensagemInput->toPlainText().size() == 0 ) + { + ErrorDialog *errordialog = new ErrorDialog(this, "A mensagem não pode ser vazia!"); + errordialog->show(); + + return; + } + + /** + Passos 1 e 2 + **/ + // Contabiliza os bytes totais da mensagem + int countBytes = 0; + + // Preciso considerar o TAMANHO do HEADER em bytes + countBytes += (tamHeaderBits/8); + + // Cada char da mensagem possui 1 byte + countBytes += ui->MensagemInput->toPlainText().size(); + + // Transformando em bits + int countBits = countBytes * 8; + + // Para ver se cabe na imagem, preciso descobrir quantos pixels ela tem e quantos bits + // o usuário escolheu utilizar para esconder sua mensagem + + // Se a quantidade disponível for menor que o necessário, mostrar janela de erro + if (quantBits < countBits) + { + QString mensagem = "A mensagem é maior do que o limite possivel de esconder."; + mensagem += "\nTente aumentar o número de bits, diminuir a mensagem ou trocar a imagem original"; + ErrorDialog *errordialog = new ErrorDialog(this, mensagem); + errordialog->show(); + + return; + } + + /** + Passo 3 - Esconder a mensagem + **/ + Algoritmos alg = Algoritmos(imagemOriginal); + imagemModificada = alg.aplicaLSB( ui->sbNumBits->value(), + ui->MensagemInput->toPlainText() ); + + QImage imagem = imagemModificada.scaled(241, 201); + ui->labelImgMod->setPixmap( QPixmap::fromImage(imagem) ); + existeImagemModificada = true; +} + +void MainWindow::on_actionAbrir_Imagem_triggered() +{ + // Pega o endereço da imagem selecionada + QString imagePath = QFileDialog::getOpenFileName(); + + // Cria um objeto imagem e carrega do arquivo selecionado + QImage imagem; + imagemOriginal.load( imagePath ); + + // Redimensiona para o tamanho das labels! + // Mantenho a imagemOriginal sem modificar! + imagem = imagemOriginal.scaled(241, 201); + + // Seta imagemOriginalEscolhida pra eu poder calcular propriedades + imagemOriginalEscolhida = true; + atualizaDimensoesComImagem(); + + // Exibe a imagem na tela + ui->labelImgOriginal->setPixmap( QPixmap::fromImage(imagem) ); +} + +void MainWindow::atualizaDimensoesComImagem() +{ + // Preenche a label de dimensões da imagem + QSize tam = imagemOriginal.size(); + QString dimensoes = QString::number(tam.width()) + " x " + + QString::number(tam.height()); + ui->labelDimensoes->setText( dimensoes ); + + ui->sbNumBits->setEnabled(true); + ui->btnEsconder->setEnabled(true); +} + +void MainWindow::on_actionSalvar_Imagem_triggered() +{ + // Salvar a imagem modificada, somente se ela já estiver definida! + if ( existeImagemModificada ) + { + // Abrindo o dialog pra escolha do arquivo + QString path = QFileDialog::getSaveFileName(); + + // Salvando a imagem + imagemModificada.save(path); + + // Exibindo confirmação + QString mensagem = "Arquivo " + path + " salvo com sucesso!"; + ErrorDialog *errordialog = new ErrorDialog(this, mensagem); + errordialog->show(); + + return; + } + + // Se a imagem modificada não estiver definida ainda + QString mensagem = "Imagem modificada ainda não foi definida!\nEsconda algo primeiro!"; + ErrorDialog *errordialog = new ErrorDialog(this, mensagem); + errordialog->show(); +} + +void MainWindow::on_actionAjuda_triggered() +{ + QString mensagem = "Seção de Ajuda em construção!\nDesculpe o inconveniente."; + ErrorDialog *errordialog = new ErrorDialog(this, mensagem); + errordialog->show(); +} + +void MainWindow::on_sbNumBits_valueChanged(int arg1) +{ + if (arg1 != 0) + { + // Preciso recalcular os limites de informação escondidas com o novo valor pro LSB + QSize tam = imagemOriginal.size(); + + // bits disponíveis = altura * largura * 3 (canais de cores R, G e B) + int countBits = tam.height() * tam.width() * 3 * arg1; + + // bytes disponíveis = (bits imagem - bits do header) / 8; + int countBytes = (countBits - tamHeaderBits)/8; + + quantBits = countBits; + + ui->labelBits->setText( QString::number(countBits - tamHeaderBits) + " bits" ); + ui->labelCaracteres->setText( QString::number(countBytes) + " caracteres" ); + } + else + { + quantBits = 0; + ui->labelBits->setText( "0 bits" ); + ui->labelCaracteres->setText( "0 caracteres" ); + } +} diff --git a/source/STAG hide/mainwindow.h b/source/STAG hide/mainwindow.h new file mode 100644 index 0000000..c541d76 --- /dev/null +++ b/source/STAG hide/mainwindow.h @@ -0,0 +1,40 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private slots: + void on_btnEsconder_clicked(); + + void on_actionAbrir_Imagem_triggered(); + + void on_actionSalvar_Imagem_triggered(); + + void on_actionAjuda_triggered(); + + void on_sbNumBits_valueChanged(int arg1); + +private: + Ui::MainWindow *ui; + QImage imagemOriginal, imagemModificada; + bool imagemOriginalEscolhida, existeImagemModificada; + + int quantBits; + int tamHeaderBits; + + void atualizaDimensoesComImagem(); +}; + +#endif // MAINWINDOW_H diff --git a/source/STAG hide/mainwindow.ui b/source/STAG hide/mainwindow.ui new file mode 100644 index 0000000..660bcbd --- /dev/null +++ b/source/STAG hide/mainwindow.ui @@ -0,0 +1,353 @@ + + + MainWindow + + + + 0 + 0 + 751 + 510 + + + + GRIS - Esteganografia + + + + + false + + + + 30 + 400 + 75 + 23 + + + + Esconder + + + + + + 40 + 13 + 91 + 16 + + + + Imagem Original + + + + + + 320 + 14 + 161 + 16 + + + + Imagem Modificada + + + + + + -10 + 250 + 771 + 20 + + + + Qt::Horizontal + + + + + + 30 + 280 + 151 + 111 + + + + + + + 310 + 270 + 161 + 191 + + + + + Mongolian Baiti + 10 + 50 + false + false + + + + Configurações + + + false + + + false + + + + + 5 + 20 + 151 + 20 + + + + Dimensões da Imagem: + + + Qt::AlignCenter + + + + + + 5 + 40 + 151 + 20 + + + + x + + + Qt::AlignCenter + + + + + + 5 + 59 + 156 + 20 + + + + Nº de Bits Alterados (LSB): + + + Qt::AlignCenter + + + + + false + + + + 62 + 80 + 40 + 22 + + + + 3 + + + + + + 5 + 110 + 156 + 16 + + + + Bits Totais Disponíveis: + + + Qt::AlignCenter + + + + + + 5 + 130 + 156 + 13 + + + + 0 bits + + + Qt::AlignCenter + + + + + + 5 + 150 + 156 + 20 + + + + 0 caracteres + + + Qt::AlignCenter + + + + + + + 29 + 30 + 241 + 201 + + + + + + + + + + 310 + 30 + 241 + 201 + + + + false + + + QFrame::Plain + + + 1 + + + + + + + + + 570 + 50 + 151 + 81 + + + + + Mongolian Baiti + 10 + + + + As imagens inseridas sofrem redimensionamento por padrão. Atente para o tamanho real da imagem, indicado abaixo + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + 570 + 30 + 91 + 20 + + + + + Mongolian Baiti + 12 + 75 + true + false + + + + ATENÇÃO + + + + + + + 0 + 0 + 751 + 21 + + + + + Arquivo + + + + + + + + + + + TopToolBarArea + + + false + + + + + + Abrir Imagem + + + + + Salvar Imagem + + + + + Ajuda + + + + + + +