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…
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
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)- A3% (1)
- B6% (2)
- C81% (25)
- D10% (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
Community Discussion
No community discussion yet for this question.
