0% found this document useful (0 votes)
14 views6 pages

PRO-C223: What Is Our GOAL For This CLASS?

The class focused on Cybersecurity, specifically on gaining access to password-protected files using brute force techniques. Students learned to use Python libraries such as PyPDF2 and zipfile to retrieve passwords from PDF and zip files. The session concluded with a successful demonstration of password recovery methods and a preview of the next class topic on phishing.

Uploaded by

luniyalovekush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views6 pages

PRO-C223: What Is Our GOAL For This CLASS?

The class focused on Cybersecurity, specifically on gaining access to password-protected files using brute force techniques. Students learned to use Python libraries such as PyPDF2 and zipfile to retrieve passwords from PDF and zip files. The session concluded with a successful demonstration of password recovery methods and a preview of the next class topic on phishing.

Uploaded by

luniyalovekush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

PRO-C223

Introduction to Cyber Security

What is our GOAL for this CLASS?


In this class, we have learned about Cybersecurity and will try to gain access to password
protected files

What did we ACHIEVE in the class TODAY?


● Understand about Cyber Security
● Using brute force, retrieve the password for the PDF file
● Using brute force attack to recover the password for protected zip files

Which CONCEPTS/ CODING BLOCKS did we cover today?

● We used the libraries, PyPDF2, zipfile, time


● We used methods pdfReader.decrypt(word),zf.extractall

Understanding concepts:
PRO-C223

Cyber Security:
Cyber security refers to the technologies, processes, and practices designed to
protect networks, devices, programs, and data from attack, damage, or unauthorized
access.
Brute Force Attack:
A brute force attack uses trial-and-error to guess user passwords. In brute force attack, a
list of commonly used passwords is used against a user account or protected documents,
such as 123456, password123, qwerty, abc123 or it runs an algorithm against an encrypted
password.

How did we DO the activities?


1. Create an encrypted folder: Steps to set a password for the folder
● Create a new folder and insert a text file, a pdf file, or an image on which you
will set a password, but make sure that the folder is not empty
● Right-click on the folder and add to the archive by clicking on zip
● Select Archive format zip on the left top side
● On the right side, there is an Encryption option, write down a 4-digit
password using numbers and small alphabets only

2. The zipfile module :Python has an inbuilt module named zipfile that can be used to
access zip files. Open the terminal and install the dependencies

● Import zipfile
● Import time to check the time to decode the password
● Get the folder path using input
● Initialize zipfile object

● Write the if statement to check if the folder is password protected or not, if not
then print the message.
● Else start the timer, initialize a variable result with ‘0’ will indicate Failure,
while ‘1’ will indicate Success
● Initialize a variable c to keep the count of passwords tried
● Build a character array including all numbers, lowercase letters
● Print “Brute Force started”
PRO-C223

3. Logic to generate four digit password and check the result:


● To generate four digit password
○ “i” loop is used to get first character from array and
○ then it will make possible combination with “j” loop,
○ “k” loop and
○ “l” loop
● After getting all possible combinations it will save all the four digit-character
combinations into guess variable
● Print the guess
● Increment the variable c by 1
● Now in try use “Open” a ZIP file, where file can be a path to a file
● The mode parameter should be “ r “ to read an existing file, “zf.extractall”
members from the archive to the current working directory.
● pwd is the password used for encrypted files.
● After getting the correct password print “Success” Message and stop the
timer and result variable set to be 1 as its true condition.
● In case of success, break the “i” loop
● In case of an exception, pass it.
● If the password is found, break from ”j” for loop, similarly “k” and “l” loop too.
PRO-C223

● If no four-character password is found, print the password not found along with the
time and number of times it was tried.
● Else password found, print the duration and display the number of times the password
has been tried along with congratulation message

4. Import PyPDF2 library for pdf reader

● Get the folder path using input


● By default, the open() function opens a file in text format. Add to the mode
parameter to open a binary file. As a result, the mode opens the file in binary
format for reading
● Using if statement check if the pdf is password protected or not, if not then
print the message
PRO-C223

● Else its password protected then initialize the variable wordlist. File,open the
file “wordlist.txt”, ”r” represents read mode and ignore errors if any.
● Intilalize the body variable as a reference to wordListFile content.lower()
function will convert and read all characters in lower case only.
● Use split() function to fetch different passwords on different lines and store it
in an array with name words.

● Apply a for loop on words which will iterate till the length of the array
“words”.
● Initialize the current value of array in variable “word”.
● pdfReader.decrypt(word) function will try to decrypt the password encrypted
file using the current value of word as password.
● The result of the same will be stored in the variable result.
● If the function is able to decrypt the file successfully it will return the value of
result as 1 and the break keyword will break the for loop,
● Else the value of result will be 0 and it will continue to the next word in array
words.
● Print the value of the result.
PRO-C223

5. While running the program needs to get a folder path. Right click on the folder whose
password you want to decode, check the location, copy the location path followed by
the folder name.
Hence we cracked the password.

We have successfully learned to gain access to password protected files

What’s NEXT?
In the next class we will be learning about phishing.

Expand Your Knowledge


To learn more about bruteforce attack click here

You might also like