LOGO

SQL Injection & DDoS Attacks: How Hackers Take Over Websites

September 28, 2016
SQL Injection & DDoS Attacks: How Hackers Take Over Websites

Understanding Common Hacker Tactics

Many individuals have at least a passing awareness of the activities of hacking collectives such as Anonymous and LulzSec, often linked to high-profile website breaches like the well-known Sony attacks. A natural question arises: what methods do these groups employ to achieve such intrusions?

A variety of tools and techniques are utilized by these actors. While this explanation isn't intended as a guide for malicious activity, comprehending these methods is valuable for understanding the current threat landscape.

Two Prevalent Attack Vectors

Two attack types frequently associated with these groups are (Distributed) Denial of Service (DDoS) attacks and SQL Injection (SQLI) attacks. The following details explain their functionality.

These methods represent core strategies in the toolkit of many hackers, allowing them to disrupt services or gain unauthorized access to data.

Understanding these techniques can help individuals and organizations better protect themselves against cyber threats.

Image by xkcd

DDoS attacks overwhelm a target server with traffic, rendering it unavailable to legitimate users. This is achieved by coordinating numerous compromised computers to simultaneously request data from the server.

SQL Injection, conversely, exploits vulnerabilities in a website’s database interaction. Attackers insert malicious SQL code into input fields, potentially gaining access to sensitive information or modifying database content.

Both DDoS and SQLI attacks demonstrate the importance of robust security measures, including firewalls, intrusion detection systems, and secure coding practices.

Denial of Service Attack

What is it?

A denial of service (often referred to as a distributed denial of service, or DDoS) attack involves overwhelming a system, such as a web server, with an excessive volume of requests. This overload exhausts the server’s resources, leading to system lockups and eventual shutdown.

Understanding the Outcome

A successful DDoS attack renders the targeted websites inaccessible to genuine user traffic. The intended consequence is disruption of service for legitimate visitors.

How Does a DDoS Attack Function?

The mechanics of a DDoS attack are best illustrated through a practical example.

Consider a scenario where a million individuals, acting as attackers, aim to disrupt the operations of Company X by incapacitating their call center. They synchronize their efforts, agreeing to simultaneously call Company X’s phone number on Tuesday at 9 AM.

The Impact on Service

It’s highly probable that Company X’s phone system would be unable to manage a million concurrent calls. This would result in all incoming lines being occupied by the attackers, effectively blocking legitimate customer calls.

Consequently, genuine customers would be unable to connect, potentially leading to lost business for Company X due to the inability to process valid requests.

Web Server Attacks: A Parallel Process

A DDoS attack targeting a web server operates on the same principle. Distinguishing between legitimate traffic and malicious requests is typically impossible until the server begins processing each request.

This inherent difficulty makes this type of attack particularly effective.

The Execution of a DDoS Attack

Given the “brute force” nature of a DDoS attack, a substantial number of computers must be coordinated to launch the attack simultaneously. Returning to our call center analogy, this requires all attackers to be aware of the 9 AM timeframe and actively participate at that time.

Leveraging Compromised Systems

While this approach is viable, it becomes significantly more streamlined when utilizing compromised computers – often referred to as “zombie computers” – instead of relying on manually operated machines.

Numerous malware and Trojan variants, once installed on a system, remain dormant and periodically connect to a central server for instructions. One such instruction could involve sending repeated requests to Company X’s web server at a specified time.

The Power of Coordination

With a single update to the malware’s control server, a single attacker can instantly mobilize hundreds of thousands of compromised computers to execute a large-scale DDoS attack.

The advantage of employing zombie computers lies not only in its effectiveness but also in the attacker’s anonymity, as they do not need to directly utilize their own resources to carry out the attack.

SQL Injection Attack

What is it?

A SQL injection (SQLI) attack exploits vulnerabilities stemming from inadequate web development practices and, often, insufficient database security measures. A successful attack’s consequences can vary significantly, ranging from user account impersonation to a complete compromise of the database or server. Importantly, SQLI attacks are entirely preventable with appropriate web application programming.

Executing the Attack

Consider the process of logging into a website. When you submit your username and password, the application typically executes a query to verify your credentials, such as:

SELECT UserID FROM Users WHERE UserName='myuser' AND Password='mypass';

String values within a SQL query are enclosed in single quotes. The query only returns a UserID if the provided username and password match an entry in the Users table; otherwise, the login fails.

