🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Command Injection and Path Traversal: all 10 questions

Quiz: Command Injection and Path Traversal · Question 3 of 10

What does this print? (code)

What does this print?

cmd = ["ping", "-c", "1", "1.1.1.1 && whoami"]
print(len(cmd), cmd[-1])
  1. A.6 whoami
  2. B.4 1.1.1.1 && whoami
  3. C.5 &&
  4. D.4 1.1.1.1
Answer & explanation

Correct answer: 4 1.1.1.1 && whoami

The user's whole text is one list item, so ping receives it as one strange host name.

Can you get the rest right without peeking?

Take the timed Quiz: Command Injection and Path Traversal quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →