Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@ Files are:
(1) Bank account statement
(2) Few certificates
where the first four letters are first four letters of your name along with your date and month of birthdate.

- This code uses MPI to perform coordinated parallel guesses using multiple processors.
- This is ideal for guessing long passwords with brute force using supercomputers.

Use Python (tested with version `3.10`) to run this
- [Optional] Create and use virtual environment: `python -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt`
- Run the code: `time mpiexec -n <num_procs> python guess_pdfPass-parallel.py`

> Dependency: qpdf (https://github.com/qpdf/qpdf), tested with version 11.9.1. Make sure `qpdf` and its libraries are added to `PATH` and `LD_LIBRARY_PATH` respectively.
40 changes: 40 additions & 0 deletions guess_pdfPass-parallel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 16 21:57:11 2024
@author: alankar
Usage: time mpiexec -n <num_procs> python guess_pdfPass-parallel.py
Dependency: qpdf (https://github.com/qpdf/qpdf), tested with version 11.9.1
Note: Make sure qpdf and its libraries are added to PATH and LD_LIBRARY_PATH respectively
Thanks: Samriddhi Sankar Maity
- This code uses MPI to perform coordinated parallel guesses using multiple processors.
- This is ideal for guessing long passwords with brute force using supercomputers
"""

import subprocess as sp
from mpi4py import MPI
from itertools import product

## start parallel programming ---------------------------------------- #
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()

verbose = False

initial_known_pass = "9899"

input_file = "sample.pdf"
output_file = "sample-decrypt.pdf"

# trying to guess unknown 6 digits
tries = list(product(range(10),range(10),range(10),range(10),range(10),range(10)))

for i in range(rank, len(tries), size):
guess_pass = "".join(str(x) for x in tries[i])
text = sp.getoutput(f'qpdf -password="{initial_known_pass}{guess_pass}" -decrypt {input_file} {output_file}')
if verbose:
print(f"{initial_known_pass}{guess_pass}: {text}", flush=True)
if "invalid password" not in text:
print(f"Password found: {initial_known_pass}{guess_pass}", flush=True)
comm.Abort()
print("Set settings failed to guess the password.")
20 changes: 0 additions & 20 deletions pdf_passwd.sh

This file was deleted.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mpi4py==3.1.5 ; python_version >= "3.10" and python_version < "4.0"