Basics of Web Exploitation Techniques: Examples Included

Shubh Jain
3 min readMay 19, 2023

--

Web exploitation was the first section of hacking or ctf which I started with because I was just enjoying it, and I felt it was easier as compared to other domains. You can try it anywhere, everywhere on the net; I remember trying cross-site scripting and SQL injection on nearly every site I visited. You just need to understand the architecture or simply the pipeline of a website, and you can attack. Web vulnerabilities are very common in the battleground. Either laziness or a small error missed can take down an entire organisation.

In this blog post, we will explore the basics of several common web exploitation techniques, including Cross-Site Scripting (XSS), SQL Injection, Cross-Site Request Forgery (CSRF), Directory Traversal, and Command Injection. Through real-world examples, we’ll shed light on the risks involved and emphasise the importance of robust security measures.

  1. Cross-Site Scripting (XSS): Cross-Site Scripting (XSS) is a prevalent web vulnerability that occurs when an attacker injects malicious scripts into a trusted website, which are then executed in the victim’s browser. By exploiting insufficient input sanitisation, attackers can steal sensitive user information, manipulate website content, or perform unauthorised actions. Example: Consider a web forum where users can post comments. If the application fails to properly sanitize user input, an attacker can inject a script that steals users’ login credentials or redirects them to a phishing website.
  2. SQL Injection: SQL Injection is a technique where an attacker injects malicious SQL queries into a web application’s database query. By exploiting improper handling of user input, attackers can manipulate queries to gain unauthorised access to the database, extract sensitive data, or modify/delete data. Example: In a login form that accepts a username and password, if the application does not sanitise input properly, an attacker can input a specially crafted string that alters the intended SQL query. This can potentially bypass authentication and grant unauthorised access to the system.
  3. Cross-Site Request Forgery (CSRF): Cross-Site Request Forgery occurs when an attacker tricks a victim into unknowingly performing unwanted actions on a trusted website where the victim is authenticated. By exploiting the victim’s trust, attackers can perform actions on their behalf, leading to unauthorised changes or data theft. Example: Suppose a victim is logged into their online banking account. An attacker could trick the victim into clicking a malicious link that automatically transfers funds from their account to the attacker’s account without the victim’s consent.
  4. Directory Traversal: Directory Traversal, also known as Path Traversal, involves exploiting insufficient security checks in file path handling to access files and directories outside of the intended scope. Attackers can traverse directories and retrieve sensitive files or execute arbitrary code. Example: If a web application allows users to view files by specifying a file name in the URL, insufficient input validation can enable an attacker to navigate to directories outside the intended scope. This can lead to unauthorised access to critical system files or expose confidential information.
  5. Command Injection: Command Injection occurs when an attacker inserts malicious commands into system commands executed by a web application. This vulnerability arises when user-supplied input is not properly validated or sanitised before being passed to the underlying operating system. Example: If a web application allows users to execute system commands, an attacker can inject malicious commands to execute arbitrary code, gain unauthorised access to the system, or perform malicious actions.

Refer to: https://ctf101.org/ (web exploitation section)for more detailed examples along with their application which will help you understand better.

Conclusion: Awareness of web exploitation techniques such as Cross-Site Scripting (XSS), SQL Injection, Cross-Site Request Forgery (CSRF), Directory Traversal, and Command Injection is crucial for building secure web applications. By understanding these vulnerabilities and implementing robust security measures like input validation, parameterised queries, output encoding, CSRF tokens, file path sanitisation, and command validation, developers can mitigate the risks associated with web exploitation. Stay vigilant, regularly update security practices, and prioritise robust coding practices to protect user data and ensure the integrity of web applications.

--

--