0% found this document useful (0 votes)
13 views4 pages

SQL Injection Lab Report Guide

Uploaded by

22110375
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

SQL Injection Lab Report Guide

Uploaded by

22110375
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Lab 5.

SQL Injection

SQL injection is a code injection technique that exploits the vulnerabilities in the
interface between web applications and database servers. The vulnerability is present
when user’s inputs are not correctly checked within the web applications before being
sent to the back-end database servers
Submission:
You will compose a lab report that documents each step you take, including screenshots
to illustrate the effects of commands you type, and describing your observations. Simply
attaching code without any explanation will not receive credits

Prepare:
- Pre-built Ubuntu VM (download from the SEED Website)
LAB GUIDE:
1. Review the lab environment

#vi /etc/host
# /etc/ apache2/sites-available/ [Link]
2. Get Familiar with SQL Statements
.
we have already created the Users database for you, you just need to load this
existing database using the following command:

you can use the following command to print out all the tables of the selected
database

After running the commands above, you need to use a SQL command to print all
the profile information of the employee Alice. Please provide the screenshot of
your results
3. SQL Injection Attack on SELECT Statement
We will use the login page from [Link] for this task
The web application authenticate users based on these two pieces of data, so only
employees who know their passwords are allowed to log in. Your job, as an attacker, is to
log into the web application without knowing any employee’s credential.
To help you started with this task, we explain how authentication is implemented
in the web application. The PHP code unsafe [Link], located in the
/var/www/SQLInjection directory, is used to conduct user authentication. The following
code snippet show how users are authenticated

4. SQL Injection Attack from webpage.


Your task is to log into the web application as the administrator from the login
page, so you can see the information of all the employees. We assume that you do
know the administrator’s account name which is admin, but you do not the password.
You need to decide what to type in the Username and Password fields to succeed in
the attack.
5. SQL Injection Attack on UPDATE Statement
If a SQL injection vulnerability happens to an UPDATE statement, the damage will
be more severe, because attackers can use the vulnerability to modify databases. In
our Employee Management application, there is an Edit Profile page that allows
employees to update their profile information, including nickname, email, address,
phone number, and password

When employees update their information through the Edit Profile page, the following
SQL UPDATE query will be executed. The PHP code implemented in unsafe edit
[Link] file is used to update employee’s profile information. The PHP file is
located in the /var/www/SQLInjection directory
• Task 5.1: Modify your own salary. As shown in the Edit Profile page, employees
can only update their nicknames, emails, addresses, phone numbers, and passwords;
they are not authorized to change their salaries. Assume that you (Alice) are a
disgruntled employee, and your boss Boby did not increase your salary this year. You
want to increase your own salary by exploiting the SQL injection vulnerability in the
Edit-Profile page. Please demonstrate how you can achieve that. We assume that you
do know that salaries are stored in a column called ’salary’.
• Task 5.2: Modify other people’ salary. After increasing your own salary, you decide
to punish your boss Boby. You want to reduce his salary to 1 dollar. Please
demonstrate how you can achieve that.
• Task 5.3: Modify other people’ password. After changing Boby’s salary, you are
still disgruntled, so you want to change Boby’s password to something that you know,
and then you can log into his account and do further damage. Please demonstrate how
you can achieve that. You need to demonstrate that you can successfully log into
Boby’s account using the new password. One thing worth mentioning here is that the
database stores the hash value of passwords instead of the plaintext password string.
You can again look at the unsafe edit [Link] code to see how password is being
stored. It uses SHA1 hash function to generate the hash value of password.

Common questions

Powered by AI

Modifying a user's password with SQL injection poses significant risks because it allows attackers to circumvent authentication by inserting a hash value of a password they know into the password field of a user's account. Despite the use of SHA1 hashing, the attacker could compute the SHA1 hash of a chosen password and inject it via SQL commands, effectively setting the account's password to the attacker's value, granting them access.

An attacker can exploit a SQL injection vulnerability in the UPDATE statement by inserting malicious SQL code into input fields intended for legitimate data changes. For example, on the Edit Profile page, if the input is not properly sanitized, Alice could input SQL code that sets her salary to a higher value. This could involve manipulating the SQL query to update the 'salary' column of her record, despite the original inputs being limited to nicknames, emails, addresses, phone numbers, and passwords.

To modify another employee's salary, an attacker inserts SQL commands through unsanitized input fields, altering the database. For example, Alice could submit an SQL command designed to set her boss Boby's salary to a specific value by manipulating the SQL query executed during the update operation. This involves targeting the salary column and injecting conditions within the SQL statement to apply changes to Boby's row in the users table.

Ethical considerations in reporting SQL injection vulnerabilities include the responsible disclosure of findings to the application owner in a way that allows them to address and patch the vulnerabilities before they are publicly known. This ensures the risks are mitigated without exposing the system to potential exploitation. Additionally, respecting confidentiality agreements and following legal and organizational guidelines are paramount to maintain trust and to encourage systemic improvements in security without causing harm.

SQL injection attacks on UPDATE statements can have severe consequences, including unauthorized data manipulation such as altering sensitive information like salaries, changing role-based permissions, or injecting erroneous data leading to system malfunctions. Such attacks can damage the integrity of the database, lead to financial loss, expose private data, and can disrupt business operations by corrupting data or causing unauthorized access that compromises the system's overall security.

Defenses against SQL injection include input validation, using prepared statements or parameterized queries, and employing ORM frameworks that abstract SQL query construction. In the provided context, ensuring that all user input is properly validated and sanitized before being included in SQL queries, and implementing security mechanisms during the handling of user submissions, such as whitelisting inputs or employing regular expressions to filter out SQL keywords, can help mitigate these vulnerabilities.

SQL injection vulnerabilities frequently occur in web applications due to their interactive nature, requiring extensive input via forms and URLs that can be used to craft malicious queries. Many web applications directly link user inputs to database queries, and if this input is not carefully validated or sanitized, it creates openings for SQL injection. Unlike other software that may have less direct database interaction, web applications are more exposed to externally provided data prone to injection when developers prioritize ease of data manipulation over security.

Storing passwords as hash values enhances security by ensuring that even if the database is compromised, plaintext passwords are not exposed. However, if a system is vulnerable to SQL injection, an attacker might still manipulate the login mechanisms or alter other aspects like password hashes directly, leading to account breaches. Despite the hashing, the exploited injection can adjust stored hash values, allowing attackers to set known values, such as hashed versions of passwords they control, thus accessing accounts.

In a SQL injection attack on a SELECT statement in a login page, an attacker attempts to gain unauthorized access by inputting SQL code into the username or password fields. The objective is to alter the query to bypass authentication controls, such as commenting out the password check in the SQL statement. This can result in unauthorized access to the application without knowing valid credentials.

SQL injection is a code injection technique that exploits vulnerabilities at the interface between web applications and database servers. It occurs when user inputs are not properly validated or sanitized before being executed. This allows attackers to execute arbitrary SQL commands that can manipulate or access the database, potentially leading to unauthorized data access or modifications.

You might also like