Loading...
Loading...
CIA Triad — Security ke 3 pillars:
| Pillar | Meaning | Attack | Control | |--------|---------|--------|---------| | Confidentiality | Only authorized access | Eavesdropping, data theft | Encryption, access control | | Integrity | Data not tampered | Man-in-middle, corruption | Hash, digital signature | | Availability | System accessible | DDoS, ransomware | Redundancy, backups |
Security Terminology:
Plaintext + Key → [Encrypt] → Ciphertext
Ciphertext + Same Key → [Decrypt] → Plaintext
AES (Advanced Encryption Standard):
DES (Data Encryption Standard):
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
import base64
key = get_random_bytes(32) # 256-bit key
cipher = AES.new(key, AES.MODE_GCM)
ciphertext, tag = cipher.encrypt_and_digest(b"Secret Message")
print(base64.b64encode(ciphertext).decode())
Public Key (anyone can have) → Encrypt
Private Key (only owner has) → Decrypt
RSA Algorithm:
Encrypt: C = M^e mod n
Decrypt: M = C^d mod n
Elliptic Curve Cryptography (ECC):
| Algorithm | Output | Status | |-----------|--------|--------| | MD5 | 128-bit | ❌ Broken (collision found) | | SHA-1 | 160-bit | ❌ Deprecated | | SHA-256 | 256-bit | ✅ Current standard | | SHA-3 | 256/512-bit | ✅ Keccak-based | | bcrypt | 60-char | ✅ Password hashing |
Properties of Cryptographic Hash:
SIGNING (Sender):
Message → SHA-256 → Hash → [Sign with Private Key] → Signature
VERIFICATION (Receiver):
Received Message → SHA-256 → Hash₁
Signature → [Verify with Sender's Public Key] → Hash₂
If Hash₁ == Hash₂ → Valid ✅
Properties provided:
Root CA (Certificate Authority)
↓ signs
Intermediate CA
↓ signs
End-entity Certificate (website, user)
X.509 Certificate contains:
Client Server
| |
|--- ClientHello (TLS version, cipher suites) -->|
|<-- ServerHello (chosen cipher, certificate) ---|
|<-- Certificate (public key) ------------|
|--- [Verify cert with CA] |
|--- ClientKeyExchange (encrypted pre-master) -->|
|--- ChangeCipherSpec -----------------------> |
|--- Finished (encrypted) -----------------> |
|<-- ChangeCipherSpec ----------------------- |
|<-- Finished (encrypted) ------------------ |
|====== Encrypted Application Data ============ |
TLS 1.3 improvements over 1.2:
Types: | Type | Layer | Inspects | Example | |------|-------|----------|---------| | Packet Filter | Network (L3) | IP/Port headers | iptables | | Stateful | Transport (L4) | Connection state | AWS Security Groups | | Application (WAF) | Application (L7) | HTTP content | Cloudflare WAF | | NGFW | All layers | Deep inspection | Palo Alto, Fortinet |
# iptables example — block port 23 (Telnet)
iptables -A INPUT -p tcp --dport 23 -j DROP
# Allow only SSH from specific IP
iptables -A INPUT -p tcp -s 192.168.1.100 --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j DROP
Site-to-Site VPN:
Office A ←—— Encrypted Tunnel ——→ Office B
(10.0.0.0/24) (Internet) (10.1.0.0/24)
Protocols:
// Vulnerable — user can access any order
GET /api/orders/12345
// Fix — verify ownership
if (order.userId !== currentUser.id) {
return res.status(403).json({ error: 'Forbidden' });
}
# WRONG — MD5 for password
import hashlib
password_hash = hashlib.md5(password.encode()).hexdigest()
# CORRECT — bcrypt
import bcrypt
hashed = bcrypt.hashpw(password.encode(), bcrypt.gensalt(rounds=12))
# VULNERABLE
query = f"SELECT * FROM users WHERE username = '{username}'"
# Attacker input: admin' OR '1'='1 → bypasses auth!
# SECURE — parameterized query
cursor.execute("SELECT * FROM users WHERE username = %s", (username,))
Fixes:
# Rate limiting login attempts
from flask_limiter import Limiter
limiter = Limiter(app)
@app.route('/login', methods=['POST'])
@limiter.limit("5 per minute")
def login():
pass
# Session security
app.config['SESSION_COOKIE_SECURE'] = True # HTTPS only
app.config['SESSION_COOKIE_HTTPONLY'] = True # No JS access
app.config['SESSION_COOKIE_SAMESITE'] = 'Strict' # CSRF protection
<!-- SRI — Subresource Integrity check -->
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.min.js"
integrity="sha384-..."
crossorigin="anonymous">
</script>
| Attack | Description | Prevention | |--------|-------------|-----------| | DDoS | Flood server with requests | CDN, rate limiting, WAF | | XSS | Inject JS into web pages | Output encoding, CSP headers | | CSRF | Trick user into unwanted action | CSRF tokens, SameSite cookies | | Phishing | Fake websites to steal creds | MFA, email filtering, training | | Man-in-Middle | Intercept communication | HTTPS, certificate pinning | | Brute Force | Try all passwords | Account lockout, CAPTCHA, MFA | | Ransomware | Encrypt files, demand payment | Backups, EDR, least privilege |
Q: Perfect Forward Secrecy kya hai? A: Har session ke liye naya session key generate hota hai (Diffie-Hellman Ephemeral). Agar private key compromise ho bhi jaye, past sessions decrypt nahi ho sakte.
Q: Zero-Day vulnerability kya hoti hai? A: Ek aisi vulnerability jo vendor ko pata nahi hai ya patch available nahi hai. Attack before patch = zero-day exploit.
Q: Kyu MD5 ab password hashing ke liye use nahi karte? A: MD5 fast hai aur GPU se quickly brute-force ho sakta hai. Rainbow tables exist karti hain. bcrypt/Argon2 intentionally slow hain aur salt use karte hain.
Complete Information Security notes for B.Tech IT Sem 6 — Cryptography, Network Security, Firewalls, VPN, SSL/TLS, OWASP Top 10, Digital Signatures, and exam prep.
50 pages · 2.5 MB · Updated 2026-03-11
Symmetric: same key for encrypt/decrypt (AES, DES) — fast. Asymmetric: public+private key pair (RSA, ECC) — slow but secure key exchange. HTTPS dono use karta hai — handshake asymmetric, data symmetric.
Sender apna private key use karke message hash sign karta hai. Receiver sender ki public key se verify karta hai. Non-repudiation provide karta hai.
User input directly SQL query mein inject ho jata hai. Prevention: Prepared statements / parameterized queries, input validation, least privilege DB user.
Firewall traffic block/allow karta hai rules ke basis pe (preventive). IDS (Intrusion Detection System) suspicious activity detect karta hai aur alert karta hai (detective).
TLS Handshake: server certificate verify, session key exchange (asymmetric), phir data symmetric encryption se jaata hai. HTTP/2 modern HTTPS use karta hai.
Digital Electronics — Complete Notes IT Sem 1
Digital Electronics
Java Programming — Complete Notes for B.Tech IT Semester 3
Java Programming
Web Technologies — HTML, CSS, JavaScript, Node.js Complete Notes
Web Technologies
Cloud Computing Notes — B.Tech IT Sem 5
Cloud Computing
Operating System Complete Notes + Viva Questions — IT Sem 4
Operating System
Your feedback helps us improve notes and tutorials.