Rust-based HTTP server to query local Have I Been Pwned password data.
10K+
This project creates a lightweight webserver written in Rust that allows you to query your large local pwnedpasswords.txt file using an API similar to https://api.pwnedpasswords.com/range/FFFFF.
Note: While it mimics the behavior of the original API, it is not a complete drop-in replacement. For example, the server does not truncate the first 5 characters of the hash in the response.
Importing a massive file like pwnedpasswords.txt into an existing database (e.g., MySQL or PostgreSQL) can be time-consuming and require significant disk space.
With hibpd, you can work directly with your existing text file and a small index file, avoiding the need for full database imports.
You might need this if you:
hibpd compresses and optimizes the file to reduce storage requirements further.
hibpd is designed to be fast when running on an SSD. Although formal benchmarks aren't available (yet), it responds to queries almost instantly.
The server is written in Rust, which provides strong memory safety guarantees. However, it is not designed to be publicly accessible in its current state.
Download the pwnedpasswords.txt file. Ensure the hashes in the file are sorted alphabetically (they usually are by default).
Run the following command:
Standalone
hibpd index pwnedpasswords.txt plain pwnedpasswords.index
Using Docker
docker run -v /directory/with/your/pwnedpasswords.txt/:/data keptdream/hibpd index /data/pwnedpasswords.txt plain /data/pwnedpasswords.index
Standalone
hibpd serve
Using Docker
docker run -v /directory/with/your/pwnedpasswords.txt/:/var/lib/hibpd/ -p 8080:8080 keptdream/hibpd
Query the API just like the original HIBP API:
http://localhost:8080/range/FFFFF
The output will look like this:
000000005AD76BD555C1D6D771DE417A4B87E4B4:10
00000000A8DAE4228F821FB418F59826079BF368:4
00000000DD7F2A1C68A35673713783CA390C9E93:876
00000001E225B908BAC31C56DB04D892E47536E0:6
00000006BAB7FC3113AA73DE3589630FC08218E7:3
00000008C4037D3E893F8E1FA7BAD32B9F60948C:3
00000008CD1806EB7B9B46A8F87690B2AC16F617:6
...
This implementation is not a complete drop-in replacement for the original HIBP API. It does not truncate the first 5 characters of the hash in the response. Keep this in mind when integrating it into your workflows.
The tool can also be used directly from the command line to query specific hash ranges:
Standalone
hibpd range 00000
Using Docker
docker run -v /directory/with/your/pwnedpasswords.txt/:/var/lib/hibpd/ -p 8080:8080 keptdream/hibpd range 00000
HIBPD_INDEX=/var/lib/hibpd/pwnedpasswords.index # Index file location
HIBPD_DATABASE=/var/lib/hibpd/pwnedpasswords.txt # Database file location
HIBPD_DATABASE_TYPE=plain # Options: plain or bgzf
HIBPD_SERVER_X_HOST=0.0.0.0 # Server host
HIBPD_SERVER_X_PORT=8080 # Server port
hibpd supports bgzf-compressed files, which can reduce the size of pwnedpasswords.txt by approximately 50%.
Compress the file:
Standalone
hibpd convert pwnedpasswords.txt pwnedpasswords.bgzf bgzf
Using Docker
docker run -v /directory/with/your/pwnedpasswords.txt/:/data keptdream/hibpd convert /data/pwnedpasswords.txt /data/pwnedpasswords.bgzf bgzf
Create a new index for the compressed file:
Standalone
hibpd index pwnedpasswords.bgzf bgzf pwnedpasswords.bgzf.index
Using Docker
docker run -v /directory/with/your/pwnedpasswords.txt/:/data keptdream/hibpd index /data/pwnedpasswords.bgzf bgzf /data/pwnedpasswords.bgzf.index
Update your configuration and enjoy the reduced file size!
You can modify the configuration file at /etc/hibpd/config.toml if needed:
database_type = "plain"
database = "/var/lib/hibpd/pwnedpasswords.txt"
index = "/var/lib/hibpd/pwnedpasswords.index"
[server]
host = "0.0.0.0"
port = 8080
This tool is provided as-is and free of charge, without any warranty or guarantee of functionality, accuracy, or security. Use it at your own risk. The developer assumes no responsibility for any damages, data loss, or issues that may arise from using this software.
Additionally, this project is not affiliated with Troy Hunt or the official Have I Been Pwned (HIBP) service. It is an independent tool inspired by the concept of querying password breach data.
Content type
Image
Digest
sha256:a82b41312…
Size
34.6 MB
Last updated
over 1 year ago
docker pull keptdream/hibpd