Python में libraries का एक समृद्ध संग्रह है जिनका उपयोग multiple purposes के लिए किया जाता है जैसे applications बनाना और develop करना, web development, scientific computation, software testing, machine learning, और बहुत कुछ। Python का उपयोग information security के संदर्भ में system applications को test और develop करने के लिए भी किया जाता है। कई अन्य libraries और tools उपलब्ध हैं जिनमें hashes बनाना, information gathering, information retrieval, encryption और decryption, web crawling, spoofing, और बहुत कुछ के लिए specific scripts होती हैं।
इस लेख में, हम एक program बनाएंगे जो password protected PDF document को decrypt करेगा। Decryption के लिए, हम एक word list का उपयोग करेंगे जिसमें कुछ common passwords होंगे और यह pdf document को decrypt करने में मदद करेगा।
PDF cracker बनाने के लिए, हम pikepdf library import करेंगे। एक बार download होने पर, हम इसे अपने notebook में include कर सकते हैं। Reference के लिए, हम इस wordlist का उपयोग उदाहरण के रूप में करेंगे जिसमें 5000 common passwords हैं।
उदाहरण
import pikepdf
from tqdm import tqdm
# Loading password list
password = [line.strip() for line in open("wordlist.txt")]
# Iterate over all the passwords
for paswrd in tqdm(password, "Cracking PDF"):
try:
# Open PDF file
with pikepdf.open("protected.pdf", password=paswrd) as pdf:
# If password matches then break the loop and print the output
print("Password found:", paswrd)
break
except pikepdf._qpdf.PasswordError as e:
# If password not found then continue
continue
आउटपुट
उपरोक्त code चलाने से पहले password ढूंढेगा और फिर इसे output के रूप में print करेगा।
