THM – How Websites Work – Part 9

Last Updated on January 25, 2022 by aghanim

Photo by Erik Mclean on Unsplash

How websites work 

When you visit a website, your browser makes a request to a web server asking for information about the page you’re visiting and will respond with data that your browser uses to show you the page; a web server is just a dedicated computer that handles your requests.  

There are two major components that make up a website:  

  1. Front End (Client-side) – the way your browser renders a website 
  2. Back End (Server-side) – a server that processes your request and returns a response 

HTML 

Websites are primarily created using: 

  • HTML, to build websites and define their structure 
  • CSS, to make websites look pretty by adding styling options 
  • JavaScript, implement complex features on pages using interactivity 

HyperText Markup Language (HTML) is the language websites are written in. Elements  (or tags) are the building blocks of HTML pages and tells the browser how to display content. Code snippet of HTML Code: 

The HTML structure (as shown in the screenshot) has the following components: 

  • The <!DOCTYPE html> defines that the page is a HTML5 document. This helps with standardisation across different browsers and tells the browser to use HTML5 to interpret the page. 
  • The <html> element is the root element of the HTML page – all other elements come after this element. 
  • The <head> element contains information about the page (such as the page title) 
  • The <body> element defines the HTML document’s body, only content inside of the body is shown in the browser. 
  • The <h1> element defines a large heading 
  • The <p> element defines a paragraph 
  • There are many other elements (tags) used for different purposes. For example, there are tags for: buttons (<button>), images (<img>), lists, and much more. 

You can view the HTML of any website by right-clicking, and selecting “View Page Source”.  

JavaScript 

JavaScript (JS) allows pages to become interactive . HTML is used to create a the website structure and content, while JavaScript is used to control the functionality of webpages. JS can dynamically update the page in real-time.  

JavaScript is added within the page source code and ca be either loaded within <script> tags or can be included remotely with the src attribute: 

<script src="/location/of/javascript_file.js"></script> 

This JavaScript code finds a HTML element on the page with the ID “demo” and changes the elements contents to “Hack the planet”: 

document.getElementById("demo").innerHTML = "Hack the Planet"; 

HTML elementes can also have events, such as “onclick” that execute JavaScript when the event occurs. This code changes the text of the element with the demo ID to Button Clicked: 

<button onclick='document.getElementById("demo").innerHTML = "Button Clicked";'>Click Me!</button> 

Sensitive Data Exposure 

Sensitive Data Exposure is when a website dosent properly protect (or remove) sensitive clear-text information to the end-user; which is found in the frontend source code of sites.  

Everyone can look at the page source code, so when a website developer forget to remove login credentials, hidden links to private parts of the webiste or other sensitive data showin in HTML or Javascript, everyone can look at them.  

HTML Injection 

HTML Injection is a vulnerability that occurs when unfiltered user input is displayed on the page. If a website fails to sanitize user input (Filter any “malicious text” that a user inputs into a website), and that input is used on the page, an attacker can inject HTML code into a vulnerable website.  

Input sanitization is very important in keeping a website secure, as information user inputs into a websites often used in other frontend and backend functionality.  

The above image show how a form outputs text to the page.  

General rule is to never trust user input – to prevent malicious input the website developer should sanitize everything the user enters before using it in the JavaScript function.

Similar Posts

  • Command And Control – C2 Framework

    Last Updated on October 3, 2024 by aghanim This is a list of Command and control (C2) servers that I’ve tested. Table Of ContentsCobalt StrikeCovenantInstallation and setupLisenersGruntsPowershell-Empire with StarkillerPoshC2GodGenesisMetasploitSliverLinks and tutorialInstallSliver and MetasploitBeacon vs sessionGenerating HTTP(S) Implants with certificateExtensions (Armory)CheatsheetExample getting beacon with msfBypassing defender with staged process hollowingHavoc C2InstallInstall the dependenciesUbuntu 20.04 / 22.04Kali…

  • THM – Linux Privilege Escalation – Part 15

    Last Updated on September 28, 2022 by aghanim This is my notes from the Junior Pentesting course at TryHackMe. This course takes you through the basics and some advanced topics regarding penetration testing. Table Of ContentsLinux Privilege escalation checklistEnumerationhostnameuname -a/proc/version/etc/issueps Commandenvsudo -llsId/etc/passwdhistoryifconfignetstatfind CommandFind files:General Linux CommandsAutomated Enumeration ToolsPrivilege Escalation: Kernel ExploitsHint/notes Privilege Escalation: SudoLeverage LD_PRELOADPrivilege Escalation:…

  • THM – Principles of Security – Part 2

    Last Updated on January 25, 2022 by aghanim This is my notes from the Junior Pentesting course at TryHackMe. This course takes you through the basics and some advanced topics regarding penetration testing. Table Of ContentsPrinciples of PrivilegesSecurity Models ContinuedThe Bell-La Padula ModelBiba ModelThreat Modelling & Incident Response Principles of Privileges The levels of access…

  • Active Directory – Notes, Methodology, Cheatsheet

    Last Updated on October 17, 2025 by aghanim These are my notes from the Active Directory networks at TryHackMe, as well as notes from other sources. Inspo: Work in progress Table Of ContentsReferences MatrixLOLBAS – Living off the landWADComs – Very useful cheatsheetIcebreakerAD MethodologyMindmap – Current 2025Mindmap – Nr 2Mindmap – Nr 3Active Directory TheoryObject…

  • THM – OWASP Top 10 – Part 12

    Last Updated on January 25, 2022 by aghanim Table Of ContentsIntro [Severity 1] Injection[Severity 1] OS Command Injection[Severity 1] Command Injection Practical [Severity 2] Broken Authentication[Severity 2] Broken Authentication Practical [Severity 3] Sensitive Data exposure (Introduction) [Severity 3] Sensitive Data exposure (Supporting material 1)  [Severity 3] Sensitive Data exposure (Supporting material 2) [Severity 3] Sensitive Data exposure (Challenge)[Severity 4] XML External…