Akhil Bhartiya Cyber Suraksha Sangathan (Regd.)
Regd. with Registrar of Society of NCT Delhi-Regd. No-287
Cyber Criminals se Suraksha, Digital India ki Raksha
अखिल भारतीय साइबर सुरक्षा संगठन (पंजी)
भारत की पहली साइबर क्राइम इन्वेस्टीगेशन एन जी ओ
ऑनलाइन रहें सतर्क, साइबर अपराध से रहें सुरक्षित
www.abcss.org Email: info@abcss.org
AMIT MALHOTRA
(Cyber Crime Investigation Specialist)
Founder Akhil Bhartiya Cyber Suraksha Sangathan
18 years of experience in crime prevention, detection and investigation. Certified Ethical Hacker from EC-Council. Certified Cyber Crime Investigator from Asian School of Cyber Laws. Presently working in the area of cyber crime investigation.
// VULNERABLE login query (DO NOT USE): SELECT * FROM users WHERE username='admin'--' AND password='anything'; // Attacker enters in username field: admin'-- // Result: Password check is bypassed! Attacker logs in as admin. // SAFE approach — use Parameterized Queries / Prepared Statements: $stmt = $pdo->prepare("SELECT * FROM users WHERE username=? AND password=?"); $stmt->execute([$username, $password]); // Input is treated as DATA, never as executable SQL code.
⚠️ How SQL Injection Is Carried Out
- Injecting malicious SQL code into website login forms and search fields
- Manipulating URL parameters to extract database contents
- Using automated tools like SQLMap to scan and exploit vulnerable websites
- Blind SQL Injection — inferring database structure through true/false responses
- Time-based SQL Injection — using database delay commands to extract data
- UNION-based attacks to retrieve data from other database tables
- Stored SQL Injection — injecting malicious code saved permanently in a database
- Second-order injection — stored payload triggered at a later time
- Targeting poorly secured e-commerce, banking, and government web portals
- Exploiting outdated CMS platforms like unpatched WordPress or Joomla sites
✅ How to Protect Against SQL Injection
- Always use Parameterized Queries (Prepared Statements) in all database operations
- Implement an ORM (Object Relational Mapper) to abstract raw SQL queries
- Validate and sanitize all user inputs on both client and server side
- Use Web Application Firewalls (WAF) to detect and block malicious requests
- Apply the principle of least privilege — give database accounts minimal permissions
- Never display database error messages publicly; use custom error pages
- Conduct regular security audits and penetration testing on your web applications
- Keep all web frameworks, libraries, and database software updated and patched
- Encode all user-supplied output before rendering it on web pages
- Continuously monitor web server and database logs for suspicious activity
Reconnaissance — Finding the Target Website
The attacker identifies a target website or web application that uses a database (most websites do). They look for input fields — login forms, contact forms, search bars, URL parameters — that interact with a database. Automated scanners are often used to quickly identify hundreds of potentially vulnerable sites.
Testing — Probing for Vulnerabilities
The attacker enters special characters such as a single quote ('), double dash (--), or Boolean conditions like OR 1=1 into input fields. If the website returns a database error message or behaves unexpectedly, it confirms the site is vulnerable to SQL Injection. This probing can take just seconds using automated tools.
Exploitation — Injecting Malicious SQL Code
The attacker crafts a specially designed SQL payload and injects it through the vulnerable input. This code manipulates the database query being executed by the server. Depending on the attack type, this can extract table names, user credentials, payment records, or personal data — all without any legitimate authorization.
Data Extraction — Dumping the Entire Database
Once the injection point is confirmed, the attacker uses UNION statements, subqueries, or repeated boolean/time-based queries to extract the entire database contents. This includes usernames, passwords (often hashed), email addresses, phone numbers, Aadhaar details, credit card numbers, OTPs, and transaction histories.
Authentication Bypass — Logging in Without a Password
By injecting code like admin'-- into a login field, the attacker can bypass the password check entirely and log in as an administrator or any other user. This gives them full access to the admin panel, user accounts, and backend systems — without knowing any valid credentials.
Escalation — Full Server Takeover & Data Sale
In advanced cases, SQL Injection is used to read and write files on the server, install web shells (backdoors), and gain full operating system access. Stolen data is then sold on the dark web, used for identity theft, financial fraud, blackmail, or ransomware deployment. The website owner may remain unaware for months.
Classic / In-Band SQL Injection
The most common and straightforward form. The attacker uses the same communication channel to inject malicious SQL and retrieve results directly in the browser or application response. Includes Error-Based SQLi (using database error messages to extract info) and UNION-Based SQLi (appending extra SELECT statements to the original query to retrieve data from other tables).
Blind SQL Injection (Boolean-Based)
The website does not display database errors or results directly, but the attacker can still extract data by asking the database true/false questions through the injected code. Based on whether the page responds differently for true or false conditions, the attacker slowly maps out the entire database structure and contents — one bit at a time.
Time-Based Blind SQL Injection
The attacker injects SQL commands that cause the database to pause (sleep) for a specific number of seconds if a condition is true. By measuring the response time of the web page, the attacker can infer database information even when no visible output is returned. This technique is used when there is no visible difference in page content for true/false responses.
Out-of-Band SQL Injection
The attacker uses a different channel to receive the extracted data — such as DNS lookups or HTTP requests sent by the database server to an attacker-controlled server. This technique is used when in-band methods are not feasible. It relies on the database server's ability to make network connections, which some configurations permit.
Stored (Persistent) SQL Injection
Malicious SQL code is submitted through a form — such as a user profile, comment box, or product review — and permanently stored in the database. Every time this stored data is retrieved and used in a database query (e.g., when an admin views reports), the injected code executes. This makes it especially dangerous for applications with admin dashboards.
Second-Order SQL Injection
The injected payload is stored safely at first (no immediate execution) but is triggered later when retrieved and used in a different, vulnerable query. The developer may think inputs are properly sanitized at entry, but the vulnerability is in how the stored data is later used. This is one of the hardest SQLi types to detect and prevent through input validation alone.
🚨 IF YOUR WEBSITE OR DATABASE HAS BEEN COMPROMISED — DO THIS IMMEDIATELY
- Take the website offline immediately to stop ongoing data theft and prevent further damage
- Preserve all server and database logs — these are critical legal evidence and must not be overwritten
- Engage a qualified cybersecurity professional to conduct forensic analysis and identify the attack vector
- Notify all affected users to change their passwords and monitor their accounts for suspicious activity
- Inform your payment gateway or bank immediately if any financial data was stored in the compromised database
- Report the incident to CERT-In (Indian Computer Emergency Response Team) at cert-in.org.in
- Call National Cyber Helpline 1930 immediately for guidance and to initiate the complaint process
- File an online complaint at cybercrime.gov.in with all technical details and evidence
- Visit the nearest Cyber Crime Cell or police station to register an FIR
- After fixing the vulnerability, have your site independently penetration tested before going back online
📞 CONTACT IMMEDIATELY — HELPLINE NUMBERS
IT Act Section 66: Dishonestly or fraudulently committing any act described under Section 43 — including unauthorized database access and data theft via SQL Injection — imprisonment up to 3 years and/or fine up to ₹5 lakh.
IT Act Section 66B: Dishonestly receiving or retaining stolen computer resources or communication data obtained through unauthorized access — imprisonment up to 3 years and/or fine up to ₹1 lakh.
IT Act Section 66C: Identity theft — using stolen credentials, passwords, or digital signatures obtained through a data breach — imprisonment up to 3 years + fine up to ₹1 lakh.
IT Act Section 70: Unauthorized access to or securing access to any "Protected System" — including critical national infrastructure, government databases, or notified computer systems — imprisonment up to 10 years + fine. This section is especially relevant for SQLi attacks on government and banking portals.
BNS Section 318 (Old IPC 420) — Cheating: Using stolen data obtained via SQL Injection to commit financial fraud, impersonate users, or deceive individuals — imprisonment up to 7 years + fine.
BNS Section 308 (Old IPC 304A) — Causing harm through negligence: Website owners and developers who fail to implement basic security practices (such as parameterized queries) and thereby allow user data to be stolen may face civil liability and regulatory action for gross negligence.
Digital Personal Data Protection (DPDP) Act 2023: Organizations that collect and process personal data are legally obligated to implement reasonable security safeguards. A data breach caused by SQL Injection can result in significant financial penalties under the DPDP Act. Failure to notify affected users and authorities of a breach is an additional offence.





