Question 89 of 509
Tools and Code AnalysismediumMultiple ChoiceObjective-mapped

Quick Answer

The answer is `reg save HKLM\SAM sam.hive`. This command is correct because `reg save` creates a binary copy of the specified registry hive, preserving the raw structure needed for offline password hash extraction. Unlike `reg export`, which outputs a human-readable text file, `reg save` produces a binary file that tools like `samdump2` or `secretsdump.py` can parse to extract NTLM hashes from the SAM hive after also saving the SYSTEM hive for the boot key. On the CompTIA PenTest+ PT0-002 exam, this question tests your ability to automate post-exploitation hash extraction after gaining SYSTEM-level access—a common trap is confusing `reg save` with `reg export`, which cannot be used for offline hash dumping. Remember the memory tip: “Save binary, export text” to quickly recall that `reg save` is the only option for creating a parseable hive file.

PT0-002 Tools and Code Analysis Practice Question

This PT0-002 practice question tests your understanding of tools and code analysis. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

A penetration tester is writing a Bash script to automate the extraction of password hashes from a Windows system after gaining SYSTEM-level access. The script uses 'reg.exe' to save the SAM and SYSTEM hives. Which command should the tester include in the script to export the SAM hive to a file?

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "which command"

    Why it matters: Tests specific CLI syntax. Recall the exact command and its required context — near-synonyms and partial matches are common distractors.

Question 1mediummultiple choice
Full question →

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

reg save HKLM\SAM sam.hive

The correct command is 'reg save HKLM\SAM sam.hive' because 'reg save' creates a binary copy of the specified registry hive, which is necessary for offline extraction of password hashes. The SAM hive contains the hashed credentials, and saving it as a file allows tools like 'samdump2' or 'secretsdump.py' to parse the hashes. The other options either export in a non-binary format or use a non-existent command.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • reg save HKLM\SAM sam.hive

    Why this is correct

    reg save creates a binary copy of the hive, which can be used for offline extraction.

    Clue confirmation

    The clue word "which command" in the question point toward this answer.

    Related concept

    Read the scenario before looking for a memorised answer.

  • reg export HKLM\SAM sam.hive

    Why it's wrong here

    reg export exports the hive as a .reg text file, not a binary hive file suitable for hash extraction.

  • reg backup HKLM\SAM sam.hive

    Why it's wrong here

    reg backup is not a valid Windows command.

  • reg copy HKLM\SAM sam.hive

    Why it's wrong here

    reg copy is not a valid Windows command.

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap here is that candidates confuse 'reg export' (which produces a human-readable text file) with 'reg save' (which produces a binary hive file), leading them to choose the export option for hash extraction.

Trap categories for this question

  • Command / output trap

    reg backup is not a valid Windows command.

Detailed technical explanation

How to think about this question

The 'reg save' command writes the hive to a file in a binary format that mirrors the on-disk registry structure, including the encrypted hash data. Tools like 'secretsdump.py' from Impacket can then parse this file offline, leveraging the boot key from the SYSTEM hive to decrypt the hashes. In real-world engagements, this technique is used to avoid live memory dumping and to extract hashes stealthily from a compromised system.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A SOC analyst notices unusual lateral movement in the network at 2 AM. The IR playbook dictates: identify and contain (isolate the affected machine), then eradicate (remove the malware), then recover (restore from backup), then document. Skipping containment before eradication risks the attacker regaining access. Questions like this test the sequence and rationale of incident response phases.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related PT0-002 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free PT0-002 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this PT0-002 question test?

Tools and Code Analysis — This question tests Tools and Code Analysis — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: reg save HKLM\SAM sam.hive — The correct command is 'reg save HKLM\SAM sam.hive' because 'reg save' creates a binary copy of the specified registry hive, which is necessary for offline extraction of password hashes. The SAM hive contains the hashed credentials, and saving it as a file allows tools like 'samdump2' or 'secretsdump.py' to parse the hashes. The other options either export in a non-binary format or use a non-existent command.

What should I do if I get this PT0-002 question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Are there clue words in this question I should notice?

Yes — watch for: "which command". Tests specific CLI syntax. Recall the exact command and its required context — near-synonyms and partial matches are common distractors.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 11, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This PT0-002 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PT0-002 exam.