Update README.md

This commit is contained in:
2025-10-29 14:40:54 +01:00
committed by GitHub
parent 32cada680e
commit 79978056f6
+97 -154
View File
@@ -1,44 +1,42 @@
# BruteForce — Demo Project # BruteForce — Demo Project
> Small educational demo showing a minimal login backend, basic frontend, and **five** brute-force attack scripts for safe, local testing and security education. > **Educational-only project** showing how login systems can be hardened against brute-force, dictionary, and rainbow-table attacks.
> Includes backend, frontend, and multiple safe attack simulations — all running **locally**.
> **This is for educational use only. Never attack systems without explicit permission.** **Never test against external or real systems.**
This demo is strictly for **security education and local testing**.
--- ## Table of Contents
## Table of contents * [Overview](#overview)
* [Prerequisites](#prerequisites)
- [Overview](#overview) * [Install](#install)
- [Prerequisites](#prerequisites) * [Structure](#project-structure)
- [Install](#install) * [Expected user data](#expected-user-data)
- [Project structure](#project-structure) * [Run demo backend](#run-demo-backend)
- [Expected `users.json` formats](#expected-usersjson-formats) * [Create users](#create-users)
- [Run the demo server](#run-the-demo-server) * [Attack scripts](#attack-scripts)
- [Create users](#create-users) * [Security & Ethics](#security--ethics-must-read)
- [Safe testing (recommended)](#safe-testing-recommended)
- [Attack scripts](#attack-scripts)
- [Security & Ethics (must read)](#security--ethics-must-read)
---
## Overview ## Overview
This project demonstrates: This project demonstrates:
- A minimal Express-based login backend * Minimal **Express-based login backend**
- A static frontend with form-based login * **Modern login UI** with clear error messages
- Five Node.js scripts simulating brute-force/dictionary/rainbow attacks * **UTF-8 Unicode charset support**
- Local-only and safe multi-instance testing * Attack simulations for:
- User/password storage in plaintext and bcrypt
- Clear separation between demo functionality and security attack simulation
--- * Brute-force (`crack.js`)
* Dictionary + mutation (`crack2.js`)
* Rainbow table (`crack3.js --mode create/rainbow`)
* Safe **local testing environment**
## Prerequisites ## Prerequisites
- Node.js (v14+) * Node.js ≥ 16
- `npm` * npm
- Terminal (or PowerShell) * Terminal or PowerShell
--- ---
@@ -46,34 +44,31 @@ This project demonstrates:
```bash ```bash
npm install npm install
```` ```
If missing packages cause errors, install them explicitly: If some packages are missing:
```bash ```bash
npm install bcryptjs node-fetch express express-rate-limit morgan fs-extra npm install express node-fetch bcryptjs fs-extra morgan express-rate-limit
``` ```
--- ---
## Project structure ## Project Structure
``` ```
BruteForce/ BruteForce/
├─ attacks/ ├─ attacks/
│ ├─ crack.js # Mono charset brute force │ ├─ crack.js # Extended charset brute-force attack
│ ├─ crack2.js # Dictionary + mutations │ ├─ crack2.js # Dictionary + personal data mutation attack
│ ├─ crack3.js # Rainbow table │ ├─ crack3.js # Rainbow Table + Parallel Instances attack
│ ├─ crack4.js # Parallel brute force │ ├─ rainbow_table.json # Optional precomputed hashes
│ ├─ crack5.js # Hybrid attack framework │ └─ dictionary.txt # Optional extra words
│ ├─ dictionary.txt
│ ├─ rainbow_table.json
│ └─ wordlist.txt
├─ public/ ├─ public/
│ ├─ Backend.js # Express server │ ├─ Backend.js # Express backend
│ └─ index.html # Login form │ ├─ index.html # Modern login UI
├─ TEST_DATA/ │ └─ TEST_DATA/
│ └─ users.json │ └─ users.json # Local user database
├─ docs/ ├─ docs/
│ └─ README.md # This file │ └─ README.md # This file
└─ package.json └─ package.json
@@ -81,185 +76,133 @@ BruteForce/
--- ---
## Expected `users.json` formats ## Expected User Data
### Preferred structure: **`TEST_DATA/users.json`**
```json ```json
{ [
"users": [ { "username": "test", "password": "test1" },
{ "username": "alice", "password": "plaintext" }, { "username": "admin", "password": "admin" }
{ "username": "bob", "passwordHash": "$2a$10$..." } ]
]
}
``` ```
--- ---
## Run the demo server ## Run Demo Backend
```bash ```bash
node public/Backend.js node public/Backend.js
``` ```
Visit: `http://localhost:3000/login` Visit [http://localhost:3000/login](http://localhost:3000/login)
--- ---
## Create users ## Create Users
### Option 1: Plaintext (demo only) ### Option 1: Plaintext
Edit `users.json` manually. Edit `TEST_DATA/users.json` manually.
### Option 2: Hashed (recommended) ### Option 2: Hashed (using bcrypt)
```bash ```bash
node -e "const bcrypt=require('bcryptjs');(async(p)=>console.log(await bcrypt.hash(p,10)))(process.argv[1])" "S3cret!" node -e "const bcrypt=require('bcryptjs');(async(p)=>console.log(await bcrypt.hash(p,10)))(process.argv[1])" "MyS3cret!"
``` ```
Then insert the hash into `users.json` under `passwordHash`. ## Safe Testing
--- All attacks operate **only against the local server** (`localhost:3000/login`).
## Safe testing (recommended)
All attacks simulate authentication attempts **locally** and do not target remote systems.
---
## Attack Scripts ## Attack Scripts
### 1. `crack.js` – Mono-Zeichensatz Brute Force ### 1. `crack.js` — Brute-Force (UTF-8 / Extended Charset)
**Simulates:** **Simulates:**
* Pure brute force using a restricted character set (`digits`, `lower`, `upper`) * Systematic password search using configurable character sets
* Exhaustive search up to configurable length * Full Mono-Alphabet support (lowercase, uppercase, numbers, symbols)
```bash ```bash
node crack.js <username> <charset> <maxlen> node attacks/crack.js <username> <charset> <maxlen>
``` ```
#### Available charsets:
| Name | Characters included | |
| --------- | -------------------------------------- | -------- |
| `digits` | `0123456789` | |
| `lower` | `abcdefghijklmnopqrstuvwxyz` | |
| `upper` | `ABCDEFGHIJKLMNOPQRSTUVWXYZ` | |
| `symbols` | `!@#$%^&*()_+-=[]{} | ;:,.<>?` |
| `mixed` | Letters, numbers, and symbols combined | |
Example: Example:
```bash ```bash
node crack.js alice digits 4 node attacks/crack.js alice mixed 4
``` ```
--- ---
### 2. `crack2.js` – Dictionary + Mutation Attack ### 2. `attacker.js` — Personal Data Dictionary + Mutations
**Simulates:** **Simulates:**
* Dictionary-based password guessing * Leetspeak, capitalization, and year/suffix mutations
* Case variants, common suffixes, and leetspeak * Smart combinations of known info (email, name, birth year)
* Limited to local dictionary and mutation rules * Optional fallback to full Unicode brute-force
Run:
```bash ```bash
node crack2.js <username> <maxlen> node attacks/crack2.js <username>
``` ```
--- ---
### 3. `crack3.js` – Rainbow Table ### 3. `attacker.js` — Rainbow Table Mode
**Simulates:** Build and use precomputed hash-password maps.
* Use of precomputed hash-password maps **Create table:**
* Includes script for building a rainbow table from a dictionary
```bash ```bash
node crack3.js <username> rainbow node attacks/crack3.js admin create
node crack3.js <username> create # To build rainbow table
``` ```
--- **Use table:**
### 4. `crack4.js` – Parallel Brute Force
**Simulates:**
* Brute-force attack split across multiple instances
* Each instance works on a portion of the keyspace
```bash ```bash
node crack4.js <username> bruteforce <instanceId> <totalInstances> node attacks/crack3.js admin rainbow
``` ```
Example (Instance 2 of 4): Rainbow tables are stored as:
```bash ```
node crack4.js alice bruteforce 1 4 attacks/rainbow_table.json
``` ```
--- ## Security & Ethics (Must Read)
### 5. `crack5.js` – Hybrid Framework (Full Simulation Suite) > **Use only in a controlled, local environment.**
**Simulates:** * Never attack networks or systems without written consent.
* Brute-force attacks, even educational ones, can **cause denial-of-service** if misused.
* This repository is intended for **learning, classroom demonstrations, and security testing**.
* Dictionary + Rainbow + Brute-force ## PowerShell Example — Parallel Testing
* Multi-instance parallelism
* Shared state file to halt on success
* Tracks stats, request speed, response time, success/failure logs
* Also supports username enumeration
```bash
node crack5.js <username> <mode> <instanceId> <totalInstances>
```
Modes:
* `dictionary`
* `bruteforce`
* `rainbow`
* `create-table`
* `enumerate`
* `hybrid` (dictionary → brute-force)
Example:
```bash
node crack5.js admin hybrid 0 4
```
---
## Security & Ethics (must read)
> **DO NOT** use any attack scripts against systems you do not own.
* These tools are **for learning and classroom use only**
* Use only against the demo server or authorized systems
* Violating ethical guidelines or legal boundaries may lead to severe consequences
* When in doubt, ask for explicit permission before testing
---
## PowerShell: Launch Parallel Instances (Example)
```powershell ```powershell
$WorkingDir = "C:\Users\your_username\your_project_folder\BruteForce\attacks" # $Dir = "C:\BruteForce\attacks"
for ($i = 0; $i -lt <number_of_instances>; $i++) {
for ($i = 0; $i -lt 10; $i++) { $cmd = "Set-Location `"$Dir`"; node <file_name>.js <username> bruteforce $i <number_of_instances>"
$cmd = "Set-Location -Path `"$WorkingDir`"; node crack5.js test hybrid $i 10"
Start-Process powershell -ArgumentList "-NoExit", "-Command", $cmd Start-Process powershell -ArgumentList "-NoExit", "-Command", $cmd
Start-Sleep -Milliseconds 100
} }
``` ```
Execute powershell script locally:
``` execute using:
powershell -ExecutionPolicy Bypass -File "C:\Users\your_username\your_project_folder\BruteForce\attacks\open_10_terminals_windows.ps1" ```powershell
``` powershell -ExecutionPolicy Bypass -File "C:\<path>\<to>\<bruteforce>\<project>\BruteForce\attacks\<file_name>.ps1"
---
## ✅ Final Notes
* `crack5.js` is the most advanced and recommended for robust demos
* Use the naive server (`Backend.js`) for all testing
* Monitor server logs and browser output during attacks
``` ```