-
Notifications
You must be signed in to change notification settings - Fork 14
/
pdfcrack.py
87 lines (84 loc) · 3.11 KB
/
pdfcrack.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import os
import platform
import time
print("[*] Checking Requirements Module....")
def header():
ascii_banner = pyfiglet.figlet_format("{PDF CRACKER}").upper()
print(colored(ascii_banner.rstrip("\n"), 'cyan', attrs=['bold']))
print(colored(" <Coded By: Clay> \n", 'yellow', attrs=['bold']))
print(colored(" <Version: 2.0> \n", 'magenta', attrs=['bold']))
return
if platform.system().startswith("Windows"):
try:
import pikepdf
except ImportError:
os.system("python -m pip install pikepdf -q -q -q")
import pikepdf
try:
from tqdm import tqdm
except ImportError:
os.system("python -m pip install tqdm -q -q -q")
from tqdm import tqdm
try:
import termcolor
except ImportError:
os.system("python -m pip install termcolor -q -q -q")
import termcolor
from termcolor import colored
try:
import pyfiglet
except ImportError:
os.system("python -m pip install pyfiglet -q -q -q")
import pyfiglet
elif platform.system().startswith("Linux"):
try:
import pikepdf
except ImportError:
os.system("python3 -m pip install pikepdf -q -q -q")
import pikepdf
try:
from tqdm import tqdm
except ImportError:
os.system("python3 -m pip install tqdm -q -q -q")
from tqdm import tqdm
try:
import termcolor
except ImportError:
os.system("python3 -m pip install termcolor -q -q -q")
import termcolor
from termcolor import colored
try:
import pyfiglet
except ImportError:
os.system("python3 -m pip install pyfiglet -q -q -q")
import pyfiglet
def crack():
os.system('cls' if os.name == 'nt' else 'clear')
header()
pdf_filename = input(termcolor.colored("[*] Enter Path Of Your PDF file:- ", 'cyan'))
if not os.path.exists(pdf_filename):
print(termcolor.colored("\n[ X ] File " + pdf_filename + " was not found, Provide Valid FileName And Path!",
'red'))
exit()
print(termcolor.colored("\n[*] Analyzing PDF File:- ", 'blue'), pdf_filename)
time.sleep(1)
if pdf_filename[-3:] == "pdf":
print(termcolor.colored("\n[ ✔ ] Valid PDF File Found...", 'green'))
else:
print(termcolor.colored("\n[ X ] This is not a valid .pdf file...\n", 'red'))
exit()
pwd_filename = input(termcolor.colored("\nEnter Path Of Your Wordlist:- ", 'yellow'))
if not os.path.exists(pwd_filename):
print(termcolor.colored("\n[ X ] File " + pwd_filename + " was not found, Provide Valid FileName And Path!",
'red'))
exit()
hello = [line.strip() for line in open(pwd_filename)]
for cra in tqdm(hello, f"Cracking PDF File->{pdf_filename}:-"):
try:
with pikepdf.open(pdf_filename, password=cra) as pdf:
print(colored("\n[ ✔ ] PDF FILE Password Found:- ", 'cyan'), cra)
break
except pikepdf._qpdf.PasswordError as e:
print()
continue
crack()