THM – How Websites Work – Part 9

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

  • THM – Network Services – FTP – Part 4

    Table Of ContentsUnderstanding FTP Enumerating FTP Exploiting FTP  Understanding FTP  What is FTP? File transfer protocol is a protocol used to allow remote transfer of files over a network. It uses a client-server model to do this. It relays command and data in a very efficient way.   How does FTP work?  A typical FTP session operates using two channels:  A command channel   A data channel  The command channel is used for transmitting commands as well as replies to those commands, while the data channel is used for transferring data.   FTP operates using a client-server protocol. The client…

  • THM – Metasploit Complete Documentation – Part 14

    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 ContentsMetasploit: IntroductionMain Components of MetasploitMsfconsole exploit rankMetasploit: ExploitationTopicsScanningThe Metasploit DatabaseVulnerability ScanningExploitationWorking with sessionsMsfvenomOutput formatsEncodersOther PayloadsMeterpreterPost-Exploitation with MeterpreterHelpMeterpreter commandsMigrateHashdumpSearchShellPost-Explotation Challenge Metasploit: Introduction The main components of the Metasploit Framework…

  • Command And Control – C2 Framework

    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 and other Debian based Distros only.Debian 10/11Building the…

  • THM – John The Ripper – Part 15

    This is a continued series where I document my path through different tryhackme courses. I recommend everyone that wants to learn cyber security to subscribe to tryhackme.com and take the courses there. Table Of ContentsCracking Basic HashesCracking Windows authentication HashesCracking /etc/shadow HashesSingle Cracking ModeCustom RulesCracking Password Protected Zip FilesCracking Password Protected RAR FilesCracking SSH Keys…

  • Pivoting and port forwarding guide

    This is notes taken from the THM room ‘Wreath’, which is a great room for learning Active Directory and pivoting. https://www.tryhackme.com/room/wreath And from other sources. Table Of ContentsSummaryWhat is pivoting?High level overviewEnumerationProxychains & FoxyProxyProxychainsFoxyProxySSH Tunnelig / Port ForwardingForward ConnectionsNMAP with SSH proxyReverse ConnectionsSSH Remote Port Forwarding (From PDF)SSH Local Port ForwardingPlink.exeSocatReverse Shell RelayPort Forwarding —…

  • AV Evasion 101: Essential Techniques and Concepts

    Table Of ContentsSourceGood toolsMalware forums/channels/discordTest payload against AVDefcon – Writing custom backdoor payloads with C#Step by Step for obfuscating codeAV Evasion MindMap – From Start to finishGeneral AV Evasion cheatsheetCheck AV – Running, Exclusion, DisableWindows FirewallPowershell – ASMI bypass methods, Disable AV, etcAMSI BypassBypass CLM (Constrained Language Mode)Bypass loggingDisable MS Defender (Require elevation)Add folder exclusionLSASS…