During a penetration test, you are analyzing data exfiltrated from a target company’s employee directory. The data is formatted in a CSV file, which includes names, departments, and email addresses. Which of the following methods would be BEST to programmatically extract and display email addresses from each line, assuming the email address is the third value in each row?
Counting the number of words in each line and using an if statement to find email addresses
Using a regular expression to match any text that follows two commas
Encrypting and decrypting each line to isolate the email addresses
Splitting each line at commas and selecting the third element of the resulting list
The correct answer is 'Splitting each line at commas and selecting the third element of the resulting list', because a CSV file is essentially a text file containing data where each line represents a row of data, and each value within that row is separated by a comma. By splitting a line of text at each comma, you create a list where each element correlates to a value in the CSV row. Since the email address is the third value, you would select the third element in the list (often indexed as [2] since most programming languages use zero-based indexing).
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is a CSV file?
Open an interactive chat with Bash
What is zero-based indexing?
Open an interactive chat with Bash
How can regular expressions be used with CSV files?