nerdexam
EC-Council

312-92 · Question #41

William, a software developer just starting his career, was asked to create a website in PHP that would allow visitors to enter a month and a year for their birth date. The PHP code he creates has…

The correct answer is D. ";rm -rf *". See the full explanation below for the reasoning.

Question

William, a software developer just starting his career, was asked to create a website in PHP that would allow visitors to enter a month and a year for their birth date. The PHP code he creates has to validate the input after it is entered. If William uses the following code, what could a malicious user input to the year value to actually delete the whole website? $month = $_GET['month']; $year = $_GET['year']; exec("cal $month $year", $result); print "<PRE>"; foreach($result as $r) { EC-Council 312-92 Exam print "$r<BR>"; } print "</PRE>";

Options

  • A";gf -rm *"
  • B";dfr -php *"
  • C";php -rf *"
  • D";rm -rf *"

How the community answered

(29 responses)
  • A
    10% (3)
  • B
    3% (1)
  • C
    3% (1)
  • D
    83% (24)

Community Discussion

No community discussion yet for this question.

Full 312-92 Practice