-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb6ef7c
commit f1898ac
Showing
4 changed files
with
107 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$pdf$5*6*256*-4*1*16*fce2fe96b7e142b4a0576f61e2e9c441*48*aef6c4bf5e8a0f3bb1adef2b8ac2367d1ce95ecc1ddc3243ce49786086a023aa310aa9f7d1d103f837e4d4f738ac913d*48*eabf37f3f1f1b208f7c8ddfad3b817c689889ecbadd30f4581382cfbf79806304fb438e9ca227a023138a38eadcf82f3*32*37afcbfcbb32d4e1bca1eb10165693a1633ebb742c00045177a284ba22196937*32*3459a644d5f4c4f7cee562b754b30df48d598e1911ea513ef29bb3928593caf3 | ||
Encryption Dictionary: | ||
/CF: {'/StdCF': {'/AuthEvent': '/DocOpen', '/CFM': '/AESV3', '/Length': 32}} | ||
/Filter: /Standard | ||
/Length: 256 | ||
/O: b'\xea\xbf7\xf3\xf1\xf1\xb2\x08\xf7\xc8\xdd\xfa\xd3\xb8\x17\xc6\x89\x88\x9e\xcb\xad\xd3\x0fE\x818,\xfb\xf7\x98\x060O\xb48\xe9\xca"z\x0218\xa3\x8e\xad\xcf\x82\xf3' | ||
/OE: b'7\xaf\xcb\xfc\xbb2\xd4\xe1\xbc\xa1\xeb\x10\x16V\x93\xa1c>\xbbt,\x00\x04Qw\xa2\x84\xba"\x19i7' | ||
/P: -4 | ||
/Perms: b'\x00\xe2p@\xe8I\xe5\xc8\xcd^\xb1\x8c\xba\x99\xceI' | ||
/R: 6 | ||
/StmF: /StdCF | ||
/StrF: /StdCF | ||
/U: b'\xae\xf6\xc4\xbf^\x8a\x0f;\xb1\xad\xef+\x8a\xc26}\x1c\xe9^\xcc\x1d\xdc2C\xceIx`\x86\xa0#\xaa1\n\xa9\xf7\xd1\xd1\x03\xf87\xe4\xd4\xf78\xac\x91=' | ||
/UE: b'4Y\xa6D\xd5\xf4\xc4\xf7\xce\xe5b\xb7T\xb3\r\xf4\x8dY\x8e\x19\x11\xeaQ>\xf2\x9b\xb3\x92\x85\x93\xca\xf3' | ||
/V: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import subprocess | ||
|
||
|
||
def run_cli(args, input_text=None): | ||
process = subprocess.Popen( | ||
["python3", "pdf2john.py"] + args, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
stdin=subprocess.PIPE, | ||
text=True, | ||
) | ||
stdout, stderr = process.communicate(input_text) | ||
return process, stdout, stderr | ||
|
||
|
||
def test_cli_extraction(): | ||
pdf_file = "tests/pdf/r6-test-bad-password.pdf" | ||
process, stdout, _ = run_cli([pdf_file]) | ||
|
||
expected = "$pdf$5*6*256*-4*1*16*fce2fe96b7e142b4a0576f61e2e9c441*48*aef6c4bf5e8a0f3bb1adef2b8ac2367d1ce95ecc1ddc3243ce49786086a023aa310aa9f7d1d103f837e4d4f738ac913d*48*eabf37f3f1f1b208f7c8ddfad3b817c689889ecbadd30f4581382cfbf79806304fb438e9ca227a023138a38eadcf82f3*32*37afcbfcbb32d4e1bca1eb10165693a1633ebb742c00045177a284ba22196937*32*3459a644d5f4c4f7cee562b754b30df48d598e1911ea513ef29bb3928593caf3" | ||
# Check if the exit code indicates success (assuming no errors occurred) | ||
assert process.returncode == 0 | ||
assert stdout == expected + "\n" | ||
|
||
|
||
def test_handle_multiple_files(): | ||
pdf_files = [ | ||
"tests/pdf/r6-test-bad-password.pdf", | ||
"tests/pdf/pypdf/r6-user-password.pdf", | ||
] | ||
process, stdout, _ = run_cli(pdf_files) | ||
|
||
expected = [ | ||
"$pdf$5*6*256*-4*1*16*fce2fe96b7e142b4a0576f61e2e9c441*48*aef6c4bf5e8a0f3bb1adef2b8ac2367d1ce95ecc1ddc3243ce49786086a023aa310aa9f7d1d103f837e4d4f738ac913d*48*eabf37f3f1f1b208f7c8ddfad3b817c689889ecbadd30f4581382cfbf79806304fb438e9ca227a023138a38eadcf82f3*32*37afcbfcbb32d4e1bca1eb10165693a1633ebb742c00045177a284ba22196937*32*3459a644d5f4c4f7cee562b754b30df48d598e1911ea513ef29bb3928593caf3", | ||
"$pdf$5*6*256*-4*1*16*fce2fe96b7e142b4a0576f61e2e9c441*48*ae700c793d687882958ce411fed797a6364e182dc4cb8c3819d347b9d577c3526d9fd5c2b9fe54cfed6539accc53ac28*48*57c08f4d2b7e02a2eb6deabf903267643bd971f5201ed5e1865311001c05d012e7a9dea18e3de1aa35675d0069944da1*32*ec81dd84bd5492acdcd5f82cd3093427d2db0eace3789f0f39c65ebea10253dd*32*557c4e6be3cc2bd0166a1b1ab3b0e09d6f0e3f5d17d305925c7055116ac14c6c", | ||
] | ||
# Check if the exit code indicates success (assuming no errors occurred) | ||
assert process.returncode == 0 | ||
assert stdout.split("\n")[:2] == expected | ||
|
||
|
||
def test_cli_debug(): | ||
pdf_file = "tests/pdf/r6-test-bad-password.pdf" | ||
process, stdout, _ = run_cli([pdf_file, "--debug"]) | ||
assert process.returncode == 0 | ||
|
||
with open("tests/debug_output.txt", "r") as file: | ||
lines = file.readlines() | ||
assert stdout == "".join(lines) |