




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which Python tool is most appropriate for creating an isolated forensic analysis environment that prevents package conflicts? A) pip B) virtualenv C) conda D) Docker Answer: B Explanation: virtualenv creates isolated Python environments, ensuring that forensic scripts use specific package versions without affecting the host system. Question 2. In VS Code, which feature provides step‑by‑step execution of a Python forensic script to locate logical errors? A) Linting B) IntelliSense C) Debugger D) Terminal Answer: C Explanation: The Debugger lets you set breakpoints and step through code, essential for verifying forensic logic. Question 3. Which data type would you choose to store a file’s size in bytes, ensuring arithmetic operations can be performed? A) str B) list C) int
D) bool Answer: C Explanation: An integer represents numeric byte counts and supports arithmetic for size comparisons. Question 4. Which Python literal creates an immutable ordered collection of hashable forensic evidence identifiers? A) [] B) {} C) () D) set() Answer: C Explanation: Parentheses define a tuple, which is immutable and preserves order. Question 5. You need to map a file hash to its corresponding file path for quick lookup. Which structure is optimal? A) list B) tuple C) dict D) set Answer: C Explanation: Dictionaries store key‑value pairs, allowing O(1) retrieval of a path using its hash as the key.
Answer: B Explanation: while True creates an infinite loop that can be broken when a stop condition is met, suitable for live monitoring. Question 9. Which module provides functions like os.rename() and shutil.move() for handling forensic file operations? A) sys B) pathlib C) os and shutil D) subprocess Answer: C Explanation: The os module handles low‑level operations like renaming, while shutil provides higher‑level file moving and copying. Question 10. To build a path that works on both Windows and Linux forensic workstations, which class should you use? A) os.path B) pathlib.Path C) string concatenation D) urllib Answer: B Explanation: pathlib.Path abstracts OS‑specific path separators, ensuring cross‑platform compatibility.
Question 11. When reading a UTF‑16 encoded log file from a Windows system, which parameter must be supplied to open()? A) mode='rb' B) encoding='utf-16' C) errors='ignore' D) newline='' Answer: B Explanation: Specifying encoding='utf-16' tells Python to decode the file correctly. Question 12. What is the primary benefit of using a context manager (with open(...)) when handling forensic evidence files? A) Faster file I/O B) Automatic closing of the file handle C) Enables multithreading D) Compresses the file Answer: B Explanation: The with statement guarantees that the file is closed even if an exception occurs, preserving evidence integrity. Question 13. Which function from the os module can be used to recursively list all files with a .sqlite extension in a forensic image directory? A) os.listdir() B) os.walk() C) os.path.isfile() D) os.rename()
Question 16. When parsing binary forensic data, which struct format character represents a 4‑byte unsigned integer in little‑endian order? A) >I B) <I C) =I D) !I Answer: B Explanation: '<' denotes little‑endian; 'I' is a 4‑byte unsigned int. Question 17. Which Python module simplifies reading CSV evidence logs into dictionaries where column headers become keys? A) json B) csv C) pandas D) sqlite Answer: B Explanation: csv.DictReader reads rows as OrderedDict objects keyed by header names. Question 18. When loading JSON data returned from a cloud API containing timestamps, which function should you use? A) json.load() B) json.dumps() C) json.loads() D) json.dump()
Answer: C Explanation: json.loads() parses a JSON string into Python objects, allowing further processing of timestamps. Question 19. Which sqlite3 method should be used to execute a parameterized query that prevents SQL injection when extracting chat messages? A) cursor.execute(sql) B) cursor.executescript(sql) C) cursor.execute(sql, parameters) D) cursor.fetchall() Answer: C Explanation: Passing parameters separately ensures values are safely escaped, protecting against injection. Question 20. To retrieve all rows from a SQLite table named “logs” ordered by timestamp descending, which SQL clause is required? A) ORDER BY timestamp ASC B) ORDER BY timestamp DESC C) GROUP BY timestamp D) HAVING timestamp Answer: B Explanation: ORDER BY … DESC sorts results from newest to oldest, aiding timeline reconstruction.
Answer: B Explanation: exifread can parse EXIF metadata, including GPS tags, from image files. Question 24. A forensic image contains a timestamp stored as a Windows FILETIME (number of 100 ‑nanosecond intervals since 1601‑ 01 ‑01). Which datetime method converts it to a Python datetime object? A) datetime.fromtimestamp() B) datetime.utcfromtimestamp() C) datetime.fromordinal() D) datetime.fromtimestamp(filetime / 10**7 - 11644473600) Answer: D Explanation: FILETIME must be divided by 10⁷ and offset by the Unix epoch (11644473600 seconds) before using fromtimestamp. Question 25. Which hashlib algorithm produces a 64‑character hexadecimal digest, commonly used for verifying large forensic files? A) MD B) SHA‑ 1 C) SHA‑ 256 D) SHA‑ 512 Answer: C Explanation: SHA‑256 yields a 256‑bit (64‑hex‑char) digest, providing strong integrity verification.
Question 26. In a forensic script, you need to compute the MD5 hash of a large file without loading it entirely into memory. Which pattern should you use? A) hashlib.md5(file.read()) B) hashlib.md5().update(file.read()) C) Loop reading chunks and updating the hash each iteration D) hashlib.md5(open(file, 'rb')).hexdigest() Answer: C Explanation: Reading the file in chunks and feeding each chunk to hash.update() avoids high memory usage. Question 27. Which Python statement correctly creates a virtual environment named “forensic_env” using the built‑in venv module? A) python - m venv forensic_env B) virtualenv forensic_env C) conda create - n forensic_env python=3. D) pipenv --python 3. Answer: A Explanation: python - m venv creates a lightweight virtual environment in the specified directory. Question 28. When debugging a Python script that processes evidence files, which VS Code feature highlights variables’ current values inline? A) CodeLens B) Inline Debugging C) Peek Definition D) Live Share
A) Path.cwd() B) Path.home() C) os.getenv('HOME') D) pathlib.gethome() Answer: B Explanation: Path.home() returns the user’s home directory across platforms. Question 32. Which exception should be specifically caught when attempting to open a non‑existent evidence file? A) PermissionError B) FileNotFoundError C) OSError D) IOError Answer: B Explanation: FileNotFoundError is raised when the file path does not exist, allowing targeted error handling. Question 33. When using shutil.copy2() to duplicate an evidence file, which attribute is preserved that is critical for forensic integrity? A) File owner only B) Modification time only C) All metadata, including timestamps and permissions D) File size only
Answer: C Explanation: copy2() copies both file data and its metadata (timestamps, permission bits), preserving forensic attributes. Question 34. Which method of a pathlib.Path object returns an iterator over all files matching the pattern “.log” recursively?* A) Path.glob('/.log') B) Path.rglob('.log') C) Path.iterdir('.log') D) Path.search('.log') Answer: B Explanation: rglob() performs a recursive glob search, yielding all matching files. Question 35. In a forensic script, you need to compare two timestamps that may be in different time zones. Which datetime method helps normalize them to UTC? A) datetime.timestamp() B) datetime.astimezone(timezone.utc) C) datetime.replace(tzinfo=None) D) datetime.isocalendar() Answer: B Explanation: astimezone(timezone.utc) converts aware datetime objects to UTC, enabling accurate comparison. Question 36. Which regex flag makes the pattern case‑insensitive, useful when searching for “password” in logs?
Explanation: datetime.strptime() parses formatted date strings into datetime instances. Question 39. In the context of forensic evidence preservation, why is it recommended to open files using mode ‘rb’ rather than ‘r’? A) Faster reading B) Prevents encoding errors and reads raw bytes unchanged C) Allows writing to the file D) Enables text decoding Answer: B Explanation: ‘rb’ reads the file as raw bytes, ensuring no implicit decoding that could alter binary evidence. Question 40. Which SQLite pragma command can be used to verify that a database file is not corrupted before extracting data? A) PRAGMA integrity_check; B) PRAGMA foreign_keys = ON; C) PRAGMA journal_mode; D) PRAGMA user_version; Answer: A Explanation: PRAGMA integrity_check runs an internal consistency test and reports any corruption. Question 41. When exporting SQLite query results to JSON, which Python module can directly serialize a list of dictionaries? A) csv B) json
C) pickle D) xml.etree Answer: B Explanation: json.dumps() converts Python data structures, like a list of dicts, into a JSON string. Question 42. Which regular expression pattern correctly captures a credit‑card number in the format “ 1234 ‑ 5678 ‑ 9012 ‑ 3456 ”? A) r'\d{4}-\d{4}-\d{4}-\d{4}' B) r'\d{4}\s\d{4}\s\d{4}\s\d{4}' C) r'\d{16}' D) r'[\d-]{19}' Answer: A Explanation: The pattern explicitly matches four groups of four digits separated by hyphens. Question 43. To compute a SHA‑1 hash of a string variable ‘data’, which code snippet is correct? A) hashlib.sha1(data).hexdigest() B) hashlib.sha1(data.encode()).hexdigest() C) hashlib.sha1().update(data) D) hashlib.sha1().digest(data) Answer: B Explanation: The string must be encoded to bytes before hashing; .hexdigest() returns the hex representation.
Answer: B Explanation: re.search() searches throughout the string and returns a match object for the first occurrence. Question 47. In a forensic timeline, you need to convert a Mac absolute timestamp (seconds since 2001 ‑ 01 ‑01) to a standard datetime. Which expression is correct? A) datetime.fromtimestamp(mac_ts) B) datetime.fromtimestamp(mac_ts + 978307200) C) datetime.fromtimestamp(mac_ts - 978307200) D) datetime.utcfromtimestamp(mac_ts) Answer: B Explanation: Adding the offset (978307200 seconds) aligns the Mac epoch with the Unix epoch before conversion. Question 48. Which method of a pathlib.Path object checks whether the path points to a regular file rather than a directory? A) Path.is_dir() B) Path.is_file() C) Path.exists() D) Path.is_symlink() Answer: B Explanation: is_file() returns True only for regular files.
Question 49. When parsing a large binary forensic image, which Python module provides the mmap class for memory‑mapped file access? A) io B) os C) mmap D) struct Answer: C Explanation: mmap.mmap() maps a file into memory, allowing random access without loading the entire image. Question 50. Which SQLite data type is optimal for storing a SHA‑256 hash as a 64‑character hexadecimal string? A) BLOB B) TEXT C) INTEGER D) REAL Answer: B Explanation: Storing the hash as a TEXT string preserves the exact hexadecimal representation. Question 51. Which Python statement correctly writes a dictionary ‘metadata’ to a JSON file with indentation for readability? A) json.dump(metadata, file) B) json.dumps(metadata, indent=4) C) json.dump(metadata, file, indent=4) D) json.dump(metadata, file, sort_keys=True)