Skip to content

whiteblackitty/SQLCipher-Password-Cracker-OpenCL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

PBKDF2-noHMAC-SHA1--AES-256-CBC encrypted SQLite database (SQLCipher v2 standard) password bruteforcing using OpenCL(utilize the great power of GPU) and Python. The code here is for cracking password which only consists of fixed-length hex chars, but can be easily adapted for universal use. This repository is the result of many developers' effort.

Warning: This repository is only for studies on computer safety, anyone who use it illegally should bear the responsibility of their own.

Installation

  1. Get python 3.7 64-Bit
  2. Download and install the OpenCL SDK (Note that only OpenCL runtime is not enough for our cracking journey, we need SDK.)(e.g. from Intel to get the Intel CPU platform SDK, and from Nvidia to get CUDA SDK (test passed for CUDA version 10.0 and 10.2, other versions are not tested) for NVIDIA GPUs). Generally Intel SDK is not required, CUDA SDK is just enough. AMD CPUs and GPUs are not supported because of the problematic AMD APP SDK.
  3. Install pyOpenCL using: python -m pip install pyopencl
    Maybe you cannot just run the command above to finish the installation, then you should manually download pyOpenCL package and configure something about your OpenCL SDK path, refer to pyOpenCL wiki
  4. Install pysqlcipher3 using the manual there, or see the information below.

Hints for pysqlcipher3 Installation

Following the manual of pysqlcipher3 will not always get things run, because of the lack of maintainence of the repository and the development of the depended tools. What's more, it's painful to configure these annoying things. Here are some suggested steps for the installation of pysqlcipher3.

Suggestion for Windows users

In the typical process of installing pysqlcipher3, you should install OpenSSL x64 libraries and then compile sqlcipher first. I suggest "Build against amalgamation", requiring no actual build of sqlcipher, which is tested on my computer, whose steps after installing OpenSSL x64 libraries are as following:

  1. Compile the amalgamation files of sqlcipher: Run the Developer Command Prompt of Visual Studio, then cded to the sqlcipher folder, run:

    nmake /f Makefile.msc sqlite3.c

  2. Copy to pysqlcipher3 folder: Make a folder named amalgamation in pysqlcipher3 folder, then copy the generated sqlite3.c and sqlite3.h to the folder.

  3. Modify the source files of pysqlcipher3: In pysqlcipher3\src\python3, change the "#include "sqlcipher\sqlite3.h"" to "#include "sqlite3.h"" of connection.h, statement.h and util.h.

  4. Modify the setup.py of pysqlcipher3: First, change the "openssl = os.path..." to "openssl = [your openssl installation folder]". Then change the string "openssl_lib_path = os.path.join(openssl, "lib")" to "openssl_lib_path = os.path.join(openssl, "lib\VC")" Then, change the string "libeay32.lib" to "libcrypto64MD.lib", then add a following statement: ext.extra_link_args.append("libssl64MD.lib") . We need x64 OpenSSL Libraries because the python is 64-bit and thus uses x64 MSVC Compiler during the process of building pysqlcipher sources along with sqlite3.c, sqlite3.h.

  5. Build and Install: cded to pysqlcipher3 folder:

    python setup.py build_amalgamation
    python setup.py install

  6. Finally copy the libcrypto-1_1-x64.dll and libssl-1_1-x64.dll in the OpenSSL path to this repository folder. If you choose to copy the libraries to system32 folder when installing the OpenSSL libraries, you needn't perform this step.

  7. That's all.

Suggestion for Linux users

  1. You can directly get sqlcipher dev package:

    sudo apt-get install libsqlcipher-dev

  2. Then install pysqlcipher3:

    python -m pip install pysqlcipher3

  3. That's all.

Run

  1. Run python genTestDB.py [password] to get a password encrypted SQLite database for test.
  2. Modify the variables from the header of Run.py to satisfy your requirments.
  3. python Run.py
  4. Now you get the available platforms and their number in console output.
  5. python Run.py [platform number]

Thanks for support

Ideas

  • Using a small trick to map the hex string password representation with OpenCL kernel numeric global id at a low cost in performance, so this code does not "generate" password in memory thus uses little (video and main) memory.
  • Reasonably divide the tasks of CPU and GPU, avoid large data transfer between devices.

Issues

  • Tested with : Intel Core i5 8300H, NVIDIA GTX 1050 Ti(As OpenCL platform) on Windows 10.
  • Tested with : Intel Xeon E3 1231 V3, NVIDIA RTX 2070(As OpenCL platform) on Windows 10.
  • AMD APP SDK is not supported because the AMD OpenCL compiler will wrongly parse the marcos in OpenCL code, thus get mistaken result. Theoritically you can replace the marcos with real functions to solve the problem, as all OpenCL functions will get inlined so no overhead would appear, but I have not practically tested this.
  • Only support maximum 16 chars for password with hex chars ranged from 0-9,a-f.
  • Commandline parser and distributed cracking is being developed, will be released soon.
  • More decryption algorithm of sqlcipher and its variant is considered for future development.

About

Password cracker for SQLCipher v2 using OpenCL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published