{
  "Module 31: Mixed Questions II": [
    {
      "question": "1. According to OWASP, which of the following is an example of Injection vulnerability?",
      "options": [
        "A. Storing passwords in /etc/shadow",
        "B. Passing unvalidated user input directly into an SQL query",
        "C. Using HTTPS for login pages",
        "D. Configuring a strong Content-Security-Policy header"
      ],
      "num_answers": 1,
      "answer": "B. Passing unvalidated user input directly into an SQL query",
      "answer_keys": ["B"],
      "explanations": {
        "A": "❌ /etc/shadow is designed to securely store password hashes, not an injection example.",
        "B": "✅ Concatenating unvalidated input into SQL is classic SQL Injection (OWASP A03: Injection).",
        "C": "❌ HTTPS helps protect data in transit, not an injection flaw.",
        "D": "❌ CSP is a mitigation against XSS, not an injection example."
      }
    },
    {
      "question": "2. Which OWASP Top 10 category focuses on flaws allowing users to access data or actions outside their intended permissions?",
      "options": [
        "A. Cryptographic Failures",
        "B. Broken Access Control",
        "C. Security Misconfiguration",
        "D. Injection"
      ],
      "num_answers": 1,
      "answer": "B. Broken Access Control",
      "answer_keys": ["B"],
      "explanations": {
        "A": "❌ Cryptographic Failures relate to weak or incorrect use of crypto.",
        "B": "✅ Broken Access Control covers missing or flawed authorization checks.",
        "C": "❌ Misconfig is about insecure default or wrong security settings.",
        "D": "❌ Injection is about untrusted data being interpreted as commands."
      }
    },
    {
      "question": "3. A web app sends detailed stack traces and SQL errors to end users. Which OWASP Top 10 issue does this BEST relate to?",
      "options": [
        "A. Identification and Authentication Failures",
        "B. Software and Data Integrity Failures",
        "C. Security Misconfiguration",
        "D. Insecure Design"
      ],
      "num_answers": 1,
      "answer": "C. Security Misconfiguration",
      "answer_keys": ["C"],
      "explanations": {
        "A": "❌ Auth failures are about login/session issues.",
        "B": "❌ Integrity failures focus on CI/CD and integrity of code/data.",
        "C": "✅ Verbose error messages and debug mode in production are classic misconfig problems.",
        "D": "❌ Insecure design is about systemic design flaws, not just verbose errors."
      }
    },
    {
      "question": "4. Which OWASP Top 10 category is MOST associated with persistent and reflected XSS?",
      "options": [
        "A. Injection",
        "B. Security Logging and Monitoring Failures",
        "C. Identification and Authentication Failures",
        "D. Insecure Design"
      ],
      "num_answers": 1,
      "answer": "A. Injection",
      "answer_keys": ["A"],
      "explanations": {
        "A": "✅ XSS is treated as a type of injection problem (untrusted input interpreted as script).",
        "B": "❌ Logging/monitoring issues are about detection gaps.",
        "C": "❌ Auth failures relate to login/session flaws.",
        "D": "❌ XSS is usually categorized as injection rather than high-level design flaw."
      }
    },
    {
      "question": "5. What is the PRIMARY purpose of input validation and sanitization?",
      "options": [
        "A. To improve application performance",
        "B. To reduce storage size of user data",
        "C. To ensure input conforms to expected format and remove dangerous characters",
        "D. To automatically encrypt all user input"
      ],
      "num_answers": 1,
      "answer": "C. To ensure input conforms to expected format and remove dangerous characters",
      "answer_keys": ["C"],
      "explanations": {
        "A": "❌ Performance is not the main security objective.",
        "B": "❌ Validation is not about shrinking data.",
        "C": "✅ Validation and sanitization prevent malicious input from reaching sensitive sinks (DB, OS, interpreter).",
        "D": "❌ Encryption alone does not stop injection or logic attacks."
      }
    },
    {
      "question": "6. Which BEST describes output encoding (e.g., HTML encoding) as a defense?",
      "options": [
        "A. It validates user input at the server",
        "B. It transforms special characters so the browser treats them as data, not executable code",
        "C. It compresses HTTP responses to save bandwidth",
        "D. It hides SQL errors from users"
      ],
      "num_answers": 1,
      "answer": "B. It transforms special characters so the browser treats them as data, not executable code",
      "answer_keys": ["B"],
      "explanations": {
        "A": "❌ Input validation happens before processing, not during output.",
        "B": "✅ Encoding converts characters like < and > so they’re not executed as HTML/JS.",
        "C": "❌ Compression is unrelated to XSS defenses.",
        "D": "❌ Hiding errors is beneficial, but not what encoding does."
      }
    },
    {
      "question": "7. Which Linux file typically stores hashed passwords and is only readable by root?",
      "options": [
        "A. /etc/passwd",
        "B. /etc/shadow",
        "C. /etc/sudoers",
        "D. /var/log/auth.log"
      ],
      "num_answers": 1,
      "answer": "B. /etc/shadow",
      "answer_keys": ["B"],
      "explanations": {
        "A": "❌ /etc/passwd holds user account info; modern systems keep hashes in /etc/shadow.",
        "B": "✅ /etc/shadow stores password hashes with restricted permissions.",
        "C": "❌ /etc/sudoers defines sudo rules.",
        "D": "❌ /var/log/auth.log stores authentication logs, not hashes."
      }
    },
    {
      "question": "8. Why is storing hashes in /etc/shadow more secure than storing them directly in /etc/passwd?",
      "options": [
        "A. /etc/shadow uses a different hash algorithm",
        "B. /etc/shadow is only readable by root, limiting offline cracking attempts",
        "C. /etc/passwd is encrypted, /etc/shadow is not",
        "D. /etc/shadow is only used on Windows systems"
      ],
      "num_answers": 1,
      "answer": "B. /etc/shadow is only readable by root, limiting offline cracking attempts",
      "answer_keys": ["B"],
      "explanations": {
        "A": "❌ Both can use the same hashing algorithms; the key difference is access control.",
        "B": "✅ Restricting file access prevents normal users from obtaining hashes for offline attacks.",
        "C": "❌ /etc/passwd is world-readable plain text, not encrypted.",
        "D": "❌ /etc/shadow is a Unix/Linux concept, not Windows."
      }
    },
    {
      "question": "9. In a penetration test, you obtain a copy of /etc/shadow. What is the MOST likely next step for an attacker?",
      "options": [
        "A. Use a password cracking tool to attempt offline hash cracking",
        "B. Directly log in using the hash values as passwords",
        "C. Delete all shadow entries to lock out users",
        "D. Convert the hashes back to plaintext using 'unhash' command"
      ],
      "num_answers": 1,
      "answer": "A. Use a password cracking tool to attempt offline hash cracking",
      "answer_keys": ["A"],
      "explanations": {
        "A": "✅ Tools like John the Ripper/Hashcat can be used to crack hashes offline.",
        "B": "❌ You can’t normally authenticate by typing the hash as a password.",
        "C": "❌ That would be noisy and detected quickly.",
        "D": "❌ There is no generic 'unhash' command; hashes are one-way."
      }
    },
    {
      "question": "10. What is the PRIMARY purpose of the /etc/sudoers file?",
      "options": [
        "A. Define which users can change the kernel",
        "B. Define which users and groups can execute commands as root or other users",
        "C. Store all user password hashes",
        "D. Configure Linux firewall rules"
      ],
      "num_answers": 1,
      "answer": "B. Define which users and groups can execute commands as root or other users",
      "answer_keys": ["B"],
      "explanations": {
        "A": "❌ Sudoers can grant root, but its scope is broader than just kernel changes.",
        "B": "✅ /etc/sudoers controls sudo privileges and command restrictions.",
        "C": "❌ Hashes are in /etc/shadow.",
        "D": "❌ Firewall configuration is usually in iptables/nftables config, not sudoers."
      }
    },
    {
      "question": "11. Which command is recommended to safely edit the /etc/sudoers file?",
      "options": [
        "A. nano /etc/sudoers",
        "B. vi /etc/sudoers",
        "C. visudo",
        "D. echo 'edit' > /etc/sudoers"
      ],
      "num_answers": 1,
      "answer": "C. visudo",
      "answer_keys": ["C"],
      "explanations": {
        "A": "❌ Editing directly risks syntax errors that can break sudo.",
        "B": "❌ Same issue as nano; no syntax checking.",
        "C": "✅ visudo checks syntax and prevents concurrent edits.",
        "D": "❌ Overwriting sudoers like this is dangerous and invalid."
      }
    },
    {
      "question": "12. From a CEH perspective, which sudoers entry poses the HIGHEST risk?",
      "options": [
        "A. alice ALL=(root) /usr/bin/less",
        "B. %admins ALL=(ALL) ALL",
        "C. bob ALL=(root) NOPASSWD: ALL",
        "D. %devs ALL=(ALL) /usr/bin/tail /var/log/app.log"
      ],
      "num_answers": 1,
      "answer": "C. bob ALL=(root) NOPASSWD: ALL",
      "answer_keys": ["C"],
      "explanations": {
        "A": "❌ less can be abused in some cases, but is more constrained.",
        "B": "❌ Powerful, but still requires password and group membership.",
        "C": "✅ Full root with no password is extremely dangerous and ideal for attackers.",
        "D": "❌ Tail of a specific log is relatively limited."
      }
    },
    {
      "question": "13. Which technique is commonly used to evade stateless packet-filtering firewalls?",
      "options": [
        "A. Using TCP three-way handshake",
        "B. Fragmenting packets to split signatures across multiple fragments",
        "C. Using only ICMP echo replies",
        "D. Enabling SYN cookies"
      ],
      "num_answers": 1,
      "answer": "B. Fragmenting packets to split signatures across multiple fragments",
      "answer_keys": ["B"],
      "explanations": {
        "A": "❌ Handshake is normal TCP behavior, not an evasion technique by itself.",
        "B": "✅ Fragmentation can bypass simple pattern-based filters that do not reassemble packets.",
        "C": "❌ Echo replies alone are not a common evasion trick.",
        "D": "❌ SYN cookies are a defense against SYN floods, not a firewall evasion."
      }
    },
    {
      "question": "14. An attacker tunnels malicious traffic over HTTPS (TCP 443) to bypass a firewall that only allows web traffic. This is an example of:",
      "options": [
        "A. Port knocking",
        "B. Protocol tunneling / using allowed ports",
        "C. ARP poisoning",
        "D. VLAN hopping"
      ],
      "num_answers": 1,
      "answer": "B. Protocol tunneling / using allowed ports",
      "answer_keys": ["B"],
      "explanations": {
        "A": "❌ Port knocking uses sequences of connection attempts to open ports.",
        "B": "✅ Hiding arbitrary traffic in allowed protocols/ports is a classic firewall evasion tactic.",
        "C": "❌ ARP poisoning targets LAN routing, not port-based firewalls.",
        "D": "❌ VLAN hopping manipulates VLAN tags, not HTTPS tunnels."
      }
    },
    {
      "question": "15. In Nmap, which scan type is often used for firewall evasion by sending only SYN packets and not completing the TCP handshake?",
      "options": [
        "A. -sT (TCP connect scan)",
        "B. -sS (SYN scan)",
        "C. -sP (ping scan)",
        "D. -sU (UDP scan)"
      ],
      "num_answers": 1,
      "answer": "B. -sS (SYN scan)",
      "answer_keys": ["B"],
      "explanations": {
        "A": "❌ -sT uses full TCP connect(), more likely to be logged.",
        "B": "✅ SYN scans are 'half-open', often less noisy and slightly stealthier.",
        "C": "❌ -sP is host discovery, not a port scan.",
        "D": "❌ -sU is UDP scanning, different use case."
      }
    },
    {
      "question": "16. Which of the following is a typical WAF (Web Application Firewall) evasion attempt?",
      "options": [
        "A. Using strong TLS cipher suites",
        "B. Encoding payloads using URL or Unicode encoding to bypass simple signature checks",
        "C. Enforcing strict input validation on the server",
        "D. Applying multi-factor authentication"
      ],
      "num_answers": 1,
      "answer": "B. Encoding payloads using URL or Unicode encoding to bypass simple signature checks",
      "answer_keys": ["B"],
      "explanations": {
        "A": "❌ Strong TLS is a defense, not an evasion.",
        "B": "✅ Obfuscating payloads with alternate encoding can bypass naive pattern-matching WAF rules.",
        "C": "❌ This is a defensive measure against attacks.",
        "D": "❌ MFA protects accounts, not a WAF evasion tactic."
      }
    },
    {
      "question": "17. In the context of OWASP, why is proper output encoding critical for HTML and JavaScript contexts?",
      "options": [
        "A. It hides SQL errors from the attacker",
        "B. It prevents buffer overflow in the browser",
        "C. It prevents untrusted data from being interpreted as active script",
        "D. It compresses web pages for faster delivery"
      ],
      "num_answers": 1,
      "answer": "C. It prevents untrusted data from being interpreted as active script",
      "answer_keys": ["C"],
      "explanations": {
        "A": "❌ Hiding errors is separate from encoding.",
        "B": "❌ Browsers are not typically susceptible to buffer overflow from HTML text alone.",
        "C": "✅ Proper encoding ensures input is treated as text, not executable JS/HTML.",
        "D": "❌ Compression (e.g., gzip) is a performance feature, not an XSS mitigation."
      }
    },
    {
      "question": "18. Which BEST describes input sanitization?",
      "options": [
        "A. Removing or transforming unsafe characters from input before processing",
        "B. Encrypting all user data at rest",
        "C. Storing input in log files for auditing",
        "D. Allowing all characters and filtering only at the firewall"
      ],
      "num_answers": 1,
      "answer": "A. Removing or transforming unsafe characters from input before processing",
      "answer_keys": ["A"],
      "explanations": {
        "A": "✅ Sanitization focuses on removing or neutralizing dangerous input before it reaches sensitive sinks.",
        "B": "❌ Encryption is a different control.",
        "C": "❌ Logging is useful, but not sanitization.",
        "D": "❌ Firewalls cannot reliably sanitize application-level input."
      }
    },
    {
      "question": "19. Which of the following MOST directly addresses the OWASP 'Security Logging and Monitoring Failures' risk?",
      "options": [
        "A. Using strong password policies",
        "B. Generating alerts for multiple failed logins and critical errors",
        "C. Disabling application logs to improve performance",
        "D. Allowing direct database access from the internet"
      ],
      "num_answers": 1,
      "answer": "B. Generating alerts for multiple failed logins and critical errors",
      "answer_keys": ["B"],
      "explanations": {
        "A": "❌ Password policies address authentication strength, not monitoring.",
        "B": "✅ Effective logging and alerting address detection/response gaps.",
        "C": "❌ Disabling logs makes detection impossible.",
        "D": "❌ Direct DB exposure is a serious misconfiguration."
      }
    },
    {
      "question": "20. Which statement about /etc/passwd and /etc/shadow is MOST accurate from a security standpoint?",
      "options": [
        "A. Both files should be world-readable",
        "B. /etc/passwd should contain password hashes; /etc/shadow is deprecated",
        "C. /etc/passwd is world-readable, while /etc/shadow is restricted to prevent hash disclosure",
        "D. /etc/shadow is used only on firewalls"
      ],
      "num_answers": 1,
      "answer": "C. /etc/passwd is world-readable, while /etc/shadow is restricted to prevent hash disclosure",
      "answer_keys": ["C"],
      "explanations": {
        "A": "❌ Hashes must not be world-readable.",
        "B": "❌ Modern systems keep hashes in /etc/shadow, not /etc/passwd.",
        "C": "✅ This split design allows user info to be public while protecting password hashes.",
        "D": "❌ /etc/shadow is standard on Linux/Unix, not firewall-specific."
      }
    },
    {
      "question": "21. From a CEH perspective, which sudoers misconfiguration BEST supports lateral movement and privilege escalation inside a network?",
      "options": [
        "A. Granting a specific admin group sudo rights for a limited set of commands",
        "B. Allowing a service account to run /bin/bash as root without a password",
        "C. Requiring all sudo commands to prompt for a password",
        "D. Removing all entries from /etc/sudoers"
      ],
      "num_answers": 1,
      "answer": "B. Allowing a service account to run /bin/bash as root without a password",
      "answer_keys": ["B"],
      "explanations": {
        "A": "❌ Least-privilege sudoers entries are normal.",
        "B": "✅ A service account with passwordless root shell is ideal for attackers to pivot and escalate.",
        "C": "❌ Requiring passwords is safer, not worse.",
        "D": "❌ Removing sudo rights may cause operational issues but doesn’t help attackers."
      }
    },
    {
      "question": "22. Which firewall evasion technique uses spoofed decoy IPs to confuse IDS/IPS and hide the real source of a scan?",
      "options": [
        "A. Nmap --data-length",
        "B. Nmap -D (decoy mode)",
        "C. Nmap -sA (ACK scan)",
        "D. Nmap -T5 (aggressive timing)"
      ],
      "num_answers": 1,
      "answer": "B. Nmap -D (decoy mode)",
      "answer_keys": ["B"],
      "explanations": {
        "A": "❌ --data-length adds padding to packets, not decoys.",
        "B": "✅ -D sends packets that appear to originate from multiple decoy IPs, obscuring the real attacker.",
        "C": "❌ -sA is an ACK scan used to map firewall rules.",
        "D": "❌ -T5 speeds up scans; it may be more noisy, not stealthy."
      }
    },
    {
      "question": "23. A developer fixes SQL injection by using parameterized queries (prepared statements) instead of string concatenation. This primarily addresses which OWASP Top 10 issue?",
      "options": [
        "A. Security Misconfiguration",
        "B. Injection",
        "C. Identification and Authentication Failures",
        "D. Server-Side Request Forgery (SSRF)"
      ],
      "num_answers": 1,
      "answer": "B. Injection",
      "answer_keys": ["B"],
      "explanations": {
        "A": "❌ Misconfiguration relates to wrong settings, not query construction.",
        "B": "✅ Prepared statements are a key defense against SQL injection.",
        "C": "❌ Auth failures are unrelated to SQL query building.",
        "D": "❌ SSRF is about making server-side requests to internal resources."
      }
    },
    {
      "question": "24. Which OWASP Top 10 risk is MOST directly mitigated by implementing strong access control checks on every request and avoiding 'security by URL'?",
      "options": [
        "A. Broken Access Control",
        "B. Cryptographic Failures",
        "C. Vulnerable and Outdated Components",
        "D. Software and Data Integrity Failures"
      ],
      "num_answers": 1,
      "answer": "A. Broken Access Control",
      "answer_keys": ["A"],
      "explanations": {
        "A": "✅ Enforcing proper authorization on each request prevents users from accessing resources they shouldn’t.",
        "B": "❌ Crypto failures focus on encryption and key management.",
        "C": "❌ Outdated components refer to unpatched libraries or frameworks.",
        "D": "❌ Integrity failures deal with supply chain and untrusted updates."
      }
    },
    {
      "question": "25. An attacker tries multiple encoded variants of `<script>alert(1)</script>` in a parameter to bypass WAF rules and trigger XSS. This scenario illustrates which combination of concepts?",
      "options": [
        "A. OWASP Injection + Firewall evasion via encoding",
        "B. Cryptographic Failures + Phishing",
        "C. Misconfiguration + Social Engineering",
        "D. Password Spraying + Logging Failures"
      ],
      "num_answers": 1,
      "answer": "A. OWASP Injection + Firewall evasion via encoding",
      "answer_keys": ["A"],
      "explanations": {
        "A": "✅ XSS is a form of injection, and using multiple encodings is a classic WAF evasion approach.",
        "B": "❌ No crypto or phishing is described here.",
        "C": "❌ This is not primarily a misconfig or social engineering case.",
        "D": "❌ Password spraying and logging are unrelated to encoded XSS payloads."
      }
    }
  ]
}
