Skip to content

About

Project for UFCD 9190: Introduction to programming applied to cybersecurity

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

UFCD 9190: Syms Utility & PyCracker

A project for UFCD 9190: Introduction to Programming Applied to Cybersecurity


πŸ“„ Overview

This project is part of UFCD 9190: Introduction to Programming Applied to Cybersecurity. It includes two main utilities:

  • syms.py: A script to identify and group duplicate files in a directory based on specific criteria.
  • pycracker.py: A password-cracking utility designed to work with files formatted like /etc/shadow.

Features of syms.py:

  • Identify duplicate files by name.
  • Group files by extension.
  • Check for duplicate binary content (e.g., identical files).
  • Use regex patterns to filter specific files.

Features of pycracker.py:

  • Cracks password hashes using a dictionary file.
  • Supports multiple hashing algorithms like SHA-512, SHA-256, MD5, and bcrypt.
  • Validates account statuses, ignoring locked or invalid accounts.
  • Verbose output for better debugging and analysis.

The scripts demonstrate real-world applications of Python for file and cybersecurity tasks. They include proper error handling, support for multiple hashing schemes, and the ability to adapt to various input file structures.


πŸš€ Usage Instructions

πŸ› οΈ Preparing the Scripts

To make the scripts executable, set the correct file permissions:

chmod 755 src/syms.py
chmod 755 src/pycracker.py

After setting the permissions, you can run the scripts directly:

./src/syms.py [OPTIONS] [DIR_PATH]
./src/pycracker.py [DICTIONARY] [PASSWORDS]

Alternatively, you can run the scripts using Python:

python src/syms.py
python src/pycracker.py

πŸ’‘ Example Commands for syms.py

Here are some examples using the tests directory:

1. Group Files by Name:

./src/syms.py -n tests

2. Group Files by Extension:

./src/syms.py -e tests

3. Group Files by Content:

./src/syms.py -c tests

4. Search Using Regex:

Find all files in tests starting with "test" or "Test" and ending with .txt:

./src/syms.py -r '^(test|Test).*\.txt$' tests

5. Display Help:

./src/syms.py --help

πŸ’‘ Example Commands for pycracker.py

1. Crack All Passwords:

Run pycracker.py with a dictionary file and a shadow-like password file:

python src/pycracker.py ../tests/dict.txt ../tests/shadow.txt

Output:


[+]  jgalamba  : 'Lmxy20#a'        (SHA-512)
[+]  formando  : 'abc'            (SHA-256)

2. Crack Passwords for a Specific User:

Use the -u flag to target a specific user:

python src/pycracker.py ../tests/dict.txt ../tests/shadow.txt -u jgalamba

Output:


[+]  jgalamba  : 'Lmxy20#a'        (SHA-512)

3. Enable Verbose Output:

Use the -v flag to see additional debug information:

python src/pycracker.py ../tests/dict.txt ../tests/shadow.txt -v

Output:


[!] Skipping user root: Account status is BLOCKED
[+]  jgalamba  : 'Lmxy20#a'        (SHA-512)

4. Display Help:

python src/pycracker.py --help

πŸŒ€ Virtual Environment Management

This project uses a Python virtual environment for managing dependencies. Follow these steps:

1. Create the Virtual Environment:

python3 -m venv .venv

2. Activate the Virtual Environment:

To activate the environment, run:

On macOS/Linux:
source .venv/bin/activate
On Windows:
.venv\Scripts\activate

3. Deactivate the Virtual Environment:

To deactivate the environment:

deactivate

4. Reactivate the Virtual Environment:

If the terminal is closed, navigate to the project directory and activate it again using the commands above.


⚠️ Troubleshooting

If you encounter zsh: permission denied: .venv/bin/activate, follow these steps:

  1. Check permissions:
        chmod +x .venv/bin/activate
        
  2. Reactivate the environment:
        source .venv/bin/activate
        
  3. If the issue persists, recreate the virtual environment:
        
        rm -rf .venv
        python3 -m venv .venv
        source .venv/bin/activate
        
        

πŸ“¦ Requirements

1. Install Required Libraries

After activating the virtual environment, install the dependencies:

pip install docopt passlib cryptography

To avoid conflicts, use the following command if needed:

python3 -m pip install passlib

2. Use a requirements.txt File

Alternatively, you can install all dependencies from the requirements.txt file:

pip install -r requirements.txt

4. Recommended Development Tools

To maintain code quality and ensure consistent formatting, the following tools are recommended:

  • Black: A Python code formatter that enforces PEP 8 compliance.
        pip install black
        
  • Flake8: A Python linter for checking code style and potential errors.
        pip install flake8
        

To apply Black and check linting, use the following commands:


# Format all files with Black
black .

# Check for linting issues with Flake8
flake8 .


πŸ“‚ Future Work

In addition to syms.py, the repository includes the pycracker.py utility, which is currently under development. This script aims to perform password cracking using dictionaries and hash comparisons. Stay tuned for its progress!


πŸ’» Recommended Extensions

For an optimized development experience in VS Code, we recommend the following extensions:

  • Python: Provides IntelliSense, debugging, and tool integration. Install via:
    code --install-extension ms-python.python
  • Pylance: Adds enhanced IntelliSense and type-checking. Install via:
    code --install-extension ms-python.vscode-pylance

Project-specific recommendations are included in the .vscode/extensions.json file.


Made with ❀️ for UFCD 9190.

About

Project for UFCD 9190: Introduction to programming applied to cybersecurity

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages