• Coding

    Python Learning: Automate Boring Stuff with Python | Chapter 13: Brute-Force PDF Password Breaker

    “I can stand brute force, but brute reason is quite unbearable. There is something unfair about it’s use. It is hitting below the intellect.” ― Oscar Wilde, The Picture of Dorian Gray I don’t get it.. 11:20:21 PM   [sourcecode language=”python”] #USAGE python brute_force.py <pdfFile> import PyPDF2, os, sys, logging logging.basicConfig(level=logging.DEBUG, format="%(asctime)s – %(levelname)s – %(message)s") if len(sys.argv) == 2: #TODO: GET PDF FILE filename = sys.argv[1] filename = os.path.abspath(filename) #TODO: CHECK IF EXISTS if not os.path.exists(filename): logging.error("File: " + str(filename) + " does not exist") else: #TODO: GET DICTIONARY dict = open(os.path.abspath(".\\automate\\dictionary.txt"), "r") #TODO: CREATE PDF READER fileRead = open(filename, "rb") pdfReader = PyPDF2.PdfFileReader(fileRead) #TODO: LOOP THROUGH WORDS for word…

  • Coding

    Python Learning: Automate Boring Stuff with Python | Chapter 13: Custom Invitations as Word Documents

    “Nothing annoys people so much as not receiving invitations.” ― Oscar Wilde, The Importance of Being Earnest I know that feeling…humph.. 10:36:20 PM   [sourcecode language=”python”] #usage python invitation.py <textFile> import docx, os, sys, logging from docx.enum.text import WD_ALIGN_PARAGRAPH logging.basicConfig(level=logging.DEBUG, format="%(asctime)s – %(levelname)s – %(message)s") if len( sys.argv ) == 2: #TODO: GET TEXT FILE textFileName = sys.argv[1] textFileName = os.path.abspath(textFileName) #TODO: TEST IF EXISTS if not os.path.exists(textFileName): logging.error("File does not exist") raise #TODO: READ FILE file = open(textFileName) #TODO: CREATE DOCX OBJECT doc = docx.Document() names = file.readlines() for name in names: name = name.strip() #TODO: CREATE INVITATION PER NAME p = doc.add_paragraph("", "Normal") p.alignment = WD_ALIGN_PARAGRAPH.CENTER p.add_run("It would be…

error: Content is protected !!