Let's examine a template authentication query where user-provided values are substituted:

SELECT UserID FROM Users WHERE UserName='[user]' AND Password='[pass]'

While seemingly straightforward, this approach is vulnerable to SQLI if simple substitution of user input is performed without proper safeguards.

For instance, if a user enters "myuser'--" in the username field and "wrongpass" in the password field, the resulting query becomes:

SELECT UserID FROM Users WHERE UserName='myuser'--' AND Password='wrongpass'

The double dashes ((--)) signify a SQL comment. Anything following these dashes is ignored by the database. Therefore, the query effectively becomes:

SELECT UserID FROM Users WHERE UserName='myuser'

The password check has been bypassed. The attacker can log in as "myuser" without knowing the actual password. This manipulation of the query to achieve unintended results constitutes a SQL injection attack.

What Damage Can Be Done?

SQL injection attacks arise from careless coding and are preventable. However, the extent of the damage depends on the database setup and the permissions granted to the web application’s database account. This account is distinct from user logins to the website itself.

The permissions can range from read/write access to existing tables to full database control. Consider the example where entering "youruser'--" or "admin'--" allows immediate login as those users, granting full access to their accounts. Database permissions typically don’t offer protection against this, as websites generally require at least read/write access.

If the website has full database control—the ability to delete records, add/remove tables, or create new accounts—the potential damage is significant. While some applications legitimately require this level of access, it increases the risk.

To illustrate, entering "Robert'; DROP TABLE Users;--" into the username field results in the following query:

SELECT UserID FROM Users WHERE UserName='Robert'; DROP TABLE Users;--' AND Password='wrongpass'

The semicolon (;) separates SQL statements. The database executes this as:

SELECT UserID FROM Users WHERE UserName='Robert'

DROP TABLE Users

The entire Users table is deleted. Attackers could also modify data, extract tables, create new login accounts, or even compromise the entire database installation.

Preventing a SQL Injection Attack

SQL injection attacks are easily preventable by never trusting user input blindly. This is a fundamental principle of secure web development.

The solution is to sanitize, or escape, user inputs. This process handles inline single quote characters (') to prevent them from prematurely terminating strings within SQL statements.

For example, to search for "O'neil", you can’t use simple substitution. Instead, use the database’s escape character. Assuming the escape character is a backslash (\), "O'neil" becomes "O\'neil".

This simple sanitation effectively prevents SQLI. Let’s revisit our previous examples with sanitized input:

myuser'-- / wrongpass:

SELECT UserID FROM Users WHERE UserName='myuser\'--' AND Password='wrongpass'

The escaped single quote ensures the database searches for the literal string "myuser'--". The dashes are also treated as part of the string, not as a comment.

Robert'; DROP TABLE Users;-- / wrongpass:

SELECT UserID FROM Users WHERE UserName='Robert\'; DROP TABLE Users;--' AND Password='wrongpass'

Escaping the single quote after "Robert" ensures the semicolon and dashes are part of the search string, preventing the table deletion.

Understanding Web Attack Vulnerabilities

As web-based threats continuously develop and gain complexity, or shift their primary targets, it remains crucial to defend against established attack methods.

These conventional attacks frequently serve as the foundation for numerous readily accessible "hacker tools" created to leverage their weaknesses.

Attack Avoidance and Potential Impact

The feasibility of preventing certain attacks, like Distributed Denial of Service (DDoS), is limited. Conversely, attacks such as SQL Injection (SQLI) can often be mitigated.

The severity of damage resulting from these attacks can vary significantly, ranging from minor disruptions to complete system failures, depending on the preventative measures implemented.

Types of Web Attacks

  • DDoS Attacks: These attacks overwhelm a system with traffic, making it unavailable.
  • SQL Injection: Exploits vulnerabilities in database queries to gain unauthorized access.

Effective security strategies involve addressing both types of threats. Proactive measures are essential for minimizing potential harm.

Mitigation Strategies

While complete prevention isn't always possible, robust security practices can significantly reduce risk. These include regular security audits and patching of vulnerabilities.

Implementing web application firewalls (WAFs) and intrusion detection systems (IDS) can also provide an additional layer of defense against malicious activity.

Protecting your web applications requires a multi-faceted approach. Staying informed about emerging threats and adapting security measures accordingly is paramount.

#SQL injection#DDoS attack#website security#hacking#cyber security#web vulnerabilities