Skip to content

Commit 9b70a5b

Browse files
Initialize README with project details and instructions
Add detailed project overview, structure, features, and usage instructions.
1 parent 0f2a441 commit 9b70a5b

1 file changed

Lines changed: 209 additions & 0 deletions

File tree

README.md

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
# 🔐 Secure Authentication System using Cryptography
2+
3+
> A C-based authentication simulator with a matching web-based frontend (HTML / CSS / JavaScript), demonstrating CIA Triad principles, XOR encryption, intrusion detection, and role-based access control.
4+
5+
---
6+
7+
## 📁 Project Structure
8+
9+
```
10+
Secure-Authentication-System/
11+
12+
├── authen/
13+
│ ├── main.c ← Entry point; menu system; session handling
14+
│ ├── functions.c ← All function implementations
15+
│ ├── functions.h ← Structs, constants, function declarations
16+
│ └── Makefile ← Builds to authen / authen.exe
17+
18+
├── index.html ← Web frontend (single-page app)
19+
├── styles.css ← Cyberpunk terminal aesthetic
20+
├── script.js ← JavaScript mirrors all C logic in-browser
21+
└── README.md ← This file
22+
```
23+
24+
> **Note:** `authen.exe` is the compiled binary generated by running `make windows` (MinGW on Windows) or `make` on Linux/macOS. It is **not** a source file — it is produced from `main.c + functions.c`.
25+
26+
---
27+
28+
## 🎯 Course Outcomes Covered
29+
30+
| CO | Description | Implementation |
31+
|----|-------------|----------------|
32+
| CO1 | Understand cyber threats; define secure auth with flowchart & algorithm | CIA Triad in README; XOR cipher algorithm |
33+
| CO2 | Implement auth logic using loops, file handling, conditionals | `authenticate_user()`, `load_users()`, `save_users()` in C |
34+
| CO3 | Apply encryption & modular programming | `xor_encrypt()` / `xor_decrypt()` functions; separate header |
35+
| CO4 | Analyze attack simulation; incorporate incident response | `trigger_intrusion_alert()`, IDS lockout, security log |
36+
| CO5 | Integrate all cybersecurity concepts in a C application | Full system: register → login → session → admin panel |
37+
38+
---
39+
40+
## 🛡️ CIA Triad – Applied Principles
41+
42+
### Confidentiality
43+
- Passwords are **never stored in plaintext**
44+
- XOR encryption with key `0x5A` applied before writing to `credentials.dat`
45+
- Masked password input (characters replaced with `*`)
46+
47+
### Integrity
48+
- All authentication events **timestamped and logged** to `security.log`
49+
- Admin-only password reset — users cannot modify other accounts
50+
- Role-based access prevents privilege escalation
51+
52+
### Availability
53+
- Account lockout after **3 consecutive failed attempts** prevents brute-force DoS
54+
- Admin can unlock accounts via the admin menu
55+
- System remains accessible to legitimate users at all times
56+
57+
---
58+
59+
## 🔑 Key Features
60+
61+
| Feature | C (Terminal) | Web (Browser) |
62+
|---------|-------------|---------------|
63+
| User Registration | `register_user()` | `registerUser()` in script.js |
64+
| XOR Password Encryption | `xor_encrypt()` | `xorEncrypt()` — same key (0x5A) |
65+
| Login / Authentication | `authenticate_user()` | `authenticateUser()` |
66+
| Attempt Counter | `failed_attempts` field in struct | `failedAttempts` in localStorage |
67+
| Intrusion Detection | `trigger_intrusion_alert()` | Alert overlay with glitch animation |
68+
| Account Lockout | `is_locked` flag | `isLocked` flag |
69+
| Audit Logging | `security.log` (binary file) | localStorage JSON array |
70+
| Admin Panel | `admin_session_loop()` | Admin dashboard page |
71+
| Password Reset | `reset_password()` | `resetPassword()` modal |
72+
| Account Unlock | Menu option 4 | Unlock button in user table |
73+
| Masked Input | `mask_input()` (raw terminal) | `type="password"` + toggle |
74+
75+
---
76+
77+
## 🔐 XOR Encryption Algorithm
78+
79+
```
80+
Encrypt: enc[i] = plaintext[i] XOR 0x5A
81+
Decrypt: plain[i] = enc[i] XOR 0x5A (XOR is its own inverse)
82+
83+
Example:
84+
Plaintext: 'A' (ASCII 65)
85+
65 XOR 90 = 27 → stored value
86+
27 XOR 90 = 65 → decrypted back to 'A' ✓
87+
```
88+
89+
> **Note:** XOR cipher is used here for demonstration purposes (as specified in the project requirements). In production systems, use bcrypt, Argon2, or SHA-256 with salt for password hashing.
90+
91+
---
92+
93+
## 🚨 Intrusion Detection System (IDS)
94+
95+
The IDS triggers when:
96+
1. A user fails to log in **3 consecutive times**
97+
2. A locked account attempts login
98+
99+
**Response Actions:**
100+
- Account is flagged `is_locked = 1` (C) / `isLocked: true` (JS)
101+
- Alert written to `security.log` with `IDS_ALERT` event type
102+
- Terminal prints a warning banner (C) / overlay modal appears (Web)
103+
- Only an administrator can unlock the account
104+
105+
---
106+
107+
## 🏃 How to Run
108+
109+
### Web Version (No setup required)
110+
```bash
111+
# Just open in a browser:
112+
open index.html
113+
# or double-click index.html in your file manager
114+
```
115+
116+
Default login credentials:
117+
- **Admin:** `admin` / `Admin@123`
118+
- **User:** `alice` / `alice123`
119+
120+
---
121+
122+
### C Version (Terminal)
123+
124+
**Prerequisites:** GCC compiler
125+
126+
#### Linux / macOS
127+
```bash
128+
cd authen/
129+
make
130+
./authen
131+
```
132+
133+
#### Windows (MinGW)
134+
```bash
135+
cd authen/
136+
make windows
137+
authen.exe
138+
```
139+
140+
#### Manual Compile (without make)
141+
```bash
142+
gcc -o authen main.c functions.c -Wall -std=c11
143+
```
144+
145+
**First run:** The system auto-creates a default admin account (`admin` / `Admin@123`).
146+
147+
---
148+
149+
## 📋 Data Structures (from functions.h)
150+
151+
```c
152+
typedef struct {
153+
char username[32];
154+
char enc_password[64]; /* XOR-encrypted, stored as raw bytes */
155+
int role; /* 0 = USER, 1 = ADMIN */
156+
int failed_attempts; /* Consecutive failed logins */
157+
int is_locked; /* Lockout flag */
158+
} User;
159+
160+
typedef struct {
161+
char username[32];
162+
int role;
163+
int logged_in;
164+
} Session;
165+
```
166+
167+
---
168+
169+
## 📊 Security Event Log Format
170+
171+
```
172+
[2025-01-15 10:23:41] REGISTER | USER: alice | User account created
173+
[2025-01-15 10:24:05] LOGIN_OK | USER: alice | User login
174+
[2025-01-15 10:25:12] LOGIN_FAIL | USER: alice | Wrong password (attempt 1/3)
175+
[2025-01-15 10:25:20] LOGIN_FAIL | USER: alice | Wrong password (attempt 2/3)
176+
[2025-01-15 10:25:30] IDS_ALERT | USER: alice | BRUTE-FORCE DETECTED – Account locked
177+
```
178+
179+
---
180+
181+
## 🗂️ Syllabus Topics Applied
182+
183+
| Topic | Where Applied |
184+
|-------|--------------|
185+
| Threat Landscape / Threat Actors | IDS simulation of brute-force attacker |
186+
| Social Engineering | Password masking; account lockout awareness |
187+
| CIA Triad | Confidentiality (encryption), Integrity (logging), Availability (lockout) |
188+
| Principle of Least Privilege | Role-based access: user vs admin capabilities |
189+
| Symmetric Encryption | XOR cipher with shared key 0x5A |
190+
| Authentication Methods | Username/password; role verification |
191+
| Vulnerability Scanning (Simulation) | 3-attempt lockout simulates IDS/IPS |
192+
| Ethical Hacking (Brute-force) | Failed attempt simulation triggers alert |
193+
| Incident Response | Admin unlock; log review; alert generation |
194+
| C Programming Concepts | Structures, functions, loops, file I/O, conditionals, arrays |
195+
196+
---
197+
198+
## 👥 Authors
199+
200+
- **Krishna757-Cyber** — Project Lead, C Implementation, Web Frontend
201+
- **Ritesh004-kira** — Password Encryption Enhancement, Login Attempts Handling
202+
203+
---
204+
205+
## 📌 Notes
206+
207+
- The `.exe` file in the repository is the **compiled binary** for Windows — built from `main.c` and `functions.c` using MinGW GCC.
208+
- Credentials are stored in `credentials.dat` (C) and `localStorage` (Web) — both simulate the same file-handling concept.
209+
- This project is a **simulator** for educational purposes. Do not use XOR cipher for real-world password storage.

0 commit comments

Comments
 (0)