Uni-Sine
Computer ScienceCourses

Hack a Website: a defensive web security course

Hack a Website is an introductory ethical hacking course focused on web security. It teaches how common website weaknesses work so that you can build and review sites that are not vulnerable to them. Across 26 short sections it covers the law and ethics of security testing, why a server must never trust what a browser sends, the OWASP Top 10, and the main classes of web weakness, each paired with the defence developers use against it.

All of the course's exercises run on simulated pages built for the purpose. The course is clear from its second section that testing a real system without permission is a crime.

What the course covers

SectionsTopic
1 to 3Learning attacks in order to defend, and only testing with permission
4 to 6Why every request can be edited, and the OWASP Top 10
7 to 10Injection into database queries, and parameterised queries as the fix
11 to 16Cross-site scripting, output encoding and Content Security Policy
17 to 18Cross-site request forgery and SameSite cookies
19 to 22Storing passwords safely, rate limits, multi-factor authentication and access control
23 to 26HTTPS, security headers, keeping secrets out of code, and how professionals test

The law and ethics come first

Accessing a computer system without permission is a criminal offence. In the UK it falls under the Computer Misuse Act 1990, and in the US under the Computer Fraud and Abuse Act; most countries have similar laws. Curiosity is not a defence. Ethical hackers test only systems they own, or systems whose owner has given clear, written permission, and they stay inside the agreed scope.

Decide which kinds of testing stay on the right side of the law, then press Mark to check your answers in the course:

Decide whether each kind of testing is allowed.

Press Mark to have your answer marked in the Hack a Website course.

How the main weaknesses work, and how they are fixed

Never trust the browser

Everything a browser sends, including form fields, hidden values, cookies and headers, is under the control of whoever is using it. So the server has to check every request itself. This one idea underlies most of the course.

Injection

Injection happens when a program mixes untrusted text into a command, such as a database query, so the text can change what the command means. The standard defence is to keep data and commands apart, for example with parameterised queries, where values are passed separately and can never be read as part of the command.

Cross-site scripting

Cross-site scripting happens when a site places a visitor's text into a page in a way that lets the browser treat it as code. The defences are output encoding, which makes text display as text, and a Content Security Policy, a header that tells the browser which scripts the site allows.

Cross-site request forgery

Browsers send a site's cookies with requests to it, even when another site started the request. Without protection, that lets another site trigger actions as a logged-in user. SameSite cookie settings and anti-forgery tokens stop it.

Accounts, access and configuration

Passwords should be stored only as slow, salted hashes, never as typed. Rate limits and multi-factor authentication make guessing impractical. Access control checks, on every request, that the logged-in user is allowed to do this action to this particular item. HTTPS, security headers and keeping secret keys out of code repositories close off further routes.

Who this course is for

  • Web developers who want to write code that holds up against the common weaknesses.
  • Computing students studying cyber security threats and how they are prevented.
  • Anyone considering a career in cyber security, who wants an honest, legal starting point.

What you need to know first

The course page lists HTML, CSS & JavaScript and APIs first. You need to know how a web page talks to a server with requests and responses. Our TLS and SSL guide covers HTTPS in more depth.

How long it takes

There are 26 sections and most take a few minutes. Learners without a plan can open two sections of a course a day, in order, so the whole course takes 13 days. A plan removes the daily limit and lets you go straight to any topic.

Guided courseHosting & DeploymentPut a site online safely: HTTPS, secrets in environment variables, and deploying from Git.

Common questions

Is this ethical hacking course free?
You can take every section without paying, two sections a day, in order. A plan removes the daily limit and opens any section straight away.
Is ethical hacking legal?
Yes, when you have permission. Testing systems you own, or systems whose owner has given written permission within an agreed scope, is legal. Doing the same thing without permission is a crime under laws such as the UK Computer Misuse Act 1990 and the US Computer Fraud and Abuse Act.
What is the OWASP Top 10?
A list of the most serious security risks to web applications, published by OWASP, a non-profit organisation that shares free security guidance. Developers use it to decide what to protect against first.
Do I need to know how to code?
Some HTML, JavaScript and an understanding of how browsers talk to servers will help you follow the examples and the fixes.
Does the course teach me to attack real websites?
No. It explains how weaknesses work using simulated pages, so that you can prevent them, and it stresses that testing a real site without permission is illegal.
How do I start a career in ethical hacking?
Learn how the web and networks work, study common weaknesses and their defences, practise only on systems you own or on legal training platforms, and look at recognised security qualifications.

Revision cards

Say the answer first, then flip the card to check it.

Where to go next

  • Learn it

    Hack a Website

    XSS, CSRF and SQL injection: learn to defend web applications

    Start the course
  • Test it

    GCSE Computer Science

    A new exam-style paper every day, with instant marking and a mark scheme

    Start today's paper
Read next
Computer Science · CoursesHardware security course: threats to devices and defencesA hardware security course in 25 short sections: side channels, faults, debug ports, secure boot, supply chains and tamper resistance.