nerdexam
CompTIA

PT0-002 · Question #477

During a REST API security assessment, a penetration tester was able to sniff JSON content containing user credentials. The JSON structure was as follows: Assuming that the variable json contains…

The correct answer is C. json['content'][1]['password'][0]. The JSON structure contains a top-level key content, which is a list of dictionaries. Each dictionary has user_id and password keys. To access the password for the user "ozzy", Access the content list at index 1 (json['content'][1]), which corresponds to the second item (for…

Tools and Code Analysis

Question

During a REST API security assessment, a penetration tester was able to sniff JSON content containing user credentials. The JSON structure was as follows:

Assuming that the variable json contains the parsed JSON data, which of the following Python code snippets correctly returns the password for the user ozzy?

Exhibit

PT0-002 question #477 exhibit

Options

  • Ajson['content']['password'][1]
  • Bjson['user_id']['password'][0][1]
  • Cjson['content'][1]['password'][0]
  • Djson['content'][0]['password'][1]

How the community answered

(31 responses)
  • A
    3% (1)
  • B
    6% (2)
  • C
    81% (25)
  • D
    10% (3)

Explanation

The JSON structure contains a top-level key content, which is a list of dictionaries. Each dictionary has user_id and password keys. To access the password for the user "ozzy", Access the content list at index 1 (json['content'][1]), which corresponds to the second item (for "ozzy"). Within that dictionary, access the password key (['password']), which contains a list. Retrieve the first (and only) element of the password list ([0]).

Topics

#JSON Parsing#Python Data Structures#API Security#Credential Exposure

Community Discussion

No community discussion yet for this question.

Full PT0-002 Practice