This is a password cracker application designed to crack hashed passwords using various strategies: numbers-only, uppercase with numbers, dictionary-based, and a combination for harder passwords. The application is built with PHP, JavaScript, and MySQL, and is intended to run in a Docker environment.
- Easy: Cracks numbers-only passwords (5 digits).
- Medium: Cracks uppercase + number passwords (e.g., EII9) and dictionary-based passwords (e.g., london).
- Hard: Cracks all passwords, including mixed patterns (e.g., AbC12z).
new-cracker/
├── config/
│ └── .env # Environment variables
├── data/
│ ├── dictionary.txt # Dictionary words for cracking
│ └── init.sql # Database initialization script
├── logs/
│ ├── password_cracker.log # Application logs
│ └── php_error.log # PHP error logs
├── public/
│ ├── index.php # Main entry point
│ ├── app.js # Front-end JavaScript
│ └── styles.css # CSS styles
├── scripts/
│ └── import_database.php # Script to import database
├── src/
│ ├── autoload.php # Autoloader for PHP classes
│ ├── Api/
│ │ └── PasswordCrackerApi.php
│ ├── Core/
│ │ ├── Database.php
│ │ ├── Logger.php
│ │ └── Config.php
│ └── Strategies/
│ ├── BaseCracker.php
│ ├── NumbersCracker.php
│ ├── UppercaseNumberCracker.php
│ ├── DictionaryCracker.php
│ └── HardCracker.php
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose configuration
└── README.md # Project documentation
- Docker and Docker Compose installed on your system.
- Windows: Ensure WSL2 is enabled for better Docker performance.
- Basic understanding of Docker commands.
-
Clone or Place the Project:
- Place the
new-crackerfolder in your desired directory (e.g.,/path/to/new-cracker).
- Place the
-
Configure Environment Variables:
- Ensure the
config/.envfile exists with the following content:DB_HOST=db DB_NAME=password_cracker DB_USER=root DB_PASS=rootpassword LOG_FILE=/var/www/html/logs/password_cracker.log DICTIONARY_FILE=/var/www/html/data/dictionary.txt PASSWORD_SALT=ThisIs-A-Salt123 - Note:
DB_HOSTis set todb(the service name indocker-compose.yml), andDB_PASSis set torootpasswordfor the MySQL container.
- Ensure the
-
Create a
Dockerfile:- In the
new-crackerdirectory, create aDockerfilewith the following content:FROM php:8.1-apache # Install PDO MySQL extension RUN docker-php-ext-install pdo_mysql # Copy application files COPY . /var/www/html/ # Set working directory WORKDIR /var/www/html # Set permissions for logs directory RUN chown -R www-data:www-data /var/www/html/logs \ && chmod -R 775 /var/www/html/logs # Enable Apache rewrite module RUN a2enmod rewrite # Expose port 80 EXPOSE 80
- In the
-
Create a
docker-compose.yml:- In the
new-crackerdirectory, create adocker-compose.ymlwith the following content:version: '3.8' services: app: build: context: . dockerfile: Dockerfile ports: - "8080:80" volumes: - .:/var/www/html depends_on: - db networks: - app-network db: image: mysql:8.0 environment: MYSQL_ROOT_PASSWORD: rootpassword MYSQL_DATABASE: password_cracker volumes: - db-data:/var/lib/mysql - ./data/init.sql:/docker-entrypoint-initdb.d/init.sql networks: - app-network networks: app-network: driver: bridge volumes: db-data:
- In the
-
Import the Database:
- Run the following command to import the database using the provided script:
php scripts/import_database.php --host=localhost --user=root --password='rootpassword' --database=password_cracker --file='data/init.sql'
- This script initializes the MySQL database with the schema and data from
data/init.sql.
- Run the following command to import the database using the provided script:
-
Build and Run the Docker Containers:
- Navigate to the
new-crackerdirectory:cd /path/to/new-cracker - Build and start the containers:
docker-compose up -d --build
- This will:
- Build the PHP-Apache container (
app). - Start a MySQL container (
db) and initialize the database usingdata/init.sql. - Map port
8080on your host to port80in the container.
- Build the PHP-Apache container (
- Navigate to the
-
Verify the Containers:
- Check that the containers are running:
docker-compose ps
- You should see
new-cracker-app-1andnew-cracker-db-1in theUpstate.
- You should see
- Check that the containers are running:
-
Access the Application:
- Open your browser and navigate to
http://localhost:8080/public/. - You should see the Password Cracker interface with three buttons: "Crack Easy," "Crack Medium," and "Crack Hard."
- Open your browser and navigate to
-
Crack Passwords:
- Click each button to crack passwords:
- Crack Easy: Cracks numbers-only passwords.
- Crack Medium: Cracks uppercase + number and dictionary-based passwords.
- Crack Hard: Cracks all passwords, including mixed patterns.
- Click each button to crack passwords:
- Easy: 4 user IDs (e.g.,
1: 22886,2: 52148,3: 75192,4: 98231). - Medium: 16 user IDs:
- 4 uppercase + number (e.g.,
5: EII9,6: XCN2,7: WKE5,8: PKL8). - 12 dictionary-based (e.g.,
9: london, ...,19: monkey,20: hello,23: monkey).
- 4 uppercase + number (e.g.,
- Hard: 20 user IDs (all of the above plus
21: AbC12z,22: XyZ89a).
- Buttons Not Clickable:
- Open the browser Console (F12 > Console) and check for errors.
- Ensure
public/app.jsandpublic/styles.cssare loading (Network tab).
- "Unexpected token '<'" Error:
- Check the Network tab for the response to
/public/index.php?action=<action>. - If the response isn’t pure JSON, there might be PHP errors. Check the container logs:
docker-compose logs app
- Verify
logs/php_error.loginside the container for PHP errors.
- Check the Network tab for the response to
- Database Connection Issues:
- Ensure the MySQL container is running and the database is initialized:
docker-compose logs db
- Verify the credentials in
config/.envmatch thedocker-compose.ymlsettings. - Confirm the database was imported correctly using the
import_database.phpscript.
- Ensure the MySQL container is running and the database is initialized:
- MySQL Deprecation Warning:
- If you see a warning about
mysql_native_password, update the MySQL user:docker exec -it new-cracker-db-1 mysql -uroot -prootpasswordALTER USER 'root'@'localhost' IDENTIFIED WITH 'caching_sha2_password' BY 'rootpassword'; FLUSH PRIVILEGES; EXIT;
- Restart the containers:
docker-compose down docker-compose up -d
- If you see a warning about
- The application logs are written to
logs/password_cracker.log. - PHP errors are logged to
logs/php_error.log. - The database data is persisted in a Docker volume (
db-data).
This Terraform project provisions AWS infrastructure for a password-cracker application using EC2, RDS, and Docker.
- A VPC with public and private subnets
- An EC2 instance (Docker-enabled) for the app
- A MySQL RDS instance in a private subnet
- Security groups and networking setup
- Auto-deployment from a GitHub repo (update URL in
main.tf)
-
Update the GitHub repo URL in
main.tf(user_datasection). -
Ensure your EC2 key pair exists in AWS.
-
Run:
terraform init terraform apply -var="key_name=your-key-name" -
SSH into EC2:
ssh -i ~/.ssh/your-key-name.pem ec2-user@<public_ip>
-
Import the Database on EC2:
- After SSHing into the EC2 instance, navigate to the project directory and run:
php scripts/import_database.php --host=localhost --user=root --password='rootpassword' --database=password_cracker --file='data/init.sql'
- Ensure the
init.sqlfile is present in thedata/directory and the RDS endpoint is correctly configured.
- After SSHing into the EC2 instance, navigate to the project directory and run:
- EC2 public IP
- RDS endpoint
- SSH command for EC2