Module 12 · Web Penetration Testing · Lesson 35 of 75

Testing inputs: SQL injection, XSS and authentication

Probe safely by hand first, confirm with tools second: SQL injection with sqlmap in the lab, XSS payload testing, and login, reset and session tests.

In this lesson · about 45 minutes

  • Find likely injection points with simple, safe probes
  • Confirm SQL injection with sqlmap on an in-scope lab app
  • Test XSS and authentication controls methodically

Probing for SQL injection

  1. Add ' to a parameter. A database error, a 500, or a changed page is a hint.
  2. Compare boolean pairs: id=5 AND 1=1 (same page) vs id=5 AND 1=2 (different page) suggests injection.
  3. Try a harmless time delay to confirm blind injection.
  4. Confirm with sqlmap only on in-scope, preferably non-production targets, starting at low risk and level. Avoid options that write to the database unless agreed.

Testing XSS

  • Put a unique, harmless marker in every input (nvq7731) and search the responses to see where it is reflected and in what context (HTML body, attribute, JavaScript string, URL).
  • Then craft a test for that context, using alert() or print() as a harmless proof, never something that steals real users' data.
  • For stored XSS, think about who will view the payload: an admin panel is the high-impact place.

Testing authentication and sessions

  • Is there rate limiting or lockout? (Test with a few attempts on your own test account, not a real user's.)
  • User enumeration in messages, timing, or the password-reset page.
  • Password-reset token: length, randomness, expiry, single use, tied to the account?
  • Session: does the cookie change at login? Is it invalid after logout? Do flags exist? Can MFA be skipped?
  • Default credentials on admin panels (from vendor docs).

Hands-on lab (simulated terminal)

Lab: confirm SQL injection with sqlmap

The RoE for the training app at http://10.10.50.12 explicitly allows sqlmap at risk 1, level 1-3, read-only. The product page /product.php?id=3 returned a database error when you added a quote. Output is simulated.

Step 1 of 3. Type each command and press Enter. Nothing runs on your computer.

kali@kali: ~/engagements/web-01

1. Confirm the hint by hand: request id=3' (URL-encode the quote as %27).

┌──(kali㉿kali)-[~/engagements/web-01]
└─$

Decision scenario

Stored XSS in the support ticket form

You are testing a helpdesk app. Your test ticket's subject field is not encoded on the agents' dashboard.

A marker in the subject field shows up unescaped in the HTML of the agent dashboard, which support staff look at all day. The client's support team is live and using the production system.

What do you recommend?

0 of 3 options explored. Try the others to see how each would play out.

Check your understanding0 of 3 correct

Question 1

1.id=5 AND 1=1 shows the product; id=5 AND 1=2 shows nothing. This suggests...

Question 2

2.Why put a unique marker in every input when testing XSS?

Question 3

3.How should you prove SQL injection impact on a production database?

Quiz score: 0 of 3

Tip: answer every quiz question correctly first.

Written by Noviq Academy in its own words. All labs are simulations: no real systems are touched, and every name, address, password and hash is made up. The offensive techniques taught here are for defending systems and for authorised testing only; never scan, access or test a system without the owner's written permission. Tool and product names belong to their owners, and command output may differ slightly from yours. Read-aloud uses your device's built-in voices.