﻿ Python program for simulating dictionary attack on password

# Python Cyber Security - Program for simulating dictionary attack on password

## Python Cyber Security: Exercise-9 with Solution

Write a Python program that simulates a dictionary attack on a password by trying out a list of commonly used passwords and their variations.

Note: This is a simple example and for educational purposes only and is not intended to be used for illegal purposes. In real-world scenarios, password attacks should only be carried out with explicit permission from the system owner being attacked.

Sample Solution:

Python Code:

import hashlib
# List of commonly used passwords and their variations
password_variations = ["", "123", "1234", "12345", "123456", "!", "@", "#", "\$", "%", "^", "&", "*", "(", ")", "-", "_", "+", "=", "/", "\\", "|", "[", "]", "{", "}", "<", ">"]
# Hash of the password to be attacked
# Try out all possible combinations of common passwords and their variations
break
else:
continue
break
else:

Sample Output:

Explanation:

In the above exercise, we first define a list of commonly used passwords and their variations. We then define the hash of the password we want to attack (in this example, "mypass12#@" is hashed using SHA-256).

We then use a nested loop to try out all possible combinations of common passwords and their variations. For each combination, we hash the password using SHA-256 and check if it matches the hashed password we want to attack. If a match is found, we print the password and exit the loop. If no match is found, we print a message indicating that the password was not available.

Note:

Possible passwords generated the said program.
[email protected]
[email protected]
letmein
letmein123
letmein1234
letmein12345
letmein123456
letmein!
[email protected]
letmein#
letmein\$
letmein%
letmein^
letmein&
letmein*
letmein(
letmein)
letmein-
letmein_
letmein+
letmein=
letmein/
letmein\
letmein|
letmein[
letmein]
letmein{
letmein}
letmein<
letmein>
qwerty
qwerty123
qwerty1234
qwerty12345
qwerty123456
qwerty!
[email protected]
qwerty#
qwerty\$
qwerty%
qwerty^
qwerty&
qwerty*
qwerty(
qwerty)
qwerty-
qwerty_
qwerty+
qwerty=
qwerty/
qwerty\
qwerty|
qwerty[
qwerty]
qwerty{
qwerty}
qwerty<
qwerty>
123456
123456123
1234561234
12345612345
123456123456
123456!
[email protected]
123456#
123456\$
123456%
123456^
123456&
123456*
123456(
123456)
123456-
123456_
123456+
123456=
123456/
123456\
123456|
123456[
123456]
123456{
123456}
123456<
123456>
abc123
abc123123
abc1231234
abc12312345
abc123123456
abc123!
[email protected]
abc123#
abc123\$
abc123%
abc123^
abc123&
abc123*
abc123(
abc123)
abc123-
abc123_
abc123+
abc123=
abc123/
abc123\
abc123|
abc123[
abc123]
abc123{
abc123}
abc123<
abc123>
[email protected]
welcome
welcome123
welcome1234
welcome12345
welcome123456
welcome!
[email protected]
welcome#
welcome\$
welcome%
welcome^
welcome&
welcome*
welcome(
welcome)
welcome-
welcome_
welcome+
welcome=
welcome/
welcome\
welcome|
welcome[
welcome]
welcome{
welcome}
welcome<
welcome>
monkey
monkey123
monkey1234
monkey12345
monkey123456
monkey!
[email protected]
monkey#
monkey\$
monkey%
monkey^
monkey&
monkey*
monkey(
monkey)
monkey-
monkey_
monkey+
monkey=
monkey/
monkey\
monkey|
monkey[
monkey]
monkey{
monkey}
monkey<
monkey>
sunshine
sunshine123
sunshine1234
sunshine12345
sunshine123456
sunshine!
[email protected]
sunshine#
sunshine\$
sunshine%
sunshine^
sunshine&
sunshine*
sunshine(
sunshine)
sunshine-
sunshine_
sunshine+
sunshine=
sunshine/
sunshine\
sunshine|
sunshine[
sunshine]
sunshine{
sunshine}
sunshine<
sunshine>

Flowchart:

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

﻿

## Python: Tips of the Day

Decapitalizes the first letter of a string:

Example:

def tips_decapitalize(s, upper_rest=False):
return s[:1].lower() + (s[1:].upper() if upper_rest else s[1:])
print(tips_decapitalize('PythonTips'))
print(tips_decapitalize('PythonTips', True))

Output:

pythonTips
pYTHONTIPS

We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook